Package org.jayasoft.woj.portal.model

Examples of org.jayasoft.woj.portal.model.UserImpl


                            request.setAttribute(Params.REDIRECT.REQUEST.MESSAGE_KEY, "illegal.state");
                            return "redirect";
                        }
                       
                        DynaActionForm f = (DynaActionForm)form;
                        UserImpl usr = (UserImpl)u;
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.PASSWORD, null);
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.CONFIRM_PASSWORD, null);
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.LOGIN, usr.getLogin());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.EMAIL, usr.getEmail());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.FIRST_NAME, usr.getFirstName());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.LAST_NAME, usr.getLastName());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.ADRESS, usr.getAdress());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.CITY, usr.getCity());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.POSTAL_CODE, usr.getPostalCode());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.COUNTRY, usr.getCountry());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.COMPANY, usr.getCompany());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.COMPANY_HOMEPAGE, usr.getCompanyHomepage());
                        f.set(Params.USER_ACCOUNT.VALIDATE.PARAMS.GODFATHER, usr.getGodfather());
                       
                        request.setAttribute("countries", Portal.getInstance().getGeographyService().getCountries());
                        request.setAttribute(Params.USER_ACCOUNT.SHOW.REQUEST.USER, u);
                        request.setAttribute(Params.USER_ACCOUNT.VALIDATE.PARAMS.LOGIN, u.getLogin());
                        request.setAttribute(Params.USER_ACCOUNT.SHOW.REQUEST.EMAIL_VALID, Boolean.valueOf(usr.isMailVerified()).toString());
                        int uPoints = ServiceFactory.getFidelityService().getUserPoint(usr).getPoints();
                        request.setAttribute(Params.USER_ACCOUNT.SHOW.REQUEST.POINTS, new Integer(uPoints));
                        request.setAttribute(Params.USER_ACCOUNT.SHOW.REQUEST.HAS_POINTS, Boolean.valueOf(uPoints>0));
                       
                        return null;
