diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
index 4b532132c9b..8babf3187bc 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
@@ -67,9 +67,6 @@
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.user.api,
org.wso2.carbon.user.core.*,
- org.wso2.carbon.governance.api.exception,
- org.wso2.carbon.governance.api.generic,
- org.wso2.carbon.governance.api.generic.dataobjects,
org.wso2.carbon.registry.core,
org.wso2.carbon.registry.core.exceptions,
org.wso2.carbon.registry.core.service,
@@ -139,10 +136,6 @@
org.wso2.carbon
org.wso2.carbon.user.api
-
- org.wso2.carbon.governance
- org.wso2.carbon.governance.api
-
org.wso2.carbon
org.wso2.carbon.registry.api
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java
index 3f26d2ae6e3..fa1ed6d72c3 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java
@@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.core.config;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.utils.CarbonUtils;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementAxis2ConfigurationObserver.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementAxis2ConfigurationObserver.java
deleted file mode 100644
index 65d52e9fdf2..00000000000
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementAxis2ConfigurationObserver.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * *
- * * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- * *
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- *
- */
-package org.wso2.carbon.device.mgt.core.internal;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
-
-public class DeviceManagementAxis2ConfigurationObserver implements Axis2ConfigurationContextObserver {
-
- @Override
- public void creatingConfigurationContext(int i) {
-
- }
-
- @Override
- public void createdConfigurationContext(ConfigurationContext configurationContext) {
-
- }
-
- @Override
- public void terminatingConfigurationContext(ConfigurationContext configurationContext) {
-
- }
-
- @Override
- public void terminatedConfigurationContext(ConfigurationContext configurationContext) {
-
- }
-
-}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java
index 8c5f11d325e..21c9379bae0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java
@@ -20,6 +20,7 @@
package org.wso2.carbon.device.mgt.core.internal;
import org.wso2.carbon.device.mgt.core.DeviceManager;
+import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManager;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService;
@@ -32,6 +33,8 @@ public class DeviceManagementDataHolder {
private DeviceManager deviceManager;
private LicenseManager licenseManager;
private RegistryService registryService;
+ private LicenseConfig licenseConfig;
+
private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder();
private DeviceManagementDataHolder() {
@@ -85,4 +88,12 @@ public class DeviceManagementDataHolder {
this.licenseManager = licenseManager;
}
+ public LicenseConfig getLicenseConfig() {
+ return licenseConfig;
+ }
+
+ public void setLicenseConfig(LicenseConfig licenseConfig) {
+ this.licenseConfig = licenseConfig;
+ }
+
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java
index 99f96cf7cfa..979323200e5 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java
@@ -74,7 +74,7 @@ public class DeviceManagementServiceComponent {
if (log.isDebugEnabled()) {
log.debug("Initializing device management core bundle");
}
- /* Initializing Device Management Configuration */
+ /* Initializing Device Management Configuration */
DeviceConfigurationManager.getInstance().initConfig();
DeviceManagementConfig config =
DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
@@ -85,11 +85,13 @@ public class DeviceManagementServiceComponent {
DeviceManager deviceManager = new DeviceManagerImpl(config, this.getPluginRepository());
DeviceManagementDataHolder.getInstance().setDeviceManager(deviceManager);
- LicenseConfigurationManager.getInstance().initConfig();
- LicenseConfig licenseConfig = LicenseConfigurationManager.getInstance().getLicenseConfig();
+ LicenseConfigurationManager.getInstance().initConfig();
+ LicenseConfig licenseConfig =
+ LicenseConfigurationManager.getInstance().getLicenseConfig();
- LicenseManager licenseManager = new LicenseManagerImpl();
- DeviceManagementDataHolder.getInstance().setLicenseManager(licenseManager);
+ LicenseManager licenseManager = new LicenseManagerImpl();
+ DeviceManagementDataHolder.getInstance().setLicenseManager(licenseManager);
+ DeviceManagementDataHolder.getInstance().setLicenseConfig(licenseConfig);
/* If -Dsetup option enabled then create device management database schema */
String setupOption =
@@ -101,7 +103,7 @@ public class DeviceManagementServiceComponent {
"is about to begin");
}
this.setupDeviceManagementSchema(dsConfig);
- this.setupDefaultLicenses(licenseConfig);
+ // this.setupDefaultLicenses(licenseConfig);
}
if (log.isDebugEnabled()) {
@@ -109,10 +111,11 @@ public class DeviceManagementServiceComponent {
}
/* Registering Device Management service */
BundleContext bundleContext = componentContext.getBundleContext();
- bundleContext.registerService(DeviceManagementService.class.getName(), new DeviceManagementService(), null);
+ bundleContext.registerService(DeviceManagementService.class.getName(),
+ new DeviceManagementService(), null);
/* Registering License Management service */
- bundleContext.registerService(LicenseManagementService.class.getName(),
- new LicenseManagementService(), null);
+ bundleContext.registerService(LicenseManagementService.class.getName(),
+ new LicenseManagementService(), null);
if (log.isDebugEnabled()) {
log.debug("Device management core bundle has been successfully initialized");
}
@@ -141,16 +144,19 @@ public class DeviceManagementServiceComponent {
}
}
- private void setupDefaultLicenses(LicenseConfig licenseConfig) throws LicenseManagementException {
- LicenseManager licenseManager = DeviceManagementDataHolder.getInstance().getLicenseManager();
- for (License license : licenseConfig.getLicenses()) {
- License extLicense = licenseManager.getLicense(license.getName(), license.getLanguage());
- if (extLicense != null) {
- continue;
- }
- licenseManager.addLicense(license);
- }
- }
+ private void setupDefaultLicenses(LicenseConfig licenseConfig)
+ throws LicenseManagementException {
+ LicenseManager licenseManager =
+ DeviceManagementDataHolder.getInstance().getLicenseManager();
+ for (License license : licenseConfig.getLicenses()) {
+ License extLicense =
+ licenseManager.getLicense(license.getName(), license.getLanguage());
+ if (extLicense != null) {
+ continue;
+ }
+ licenseManager.addLicense(license);
+ }
+ }
/**
* Sets Device Manager service.
@@ -202,29 +208,29 @@ public class DeviceManagementServiceComponent {
DeviceManagementDataHolder.getInstance().setRealmService(null);
}
- /**
- * Sets Registry Service.
- *
- * @param registryService An instance of RegistryService
- */
- protected void setRegistryService(RegistryService registryService) {
- if (log.isDebugEnabled()) {
- log.debug("Setting Registry Service");
- }
- DeviceManagementDataHolder.getInstance().setRegistryService(registryService);
- }
-
- /**
- * Unsets Registry Service.
- *
- * @param registryService An instance of RegistryService
- */
- protected void unsetRegistryService(RegistryService registryService) {
- if (log.isDebugEnabled()) {
- log.debug("Unsetting Registry Service");
- }
- DeviceManagementDataHolder.getInstance().setRegistryService(null);
- }
+ /**
+ * Sets Registry Service.
+ *
+ * @param registryService An instance of RegistryService
+ */
+ protected void setRegistryService(RegistryService registryService) {
+ if (log.isDebugEnabled()) {
+ log.debug("Setting Registry Service");
+ }
+ DeviceManagementDataHolder.getInstance().setRegistryService(registryService);
+ }
+
+ /**
+ * Unsets Registry Service.
+ *
+ * @param registryService An instance of RegistryService
+ */
+ protected void unsetRegistryService(RegistryService registryService) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unsetting Registry Service");
+ }
+ DeviceManagementDataHolder.getInstance().setRegistryService(null);
+ }
private DeviceManagementRepository getPluginRepository() {
return pluginRepository;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/GenericArtifactManagerFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/GenericArtifactManagerFactory.java
deleted file mode 100644
index 6c132ca6b1d..00000000000
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/GenericArtifactManagerFactory.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.wso2.carbon.device.mgt.core.license.mgt;
-
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
-import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
-import org.wso2.carbon.governance.api.generic.GenericArtifactManager;
-import org.wso2.carbon.registry.api.Registry;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class GenericArtifactManagerFactory {
-
- private static Map tenantArtifactManagers =
- new HashMap();
- private static final Object lock = new Object();
-
- public static GenericArtifactManager getTenantAwareGovernanceArtifactManager() throws
- LicenseManagementException {
- Registry registry;
- int tenantId;
- try {
- tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- registry =
- DeviceManagementDataHolder.getInstance().getRegistryService().getGovernanceSystemRegistry(
- tenantId);
- } catch (RegistryException e) {
- throw new LicenseManagementException("Error occurred while initializing tenant system registry " +
- "to be used to manipulate License artifacts", e);
- }
-
- try {
- GenericArtifactManager artifactManager;
- synchronized (lock) {
- artifactManager =
- tenantArtifactManagers.get(tenantId);
- if (artifactManager == null) {
- /* Hack, to fix https://wso2.org/jira/browse/REGISTRY-2427 */
- //GovernanceUtils.loadGovernanceArtifacts((UserRegistry) registry);
- artifactManager =
- new GenericArtifactManager((org.wso2.carbon.registry.core.Registry) registry,
- DeviceManagementConstants.LicenseProperties.LICENSE_REGISTRY_KEY);
- tenantArtifactManagers.put(tenantId, artifactManager);
- }
- }
- return artifactManager;
- } catch (RegistryException e) {
- throw new LicenseManagementException("Error occurred while initializing GovernanceArtifactManager " +
- "associated with tenant '" + CarbonContext.getThreadLocalCarbonContext().getTenantDomain() + "'");
- }
- }
-
-}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java
index face0b3a9c0..dca15462bc1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/license/mgt/LicenseManagerImpl.java
@@ -20,89 +20,38 @@ package org.wso2.carbon.device.mgt.core.license.mgt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.DeviceManagerImpl;
import org.wso2.carbon.device.mgt.core.config.license.License;
-import org.wso2.carbon.governance.api.exception.GovernanceException;
-import org.wso2.carbon.governance.api.generic.GenericArtifactFilter;
-import org.wso2.carbon.governance.api.generic.GenericArtifactManager;
-import org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact;
+import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
+import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
-import javax.xml.namespace.QName;
import java.text.DateFormat;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
public class LicenseManagerImpl implements LicenseManager {
- private static Log log = LogFactory.getLog(DeviceManagerImpl.class);
- private static final DateFormat format = new SimpleDateFormat("dd-mm-yyyy", Locale.ENGLISH);
-
- @Override
- public License getLicense(final String deviceType, final String languageCode) throws LicenseManagementException {
- GenericArtifactManager artifactManager =
- GenericArtifactManagerFactory.getTenantAwareGovernanceArtifactManager();
- try {
- GenericArtifact[] artifacts = artifactManager.findGenericArtifacts(new GenericArtifactFilter() {
- @Override
- public boolean matches(GenericArtifact artifact) throws GovernanceException {
- String attributeNameVal = artifact.getAttribute(
- DeviceManagementConstants.LicenseProperties.NAME);
- String attributeLangVal = artifact.getAttribute(
- DeviceManagementConstants.LicenseProperties.LANGUAGE);
- return (attributeNameVal != null && attributeLangVal != null && attributeNameVal.equals
- (deviceType) && attributeLangVal.equals(languageCode));
- }
- });
- if (artifacts == null || artifacts.length <= 0) {
- return null;
- }
- return this.populateLicense(artifacts[0]);
- } catch (GovernanceException e) {
- throw new LicenseManagementException("Error occurred while retrieving license corresponding to " +
- "device type '" + deviceType + "'");
- } catch (ParseException e) {
- throw new LicenseManagementException("Error occurred while parsing the ToDate/FromDate date string " +
- "of the license configured upon the device type '" + deviceType + "'");
- }
- }
-
- private License populateLicense(GenericArtifact artifact) throws GovernanceException, ParseException {
- License license = new License();
- license.setName(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.NAME));
- license.setProvider(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.PROVIDER));
- license.setVersion(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.VERSION));
- license.setLanguage(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.LANGUAGE));
- license.setText(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.TEXT));
- license.setValidFrom(format.parse(artifact.getAttribute(
- DeviceManagementConstants.LicenseProperties.VALID_FROM)));
- license.setValidTo(format.parse(artifact.getAttribute(
- DeviceManagementConstants.LicenseProperties.VALID_TO)));
- return license;
- }
-
- @Override
- public void addLicense(License license) throws LicenseManagementException {
- GenericArtifactManager artifactManager =
- GenericArtifactManagerFactory.getTenantAwareGovernanceArtifactManager();
- try {
- GenericArtifact artifact =
- artifactManager.newGovernanceArtifact(new QName("http://www.wso2.com",
- DeviceManagementConstants.LicenseProperties.LICENSE_REGISTRY_KEY));
- 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.VALID_TO,
- license.getValidTo().toString());
- artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_FROM,
- license.getValidFrom().toString());
- artifactManager.addGenericArtifact(artifact);
- } catch (GovernanceException e) {
- throw new LicenseManagementException("Error occurred while adding license artifact", e);
- }
- }
+ private static Log log = LogFactory.getLog(DeviceManagerImpl.class);
+ private static final DateFormat format = new SimpleDateFormat("dd-mm-yyyy", Locale.ENGLISH);
+
+ @Override
+ public License getLicense(final String deviceType, final String languageCode)
+ throws LicenseManagementException {
+ License deviceLicense = new License();
+ LicenseConfig licenseConfig = DeviceManagementDataHolder.getInstance().getLicenseConfig();
+ for (License license : licenseConfig.getLicenses()) {
+ if ((deviceType.equals(license.getName())) &&
+ (languageCode.equals(license.getLanguage()))) {
+ deviceLicense = license;
+ break;
+ }
+ }
+ return deviceLicense;
+ }
+
+ @Override
+ public void addLicense(License license) throws LicenseManagementException {
+
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagementSchemaInitializer.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagementSchemaInitializer.java
index 57880cbd03e..6c14870edf4 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagementSchemaInitializer.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagementSchemaInitializer.java
@@ -24,7 +24,6 @@ import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
-import javax.sql.DataSource;
import java.io.File;
public final class DeviceManagementSchemaInitializer extends DatabaseCreator {
diff --git a/pom.xml b/pom.xml
index 98ea9452411..5191ff4a602 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
org.wso2.carbon.base
${carbon.kernel.version}
-
+