Package org.jayasoft.woj.portal.data.dao.product

Examples of org.jayasoft.woj.portal.data.dao.product.LicenseDao


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

            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);
View Full Code Here


    long validUntil = cal.getTimeInMillis();
    return validUntil;
  }
   
    public void addTrialLicense(User u, String hostId) throws ServiceException {
        LicenseDao licenseDao = DaoFactory.getLicenseDao();
        LOGGER.info("adding trial to user " + u.getLogin() + " registring from host " + hostId);

        // TODO check trial re registration
        if(licenseDao.hasTrialLicenseForHost(hostId)) {
            LOGGER.warn("user " + u.getLogin() + " is trying to register another trial for host " + hostId);
            throw ServiceException.create("You have already requested a trial license. If you want an extra trial time please contact us.", "Host id alread use in trial license", null);
        }
        try {
            License l = licenseDao.createTrial();
            l.setHostId(hostId);
           
            addFreeLicense(u, l);
        } catch (DaoException e) {
            LOGGER.warn("failed to add trial license to user " + u.getLogin() + " from host " + hostId, e);
View Full Code Here

            throw new ServiceException("cannot add trial license to user");
        }
    }

    public void addPersonalLicense(User u) throws ServiceException {
        LicenseDao licenseDao = DaoFactory.getLicenseDao();
        LOGGER.info("adding personal license to user " + u.getLogin());

        try {
            License l = licenseDao.createPersonal();
           
            addFreeLicense(u, l);
        } catch (DaoException e) {
            throw new ServiceException("failed to add personal license to user " + u.getLogin(), e);
        }
View Full Code Here

            throw new ServiceException("failed to add personal license to user " + u.getLogin(), e);
        }
    }

    public void addCommunityLicense(User u, String projectHome) throws ServiceException {
        LicenseDao licenseDao = DaoFactory.getLicenseDao();
        LOGGER.info("adding community license to user " + u.getLogin());

        try {
            CommunityLicense l = licenseDao.createCommunity();
            l.setProjectHomeUrl(projectHome);
           
            addFreeLicense(u, l);
        } catch (DaoException e) {
            throw new ServiceException("failed to add community license to user " + u.getLogin(), e);
View Full Code Here

     * @param buyer the buyer must not be null
     * @return A list of License.
     */
    public List getLicenseBuyedBy(User buyer) {
      List licenses = new ArrayList();
      LicenseDao licenseDao = DaoFactory.getLicenseDao();
    licenses.addAll(licenseDao.findLicenseBuyedBy(buyer.getId()));
    return licenses;
    }
View Full Code Here

  public List getLicensesInGroup(Group editedGroup) {
        if (editedGroup==null) {
            return Collections.EMPTY_LIST;
        }
      List licenses = new ArrayList();
      LicenseDao licenseDao = DaoFactory.getLicenseDao();
    licenses.addAll(licenseDao.findLicenseInGroup(editedGroup.getId()));
    return licenses;
  }
View Full Code Here

    return licenses;
  }

    public void uninviteUserFromLicense(long licenseId) throws ServiceException {
        try {
            LicenseDao ldao = DaoFactory.getLicenseDao();
            License l = (License)ldao.find(new Long(licenseId));
            if (l.getInvitedMail()!=null) {
                l.setInvitedMail(null);
                ldao.save(l);
            }
        } catch (DaoException e) {
            throw ServiceException.create("cannot cancel invitation on license " + licenseId, "cannot cancel invitation on license " + licenseId + ", license not found in DB", e);
        }
    }
View Full Code Here

    return getLicenseWithoutGroupBuyedBy(u, null, onlyNotAffectedLicenses);
  }

  public Collection getLicenseWithoutGroupBuyedBy(User user, String type, final boolean onlyNotAffectedLicenses) {
      List licenses = new ArrayList();
      LicenseDao licenseDao = DaoFactory.getLicenseDao();
        Collection foundLicenses = licenseDao.findLicenseWithoutGroupBuyedBy(user.getId(), type );
       
        final LicenseService ls = ServiceFactory.getLicenseService();
        FilterIterator fi = new FilterIterator(foundLicenses.iterator(), new Predicate() {
            public boolean evaluate(Object object) {
                if (object instanceof License) {
View Full Code Here

    return licenses;
  }
 
  public Collection getLicenseBuyedBy(User buyer, String type) {
      List licenses = new ArrayList();
      LicenseDao licenseDao = DaoFactory.getLicenseDao();
    licenses.addAll(licenseDao.findLicenseBuyedBy(buyer.getId(), type ));
    return licenses;
  }
View Full Code Here

     * Save the given license
     * @param l
     * @throws ServiceException
     */
    public void saveLicense(License l) throws ServiceException {
        LicenseDao lDao = DaoFactory.getLicenseDao();
        try {
            lDao.save(l);
        } catch (DaoException e) {
            throw new ServiceException("license could not be saved", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.portal.data.dao.product.LicenseDao

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.