Package org.jayasoft.woj.common.model

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


                new AbstractActionCall() {
                    public String doInAction(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServiceException {
                        ActionsHelper.rememberPage(request, "/user/account/show");
                        ActionsHelper.rememberContext(request, "admin");
                       
                        User userLogged = (User)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                        if (userLogged==null) {
                            LOGGER.debug("user try to access account page without being logged in.");
                            return ActionsHelper.loginForwardName();
                        }
                        String userLogin = (String)request.getParameter(Params.USER_ACCOUNT.SHOW.PARAMS.LOGIN);
                        User 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 + " page without admin rights");
                                return ActionsHelper.homepageForwardName();
                            }
                            LOGGER.debug("showing account form for user with login : " + userLogin);
                            u = DaoFactory.getUserDao().findUser(userLogin);
                        } else {
                            LOGGER.debug("showing account form for connected user");
                            u = (User)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                            if (u!=null) {
                                // We refresh the user
                                u = 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 account form");
                            request.setAttribute(Params.REDIRECT.REQUEST.REDIRECTION_URL, ActionsHelper.homepageForward().getPath());
                            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));
                       
View Full Code Here


   
    public ActionForward sendEmailConfirmation(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 {
                        User u = ServiceFactory.getUserService().getUser(request.getParameter(Params.USER_ACCOUNT.VALIDATE.PARAMS.LOGIN));
                        try {
                            ServiceFactory.getMailService().sendMail(Portal.getInstance().getMailFactory().createConfirmationMail(u));
                            addWOJMessages(request, RessourceBundleApplicationMessage.info("woj.user.account.emailconfirmed.sent", new Object[] {u.getEmail()}));
                        } catch (MessagingException e) {
                            LOGGER.warn("cannot send confimration email to user " + u.getLogin(), e);
                            addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.user.account.emailconfirmed.error.sent", new Object[] {u.getEmail()}));
                        }
                        return null;
                    }
                }
                , "user.account.mail.sent"
View Full Code Here

    }
   
    public List addLicense(Order order) throws ServiceException, RegistrationException {
        LOGGER.info("adding licenses to order:" + order.getId());
      List newLicense = new ArrayList();
      User u = order.getBuyer();
      Price price = order.getPrice();
      SpecialOffer so = order.getSpecialOffer();
      int nb = order.getSubscribedUsers();
      int duration = order.getSubscribedYears();
      UserDao userDao = DaoFactory.getUserDao();
      LicenseDao licenseDao = DaoFactory.getLicenseDao();
      try {
            ClufImpl cluf = getActiveCluf();
           
        userDao.fetch(u);
        UserImpl user = (UserImpl)userDao.findUser(u.getLogin());
        userDao.fetch(user);

            if ((user.getLastAcceptedCluf() == null) || !cluf.getVersion().equals(user.getLastAcceptedCluf().getVersion())) {
                user.setLastAcceptedCluf(cluf);
            }
View Full Code Here

       
        if (mail==null || !EmailHelper.doEmailSeemsValid(mail)) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.license.error.invite.no.mail", new Object[] {licenseToAffect.getProductCode(), TimeUtil.getDate(licenseToAffect.getValidUntil())}));
        }
       
    User userToAffect = ServiceFactory.getUserService().getUserByEmail(mail);
    String invitedFisrtName = "";
    String invitedLastName = "";   
    if (userToAffect != null) {
      invitedFisrtName = ((UserImpl)userToAffect).getFirstName();
      invitedLastName = ((UserImpl)userToAffect).getLastName();
View Full Code Here

  public void acceptInvitation(InvitationInfo invitInfo) throws ServiceException {
    String mail = invitInfo.getMail();
    try {
      ClufImpl cluf = ServiceFactory.getLicenseService().getActiveCluf();
      License licenseToAffect = (License) DaoFactory.getLicenseDao().find(new Long(Long.parseLong(invitInfo.getLicenseId())));
      User userToAffect = invitInfo.getUser();
      if (mail == null || !mail.equals(licenseToAffect.getInvitedMail())) {
        throw new IllegalArgumentException("Failed to accept invitation for user with mail : " + mail + ". This user hasn't been invited");
       
      }
      // Check user is in session
      User u = DaoFactory.getUserDao().findUser(userToAffect.getLogin());
      if (u != null) {
//      BeanHelper.copy(userToAffect, u, UserImpl.class);
      userToAffect = u;
      }
View Full Code Here

        return null;
    }

  public User getOwner(License l) {
    UserDao userDao = DaoFactory.getUserDao();
    User user = userDao.findUserUsinglicense(l);
    return user;
  }
View Full Code Here

   
    public ActionForward showUserForm(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 {
                        User user = (User)request.getSession().getAttribute(Params.LOGIN.SESSION.USER);
                        if (user != null) {
                            if (ServiceFactory.getLicenseService().getCurrentClufVersion().equals(((UserImpl)user).getLastAcceptedCluf().getVersion())) {
                                request.setAttribute(Params.USER_LICENSE.SHOW.REQUEST.ACCEPTED_LAST_CLUF, Boolean.TRUE);
                            }
                            return "account.register.userFormUserLogged";
View Full Code Here

                        LOGGER.debug("dealing invitation usrMail:" + mail + " licId:" + licenseId + " admId:" + adminId);
                       
                        InvitationInfo invitationInfo = ServiceFactory.getUserService().getInvitationInfo(mail, licenseId, adminId);
            request.getSession().setAttribute(Params.REGISTER.SESSION.INVITATION_INFORMATION, invitationInfo);
                       
                        User invitedUser = ServiceFactory.getUserService().getUserByEmail(mail);
                        if (invitedUser != null) {
                          invitationInfo.setUser(invitedUser);
                            return "account.register.showClufFormAction";
                        } else {
                            DynaActionForm f = (DynaActionForm)form;
View Full Code Here

    }   
   
   

    private boolean checkEmail(HttpServletRequest request, String email) {
        User u = Portal.getInstance().getSecurityService().findUserByEmail(email);
      String userId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID);
    return (u != null) && !(String.valueOf(u.getId()).equals(userId));
    }
View Full Code Here

      String userId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID);
    return (u != null) && !(String.valueOf(u.getId()).equals(userId));
    }
   
  private boolean checkLogin(HttpServletRequest request, String login) {
        User u = Portal.getInstance().getSecurityService().findUser(login);
      String userId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.CURRENT_USER_ID);
    return (u != null) && !(String.valueOf(u.getId()).equals(userId));
  }
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.