Package org.jayasoft.woj.portal.business.services

Examples of org.jayasoft.woj.portal.business.services.ServiceException


  public void addLicense(User user, Long groupId, String type, int nbLicense, ProductList prodList) throws ServiceException {
    try {
      Group group = (Group) DaoFactory.getGroupDao().find(groupId);
      Collection lics = prodList.getLicenses();
      if (lics.size() < nbLicense) {
          throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.administrated.error.too.many.license", new Object[] {new Integer(nbLicense), new Integer(lics.size())}));
      }
      Iterator it = lics.iterator();
      for (int i=0; i< nbLicense; i++) {
        License lic = (License) it.next();
        doAddLicense(group, lic);
      }
      DaoFactory.getGroupDao().save(group);
      NotificationService.updateGroups(new Group[]{group});
    } catch (DaoException e) {
        LOGGER.error("failed to add license to group", e);
        throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.administrated.error.affect", null));     
    }
  }
View Full Code Here


            Group g = (Group)DaoFactory.getGroupDao().find(groupID);
            License l = (License)DaoFactory.getLicenseDao().find(licenseID);
            addLicense(g, l);
        } catch (DaoException e) {
            LOGGER.warn("failed to retrieve group:" + groupID + " or license:" + licenseID);
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.administrated.error.affect", null));         
        }
    }
View Full Code Here

        try {
            doAddLicense(group, lic);
//            DaoFactory.getGroupDao().save(group);
//            NotificationService.updateGroups(new Group[]{group});
        } catch (DaoException e) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.administrated.error.affect", null));         
        }
    }
View Full Code Here

            if (license.getOwner()!=null) {
                ServiceFactory.getUserService().update(license.getOwner());
            }
    } catch (DaoException e) {
      LOGGER.error("failed to unSet license group", e);
      throw new ServiceException("cannot unset license group", e);     
    }
  }
View Full Code Here

          for (Iterator iter = groups.iterator(); iter.hasNext();) {
              Group group = (Group)iter.next();
              updateSpace(group);
          }
      } catch (DaoException e) {
          throw new ServiceException("failed to update space for groups of "+buyer, e);           
      }
  }
View Full Code Here

           
            updateSpace(group);
            return l;
        } catch (DaoException e) {
            LOGGER.warn("failed to add trial license to user " + userLogged.getLogin() + " from group " + groupId, e);
            throw new ServiceException("cannot add trial license to user");
        }
    }
View Full Code Here

      grp = (Group) grpDao.find(grpId);
      grpDao.remove(grp);
            NotificationService.removeGroups(new Group[] {grp});
    } catch (DaoException e) {
            LOGGER.warn("failed to remove group for Id: " + grpId, e);
            throw new ServiceException("Cannot remove group");
    }
    return false;
  }
View Full Code Here

    return false;
  }

    public void inviteUser(User userLogged, Long groupId, String userMail) throws ServiceException {
        if (userMail==null || !EmailHelper.doEmailSeemsValid(userMail)) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.no.mail", new Object[] {userMail}));
        }
        UserImpl u = (UserImpl)DaoFactory.getUserDao().findUserByEmail(userMail);
        Group g;
        try {
            g = (Group)DaoFactory.getGroupDao().find(groupId);
        } catch (DaoException e) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.group.not.found", new Object[] {groupId}));
        }
        if (u==null) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.no.user.by.mail", new Object[] {userMail}));
        }
   
        License l = u.getLicenseUsed();
        if (l==null || !u.isLicenseValid()) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.user.no.license.valid", new Object[] {userMail}));
        }
        if (!ServiceFactory.getLicenseService().isGroupable(l)) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.user.license.non.groupable", new Object[] {userMail}));
        }
        try {
            ServiceFactory.getMailService().sendMail(Portal.getInstance().getMailFactory().createInviteUserMail(userLogged, u, g));
        } catch (MessagingException e) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.send.mail", null));
        }
    }
View Full Code Here

            UserImpl user = (UserImpl)DaoFactory.getUserDao().find(userID);
            Group group = (Group)DaoFactory.getGroupDao().find(grpID);
           
            License l = user.getLicenseUsed();
            if (!ServiceFactory.getLicenseService().isGroupable(l)) {
                throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.accepted.error.bad.license", null));
            }
            if (!user.isLicenseValid()) {
                throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.accepted.error.license.expired", null));
            }
            if (l.getGroup() != null) {
                removeLicense(new Long(l.getGroup().getId()), new Long(l.getId()));
            }
            addLicense(group, l);
        } catch (DaoException e) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.accepted.error.bad.params", null));
        }
    }
View Full Code Here

                FidelityOfferDao foDao = DaoFactory.getFidelityOfferDao();
                FidelityOffer fo = (FidelityOffer)foDao.find(giftId);
                if (fo != null) {
                    UserPoint oldUP = getUserPoint(user);
                    if (oldUP.getPoints() < fo.getNeededPoints()) {
                        throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.fidelity.offers.not.enough.points", null));
                    }
                    UserPoint up = UserPointFactory.orderGift(u, oldUP, fo);
                    upDao.save(up);
                    ServiceFactory.getRegistrationService().sendOrderGiftMail(user, Messages.DEFAULT.getString(fo.getKey()), fo.getNeededPoints(), up.getPoints());
                    LOGGER.info("removing " + fo.getNeededPoints() + " from user: " + user.getId() + ", he ordered: " + fo.getKey());
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.portal.business.services.ServiceException

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.