Package edu.uga.galileo.voci.bo

Examples of edu.uga.galileo.voci.bo.Project


    // within
    if (request.getSession().getAttribute("user") != null) {
      User user = (User) request.getSession().getAttribute("user");
      HashMap<String, String> userAdminRoleMap;

      Project project = projectMap.get(command.getProject());
      if (project.getParentId() > 0) {
        // this is a support project, so get the parent project's name
        // and
        // handle for public face linking (LeftHandMenu.jsp)
        try {
          Project parentProject = pm.getProject(pm
              .getProjectHandle(project.getParentId()));
          userAdminRoleMap = user.getAdminRoles().get(
              parentProject.getHandle());
          if ((userAdminRoleMap != null)
              && (userAdminRoleMap.size() > 0)) {
            request.setAttribute("parentProject", parentProject);
          }
        } catch (NoSuchProjectException e) {
View Full Code Here


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

    if (goToMetadataList) {
      Project project = ((HashMap<String, Project>) getServletContext()
          .getAttribute("projectMap")).get(command.getProject());
      // use the community list by default, if none was provided
      if (command.getModifier() == null) {
        command.setModifier("community");
      }
      request.setAttribute("metadata", MetadataManager.getMetadataList(
          project.getId(), ContentType.valueOf(
              command.getModifier().toUpperCase()).getValue()));

      try {
        request.setAttribute("sessionId", request.getSession().getId());
        request.getRequestDispatcher(
View Full Code Here

    int userId = user.getUserId();
    String pwd = user.getPwd();
    String oldPwd = request.getParameter("oldPwd");
    boolean isErrors = false;
    User oldUser = null;
    Project project = null;
    boolean isUser = false;

    // encrypt password if user is attempting to change password and no
    // errors exist,
    if ((!oldPwd.equals(pwd)) && (fieldMessages.size() == 0))
    {
      try
      {
        // encrypt and set new password
        user.setPwd(Encrypt.encrypt(Configuration.getString("keyfile"), pwd));

        if (pwd.length() > 40)
        {
          errors.add("Password length after encryption is greater than 40...");
          isErrors = true;
        }
      }
      catch( Exception ex )
      {
        isErrors = true;
        Logger.error("\n Could not ENCRYPT password \n", ex);
        errors.add("Security errors occurred while processing password");
      }
    }

    // get user original record from database
    try
    {
      oldUser = new UserManager().getUserById(userId, command);
      if (oldUser == null)
      {
        isErrors = true;
        errors.add("User ID was not found");
      }
    }
    catch( NoSuchUserException nsue )
    {
      isErrors = true;
      Logger.error("\n Attempting to updateUser but could not retrieve user by user_id " + userId + "\n", nsue);
      errors.add("User ID was not found");
      // request.setAttribute("errorMessage", "Could not find user - " +
      // userId);
    }
    catch( NoSuchRoleException nsrex )
    {
      Logger.debug("Could not retrieve roles", nsrex);
      request.setAttribute("errorMessage", "Could not retrieve roles...");
    }

    if (errors.size() == 0)
    {
      String oldContent = oldUser.toString();
      // detect whether user data changed
      Logger.debug("\n\n oldContent = " + oldContent.toString() + "\n\n");
      Logger.debug("\n\n user content = " + user.toString() + "\n\n");
      if (oldContent.equals(user.toString()))
      {
        errors.add("No changes detected.");
        isErrors = true;
      }

      // if user is attempting to change userName,
      // the system must validate user name doesn't exist
      if (!oldUser.getUserName().equalsIgnoreCase(user.getUserName()))
      {
        // if user name exist add to errors messaging
        isUser = userManager.isUserExist(user.getUserName().toLowerCase());
        if (isUser)
        {
          errors.add("User Name: " + user.getUserName() + " already exist.  Please enter another user name.");
          isErrors = true;
        }
      }

      // if no errors occurred update user record
      if ((!isErrors) && (fieldMessages.size() == 0) && (errors.size() == 0))
      {
        try
        {
          User sessionUser = (User) request.getSession().getAttribute("user");
          userManager.updateUser(new ProjectManager().getProject(command.getProject()), sessionUser, user, oldContent);
          request.setAttribute("successMessage", "User successfully updated <span class=\"tinyformtext\">("
              + Calendar.getInstance().getTime().toString() + ")</span>");

        }
        catch( RoleUpdateAddException roleEx )
        {
          errors.add("System failed to update roles for user.");
        }
        catch( UserAddUpdateException nsuex )
        {
          Logger.error("\n Could not update user data \n", nsuex);
          errors.add("User update failed...");
        }
        catch( NoSuchProjectException ex )
        {
          Logger.error("\n Could not update user.  Project doesn't exist (" + project.toString() + ") \n", ex);
          errors.add("Project doesn't exist.");
        }
      }
    }
View Full Code Here

   */
  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    try {
      Project project = DAOFactory.getProjectDAO().getProject(
          command.getProject());
      request.setAttribute("project", project);
    } catch (NoSuchProjectException e1) {
      Logger.warn("The requested project (" + command.getProject()
          + ") couldn't be retrieved", e1);
View Full Code Here

  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    ProjectManager manager = new ProjectManager();

    Project project = null;
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();

    // 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);
    }

    // set up error and field messages, as appropriate
View Full Code Here

    Role role = new Role();
    populateVBOFromRequest(role, request, fieldMessages, true);
    int roleId = role.getRoleId();
    boolean isErrors = false;
    Role oldRole = null;
    Project project = null;

    // get original role record from database
    try {
      oldRole = new RoleManager().getRoleByRoleId(roleId);
      if (oldRole == null) {
        isErrors = true;
        errors.add("Role ID was not found");
      }
    } catch (NoSuchRoleException nsue) {
      isErrors = true;
      Logger.error(
          "\n Attempting to update Role but could not retrieve role by role_id "
              + roleId + "\n", nsue);
      errors.add("Role ID was not found");
    }

    String oldContent = oldRole.toString();
    // set parentId of new Info if its > 0
    role.setParentRoleId(oldRole.getParentRoleId());

    // detect whether role data changed
    if (oldContent.equals(role.toString())) {
      errors.add("No changes detected.");
      isErrors = true;
    }

    // if user is attempting to change role name,
    // the system must validate role name/manager pair doesn't already exist
    if ((!oldRole.getName().equalsIgnoreCase(role.getName()))
        && (!oldRole.isManager() == role.isManager())) {
      // if role exist add to errors messaging
      if (roleManager.isRoleExist(role.getName().toLowerCase(), role
          .isManager(), role.getParentRoleId())) {
        errors.add("Role Name: " + role.getName()
            + " already exist.  Please enter another role name.");
        isErrors = true;
      }
    }

    // if no errors occurred update role record
    if ((!isErrors) && (fieldMessages.size() == 0)) {
      try {
        User sessionUser = (User) request.getSession().getAttribute(
            "user");
        roleManager.updateRole(new ProjectManager().getProject(command
            .getProject()), sessionUser, role, oldContent);
        // if update was successful send messages....
        request.setAttribute("successMessage",
            "Role successfully updated <span class=\"tinyformtext\">("
                + Calendar.getInstance().getTime().toString()
                + ")</span>");
      } catch (RoleUpdateAddException nsuex) {
        Logger.error("\n Could not update role data \n", nsuex);
        errors.add("Role update failed...");
      } catch (NoSuchProjectException ex) {
        Logger.error("\n Project doesn't exist (" + project.toString()
            + ") \n", ex);
        errors.add("Project doesn't exist.");
      }
    }
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.bo.Project

Copyright © 2018 www.massapicom. 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.