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

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


        ActionForward forward = mapping.findForward("yourProfile.page");
        try
        {
            RollerSession rollerSession = RollerSession.getRollerSession(request);
            UserData ud = rollerSession.getAuthenticatedUser();
            UserFormEx form = (UserFormEx)actionForm;
            form.copyFrom(ud, request.getLocale());
            form.setPasswordText(null);
            form.setPasswordConfirm(null);
            form.setLocale(ud.getLocale());
            form.setTimeZone(ud.getTimeZone());
            request.setAttribute("model", new BasePageModel(
                "yourProfile.title", request, response, mapping));
        }
        catch (Exception e)
        {
View Full Code Here


        ActionForm          actionForm,
        HttpServletRequest  request,
        HttpServletResponse response)
        throws IOException, ServletException
    {
        UserFormEx form = (UserFormEx)actionForm;
        ActionForward forward = mapping.findForward("yourProfile.page");
        ActionMessages msgs = new ActionMessages();
        try
        {
            ActionMessages errors = validate(form, new ActionErrors());
            if (errors.size() == 0)
            {
                // We ONLY modify the user currently logged in
                RollerSession rollerSession = RollerSession.getRollerSession(request);
                UserData data = rollerSession.getAuthenticatedUser();
               
                // We want to be VERY selective about what data gets updated
                data.setFullName(form.getFullName());
                data.setEmailAddress(form.getEmailAddress());
                data.setLocale(form.getLocale());
                data.setTimeZone(form.getTimeZone());
               
                // If user set both password and passwordConfirm then reset password
                if (    !StringUtils.isEmpty(form.getPasswordText())
                     && !StringUtils.isEmpty(form.getPasswordConfirm()))
                {
                    try
                    {
                        data.resetPassword(RollerFactory.getRoller(),
                           form.getPasswordText(),
                           form.getPasswordConfirm());
                    }
                    catch (RollerException e)
                    {
                        msgs.add(ActionMessages.GLOBAL_MESSAGE,
                            new ActionMessage("yourProfile.passwordResetError"));
View Full Code Here

        ActionForm          actionForm,
        HttpServletRequest  request,
        HttpServletResponse response)
        throws IOException, ServletException
    {
        UserFormEx userForm = (UserFormEx)actionForm;
        userForm.setAdminCreated(true);
        return registerUser(mapping, actionForm, request, response);
    }
View Full Code Here

        ActionForward forward = mapping.findForward("registerUser.page");
        ActionErrors errors = new ActionErrors();
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        try
        {
            UserFormEx userForm = (UserFormEx)actionForm;
           
            userForm.setLocale(Locale.getDefault().toString());
            userForm.setTimeZone(TimeZone.getDefault().getID());
           
            userForm.setPasswordText(null);
            userForm.setPasswordConfirm(null);           
            request.setAttribute("model", new BasePageModel(
                    "newUser.addNewUser", request, response, mapping));
        }
        catch (Exception e)
        {
View Full Code Here

        ActionForm          actionForm,
        HttpServletRequest  request,
        HttpServletResponse response)
        throws IOException, ServletException
    {
        UserFormEx form = (UserFormEx)actionForm;
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        ServletContext ctx = rreq.getServletContext();
        RollerContext rollerContext = RollerContext.getRollerContext();

        boolean reg_allowed =
                RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");

        if ( !reg_allowed && !request.isUserInRole("admin"))
        {
            throw new ServletException("New users disabled!");
        }

        ActionMessages msgs = new ActionMessages();
        ActionMessages errors = validate(form, new ActionErrors());
        if (!errors.isEmpty())
        {
            saveErrors(request, errors);
        }
        else try
        {
            // Add new user
            UserManager mgr = RollerFactory.getRoller().getUserManager();

            UserData ud = new UserData();
            form.copyTo(ud, request.getLocale()); // doesn't copy password
            ud.setId(null);
            ud.setDateCreated(new java.util.Date());
            ud.setEnabled(Boolean.TRUE);

            // If user set both password and passwordConfirm then reset password
            if (    !StringUtils.isEmpty(form.getPasswordText())
                 && !StringUtils.isEmpty(form.getPasswordConfirm()))
            {
               ud.resetPassword(RollerFactory.getRoller(),
                  form.getPasswordText(), form.getPasswordConfirm());
            }
           
            // save new user
            mgr.addUser(ud);
            RollerFactory.getRoller().flush();
           
            if (form.getAdminCreated())
            {
                // User created for admin, so return to new user page with empty form
                msgs.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("newUser.created"));
                saveMessages(request, msgs);
                form.reset(mapping, request);
                return createUser(mapping, actionForm, request, response);
            }
            else
            {
                // User registered, so go to welcome page
                String weblogURL = rollerContext.getAbsoluteContextUrl(request)
                                 + "/page/"+ud.getUserName();
                request.setAttribute("weblogURL",weblogURL);  
                String rssURL = rollerContext.getAbsoluteContextUrl(request)
                              + "/rss/"+ud.getUserName();
                request.setAttribute("rssURL",rssURL)
                request.setAttribute("contextURL",
                                 rollerContext.getAbsoluteContextUrl(request));
                return mapping.findForward("welcome.page");
            }
        }
        catch (RollerException e)
        {
            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(e.getMessage()));
            saveErrors(request,errors);         
            mLogger.error("ERROR in addUser", e);
            form.setUserName("");
        }

        if (form.getAdminCreated())
        {
            return mapping.findForward("createUser");
        }
        else
        {
View Full Code Here

TOP

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

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.