View Full Code Here


                        String pass = f.getString(Params.USER_ACCOUNT.VALIDATE.PARAMS.PASSWORD);
                        String passConfirm = f.getString(Params.USER_ACCOUNT.VALIDATE.PARAMS.CONFIRM_PASSWORD);
                        boolean emailChanged = false;
                       
                        if (ActionsHelper.noneEmpty(new String[] {login,email,fName,lName,country})) {
                            UserImpl u = (UserImpl)ServiceFactory.getUserService().getUser(login);

                            if (!StringUtils.isEmpty(pass) && !StringUtils.isEmpty(passConfirm)) {
                                // both password are given, we check equality
                                if (pass.equals(passConfirm)) {
                                    LOGGER.info("user " + u.getLogin() + " is changing is password");
                                    u.setPassword(pass);
                                } else {
                                    addWOJMessages(request, RessourceBundleApplicationMessage.error("registration.user-form.error.password.not.identical", null));
                                    LOGGER.debug("passwords are not identiqual [" + pass + ":" + passConfirm +"]");
                                    return "user.account.showForm";
                                }
                            } else {
                                // at least one of password is empty
                                if (!ActionsHelper.allEmpty(new String[] {pass, passConfirm})){
                                    addWOJMessages(request, RessourceBundleApplicationMessage.error("registration.user-form.error.password.missing", null));
                                    LOGGER.debug("only one password provided [" + pass + ":" + passConfirm +"]");
                                    return "user.account.showForm";
                                }
                                // both passwords are empty
                            }
                            if (!email.equals(u.getEmail())) {
                                if (ServiceFactory.getUserService().getUserByEmail(email) != null) {
                                    // The user already exists
                                    addWOJMessages(request, RessourceBundleApplicationMessage.error("registration.user-form.error.email.already.exists", null));
                                    LOGGER.debug("duplicate email found when validating user account page, " + email +  " is already used");
                                    return "user.account.showForm";
                                }
                                // Email has changed
                                u.setEmail(email);
                                u.setMailVerified(false);
                                emailChanged = true;
                                addWOJMessages(request, RessourceBundleApplicationMessage.warning("woj.user.account.email.changed", null));
                            }
                            u.setFirstName(fName);
                            u.setLastName(lName);
                            u.setAdress(adress);
                            u.setCity(city);
                            u.setPostalCode(postalCode);
                            u.setCountry(country);
                            u.setCompany(cName);
                            u.setCompanyHomepage(cHomepage);
                           
                            ServiceFactory.getUserService().update(u);
                           
                            addWOJMessages(request, RessourceBundleApplicationMessage.info("woj.user.account.updated", null));
                            if (emailChanged) {
View Full Code Here

                      List foundUsers = s.createCriteria(User.class)
                          .add(Restrictions.gt("timestamp", since))
                          .list();
                     
                      for (Iterator it = foundUsers.iterator(); it.hasNext();) {
                        UserImpl u = (UserImpl)it.next();
                        Set licenses = u.getBuyedLicenses();
                        if (licenses!=null) {
                            licenses.size();
                        }
                        if (u.getGroup() != null) {
                            u.getGroup().getName();
                        }
                        License used = u.getLicenseUsed();
                        if (used!=null) {
                            used.getValidUntil();
                        }
                      }
                     
View Full Code Here

   
    /* (non-Javadoc)
     * @see org.jayasoft.woj.portal.data.dao.hibernate.DefaultHibernateWOJDao#newHandledObject()
     */
    public WOJObject newHandledObject() {
        return new UserImpl();
    }
View Full Code Here

        getHelper().doRemove(o);
    }

    public void fetch(final WOJObject o) throws DaoException {
        if (o instanceof UserImpl) {
            final UserImpl u = (UserImpl)o;
            HibernateTemplate t = new HibernateTemplate(getSessionFactory());
            t.execute(
                    new HibernateCallback() {
                        public Object doInHibernate(Session s) throws HibernateException, SQLException {
                            s.lock(u, LockMode.NONE);
                            u.getBuyedLicenses().size();
                            return null;
                        }
                    }
            );
        }
View Full Code Here

        return _uDao.findUserByEmail(email);
    }
   
    public void addUser(User u) throws RegistrationException {
        // We ensure that we save a correct user implementation
        UserImpl userToSave = (UserImpl)_uDao.newHandledObject();
        BeanHelper.copy(u, userToSave, User.class);
       
        User usr = _uDao.findUser(u.getLogin());
       
        if (usr!=null) {
View Full Code Here

    }

    public void update(User user) throws ServiceException {
    try {
      boolean isNew = user.getId() == 0;
      UserImpl userToSave = null;
      if (user instanceof UserImpl) {
        userToSave = (UserImpl) user;
      } else {
        userToSave = (UserImpl)DaoFactory.getUserDao().newHandledObject();
        BeanHelper.copy(user, userToSave, User.class);
      }
      DaoFactory.getUserDao().save(userToSave);
      License license = userToSave.getLicenseUsed();
      PrincipalRight pr = null;
      if (license != null && ServiceFactory.getLicenseService().isProfessional(license)) {
        pr = new PrincipalRight(userToSave.getId(), Visibility.PRIVATE);
      } else {
        pr = new PrincipalRight(userToSave.getId(), Visibility.SANDBOX);       
      }
      if(isNew) {
        NotificationService.addUsers(new User[]{userToSave});
      } else {
        NotificationService.updateUsers(new User[]{userToSave});
View Full Code Here

                        if (userLogged==null) {
                            LOGGER.debug("user try to access license page without being logged in.");
                            return ActionsHelper.loginForwardName();
                        }
                        String userLogin = (String)request.getParameter(Params.USER_LICENSE.SHOW.PARAMS.LOGIN);
                        UserImpl u = null;
                        if (userLogin!=null) {
                            if (!userLogged.getLogin().equals(userLogin) && !ActionsHelper.isAdmin(request)) {
                                // a non admin user try to edit another user page
                                LOGGER.debug("user " + userLogged.getLogin() + " try to edit " + userLogin + " license page without admin rights");
                                return ActionsHelper.homepageForwardName();
                            }
                            LOGGER.debug("showing license form for user with login : " + userLogin);
                            u = (UserImpl)DaoFactory.getUserDao().findUser(userLogin);
                        } else {
                            LOGGER.debug("showing license form for connected user");
                            u = (UserImpl)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                            if (u!=null) {
                                // We refresh the user
                                u = (UserImpl)Portal.getInstance().getUserService().getUser(u.getLogin());
                                if (u!=null) {
                                    request.getSession().setAttribute(Params.LOGIN.SESSION.USER, u);
                                }
                            }
                        }
                       
                        if (u == null) {
                            LOGGER.debug("failed to retrieve user to modify in license form");
                            request.setAttribute(Params.REDIRECT.REQUEST.REDIRECTION_URL, ActionsHelper.homepageForward().getPath());
                            request.setAttribute(Params.REDIRECT.REQUEST.MESSAGE_KEY, "illegal.state");
                            return "redirect";
                        }
               
                        if (u.getLastAcceptedCluf() != null) {
                            if (ServiceFactory.getLicenseService().getCurrentClufVersion().equals(u.getLastAcceptedCluf().getVersion())) {
                                request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.ACCEPTED_LAST_CLUF, Boolean.TRUE);
                            } else {
                                request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.ACCEPTED_LAST_CLUF, Boolean.FALSE);
                            }
                        } else {
                            request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.ACCEPTED_LAST_CLUF, Boolean.FALSE);
                        }
                       
                        License currentLicense = null;
                        if (u instanceof UserImpl) {
                          currentLicense = ((UserImpl)u).getLicenseUsed();
                          request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.CURRENT_LICENSE, currentLicense);
                        }
               
                        List boughtLicenses =  ServiceFactory.getLicenseService().getLicenseBuyedBy(u);
                        request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.BOUGHT_LICENSES, boughtLicenses);
                       
                        request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.USER, u);
                        request.setAttribute(Params.USER_LICENSE.VALIDATE.PARAMS.LOGIN, u.getLogin());
                       
                        return null;
                    }
                }
                , "user.license.show"
