Package org.jayasoft.woj.portal.model

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


      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);
            }

            for (int i = 0; i < nb; i++) {
          License l = (License) licenseDao.newHandledObject();
          l.setBuyer(user);
          l.setPrice(price);
          l.setSpecialOffer(so);
          long validUntil = getValidUntil(duration);
        l.setValidUntil(validUntil);
          user.getBuyedLicenses().add(l);
          newLicense.add(l);
          //counter increment
          price.getCounter().increment();
          if(so != null) {
            so.getCounter().increment();
View Full Code Here


        LOGGER.debug(trialLicensesByOwner.size()+" licenses still need to be upgraded, "+availableLicenses.size()+" available");
        if (! trialLicensesByOwner.isEmpty() && trialLicensesByOwner.size() <= availableLicenses.size()) {
            // there is enough licenses for the number of currently used trial licenses: we upgrade them all
            LOGGER.debug("upgrading licenses of "+trialLicensesByOwner.keySet());
            for (Iterator iter = trialLicensesByOwner.keySet().iterator(); iter.hasNext();) {
                UserImpl owner = (UserImpl)iter.next();
                License newLicense = (License)availableLicenses.remove(0);
                owner.setLicenseUsed(newLicense);
                DaoFactory.getUserDao().save(owner);
                usersToUpdate.add(owner);
            }
        } else {
            LOGGER.debug("not enough licenses, no upgrade");
View Full Code Here

    }

    private void addFreeLicense(User u, License l) throws DaoException, ServiceException {
        UserDao userDao = DaoFactory.getUserDao();
        ClufImpl cluf = getActiveCluf();
        UserImpl user = (UserImpl)userDao.findUser(u.getLogin());
        userDao.fetch(user);
        if ((user.getLastAcceptedCluf() == null) || !cluf.getVersion().equals(user.getLastAcceptedCluf().getVersion())) {
            user.setLastAcceptedCluf(cluf);
        }
        user.getBuyedLicenses().add(l);
        l.setBuyer(user);
       
        if (!License.TRIAL.equals(l.getProductCode())) {
            upgradeLicenses(user, Collections.singletonList(l));
        }

        user.setLicenseUsed(l);
        ServiceFactory.getUserService().update(user);
        LOGGER.info("license added to user " + u.getLogin()+": "+l);
    }
View Full Code Here

        try {
            List licenses = ldao.find(licIDs);
            for (Iterator it = licenses.iterator(); it.hasNext();) {
                License lic = (License)it.next();
                if (lic.getOwner()!=null) {
                    UserImpl u = (UserImpl)lic.getOwner();
                    u.setLicenseUsed(null);
                    ServiceFactory.getUserService().update(u);
                    LOGGER.debug("license " + lic+ " was free from user " + u);
                }
            }
            // No need to save licenses, the u.setLicenseUsed do it for us
View Full Code Here

                if (!(l1.getOwner()==null && l2.getOwner()==null) && !(l1.getOwner()!=null && l2.getOwner()!=null)) {
                    License licToAffect = (l1.getOwner()==null)?l1:l2;
                    License licToFree = (l1.getOwner()==null)?l2:l1;

                    licToAffect.setInvitedMail(null);
                    UserImpl u = (UserImpl)licToFree.getOwner();
                   
                    LOGGER.info("swapping license used by user:" + u.getLogin() + " from " + licToFree.getId() + " to " + licToAffect.getId());
                    u.setLicenseUsed(licToAffect);
                    ServiceFactory.getUserService().update(u);
                } else {
                    throw new ServiceException(RessourceBundleApplicationMessage.warning("woj.page.admin.user.license.error.swap.failed.bad.owners", null));
                }
            } else {
View Full Code Here

        }
    }

    public void useLicence(User userLogged, Long licID) throws ServiceException {
        try {
            UserImpl u = (UserImpl)DaoFactory.getUserDao().find(new Long(userLogged.getId()));
            License l = (License)DaoFactory.getLicenseDao().find(licID);
            if (l!=null) {
                l.setInvitedMail(null);
                u.setLicenseUsed(l);
                ServiceFactory.getUserService().update(u);
            }
        } catch (DaoException e) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.license.error.use", null));
        }
View Full Code Here

                            LOGGER.debug("user try to access group page without being logged in.");
                            return ActionsHelper.homepageForwardName();
                        }
                      
                        String userLogin = (String)request.getParameter(Params.USER_GROUP.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 + " groups page without admin rights");
                                return ActionsHelper.homepageForwardName();
                            }
                            LOGGER.debug("showing group form for user with login : " + userLogin);
                            u = (UserImpl)DaoFactory.getUserDao().findUser(userLogin);
                        } else {
                            LOGGER.debug("showing group 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);
                                }
                            }
                        }
View Full Code Here

    if(userId == null) {
      throw ServiceException.create("Bad parameter", "Can't confirm user with null id", null);
    }
    try {
      Long longId = Long.valueOf(userId);
      UserImpl userImpl = (UserImpl) DaoFactory.getUserDao().find(longId);
            if (userImpl==null) {
                throw new ServiceException("cannot confirm email, userid" + longId + " is unknown");
            }
      if(!userImpl.isMailVerified()) {
        userImpl.setMailVerified(true);
        update(userImpl);
        ServiceFactory.getRegistrationService().sendRegistrationConfirmationMail(userImpl);
                NotificationService.updateUsers(new User[] {userImpl});
      }
    } catch (NumberFormatException e) {
View Full Code Here

                , "user.group.accept.invitation.existing.user"
        );
    }
   
    protected String prepareShowAcceptedUserInvitation(HttpServletRequest request, Long usrId, Long grpId) {
        UserImpl u = null;
        Group g = null;
        try {
            u = (UserImpl)DaoFactory.getUserDao().find(usrId);
            g = (Group)DaoFactory.getGroupDao().find(grpId);
        } catch (Exception e) {
View Full Code Here

                , "user.group.accept.invitation.existing.user"
        );
    }
   
    protected String prepareShowAcceptUserInvitation(HttpServletRequest request, Long usrId, Long grpId) {
        UserImpl u = null;
        Group g = null;
        try {
            u = (UserImpl)DaoFactory.getUserDao().find(usrId);
            g = (Group)DaoFactory.getGroupDao().find(grpId);
        } catch (Exception e) {
            addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.error.invalid.parameters", null));
            return "error.msg";
        }
        if (u==null || g==null) {
            addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.error.invalid.parameters", null));
            return "error.msg";
        }
       
        License userLicense = u.getLicenseUsed();
       
        if (userLicense == null || !ServiceFactory.getLicenseService().isGroupable(userLicense) || !u.isLicenseValid()) {
            addWOJMessages(request, RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.error.invalid.parameters", null));
            return "error.msg";
        }
        if (userLicense.getGroup() != null) {
            request.setAttribute(Params.USER_GROUP.INVITATION.SHOW.REQUEST.CURRENT_GROUP, userLicense.getGroup());
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.