Package edu.uga.galileo.voci.bo

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


        // search results
        if ((forwardRequestTo.indexOf("/do/") != -1)
            && (results != null)) {
          WorkflowManager wm = new WorkflowManager();
          ProjectManager pm = new ProjectManager();
          User user = (User) request.getSession()
              .getAttribute("user");
          // if user is null, stick with the default that none of
          // the results is editable
          if (user != null) {
            SearchResult result;
View Full Code Here


    HashMap<ContentType, ArrayList<String>> useBlurbFields = setUpMetadataBlurbFields(command);

    // we only change the defaults if we're in the admin section
    if ((!command.isViewCommand())
        && (request.getSession().getAttribute("user") != null)) {
      User user = (User) request.getSession().getAttribute("user");
      String communityBlurbFields = user.getPreference(command
          .getProject()
          + "-communityBlurbFields");
      if (communityBlurbFields != null) {
        useBlurbFields.put(ContentType.COMMUNITY, ArrayUtils
            .arrayToArrayList(communityBlurbFields.split("\\|")));
      }

      String collectionBlurbFields = user.getPreference(command
          .getProject()
          + "-collectionBlurbFields");
      if (collectionBlurbFields != null) {
        useBlurbFields.put(ContentType.COLLECTION, ArrayUtils
            .arrayToArrayList(collectionBlurbFields.split("\\|")));
      }

      String bundleBlurbFields = user.getPreference(command.getProject()
          + "-bundleBlurbFields");
      if (bundleBlurbFields != null) {
        useBlurbFields.put(ContentType.BUNDLE, ArrayUtils
            .arrayToArrayList(bundleBlurbFields.split("\\|")));
      }

      String itemBlurbFields = user.getPreference(command.getProject()
          + "-itemBlurbFields");
      if (itemBlurbFields != null) {
        useBlurbFields.put(ContentType.ITEM, ArrayUtils
            .arrayToArrayList(itemBlurbFields.split("\\|")));
      }
View Full Code Here

   */
  @Override
  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    User user = (User) request.getSession().getAttribute("user");
    ArrayList<String> errors = new ArrayList<String>();
    ArrayList<VociBusinessObject> problems = new ArrayList<VociBusinessObject>();
    ImportManager iman = new ImportManager();

    // always get the list of importers for display to users
View Full Code Here

    // then add any "support project"-related information to the servlet
    // request, listing on those that the user has administrative privileges
    // 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) {
          Logger.warn("Couldn't find parent project for display.", e);
        }
      } else {
        // this is a main project, so get any available child projects'
        // names and handles for public face linking
        // (LeftHandMenu.jsp)
        ArrayList<Project> supportProjects = pm
            .getSupportProjects(project);
        if (supportProjects!=null) {
          for (int m = supportProjects.size() - 1; m >= 0; m--) {
            userAdminRoleMap = user.getAdminRoles().get(
                supportProjects.get(m).getHandle());
            if ((userAdminRoleMap == null)
                || (userAdminRoleMap.size() < 1)) {
              supportProjects.remove(m);
            }
View Full Code Here

    // now do the real checks
    HttpSession session = request.getSession();
    // check to see if the user's already logged in, and if so,
    // check permissions for the command
    if (session.getAttribute("user") != null) {
      User user = (User) session.getAttribute("user");

      // this is a basic workflow check, and it only makes sure that the
      // user is allowed to perform administration on the requested
      // content type. specific item editing-related checks should be
      // done in the respective servlets.
      if (wm
          .canEdit(user, command.getProject(), command.getCommand(),
              -1)) {
        // user can manage command, so all's well
        Logger.debug("user '" + user.getUserName() + "' is an admin");
        return false;
      } else {
        // user can't manage requested area, and should be
        // bounced to the login page; so set the error message,
        // and let the rest of the page take over
View Full Code Here

    Command command = (Command) request.getAttribute("command");
    HttpSession session = request.getSession();
    if ((command.getModifier() != null)
        && (command.getModifier().equals("exit"))) {
      if (session.getAttribute("user") != null) {
        User user = (User) session.getAttribute("user");
        ContentLockManager.unlockAllUserContent(user);
        session.setAttribute("user", null);
      }
    }

    if (request.getParameter("username") == null) {
      forwardToLoginPage(request, response);
    } else {
      UserManager um = new UserManager();
      try {
        User user = um.getUser(request.getParameter("username"),
            request.getParameter("password"));
        session.setAttribute("user", user);
        try {
          if ((request.getParameter("originator") != null)
              && (request.getParameter("originator").indexOf(
View Full Code Here

  private void updateUser( HttpServletRequest request, HttpServletResponse response, Command command )
  {
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    UserManager userManager = new UserManager();
    User user = new User();
    populateVBOFromRequest(user, request, fieldMessages, true);
    Logger.debug("\n\n xxxxx" + fieldMessages.size() + "\n\n");
    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>");

        }
View Full Code Here

  private void addNewUser( HttpServletRequest request, HttpServletResponse response, Command command )
  {
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    UserManager userManager = new UserManager();
    User user = new User();
    populateVBOFromRequest(user, request, fieldMessages, true);
    String pwd = user.getPwd();
    String oldPwd = request.getParameter("oldPwd");
    boolean isErrors = false;
    boolean isUser = false;

    Logger.debug("\n\n adding a new user and role... roles -=" + user.getRoles() + "\n\n");

    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 is greater than 40. Please re-enter password.");
          isErrors = true;
        }
      }
      catch( Exception ex )
      {
        Logger.error("\n Could not ENCRYPT password \n", ex);
        errors.add("Security errors occurred while processing password");
        // request.setAttribute("errorMessage", "Security(encryption)
        // errors
        // occurred while processing password");
        isErrors = true;
      }
    }

    // if user exist add to errors log
    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 and user doesn't already exist add new user record
    if ((!isErrors) && (fieldMessages.size() == 0) && (errors.isEmpty()))
    {
      try
      {
        int projectId = new ProjectManager().getProjectID(command.getProject());
        userManager.addUser(((User) request.getSession().getAttribute("user")), user, projectId);
        request.setAttribute("successMessage", "New user created.");
      }
      catch( NoSuchUserException nsuex )
      {
        Logger.error("\n Could not add user data \n", nsuex);
        // request.setAttribute("errorMessage", "Errors occurred while
        // processing
        // add new user request...");
        errors.add("Errors occurred while processing add new user request...");
        isErrors = true;
      }
      catch( RoleUpdateAddException ruaex )
      {
        Logger.debug("Couldn't add role for user : " + user.getUserName(), ruaex);
        errors.add("Couldn't add role for user : " + user.getUserName());
      }
      catch( NoSuchProjectException ex )
      {
        Logger.error("System can't retrieve correct Project" + Calendar.getInstance().getTime().toString());
        errors.add("Project does not exist.  Please contact an Administrator.");
      }
    }

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

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

    // attach full list of roles to user
    try
    {
      user = new RoleManager().setFullListRoleNames(new ProjectManager().getProjectID(command.getProject()), user);
    }
    catch( NoSuchProjectException ex )
    {
      Logger.error("System can't retrieve correct Project" + Calendar.getInstance().getTime().toString());
      errors.add("Project does not exist.  Please contact an Administrator.");
    }

    user.setRoles(user.getRoles());
    request.setAttribute("user", user);
    request.setAttribute("oldPwd", user.getPwd());

    if ((errors.size() > 0) || (isErrors) || (fieldMessages.size() > 0))
    {
      // go back to user.jsp and state error
      sendRequestToUserJSP(request, response, command);
View Full Code Here

    if ((userId < Integer.MIN_VALUE) || (userId > Integer.MAX_VALUE))
    {
      errors.add("Invalid update request.");
    }

    User user = new User();
    try
    {
      // get user object associated with userId
      // get full roles list according to project
      // get roles attached to this specific user
      user = new UserManager().getUserById(userId, command);
    }
    catch( NoSuchUserException nsuex )
    {
      Logger.debug("Could not retrieve userId", nsuex);
      request.setAttribute("errorMessage", "Could not retrieve userId...");
    }
    catch( NoSuchRoleException nsrex )
    {
      Logger.debug("Could not retrieve list roles", nsrex);
      request.setAttribute("errorMessage", "Could not retrieve list of roles...");
    }

    request.setAttribute("user", user);
    request.setAttribute("oldPwd", user.getPwd());
    int projectId = -1;
    ArrayList historyRecords = new ArrayList();
    try
    {
      projectId = new ProjectManager().getProjectID(command.getProject());
      historyRecords = (new AuditLogManager()).getUpdateRecords(projectId, ContentType.USER, user.getUserId());
    }
    catch( NoSuchProjectException ex )
    {
      Logger.debug("\n\n Could not retrieve projectId - UserServlet.processUpdateRequest \n\n");
      errors.add("The system couldn't retrieve project data.");
    }

    if ((historyRecords != null) && (historyRecords.size() > 0))
    {
      request.setAttribute("history", historyRecords);
    }

    if (errors.size() > 0)
    {
      request.setAttribute("errorMessage", generateErrorMessage(errors));
      // go back to userList.jsp and state error
      listUsers(request, response, command);
      Logger.debug("\n\n this user data had erros : " + user.toString() + "\n\n");
    }
    else
    {
      sendRequestToUserJSP(request, response, command);
    }
View Full Code Here

  {
    ArrayList<String> errors = new ArrayList<String>();
    String[] vals = command.getOther().get(0).split("\\|");
    AuditLogManager alm = new AuditLogManager();
    boolean isErrors = false;
    User user = new User();
    int projectId = -1;
    String data = "";

    try
    {
      // userid/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");

      user = new User();
      user.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 - UserServlet.processUpdateRequest \n\n");
      errors.add("Could not retrieve projectId.");
    }

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

    // attach full list of roles to user
    try
    {
      user = new RoleManager().setFullListRoleNames(new ProjectManager().getProjectID(command.getProject()), user);
    }
    catch( NoSuchProjectException ex )
    {
      Logger.error("System can't retrieve correct Project" + Calendar.getInstance().getTime().toString());
      errors.add("Project does not exist.  Please contact an Administrator.");
    }

    user.setRoles(user.getRoles());

    request.setAttribute("user", user);
    request.setAttribute("oldPwd", user.getPwd());

    projectId = -1;
    ArrayList historyRecords = new ArrayList();
    try
    {
      projectId = new ProjectManager().getProjectID(command.getProject());
      historyRecords = (new AuditLogManager()).getUpdateRecords(projectId, ContentType.USER, user.getUserId());
    }
    catch( NoSuchProjectException ex )
    {
      Logger.debug("\n\n Could not retrieve projectId - UserServlet.handleHistory \n\n");
      errors.add("Project Id couldn't be found. ");
    }

    if ((!historyRecords.isEmpty()) && (historyRecords.size() > 0))
    {
      request.setAttribute("history", historyRecords);
    }

    if ((errors.size() > 0) || (isErrors))
    {
      // go back to user.jsp and state error
      sendRequestToUserJSP(request, response, command);
      Logger.debug("\n\n this user data had erros : " + user.toString() + "\n\n");
    }
    else
    {
      sendRequestToUserJSP(request, response, command);
    }
View Full Code Here

TOP

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

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.