mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Refactored LicenseManager
This commit is contained in:
parent
4709107719
commit
f36c82b059
@ -69,6 +69,7 @@ public final class DeviceManagementConstants {
|
|||||||
public static final String VALID_TO = "overview_validityTo";
|
public static final String VALID_TO = "overview_validityTo";
|
||||||
public static final String TEXT = "overview_license";
|
public static final String TEXT = "overview_license";
|
||||||
public static final String LICENSE_REGISTRY_KEY = "license";
|
public static final String LICENSE_REGISTRY_KEY = "license";
|
||||||
|
public static final String ARTIFACT_NAME = "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class NotificationProperties {
|
public static final class NotificationProperties {
|
||||||
|
|||||||
@ -71,7 +71,8 @@
|
|||||||
org.wso2.carbon.registry.core.exceptions,
|
org.wso2.carbon.registry.core.exceptions,
|
||||||
org.wso2.carbon.registry.core.session,
|
org.wso2.carbon.registry.core.session,
|
||||||
javax.xml.bind,
|
javax.xml.bind,
|
||||||
org.wso2.carbon.utils
|
org.wso2.carbon.utils,
|
||||||
|
org.apache.commons.logging
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public class RegistryBasedLicenseManager implements LicenseManager {
|
|||||||
GenericArtifact artifact = this.getGenericArtifact(deviceType, languageCode);
|
GenericArtifact artifact = this.getGenericArtifact(deviceType, languageCode);
|
||||||
if (artifact == null) {
|
if (artifact == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Generic artifact is null for '" + deviceType + "' device type, Hence license does not " +
|
log.debug("Generic artifact is null for '" + deviceType + "' device type. Hence license does not " +
|
||||||
"have content");
|
"have content");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -109,7 +109,10 @@ public class RegistryBasedLicenseManager implements LicenseManager {
|
|||||||
try {
|
try {
|
||||||
GenericArtifact artifact = this.getGenericArtifact(deviceType, license.getLanguage());
|
GenericArtifact artifact = this.getGenericArtifact(deviceType, license.getLanguage());
|
||||||
if (artifact != null) {
|
if (artifact != null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Generic artifact is null for '" + deviceType + "' device type. Hence license does not " +
|
||||||
|
"have content");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
artifact = artifactManager.newGovernanceArtifact(new QName("http://www.wso2.com", deviceType));
|
artifact = artifactManager.newGovernanceArtifact(new QName("http://www.wso2.com", deviceType));
|
||||||
@ -118,7 +121,7 @@ public class RegistryBasedLicenseManager implements LicenseManager {
|
|||||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.PROVIDER, license.getProvider());
|
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.PROVIDER, license.getProvider());
|
||||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.LANGUAGE, license.getLanguage());
|
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.LANGUAGE, license.getLanguage());
|
||||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.TEXT, license.getText());
|
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.TEXT, license.getText());
|
||||||
artifact.setAttribute("name", license.getName());
|
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.ARTIFACT_NAME, license.getName());
|
||||||
Date validTo = license.getValidTo();
|
Date validTo = license.getValidTo();
|
||||||
if (validTo != null) {
|
if (validTo != null) {
|
||||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_TO, validTo.toString());
|
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_TO, validTo.toString());
|
||||||
@ -147,7 +150,7 @@ public class RegistryBasedLicenseManager implements LicenseManager {
|
|||||||
equalsIgnoreCase(deviceType) && attributeLangVal.equalsIgnoreCase(languageCode));
|
equalsIgnoreCase(deviceType) && attributeLangVal.equalsIgnoreCase(languageCode));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return (artifacts == null || artifacts.length < 1) ? null : artifacts[0];
|
return (artifacts == null || artifacts.length == 0) ? null : artifacts[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user