Package org.jayasoft.woj.common.model

Examples of org.jayasoft.woj.common.model.User


                        String buyerId = request.getParameter(Params.REGISTER.CLUF.SHOW.PARAMS.BUYER_ID);
                        if (buyerId!=null) {
                            // We come from the license manage page
                            // buyer wants to buy new licenses but has not accepted the last cluf
                            // We build the registration
                            User user = Portal.getInstance().getUserService().getUserById(buyerId);
                            org.jayasoft.woj.portal.model.registration.Registration reg = new org.jayasoft.woj.portal.model.registration.Registration();
                            reg.setUser(user);
                            request.getSession().setAttribute(Params.REGISTER.SESSION.CURRENT_REGISTRATION, reg);
                            request.getSession().setAttribute(Params.REGISTER.SESSION.BUYER_ID, buyerId);
                            // We consider that we are modifying a existing user.
View Full Code Here


                        String buyerId = request.getParameter(Params.REGISTER.CLUF.VALIDATE.PARAMS.BUYER_ID);
                        InvitationInfo invitInfo = (InvitationInfo) request.getSession().getAttribute(Params.REGISTER.SESSION.INVITATION_INFORMATION);
                        if (buyerId != null) {
                            // A trial user want to buy a license
                            // We build the registration
                            User user = Portal.getInstance().getUserService().getUserById(buyerId);
                            org.jayasoft.woj.portal.model.registration.Registration reg = new org.jayasoft.woj.portal.model.registration.Registration();
                            reg.setUser(user);
                            request.getSession().setAttribute(Params.REGISTER.SESSION.CURRENT_REGISTRATION, reg);
                            request.getSession().setAttribute(Params.REGISTER.SESSION.BUYER_ID, buyerId);
                            // We consider that we are modifying a existing user.
                            request.getSession().setAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID, buyerId);
                            clufAccepted = "1";
                        } else if (invitInfo != null) {
                          // Invitation case
                            if ("1".equals(clufAccepted)) {
                                LOGGER.debug("user has accepted the license");
                                String adminId = invitInfo.getAdminId();
                                User admin = ServiceFactory.getUserService().getUserById(adminId);
                                ServiceFactory.getLicenseService().acceptInvitation(invitInfo);
                                request.setAttribute(Params.REGISTER.INVITATION_SUCCEED.REQUEST.ADMIN_MAIL, admin.getEmail());
                                request.getSession().removeAttribute(Params.REGISTER.SESSION.CURRENT_REGISTRATION);
                                request.getSession().removeAttribute(Params.REGISTER.SESSION.INVITATION_INFORMATION);
                                return "account.register.showInvitationAcceptedForm";
                            } else {
                                LOGGER.debug("user has refused the license");
View Full Code Here

            if (buyerId != null) {
                LOGGER.debug("Creating mode buyerId = "+buyerId);
                f.set(Params.REGISTER.PRODUCT.VALIDATE.PARAMS.LICENSE_TYPE, Params.REGISTER.PRODUCT.LICENSES.COMMERCIAL_LICENSE);
                request.setAttribute(Params.REGISTER.PRODUCT.VALIDATE.PARAMS.TRIAL_LICENSE_DISABLE, Boolean.TRUE);
                // Check for licence upgrade
                User user = Portal.getInstance().getUserService().getUserById(buyerId);
                fillProductInForm(user, f, request);
            } else {
                LOGGER.debug("Creating mode no buyer id");
                boolean noProduct = products.size()==0;
                request.setAttribute(Params.REGISTER.PRODUCT.VALIDATE.PARAMS.COMMERCIAL_LICENSE_DISABLE, new Boolean(noProduct));
View Full Code Here

    }

    private static Object getDTO(Object o) {
        Object sentObject = null;
        if (o instanceof User) {
            sentObject = new User();
            BeanHelper.copy(o, sentObject, User.class);
            ((User)sentObject).setGroup((Group) getDTO(((User)o).getGroup()));
        } else
            if (o instanceof Group) {
              sentObject = new Group();
View Full Code Here

                            return "message";
                        } else if (Params.REGISTER.PRODUCT.LICENSES.TRIAL_LICENSE.equals(productType)) {
                            // The user choose a trial license
                            try {
                                LOGGER.debug("adding user in DB");
                                User newUser = ServiceFactory.getRegistrationService().registerTrialUser(r.getUser(), null);
                                LOGGER.debug("user has been registered send mail to check mail");
                                ServiceFactory.getRegistrationService().sendEmailVerification(newUser);
                                request.setAttribute(Params.REGISTER.FINISH.REQUEST.FINISH_OK, Boolean.TRUE);
                                forward = "account.register.showFinishForm";
                            } catch (RegistrationException e) {
                                // Ajout de license impossible
                                request.setAttribute(Params.GENERAL.REQUEST.ERROR_TITLE, "Trial license Error");
                                request.setAttribute(Params.GENERAL.REQUEST.ERROR_DETAIL, e.getMessage());
                                forward = "woj.error";
                            }
                        } else if (Params.REGISTER.PRODUCT.LICENSES.PERSONAL_LICENSE.equals(productType)) {
                            // The user chose a personal license
                            if (!"true".equals(request.getParameter(Params.REGISTER.PRODUCT.VALIDATE.PARAMS.CONFIRM_PERSONAL))) {
                                request.setAttribute(Params.REGISTER.PRODUCT.SHOW.REQUEST.ERROR, "registration.product-form.error.accept.personal.conditions.required");
                                return "account.register.showProductFormAction";                                
                            }

                            String userId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID);
                            if (userId == null) {
                                // Creating mode
                                try {
                                    LOGGER.debug("adding user "+r.getUser()+" in DB");
                                    User newUser = ServiceFactory.getRegistrationService().registerPersonalUser(r.getUser());
                                    LOGGER.debug("user "+newUser+" has been registered send mail to check mail");
                                    ServiceFactory.getRegistrationService().sendEmailVerification(newUser);
                                    request.setAttribute(Params.REGISTER.FINISH.REQUEST.FINISH_OK, Boolean.TRUE);
                                    forward = "account.register.showFinishForm";
                                    request.getSession().setAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID, String.valueOf(newUser.getId()));          
                                } catch (RegistrationException e) {
                                    // Ajout de license impossible
                                    request.setAttribute(Params.GENERAL.REQUEST.ERROR_TITLE, "Personal license Error");
                                    request.setAttribute(Params.GENERAL.REQUEST.ERROR_DETAIL, e.getMessage());
                                    forward = "woj.error";
                                }
                            } else {
                                // Modifying mode
                                UserImpl modifiedUser = (UserImpl) r.getUser();
                                LOGGER.debug("Updating user "+modifiedUser);
                                ServiceFactory.getLicenseService().addPersonalLicense(modifiedUser);
                            }
                        } else if (Params.REGISTER.PRODUCT.LICENSES.COMMUNITY_LICENSE.equals(productType)) {
                            // The user chose a community license
                            if (!"true".equals(request.getParameter(Params.REGISTER.PRODUCT.VALIDATE.PARAMS.CONFIRM_COMMUNITY))) {
                                request.setAttribute(Params.REGISTER.PRODUCT.SHOW.REQUEST.ERROR, "registration.product-form.error.accept.community.conditions.required");
                                return "account.register.showProductFormAction";                                
                            }

                            String projectHome = f.getString(Params.REGISTER.PRODUCT.VALIDATE.PARAMS.COMMUNITY_PROJECT_HOME);
                            if (StringUtils.isBlank(projectHome)) {
                                request.setAttribute(Params.REGISTER.PRODUCT.SHOW.REQUEST.ERROR, "registration.product-form.error.project.home.page.required");
                                return "account.register.showProductFormAction";
                            }


                            String userId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID);
                            if (userId == null) {
                                // Creating mode
                                try {
                                    LOGGER.debug("adding user "+r.getUser()+" in DB");
                                    User newUser = ServiceFactory.getRegistrationService().registerCommunityUser(r.getUser(), projectHome);
                                    LOGGER.debug("user "+newUser+" has been registered send mail to check mail");
                                    ServiceFactory.getRegistrationService().sendEmailVerification(newUser);
                                    request.setAttribute(Params.REGISTER.FINISH.REQUEST.FINISH_OK, Boolean.TRUE);
                                    forward = "account.register.showFinishForm";
                                    request.getSession().setAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID, String.valueOf(newUser.getId()));          
                                } catch (RegistrationException e) {
                                    // Ajout de license impossible
                                    request.setAttribute(Params.GENERAL.REQUEST.ERROR_TITLE, "Community license Error");
                                    request.setAttribute(Params.GENERAL.REQUEST.ERROR_DETAIL, e.getMessage());
                                    forward = "woj.error";
View Full Code Here

                ((RegistrationError)r).setCause(new RegistrationException("missing required fields or fields contain only spaces"));
            } else if (!EmailHelper.doEmailSeemsValid(u.getEmail())) {
                r = new RegistrationError();
                ((RegistrationError)r).setCause(new RegistrationException("your email seems to be invalid"));
            } else {
                User registeredUser = ServiceFactory.getRegistrationService().registerTrialUser(u, hostId);
                ServiceFactory.getRegistrationService().sendEmailVerification(registeredUser);
                r = new RegistrationSuccessfull();
            }
        } catch (RegistrationException e) {
            r = new RegistrationError();
View Full Code Here

                        String type = request.getParameter(Params.RETRIEVE_PASSWORD.PARAMS.TYPE);
                       
                        request.removeAttribute(Params.RETRIEVE_PASSWORD.REQUEST.ERROR_KEY);
                        UserService us = ServiceFactory.getUserService();
                       
                        User u = null;
                        if (Params.RETRIEVE_PASSWORD.CONST.TYPE_LOGIN.equals(type)) {
                            if (!StringUtils.isBlank(login)) {
                                u = us.getUser(login);
                            } else {
                                addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.retrieve-password.error.no.login", null));
                                return "account.retrieve-password.show";
                            }
                        } else if (Params.RETRIEVE_PASSWORD.CONST.TYPE_EMAIL.equals(type)) {
                            if (!StringUtils.isBlank(email)) {
                                u = us.getUserByEmail(email);
                            } else {
                                addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.retrieve-password.error.no.email", null));
                                return "account.retrieve-password.show";
                            }
                        } else {
                            addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.retrieve-password.error.no.type", null));
                            return "account.retrieve-password.show";
                        }
               
                        if (u==null) {
                            // no user found
                            addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.retrieve-password.error.no.user.found", null));
                            return "account.retrieve-password.show";
                        }
                       
                        String newPassword = AlphaNumericalPassGenerator.INSTANCE.generate();
                        u.setPassword(ChecksumUtil.encodeAsString(ChecksumUtil.SHA_1, newPassword));
                       
                        LOGGER.debug("changing password for user " + u.getLogin() + "[" + newPassword + ":" + u.getPassword() + "]");
                        us.update(u);
                        Portal.getInstance().getMailService().asyncSendMail(Portal.getInstance().getMailFactory().createRetrievePasswordMail(u.getEmail(), u.getLogin(), newPassword));
                       
                        return null;
                    }
                }
                , "account.retrieve-password.done");