View Full Code Here

                        if (userLogged==null) {
                            LOGGER.debug("user try to access license page without being logged in.");
                            return ActionsHelper.loginForwardName();
                        }
                        String userLogin = (String)request.getParameter(Params.USER_LICENSE.SHOW.PARAMS.LOGIN);
                        UserImpl u = null;
                        if (userLogin!=null) {
                            if (!userLogged.getLogin().equals(userLogin) && !ActionsHelper.isAdmin(request)) {
                                // a non admin user try to edit another user page
                                LOGGER.debug("user " + userLogged.getLogin() + " try to edit " + userLogin + " license page without admin rights");
                                return ActionsHelper.homepageForwardName();
                            }
                            LOGGER.debug("showing license form for user with login : " + userLogin);
                            u = (UserImpl)DaoFactory.getUserDao().findUser(userLogin);
                        } else {
                            LOGGER.debug("showing license form for connected user");
                            u = (UserImpl)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                            if (u!=null) {
                                // We refresh the user
                                u = (UserImpl)Portal.getInstance().getUserService().getUser(u.getLogin());
                                if (u!=null) {
                                    request.getSession().setAttribute(Params.LOGIN.SESSION.USER, u);
                                }
                            }
                        }
                        String licenseID = request.getParameter("license");
                        try {
                          License l = (License) DaoFactory.getLicenseDao().find(new Long(licenseID));
                          UserImpl owner = (UserImpl) l.getOwner();
                          if(owner != null){
                            //free our license
                            if(u.getId() == owner.getId()) {
                              request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.CURRENT_LICENSE, null);
                            }
                            owner.setLicenseUsed(null);
                            ServiceFactory.getUserService().update(owner);
                          }
                        } catch (Exception e) {
              LOGGER.error("unable to free license id="+licenseID, e);
            }
View Full Code Here

                        if (userLogged==null) {
                            LOGGER.debug("user try to access license page without being logged in.");
                            return ActionsHelper.loginForwardName();
                        }
                        String userLogin = (String)request.getParameter(Params.USER_LICENSE.SHOW.PARAMS.LOGIN);
                        UserImpl u = null;
                        if (userLogin!=null) {
                            if (!userLogged.getLogin().equals(userLogin) && !ActionsHelper.isAdmin(request)) {
                              // a non admin user try to edit another user page
                                LOGGER.debug("user " + userLogged.getLogin() + " try to edit " + userLogin + " license page without admin rights");
                                return ActionsHelper.homepageForwardName();
                            }
                            LOGGER.debug("showing license form for user with login : " + userLogin);
                            u = (UserImpl)DaoFactory.getUserDao().findUser(userLogin);
                        } else {
                            LOGGER.debug("showing license form for connected user");
                            u = (UserImpl)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                            if (u!=null) {
                                // We refresh the user
                                u = (UserImpl)Portal.getInstance().getUserService().getUser(u.getLogin());
                                if (u!=null) {
                                    request.getSession().setAttribute(Params.LOGIN.SESSION.USER, u);
                                }
                            }
                        }
                        String licenseID = request.getParameter("license");
                        try {
                          License l = (License) DaoFactory.getLicenseDao().find(new Long(licenseID));
                          request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.CURRENT_LICENSE, l);
                          u.setLicenseUsed(l);
                          ServiceFactory.getUserService().update(u);
            } catch (Exception e) {
              LOGGER.error("unable to affect license id="+licenseID, e);
            }
           
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.portal.model.UserImpl

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.