Package org.apache.roller.presentation.website.formbeans

Examples of org.apache.roller.presentation.website.formbeans.UserAdminForm


            UserData user = null;
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rollerSession = RollerSession.getRollerSession(request);
            if (rollerSession.isGlobalAdminUser() )
            {
                UserAdminForm userForm = (UserAdminForm)actionForm;
                UserManager mgr = RollerFactory.getRoller().getUserManager();
                if (userForm!=null
                      && userForm.getUserName()!=null && !userForm.isNewUser())
                {
                    ActionMessages msgs = getErrors(request);
                    msgs = (msgs == null) ? new ActionMessages() : msgs;
                    user = mgr.getUserByUsername(userForm.getUserName(), null);                   
                    if (user != null)
                    {
                        userForm.copyFrom(user, request.getLocale());                       
                        // User must set new password twice
                        userForm.setPasswordText(null);
                        userForm.setPasswordConfirm(null);
                    }
                    else
                    {
                        msgs.add(ActionErrors.GLOBAL_ERROR,
                            new ActionMessage("userAdmin.invalidNewUserName"));
                        userForm.setUserName("");
                    }
                    if (request.getSession().getAttribute("cookieLogin")!=null)
                    {
                        // TODO: make it possible to change passwords
                        // regardless of remember me
View Full Code Here


            RollerSession rollerSession =
                RollerSession.getRollerSession(request);
            if (rollerSession.isGlobalAdminUser() )
            {
                UserManager mgr = RollerFactory.getRoller().getUserManager();
                UserAdminForm userForm = (UserAdminForm)actionForm;
               
                if (userForm.isNewUser()) {
                    UserData user = new UserData();
                    userForm.copyTo(user, request.getLocale());
                    user.setId(null);
                    user.setDateCreated(new java.util.Date());
                    user.setEnabled(Boolean.TRUE);
                   
                    // Check username and email addresses
                    msgs = validate(userForm, msgs);

                    // Must have matching passwords and confirm passwords
                    if (    !StringUtils.isEmpty(userForm.getPasswordText())
                         && !StringUtils.isEmpty(userForm.getPasswordConfirm()))
                    {
                        try {
                            user.resetPassword(RollerFactory.getRoller(),
                               userForm.getPasswordText(),
                               userForm.getPasswordConfirm());
                        } catch (RollerException e) {
                            msgs.add(ActionErrors.GLOBAL_ERROR,
                            new ActionError("userSettings.passwordResetError"));
                        }
                    } else {
                        msgs.add(ActionErrors.GLOBAL_ERROR,
                            new ActionError("userSettings.needPasswordTwice"));
                    }
                   
                    // If no error messages, then add user
                    if (msgs.isEmpty()) {
                        try {
                            // Save new user to database
                            mgr.addUser(user);                           
                            RollerFactory.getRoller().flush();
                           
                            msgs.add(ActionMessages.GLOBAL_MESSAGE,
                                new ActionMessage("userSettings.saved"));
                            saveMessages(request, msgs);
                           
                            // Operation complete, return to edit action
                            userForm.setUserName(null);
                            userForm.setNewUser((false));
                           
                        } catch (RollerException e) {
                            // Add and commit failed, so show nice error message
                            msgs.add(ActionErrors.GLOBAL_ERROR,
                                new ActionError(e.getMessage()));
                            saveErrors(request, msgs);
                        }
                    } else {
                        saveErrors(request, msgs);
                    }
                    return edit(mapping, actionForm, request, response)
                   
                } else {
                   
                    UserData user = mgr.getUser(userForm.getId());
                    userForm.copyTo(user, request.getLocale());
               
                    // Check username and email addresses
                    msgs = validate(userForm, msgs);
                   
                    // If user set both password and passwordConfirm then reset
                    if (    !StringUtils.isEmpty(userForm.getPasswordText())
                         && !StringUtils.isEmpty(userForm.getPasswordConfirm()))
                    {
                        try {
                            user.resetPassword(RollerFactory.getRoller(),
                               userForm.getPasswordText(),
                               userForm.getPasswordConfirm());
                        } catch (RollerException e) {
                            msgs.add(ActionErrors.GLOBAL_ERROR,
                                new ActionMessage(
                                    "userSettings.passwordResetError"));
                        }
                    } else if (!StringUtils.isEmpty(userForm.getPasswordText())
                            || !StringUtils.isEmpty(userForm.getPasswordConfirm())) {
                        // But it's an error to specify only one of the two
                        msgs.add(ActionErrors.GLOBAL_ERROR,
                            new ActionMessage(
                                "userSettings.needPasswordTwice"));
                    }
                   
                    if (msgs.isEmpty()) {
                        try {
                           // Persist changes to user
                            mgr.saveUser(user);
                            RollerFactory.getRoller().flush();
                           
                            msgs.add(ActionMessages.GLOBAL_MESSAGE,
                                new ActionMessage("userSettings.saved"));
                            saveMessages(request, msgs);

                            // Operation complete, return to edit action
                            userForm.setUserName(null)
                           
                        } catch (RollerException e) {
                            msgs.add(ActionErrors.GLOBAL_ERROR,
                                new ActionMessage(e.getMessage()));
                            saveErrors(request, msgs);
View Full Code Here

    ActionForm          actionForm,
    HttpServletRequest  request,
    HttpServletResponse response)
    throws IOException, ServletException
  {
         UserAdminForm userForm = (UserAdminForm)actionForm;
         userForm.setUserName(null);        
         userForm.setNewUser(false);
         return edit(mapping, actionForm, request, response);
    }
View Full Code Here

    ActionForm          actionForm,
    HttpServletRequest  request,
    HttpServletResponse response)
    throws IOException, ServletException
  {
         UserAdminForm userForm = (UserAdminForm)actionForm;
         userForm.setNewUser(true);
         userForm.setEnabled(Boolean.TRUE);
         return edit(mapping, actionForm, request, response);
    }
View Full Code Here

    {
      RollerRequest rreq = RollerRequest.getRollerRequest(request);
             RollerSession rollerSession = RollerSession.getRollerSession(request);
      if (rollerSession.isGlobalAdminUser() )
      {
        UserAdminForm uaf = (UserAdminForm)actionForm;
       
        // if admin requests an index be re-built, do it
        IndexManager manager = RollerFactory.getRoller().getIndexManager();                
        manager.rebuildWebsiteIndex();
         request.getSession().setAttribute(
View Full Code Here

TOP

Related Classes of org.apache.roller.presentation.website.formbeans.UserAdminForm

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.