License issue fixed

revert-70aa11f8
harshanl 9 years ago
parent 09fbf9e8a1
commit 1d4bba9807

@ -107,23 +107,42 @@ public class RegistryBasedLicenseManager implements LicenseManager {
@Override @Override
public void addLicense(final String deviceType, final License license) throws LicenseManagementException { public void addLicense(final String deviceType, final License license) throws LicenseManagementException {
try { try {
GenericArtifact artifact = GenericArtifact artifact = this.getGenericArtifact(deviceType, license.getLanguage());
artifactManager.newGovernanceArtifact(new QName("http://www.wso2.com", deviceType)); if(artifact != null) {
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.NAME, license.getName()); artifact.setAttribute(DeviceManagementConstants.LicenseProperties.NAME, license.getName());
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VERSION, license.getVersion()); artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VERSION, license.getVersion());
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(DeviceManagementConstants.LicenseProperties.ARTIFACT_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());
} }
Date validFrom = license.getValidFrom(); Date validFrom = license.getValidFrom();
if (validFrom != null) { if (validFrom != null) {
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_FROM, validFrom.toString()); artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_FROM, validFrom.toString());
}
artifactManager.updateGenericArtifact(artifact);
} else {
artifact =
artifactManager.newGovernanceArtifact(new QName("http://www.wso2.com", deviceType));
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.NAME, license.getName());
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VERSION, license.getVersion());
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.PROVIDER, license.getProvider());
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.LANGUAGE, license.getLanguage());
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.TEXT, license.getText());
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.ARTIFACT_NAME, license.getName());
Date validTo = license.getValidTo();
if (validTo != null) {
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_TO, validTo.toString());
}
Date validFrom = license.getValidFrom();
if (validFrom != null) {
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_FROM, validFrom.toString());
}
artifactManager.addGenericArtifact(artifact);
} }
artifactManager.addGenericArtifact(artifact);
} catch (GovernanceException e) { } catch (GovernanceException e) {
throw new LicenseManagementException("Error occurred while adding license for device type " + throw new LicenseManagementException("Error occurred while adding license for device type " +
deviceType + "'", e); deviceType + "'", e);

Loading…
Cancel
Save