Package org.jayasoft.woj.server.data.model

Examples of org.jayasoft.woj.server.data.model.License


        setLogin(rs.getString("USR_LOGIN"));
        setPassword(rs.getString("USR_PASSWORD"));
        setEmail(rs.getString("USR_EMAIL"));
        if (WOJServer.getInstance().isEnterpriseEdition()) {
            Long licID = new Long(rs.getLong("USR_LIC_ID"));
            License lic = WOJServer.getInstance().getLicenseService().get(licID);
            if (lic==null) {
                setValidUntil(0);
            } else {
                setValidUntil(lic.getExpirationDate().getTime());
            }
        } else {
            setValidUntil(rs.getLong("USR_VALID_UNTIL"));
        }
        setWojServer(rs.getString("USR_SERVER"));
View Full Code Here


    DataSource getDataSource() {
        return DSManager.getInstance().getUserDS();
    }
   
    protected Object[] getInsertParameters(Object o) {
      License l = (License) o;
        List parameters = new ArrayList();
        parameters.add(JDBCIDGenerator.getNextId("license", getJdbcTemplate()));
        parameters.add(l.getKey());
        return parameters.toArray();
    }
View Full Code Here

        parameters.add(l.getKey());
        return parameters.toArray();
    }
   
    protected Object[] getUpdateParameters(Object o) {
      License l = (License) o;
        List parameters = new ArrayList();
        parameters.add(new Long(l.getId()));
        parameters.add(l.getKey());
        return parameters.toArray();
    }
View Full Code Here

        parameters.add(l.getKey());
        return parameters.toArray();
    }

    protected Object[] getDeleteParameters(Object o) {
      License l = (License) o;
        List parameters = new ArrayList();
        parameters.add(new Long(l.getId()));
        return parameters.toArray();
    }
View Full Code Here

    public License get(Long licID) {
        if (_licenses.size()==0) {
            getAll();
        }
        License l = (License)_licenses.get(licID);
       
        if (l==null) {
            try {
        l = WOJServer.getInstance().getDataService().getLicenseDao().get(licID);
        _licenses.put(new Long(l.getId()), l);
        LOGGER.info("license[" + l.getId() + "] has been put in cache: " + l);
      } catch (Exception e) {
        LOGGER.warn("error while getting license for id" + licID);
      }
        }
        return l;
View Full Code Here

    }

    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

        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

        }
    }

    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

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

      }
      return display();
    }

  public String giveLicense() {
      License selectedLicense = getSelectedLicense();
      String[] selectedUsersId = getAllChecked("user_id_"); //$NON-NLS-1$
      if(ArrayUtils.isEmpty(selectedUsersId) || selectedLicense == null) {
        addWarning("user.warning.noselection"); //$NON-NLS-1$
      } else {
        Long licenseId = new Long(selectedLicense.getId());
        for (int i = 0; i < selectedUsersId.length; i++) {
          String id = selectedUsersId[i];
          try {
            WOJServer.getInstance().getLicenseService().affectLicense(Long.valueOf(id), licenseId);
          } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.server.data.model.License

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.