Examples of LicenseDao


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

    /**
     * Free the given licenses from their owner
     * @param licIDs a list of license IDs as Long
     */
    public void freeLicenses(List licIDs) throws ServiceException {
        LicenseDao ldao = DaoFactory.getLicenseDao();
       
        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);
View Full Code Here

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

            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.license.error.free.failed", null));
        }
    }

    public void swapLicenses(Long licID1, Long licID2) throws ServiceException {
        LicenseDao ldao = DaoFactory.getLicenseDao();
        try {
            License l1 = (License)ldao.find(licID1);
            License l2 = (License)ldao.find(licID2);
           
            if (l1!=null && l2!=null) {
                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;
View Full Code Here

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

       
    }

    public License createTrialLicenseForGroup(User userLogged, Long groupId) throws ServiceException {
        UserDao userDao = DaoFactory.getUserDao();
        LicenseDao licenseDao = DaoFactory.getLicenseDao();
        GroupDao groupDao = DaoFactory.getGroupDao();
        LOGGER.info("adding trial to user " + userLogged.getLogin() + " registring for a group: " + groupId);

        try {
            ClufImpl cluf = ServiceFactory.getLicenseService().getActiveCluf();
            License l = licenseDao.createTrial();
           
            Group group = (Group) groupDao.find(groupId);
//            l.setHostId(hostId); No Host
            UserImpl user = (UserImpl)userDao.findUser(userLogged.getLogin());
            userDao.fetch(user);
View Full Code Here

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

        }
    }

  public boolean remove(User userLogged, Long grpId) throws ServiceException {
    GroupDao grpDao = DaoFactory.getGroupDao();
    LicenseDao licDao = DaoFactory.getLicenseDao();
    Group grp;
    try {
      List lics = licDao.findLicenseInGroup(grpId.longValue());
      for (Iterator iter = lics.iterator(); iter.hasNext();) {
        License lic = (License) iter.next();
        lic.setGroup(null);
      }
      grp = (Group) grpDao.find(grpId);
View Full Code Here

Examples of org.jayasoft.woj.server.data.LicenseDao

        }
        return l;
    }

    public License add(String encryptedLicense) {
        LicenseDao lDao = WOJServer.getInstance().getDataService().getLicenseDao();
       
        License l = lDao.getByKey(encryptedLicense);
        if (l != null) {
            LOGGER.info("cannot insert same license twice");
            return l;
        }
       
        l = new License();
        try {
            l.setKey(encryptedLicense);
        } catch (Exception e) {
            throw new IllegalArgumentException("license cannot be decoded: " + encryptedLicense);
        }
        lDao.insert(l);
        //reload for id
        l = lDao.getByKey(encryptedLicense);
        _licenses.put(new Long(l.getId()), l);
       
        return l;
    }
View Full Code Here

Examples of org.jayasoft.woj.server.data.LicenseDao

        return new Date(Long.parseLong(decodeEncodedLicense(encodedLicense)[2]));
    }

    public void controlLicenses() throws LicenseException {
        License[] licenses = getAll();
        LicenseDao lDao = WOJServer.getInstance().getDataService().getLicenseDao();

        int licensesByKey = lDao.getLicenseCountByKey();
        if (licensesByKey > licenses.length) {
            throw new LicenseException("similar licenses found in DB");
        }
        for (int i = 0; i < licenses.length; i++) {
            License l = licenses[i];
            int usedLicenses = lDao.getUsedLicense(new Long(l.getId()));
            if (usedLicenses>l.getLicenseCount()) {
                LOGGER.warn("too many licenses in use for license: " + l.getKey());
                throw new LicenseException("too many licenses in use for license: " + l.getKey());
            }
        }
View Full Code Here

Examples of org.jayasoft.woj.server.data.LicenseDao

            }
        }
    }

    public void affectLicense(Long userId, Long licId) throws LicenseException {
        LicenseDao lDao = WOJServer.getInstance().getDataService().getLicenseDao();
        try {
          if(getAvailableLicenses(licId) > 0) {
            lDao.affectLicense(userId, licId);  
          } else {
            throw new LicenseException("No more free license for:"+get(licId));
          }
        } catch (DataAccessException dae) {
            LOGGER.warn("db error while affecting license:" + licId + " to user: " + userId);
View Full Code Here

Examples of org.jayasoft.woj.server.data.LicenseDao

            throw new LicenseException("cannot affect license:" + licId + " to user: " + userId);
        }
    }

    public void affectLicense(Long userId, String licKey) throws LicenseException {
        LicenseDao lDao = WOJServer.getInstance().getDataService().getLicenseDao();
        License l = lDao.getByKey(licKey);
        if (l!=null) {
            affectLicense(userId, new Long(l.getId()));
        } else {
            LOGGER.info("no license foudn for key: " + licKey);
        }
View Full Code Here

Examples of org.jayasoft.woj.server.data.LicenseDao

            LOGGER.info("no license foudn for key: " + licKey);
        }
    }

    public void freeLicense(Long userId) throws LicenseException {
        LicenseDao lDao = WOJServer.getInstance().getDataService().getLicenseDao();
        try {
            lDao.freeLicense(userId);
        } catch (DataAccessException dae) {
            LOGGER.warn("db error while freeing license for user:" + userId);
            throw new LicenseException("cannot free license of user:" + userId);
        }
    }
View Full Code Here

Examples of org.jayasoft.woj.server.data.LicenseDao

    }
   
    public int getAvailableLicenses(Long licId) {
      try {
      License l = get(licId);
      LicenseDao lDao = WOJServer.getInstance().getDataService().getLicenseDao();
      int used = lDao.getUsedLicense(licId);
      return l.getLicenseCount()-used;
    } catch (Exception e) {
      LOGGER.error("unable to get AvailableLicenses for license id" +licId, e);
    }
    return -1;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.