public static void validateLicense(String product, String version)
throws LicenseException {
loadLicenses();
if (!licenses.isEmpty()) {
int needsVersion = Integer.parseInt(version.substring(0, 1));
for (int i = 0; i < licenses.size(); i++) {
License license = (License) licenses.get(i);
int hasVersion = Integer.parseInt(license.getVersion().substring(0, 1));
if (isValidProduct(product, license) && hasVersion >= needsVersion)
return;
}
String productNames = "";
for (int i = 0; i < licenses.size(); i++) {
License license = (License) licenses.get(i);
if (i != 0)
productNames = productNames + ", ";
productNames = productNames + license.getProduct() + " " + license.getVersion();
}
throw new LicenseException("You are not licensed to use this product. You are licensed for the following product(s): " + productNames + "; required product: " + product + " " + version + ".");
} else {
throw new LicenseException("You do not have a valid license for this product. Please check the jiveHome/logs/jive.error.log file for error messages.");
}
}
public static void reloadLicenses() {
if (licenses != null)
licenses.clear();
licenses = null;
loadLicenses();
}
public static Iterator getLicenses() {
if (licenses == null)
return Collections.EMPTY_LIST.iterator();
List licenseProxies = new ArrayList();
for (int i = 0; i < licenses.size(); i++)
licenseProxies.add(new LicenseWrapper((License) licenses.get(i)));
return licenseProxies.iterator();
}
public static int getNumClusterMembers() {
int allowedMembers = 1;
for (Iterator licenses = getLicenses(); licenses.hasNext();) {
LicenseWrapper licenseWrapper = (LicenseWrapper) licenses.next();
if (licenseWrapper.getNumClusterMembers() < allowedMembers)
allowedMembers = licenseWrapper.getNumClusterMembers();
if (allowedMembers == 1)
allowedMembers = licenseWrapper.getNumClusterMembers();
}
private final String name;
public static final LicenseType NON_COMMERCIAL = new LicenseType("Non-Commercial");
public static final LicenseType COMMERCIAL = new LicenseType("Commercial");
public static final LicenseType EVALUATION = new LicenseType("Evaluation");