Package edu.uga.galileo.voci.model

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


      } catch (NoSuchProjectException e) {
        Logger.warn("Couldn't get project ID for handle '"
            + command.getProject() + "'");
      }

      (new UserManager()).setUserPreference((User) request.getSession()
          .getAttribute("user"), command.getProject() + "-"
          + contentType.toString().toLowerCase() + "BlurbFields",
          StringUtils.join(newFieldsToBlurbFrom, "|"));
    }
  }
View Full Code Here


   *            they're encountered.
   */
  protected void setSearchObject(Command command,
      ContentManager contentManager, HttpServletRequest request,
      ArrayList<String> errors) {
    request.setAttribute("adminUsers", new UserManager()
        .getContentAdminUserList(command.getProject()));
    if (request.getParameter("start") != null) {
      request.setAttribute("startDate", request.getParameter("start"));
    }
    if (request.getParameter("end") != null) {
View Full Code Here

    }

    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>");

        }
        catch( RoleUpdateAddException roleEx )
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);
View Full Code Here

    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...");
View Full Code Here

   *            The url command.
   */
  private void listUsers( HttpServletRequest request, HttpServletResponse response, Command command )
  {
    ArrayList<User> userList = new ArrayList<User>();
    userList = new UserManager().getUserList();

    if (userList == null)
    {
      request.setAttribute("errorMessage", "A system error was encountered. Database could not retrieve list. "
          + "Please contact a system administrator.");
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.model.UserManager

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.