From 6c80688af2791624eb4b7768ea46a17225622724 Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 18 May 2015 15:02:18 +0530 Subject: [PATCH 1/4] Remove app list from device info update service --- .../wso2/carbon/device/mgt/common/spi/DeviceManager.java | 2 +- .../mgt/core/DeviceManagementServiceProviderImpl.java | 7 +++---- .../mgt/core/service/DeviceManagementServiceImpl.java | 5 ++--- .../org/wso2/carbon/device/mgt/core/TestDeviceManager.java | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java index aeb84c669e..72ed8ecbb7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManager.java @@ -121,7 +121,7 @@ public interface DeviceManager { * @param device Updated device information related data * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info */ - boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException; + boolean updateDeviceInfo(Device device) throws DeviceManagementException; /** * Method to set the ownership type of a particular device. i.e. BYOD, COPE. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java index 0463c16d53..0198835589 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java @@ -378,10 +378,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } @Override - public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { - DeviceManager dms = - this.getPluginRepository().getDeviceManagementProvider(device.getType()); - return dms.updateDeviceInfo(device,applicationList); + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); + return dms.updateDeviceInfo(device); } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java index 621cea3669..a0c363854d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java @@ -98,9 +98,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider(). - updateDeviceInfo(device, applicationList); + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateDeviceInfo(device); } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java index ea8ad2e2f9..f0d64f389a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java @@ -79,7 +79,7 @@ public class TestDeviceManager implements DeviceMgtService { } @Override - public boolean updateDeviceInfo(Device device, List applicationList) throws DeviceManagementException { + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { return false; } From 1534099f0a6d4156022a38b73808f09b1f596ac3 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 18 May 2015 16:57:42 +0530 Subject: [PATCH 2/4] Removing staging repository config from the parent pom --- pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pom.xml b/pom.xml index 0cbacff5b1..cf2b6fc79f 100644 --- a/pom.xml +++ b/pom.xml @@ -1078,16 +1078,6 @@ false - - wso2-staging - WSO2 Staging Repository - http://maven.wso2.org/nexus/content/repositories/orgwso2carbonapimgt-009/ - - true - daily - ignore - - From c918622cc6e876786651bca2218d145bb2c3ef27 Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 18 May 2015 19:27:41 +0530 Subject: [PATCH 3/4] Refractor Email service and change user server feature name components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml --- .../DeviceManagementServiceComponent.java | 256 +++++++++--------- .../core/internal/EmailServiceComponent.java | 5 + .../DeviceMgtUserServiceComponent.java | 4 +- 3 files changed, 136 insertions(+), 129 deletions(-) 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 c253594710..6d3aa4f022 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 @@ -24,6 +24,8 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; +import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; @@ -37,8 +39,6 @@ import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService; import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherServiceImpl; import org.wso2.carbon.device.mgt.core.api.mgt.APIRegistrationStartupObserver; import org.wso2.carbon.device.mgt.core.app.mgt.AppManagementServiceImpl; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector; -import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException; import org.wso2.carbon.device.mgt.core.app.mgt.RemoteAppManagerConnector; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfigurationManager; @@ -55,9 +55,11 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; import org.wso2.carbon.device.mgt.user.core.UserManager; -import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.device.mgt.user.core.service.UserManagementService; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.core.service.RealmService; + import java.util.ArrayList; import java.util.List; @@ -93,34 +95,34 @@ import java.util.List; * policy="dynamic" * bind="setDataSourceService" * unbind="unsetDataSourceService" - * @scr.reference name="org.wso2.carbon.device.mgt.usermanager.service" + * @scr.reference name="org.wso2.carbon.device.mgt.user.core.usermanager" * interface="org.wso2.carbon.device.mgt.user.core.UserManager" - * cardinality="1..1" + * cardinality="1..1 * policy="dynamic" * bind="setUserManager" * unbind="unsetUserManager" */ public class DeviceManagementServiceComponent { - private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); - private DeviceManagementRepository pluginRepository = new DeviceManagementRepository(); + private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); + private DeviceManagementRepository pluginRepository = new DeviceManagementRepository(); private static final Object LOCK = new Object(); private boolean isInitialized; private List deviceManagers = new ArrayList(); - protected void activate(ComponentContext componentContext) { - try { - if (log.isDebugEnabled()) { - log.debug("Initializing device management core bundle"); - } - /* Initializing Device Management Configuration */ - DeviceConfigurationManager.getInstance().initConfig(); - DeviceManagementConfig config = - DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + protected void activate(ComponentContext componentContext) { + try { + if (log.isDebugEnabled()) { + log.debug("Initializing device management core bundle"); + } + /* Initializing Device Management Configuration */ + DeviceConfigurationManager.getInstance().initConfig(); + DeviceManagementConfig config = + DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); - DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig(); - DeviceManagementDAOFactory.init(dsConfig); + DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig(); + DeviceManagementDAOFactory.init(dsConfig); /* Initializing license manager */ this.initLicenseManager(); @@ -132,19 +134,19 @@ public class DeviceManagementServiceComponent { DeviceManagementService deviceManagementProvider = new DeviceManagementServiceProviderImpl(this.getPluginRepository()); DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider); - OperationManagementDAOFactory.init(dsConfig); + OperationManagementDAOFactory.init(dsConfig); /* If -Dsetup option enabled then create device management database schema */ - String setupOption = - System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug("-Dsetup is enabled. Device management repository schema initialization is about to " + + String setupOption = + System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP); + if (setupOption != null) { + if (log.isDebugEnabled()) { + log.debug("-Dsetup is enabled. Device management repository schema initialization is about to " + "begin"); - } - this.setupDeviceManagementSchema(dsConfig); - this.setupDefaultLicenses(DeviceManagementDataHolder.getInstance().getLicenseConfig()); - } + } + this.setupDeviceManagementSchema(dsConfig); + this.setupDefaultLicenses(DeviceManagementDataHolder.getInstance().getLicenseConfig()); + } synchronized (LOCK) { for (DeviceMgtService deviceManager : deviceManagers) { @@ -157,12 +159,12 @@ public class DeviceManagementServiceComponent { this.registerServices(componentContext); if (log.isDebugEnabled()) { - log.debug("Device management core bundle has been successfully initialized"); - } - } catch (Throwable e) { - log.error("Error occurred while initializing device management core bundle", e); - } - } + log.debug("Device management core bundle has been successfully initialized"); + } + } catch (Throwable e) { + log.error("Error occurred while initializing device management core bundle", e); + } + } protected void deactivate(ComponentContext componentContext) { //do nothing @@ -188,7 +190,7 @@ public class DeviceManagementServiceComponent { AppManagementConfig appConfig = AppManagementConfigurationManager.getInstance().getAppManagementConfig(); DeviceManagementDataHolder.getInstance().setAppManagerConfig(appConfig); - RemoteAppManagerConnector appManager = new RemoteAppManagerConnector(appConfig,this.getPluginRepository()); + RemoteAppManagerConnector appManager = new RemoteAppManagerConnector(appConfig, this.getPluginRepository()); DeviceManagementDataHolder.getInstance().setAppManager(appManager); } @@ -208,36 +210,36 @@ public class DeviceManagementServiceComponent { bundleContext.registerService(ServerStartupObserver.class, new APIRegistrationStartupObserver(), null); /* Registering App Management service */ - bundleContext.registerService(AppManagerConnector.class.getName(), new AppManagementServiceImpl(), null); + bundleContext.registerService(AppManagerConnector.class.getName(), new AppManagementServiceImpl(), null); } - private void setupDeviceManagementSchema(DataSourceConfig config) - throws DeviceManagementException { - DeviceManagementSchemaInitializer initializer = - new DeviceManagementSchemaInitializer(config); - log.info("Initializing device management repository database schema"); - - try { - initializer.createRegistryDatabase(); - } catch (Exception e) { - throw new DeviceManagementException( - "Error occurred while initializing Device Management database schema", e); - } - if (log.isDebugEnabled()) { - log.debug("Device management metadata repository schema has been successfully initialized"); - } - } - - 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) { + private void setupDeviceManagementSchema(DataSourceConfig config) + throws DeviceManagementException { + DeviceManagementSchemaInitializer initializer = + new DeviceManagementSchemaInitializer(config); + log.info("Initializing device management repository database schema"); + + try { + initializer.createRegistryDatabase(); + } catch (Exception e) { + throw new DeviceManagementException( + "Error occurred while initializing Device Management database schema", e); + } + if (log.isDebugEnabled()) { + log.debug("Device management metadata repository schema has been successfully initialized"); + } + } + + 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) { licenseManager.addLicense(license.getName(), license); - } - } - } + } + } + } private void registerDeviceManagementProvider(DeviceMgtService deviceManager) { try { @@ -248,12 +250,12 @@ public class DeviceManagementServiceComponent { } } - /** - * Sets Device Manager service. - * - * @param deviceManager An instance of DeviceManager - */ - protected void setDeviceManager(DeviceMgtService deviceManager) { + /** + * Sets Device Manager service. + * + * @param deviceManager An instance of DeviceManager + */ + protected void setDeviceManager(DeviceMgtService deviceManager) { if (log.isDebugEnabled()) { log.debug("Setting Device Management Service Provider: '" + deviceManager.getProviderType() + "'"); } @@ -265,15 +267,15 @@ public class DeviceManagementServiceComponent { } } - /** - * Unsets Device Management service. - * - * @param deviceManager An Instance of DeviceManager - */ - protected void unsetDeviceManager(DeviceMgtService deviceManager) { - if (log.isDebugEnabled()) { - log.debug("Un setting Device Management Service Provider : '" + deviceManager.getProviderType() + "'"); - } + /** + * Unsets Device Management service. + * + * @param deviceManager An Instance of DeviceManager + */ + protected void unsetDeviceManager(DeviceMgtService deviceManager) { + if (log.isDebugEnabled()) { + log.debug("Un setting Device Management Service Provider : '" + deviceManager.getProviderType() + "'"); + } try { this.getPluginRepository().removeDeviceManagementProvider(deviceManager); } catch (DeviceManagementException e) { @@ -282,53 +284,53 @@ public class DeviceManagementServiceComponent { } } - /** - * Sets Realm Service. - * - * @param realmService An instance of RealmService - */ - protected void setRealmService(RealmService realmService) { - if (log.isDebugEnabled()) { - log.debug("Setting Realm Service"); - } - DeviceManagementDataHolder.getInstance().setRealmService(realmService); - } - - /** - * Unsets Realm Service. - * - * @param realmService An instance of RealmService - */ - protected void unsetRealmService(RealmService realmService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting Realm Service"); - } - 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("Un setting Registry Service"); - } - DeviceManagementDataHolder.getInstance().setRegistryService(null); - } + /** + * Sets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void setRealmService(RealmService realmService) { + if (log.isDebugEnabled()) { + log.debug("Setting Realm Service"); + } + DeviceManagementDataHolder.getInstance().setRealmService(realmService); + } + + /** + * Unsets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void unsetRealmService(RealmService realmService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Realm Service"); + } + 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("Un setting Registry Service"); + } + DeviceManagementDataHolder.getInstance().setRegistryService(null); + } /** * Sets UserManager Service. @@ -354,9 +356,9 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setUserManager(null); } - private DeviceManagementRepository getPluginRepository() { - return pluginRepository; - } + private DeviceManagementRepository getPluginRepository() { + return pluginRepository; + } protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { //do nothing diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java index dfad072f8c..708198a0c4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java @@ -22,6 +22,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; import org.wso2.carbon.device.mgt.core.email.sender.EmailServiceProviderImpl; import org.wso2.carbon.device.mgt.core.service.EmailService; import org.wso2.carbon.device.mgt.core.service.EmailServiceImpl; @@ -48,6 +50,9 @@ public class EmailServiceComponent { log.debug("Initializing email service bundle"); } + DeviceConfigurationManager.getInstance().initConfig(); + DeviceManagementConfig config = + DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); /* Initializing Email Service Configurations */ EmailService emailServiceProvider = new EmailServiceProviderImpl(); diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java index 4e0902269b..bdacc71d8e 100644 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java @@ -55,8 +55,8 @@ public class DeviceMgtUserServiceComponent { } /* Registering User Management service */ BundleContext bundleContext = componentContext.getBundleContext(); - bundleContext.registerService(UserManager.class, - new UserManagementService(), null); + bundleContext.registerService(org.wso2.carbon.device.mgt.user.core.UserManager.class, + new org.wso2.carbon.device.mgt.user.core.service.UserManagementService(), null); if (log.isDebugEnabled()) { log.debug("User management core bundle has been successfully initialized"); } From f25dc65b542fb0c68b8b8eed36746c1c57a7a1f1 Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 18 May 2015 19:30:16 +0530 Subject: [PATCH 4/4] Refractor device mgt user core service --- components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 80f79adcc4..8b7f1a2d67 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 @@ -83,7 +83,7 @@ org.wso2.carbon.identity.oauth.stub, org.wso2.carbon.identity.oauth.stub.dto, org.wso2.carbon.ndatasource.core, - org.wso2.carbon.device.mgt.user.core, + org.wso2.carbon.device.mgt.user.core.*, org.wso2.carbon.device.mgt.user.common,