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