/**
   * Performs the actual filtering, based on QueryParameters returns false if the logEntry fails the
   * filtering process
   */
  public boolean filterLogs(ActivityLogEntry logEntry) {
    if (!logEntry.toShow()) {
      return false;
    }

    if (q == null) {
      if (this.queryMessage == null) {
        this.queryMessage = "Error parsing the query. QueryParameters not created.";
      }
      return true;
    }

    // Filter based on what is in the query
    if (q.toDate) {
      if (logEntry.getTime() > q.toDateValue) {
        return false;
      }
    }
    if (q.fromDate) {
      if (logEntry.getTime() < q.fromDateValue) {
        return false;
      }
    }
    if (q.request) {
      if (!arrayContains(q.requestValues, logEntry.getServletName())) {
        return false;
      }
    }
    if (q.response) {
      if (!arrayContains(q.responseValues, logEntry.getAction())) {
        return false;
      }
    }
    if (q.person) {
      if (!logEntry.getName().toLowerCase().contains(q.personValue)
          && !logEntry.getId().toLowerCase().contains(q.personValue)
          && !logEntry.getEmail().toLowerCase().contains(q.personValue)) {
        return false;
      }
    }
    if (q.role) {
      if (!arrayContains(q.roleValues, logEntry.getRole())) {
        return false;
      }
    }

    return true;
  }
  @Override
  public boolean execute() {

    log.info(
        "Adjusting submissions for feedback session :" + sessionName + "in course : " + courseId);

    FeedbackSessionAttributes feedbackSession =
        FeedbackSessionsLogic.inst().getFeedbackSession(sessionName, courseId);

    String errorString =
        "Error encountered while adjusting feedback session responses of %s in course : %s : %s\n%s";

    if (feedbackSession == null) {
      log.severe(String.format(errorString, sessionName, courseId, "feedback session is null", ""));
      return false;
    }

    List<FeedbackResponseAttributes> allResponses =
        FeedbackResponsesLogic.inst()
            .getFeedbackResponsesForSession(
                feedbackSession.getFeedbackSessionName(), feedbackSession.getCourseId());
    Gson gsonParser = Utils.getTeammatesGson();
    ArrayList<StudentEnrollDetails> enrollmentList =
        gsonParser.fromJson(
            enrollmentDetails, new TypeToken<ArrayList<StudentEnrollDetails>>() {}.getType());
    for (FeedbackResponseAttributes response : allResponses) {
      try {
        StudentsLogic.inst().adjustFeedbackResponseForEnrollments(enrollmentList, response);
      } catch (Exception e) {
        log.severe(
            String.format(
                errorString,
                sessionName,
                courseId,
                e.getMessage(),
                ActivityLogEntry.generateServletActionFailureLogMessage(request, e)));
        return false;
      }
    }
    return true;
  }
示例#3
0
 protected void logMessage(HttpServletRequest request, String message) {
   String url = HttpRequestHelper.getRequestedURL(request);
   ActivityLogEntry activityLogEntry =
       new ActivityLogEntry(servletName, action, null, message, url);
   log.log(Level.INFO, activityLogEntry.generateLogMessage());
 }