Examples of AuditLogManager


Examples of edu.uga.galileo.voci.model.AuditLogManager

        && (command.getModifier().equals("history"))) {
      // user is requesting an old item record from the audit log
      goToList = false;

      String[] vals = command.getOther().get(0).split("\\|");
      AuditLogManager alm = new AuditLogManager();
      int itemId = -1;
      try {
        itemId = Integer.parseInt(vals[2]);
        if (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), itemId)) {
          errors.add("You don't have permission to edit "
              + "the requested item.");
          goToList = true;
        } else {
          AuditLog record = alm.getRecord(Integer.parseInt(vals[0]),
              ContentType.valueOf(Integer.parseInt(vals[1])),
              (itemId = Integer.parseInt(vals[2])), Timestamp
                  .valueOf(vals[3]));
          String data = record.getDataExport();
          item = new Item();
          item.fromString(data);
        }
      } catch (NullPointerException e) {
        goToList = true;
        errors.add("Invalid history request format.");
      } catch (NumberFormatException e) {
        goToList = true;
        errors.add("Invalid history request format.");
      } catch (NoSuchAuditLogRecordException e) {
        errors.add("The history record requested couldn't be located.");
      } catch (DataTypeMismatchException e) {
        Logger.error("Data type mismatch occurred pulling "
            + command.getOther().get(0) + " from the audit log", e);
        errors
            .add("A system error was encountered (DataTypeMismatch). "
                + "Please contact a system administrator.");
      }

      if (!goToList) {
        if (item == null) {
          try {
            item = itemManager.getItem(command, itemId, false);
          } catch (NoSuchItemException e) {
            goToList = true;
            errors.add("No such item (" + itemId + ") found.");
          }
        }
      }

      request.setAttribute("isDirty", "t");
    }

    // one last permissions check if we're on our way to the edit page
    if ((item != null)
        && (!command.isViewCommand())
        && (errors.size() == 0)
        && (fieldMessages.size() == 0)
        && (!goToList)
        && (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), item.getItemId()))) {
      errors.add("You don't have permission to "
          + "work on the requested content.");
      goToList = true;
    }

    if (errors.size() > 0) {
      request.setAttribute("errorMessage", generateErrorMessage(errors));
    }

    if (fieldMessages.size() > 0) {
      request.setAttribute("fieldMessages", fieldMessages);
    }

    if (goToList) {
      // the request dispatcher's forward method strips anchors, so we
      // set page target here and let the ContentList.jsp handle it
      // in the body tag's onload event.
      if (item != null) {
        if (request.getParameter("parentId") != null) {
          request.setAttribute("jumpToTarget", "#node"
              + request.getParameter("parentId"));
        } else {
          request.setAttribute("jumpToTarget", "#node"
              + item.getItemId());
        }
      }

      if ((command.getModifier() == null)
          || (!command.getModifier().equals("search"))) {
        ArrayList<VBOTreeNodeWrapper> tree = TreeManager.getInstance()
            .getTreeNodeWrappers(
                command.getProject(),
                openNodes,
                command.isViewCommand() ? true : false,
                -1,
                (User) request.getSession()
                    .getAttribute("user"));
        request.setAttribute("tree", tree);
      }

      // if this is from a search, flag it as such for the ContentList.jsp
      // page
      if (request.getParameter("fs") != null) {
        command.setModifier("search");
        ArrayList<String> other = new ArrayList<String>();
        other.add("results");
        command.setOther(other);
      } else if ((updated)
          && (request.getSession().getAttribute("savedCommand") != null)) {
        command = (Command) request.getSession().getAttribute(
            "savedCommand");
        try {
          request.getRequestDispatcher(
              response.encodeURL("/do" + command.buildURL()))
              .forward(request, response);
          return;
        } catch (ServletException e) {
          Logger.error("Couldn't forward request ContentList.jsp", e);
        } catch (IOException e) {
          Logger.error("Couldn't forward request ContentList.jsp", e);
        }
      }

      try {
        request.getRequestDispatcher(
            response.encodeURL(contentListPage)).forward(request,
            response);
      } catch (ServletException e) {
        Logger.error("Couldn't forward request to " + contentListPage,
            e);
      } catch (IOException e) {
        Logger.error("Couldn't forward request to " + contentListPage,
            e);
      }
    } else {
      ArrayList<GUIElement> guiElements = item.getGUIElements();
      String addToRepeatables = request.getParameter("addToRepeatables");
      if ((addToRepeatables != null)
          && (addToRepeatables.trim().length() > 0)) {
        for (GUIElement guiElem : guiElements) {
          if (guiElem.getName().equals(addToRepeatables)) {
            guiElem.setRepeatableElementsToAdd(3);
            request.setAttribute("isDirty", "t");
            break;
          }
        }
      }
      request.setAttribute("elements", guiElements);

      request.setAttribute("item", item);
      ArrayList<AuditLog> historyRecords = (new AuditLogManager())
          .getUpdateRecords(
              ((HashMap<String, Project>) getServletContext()
                  .getAttribute("projectMap")).get(
                  command.getProject()).getProjectId(),
              ContentType.ITEM, item.getItemId());
View Full Code Here

Examples of edu.uga.galileo.voci.model.AuditLogManager

    // first check to see if we're just pulling a record from the history
    try {
      if ((command.getModifier() != null)
          && (command.getModifier().equals("history"))) {
        String[] vals = command.getOther().get(0).split("\\|");
        AuditLogManager alm = new AuditLogManager();
        try {
          AuditLog record = alm.getRecord(Integer.parseInt(vals[0]),
              ContentType.valueOf(Integer.parseInt(vals[1])),
              Integer.parseInt(vals[2]), Timestamp
                  .valueOf(vals[3]));
          String data = record.getDataExport();
          project = new Project();
          project.fromString(data);
          request.setAttribute("isDirty", "t");
        } catch (NullPointerException e) {
          errors.add("Invalid history request format.");
        } catch (NumberFormatException e) {
          errors.add("Invalid history request format.");
        } catch (NoSuchAuditLogRecordException e) {
          errors
              .add("The history record requested couldn't be located.");
        } catch (DataTypeMismatchException e) {
          Logger.error(
              "Data type mismatch occurred pulling "
                  + command.getOther().get(0)
                  + " from the audit log", e);
          errors
              .add("A system error was encountered (DataTypeMismatch). "
                  + "Please contact a system administrator.");
        }

        if (project == null) {
          project = manager.getProject(command.getProject());
        }
      } else {
        // if it's not from history, then...
        project = manager.getProject(command.getProject());

        String cancel;
        if (((cancel = request.getParameter("cancelChanges")) != null)
            && (cancel.equals("yes"))) {
          request.setAttribute("successMessage",
              "Your changes have been cancelled.");
        } else {
          if (request.getParameter("projectId") != null) {
            // this is an update from the project form if the
            // projectId param is set
            String oldVersion = project.toString();
            if ((project.getProjectId() != Integer.parseInt(request
                .getParameter("projectId")))
                || (!project.getHandle().equals(
                    request.getParameter("handle")))
                || (!project.getHandle().equals(
                    command.getProject()))) {
              errors
                  .add("Form corruption occurred ... please try again.");
            } else {
              // go ahead and populate the data from the request
              populateVBOFromRequest(project, request,
                  fieldMessages, true);
            }

            if (project.toString().equals(oldVersion)) {
              errors.add("No changes detected.");
            }

            if ((errors.size() == 0) && (fieldMessages.size() == 0)) {
              User user = (User) request.getSession()
                  .getAttribute("user");
              manager.updateProject(project, user, oldVersion);
              request.setAttribute("successMessage",
                  "Project successfully updated <span class=\"tinyformtext\">("
                      + Calendar.getInstance().getTime()
                          .toString() + ")</span>");
            }
          }
        }
      }
    } catch (NoSuchProjectException e) {
      Logger.fatal("Project handle '" + command.getProject()
          + "' doesn't exist!", e);
      request
          .setAttribute(
              "errorMessage",
              "The requested project couldn't be located.  "
                  + "This is a FATAL error, so please stop working in this area, "
                  + "and contact the system administrator.");
    }

    request.setAttribute("project", project);
    // put the project's history in the request scope (the project itself
    // is in the application scope)
    ArrayList<AuditLog> historyRecords = (new AuditLogManager())
        .getUpdateRecords(project.getProjectId(), ContentType.PROJECT,
            project.getProjectId());
    if ((historyRecords != null) && (historyRecords.size() > 0)) {
      request.setAttribute("history", historyRecords);
    }
View Full Code Here

Examples of edu.uga.galileo.voci.model.AuditLogManager

    int projectId = -1;
    ArrayList historyRecords = new ArrayList();
    try {
      projectId = new ProjectManager().getProjectID(command.getProject());
      historyRecords = (new AuditLogManager()).getUpdateRecords(projectId,
          ContentType.ROLE, role.getRoleId());
    } catch (NoSuchProjectException ex) {
      Logger
          .debug("\n\n Could not retrieve projectId - RoleServlet.processUpdateRequest \n\n");
    }
View Full Code Here

Examples of edu.uga.galileo.voci.model.AuditLogManager

   */
  private void handleHistory(HttpServletRequest request,
      HttpServletResponse response, Command command) {
    ArrayList<String> errors = new ArrayList<String>();
    String[] vals = command.getOther().get(0).split("\\|");
    AuditLogManager alm = new AuditLogManager();
    boolean isErrors = false;
    Role role = new Role();
    int projectId = -1;
    String data = "";

    try {
      // roleId/type/date
      // getRecord(int projectId, ContentType contentType, int contentId,
      // Timestamp update)
      projectId = new ProjectManager().getProjectID(command.getProject());
      AuditLog record = alm.getRecord(projectId, ContentType
          .valueOf(Integer.parseInt(vals[1])), Integer
          .parseInt(vals[0]), Timestamp.valueOf(vals[2].replace(
          "%20", " ")));
      data = record.getDataExport();

      Logger.debug("\n\n the data looks like : " + data + "\n\n");

      role = new Role();
      role.fromString(data);
      request.setAttribute("isDirty", "t");
    } catch (NullPointerException e) {
      errors.add("Invalid history request format.");
    } catch (NumberFormatException e) {
      errors.add("Invalid history request format.");
    } catch (NoSuchAuditLogRecordException e) {
      errors.add("The history record requested couldn't be located.");
    } catch (DataTypeMismatchException e) {
      Logger.error("Data type mismatch occurred pulling "
          + command.getOther().get(0) + " from the audit log", e);
      errors.add("A system error was encountered (DataTypeMismatch). "
          + "Please contact a system administrator.");
    } catch (NoSuchProjectException ex) {
      Logger
          .debug("\n\n Could not retrieve projectId - RoleServlet.processUpdateRequest \n\n");
      errors.add("Could not retrieve projectId.");
    }

    if (errors.size() > 0) {
      request.setAttribute("errorMessage", generateErrorMessage(errors));
    }

    request.setAttribute("role", role);

    projectId = -1;
    ArrayList historyRecords = new ArrayList();
    try {
      projectId = new ProjectManager().getProjectID(command.getProject());
      historyRecords = (new AuditLogManager()).getUpdateRecords(projectId,
          ContentType.ROLE, role.getRoleId());
    } catch (NoSuchProjectException ex) {
      Logger
          .debug("\n\n Could not retrieve projectId - RoleServlet.handleHistory \n\n");
    }
View Full Code Here

Examples of edu.uga.galileo.voci.model.AuditLogManager

    request.setAttribute("role", role);
    int projectId = -1;
    ArrayList historyRecords = new ArrayList();
    try {
      projectId = new ProjectManager().getProjectID(command.getProject());
      historyRecords = (new AuditLogManager()).getUpdateRecords(projectId,
          ContentType.ROLE, role.getRoleId());
    } catch (NoSuchProjectException ex) {
      Logger
          .debug("\n\n Could not retrieve projectId - RoleServlet.processUpdateRequest \n\n");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.