userForm.getFullName()));
user.getFullName()));
    public ActionForward save(ActionMapping mapping, ActionForm form,                              HttpServletRequest request,                              HttpServletResponse response)    throws Exception {        if (log.isDebugEnabled()) {            log.debug("Entering 'save' method");        }                // Extract attributes and parameters we will need        ActionMessages errors = new ActionMessages();        ActionMessages messages = new ActionMessages();        HttpSession session = request.getSession();        UserForm userForm = (UserForm) form;        String password = userForm.getPassword();        User user = new User();        // Exceptions are caught by ActionExceptionHandler        // all we need to persist is the parent object        BeanUtils.copyProperties(user, userForm);        if (StringUtils.equals(request.getParameter("encryptPass"), "true")) {            String algorithm =                (String) getConfiguration().get(Constants.ENC_ALGORITHM);            if (algorithm == null) { // should only happen for test case                log.debug("assuming testcase, setting algorigthm to 'SHA'");                algorithm = "SHA";            }            user.setPassword(StringUtil.encodePassword(password, algorithm));        }        UserManager mgr = (UserManager) getBean("userManager");        RoleManager roleMgr = (RoleManager) getBean("roleManager");        String[] userRoles = request.getParameterValues("userRoles");        for (int i = 0; userRoles != null &&  i < userRoles.length; i++) {            String roleName = userRoles[i];            user.addRole(roleMgr.getRole(roleName));        }        try {            mgr.saveUser(user);        } catch (UserExistsException e) {            log.warn(e.getMessage());            errors.add(ActionMessages.GLOBAL_MESSAGE,                       new ActionMessage("errors.existing.user",                                         userForm.getUsername(),                                         userForm.getEmail()));            saveErrors(request, errors);            return mapping.findForward("edit");        }        BeanUtils.copyProperties(userForm, convert(user));        userForm.setConfirmPassword(userForm.getPassword());        updateFormBean(mapping, request, userForm);        if (!StringUtils.equals(request.getParameter("from"), "list")) {            session.setAttribute(Constants.USER_KEY, user);            // update the user's remember me cookie if they didn't login            // with a cookie            if ((RequestUtil.getCookie(request, Constants.LOGIN_COOKIE) != null) &&                    (session.getAttribute("cookieLogin") == null)) {                // delete all user cookies and add a new one                mgr.removeLoginCookies(userForm.getUsername());                String autoLogin =                    mgr.createLoginCookie(userForm.getUsername());                RequestUtil.setCookie(response, Constants.LOGIN_COOKIE,                                      autoLogin, request.getContextPath());            }            // add success messages            messages.add(ActionMessages.GLOBAL_MESSAGE,                         new ActionMessage("user.saved"));            saveMessages(request.getSession(), messages);            // return a forward to main Menu            return mapping.findForward("mainMenu");        } else {            // add success messages            if ("".equals(request.getParameter("version"))) {                messages.add(ActionMessages.GLOBAL_MESSAGE,                             new ActionMessage("user.added",                                               userForm.getFullName()));                session.setAttribute(Globals.MESSAGE_KEY, messages);                sendNewUserEmail(request, userForm);                return mapping.findForward("addUser");            } else {                messages.add(ActionMessages.GLOBAL_MESSAGE,                             new ActionMessage("user.updated.byAdmin",                                               userForm.getFullName()));                saveMessages(request, messages);                return mapping.findForward("edit");            }        }    }