View Full Code Here

        return u;
    }

    public User register(User u) throws ServiceException, RegistrationException {
        LOGGER.info("registring user " + u.getLogin());
        User usr = ServiceFactory.getUserService().getUser(u.getLogin());
        if (usr!=null) {
            // a user already exists with the same login
            LOGGER.debug("cannot register user" + u.getLogin() + ", login in use");
            throw new LoginExistsException("login :"+ u.getLogin()+ " already exists");
        }
View Full Code Here

    public ActionForward showFidelityOffersForUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        return new SecuredActionTemplate(mapping, form, request, response).execute(
                new AbstractActionCall(){
                    public String doInAction(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServiceException {
                        ActionsHelper.rememberPage(request, "/fidelity/showFidelityOffersForUser");
                        User userLogged = (User)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                        if (userLogged==null) {
                            return ActionsHelper.loginForwardName();
                        }
                       
                        prepareUserPointsPage(request, userLogged);
View Full Code Here

    public ActionForward showUserPoints(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        return new SecuredActionTemplate(mapping, form, request, response).execute(
                new AbstractActionCall(){
                    public String doInAction(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServiceException {
                        ActionsHelper.rememberPage(request, "/fidelity/showUserPoints");
                        User userLogged = (User)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                        if (userLogged==null) {
                            return ActionsHelper.loginForwardName();
                        }

                        prepareUserPointsPage(request, userLogged);
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.common.model.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.