use of com.serotonin.m2m2.util.license.ModuleLicense in project ma-core-public by infiniteautomation.
the class DataSourceTypePointsLimit method checkLimit.
public static void checkLimit(String dataSourceType, ProcessResult response) {
for (DataSourceTypePointsLimit limit : ModuleRegistry.getLicenseEnforcements(DataSourceTypePointsLimit.class)) {
if (StringUtils.equals(dataSourceType, limit.getDataSourceType())) {
// Found a limit object.
ModuleLicense license = ModuleRegistry.getModule(limit.getModuleName()).license();
int pointLimit = -1;
if (license == null)
// No license.
pointLimit = limit.getNoLicenselimit();
else if (limit.getFeatureName() != null) {
try {
LicenseFeature feature = license.getFeature(limit.getFeatureName());
if (feature != null)
pointLimit = Integer.parseInt(feature.getValue());
} catch (NumberFormatException e) {
// If the feature is non-numeric, we assume that it is unlimited.
}
}
if (pointLimit != -1) {
// Find out how many points there are for this type of data source.
int count = DataPointDao.instance.countPointsForDataSourceType(dataSourceType);
// Apply count restriction.
if (count > pointLimit)
response.addGenericMessage("license.dataSourcePointLimit", pointLimit);
}
}
}
}
Aggregations