From 4ded86a1348ddc10a82244cb06cf5c6d12aee743 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Wed, 19 Sep 2018 15:55:11 +0530 Subject: [PATCH] Add app manager osgi fixes --- .../pom.xml | 8 +++---- .../mgt/core/config/Extension.java | 2 +- .../core/impl/SubscriptionManagerImpl.java | 10 ++++---- ...pplicationManagementServiceComponent.java} | 24 +++++++++---------- .../core/util/ApplicationManagementUtil.java | 4 ++-- .../DeviceManagementServiceComponent.java | 3 +++ .../pom.xml | 22 +++++++++++++++++ .../main/resources/conf/application-mgt.xml | 4 ++-- pom.xml | 2 +- 9 files changed, 51 insertions(+), 28 deletions(-) rename components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/{ServiceComponent.java => ApplicationManagementServiceComponent.java} (89%) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index 932265189f..bd2a14ba47 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -42,7 +42,6 @@ org.apache.felix maven-bundle-plugin - 3.0.1 true @@ -50,9 +49,7 @@ ${project.artifactId} ${carbon.device.mgt.version} Application Management Core Bundle - - org.wso2.carbon.device.application.mgt.core.internal - + org.wso2.carbon.device.application.mgt.core.internal org.osgi.framework, org.osgi.service.component, @@ -81,7 +78,8 @@ org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.apache.commons.codec.digest;version="${commons-codec.wso2.osgi.version.range}", org.wso2.carbon.base, - net.dongliu.apk.parser.* + com.dd.*, + org.apache.commons.validator.routines apk-parser;scope=compile|runtime;inline=false diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Extension.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Extension.java index 07e3b09a85..593ecd4a99 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Extension.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/Extension.java @@ -81,7 +81,7 @@ public class Extension { ApplicationManager, ApplicationReleaseManager, CategoryManager, - CommentsManager, + ReviewManager, LifecycleStateManager, PlatformManager, VisibilityTypeManager, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index b82057447f..1717be58c6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -27,7 +27,7 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; import org.wso2.carbon.device.application.mgt.core.dao.SubscriptionDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory; -import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil; +import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.HelperUtil; import org.wso2.carbon.device.mgt.common.Device; @@ -68,7 +68,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (log.isDebugEnabled()) { log.debug("Install application: " + applicationUUID + " to " + deviceList.size() + "devices."); } - ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); + ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); Application application = applicationManager.getApplicationByRelease(applicationUUID); return installApplication(application, deviceList); @@ -80,7 +80,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (log.isDebugEnabled()) { log.debug("Install application: " + applicationUUID + " to " + userList.size() + " users."); } - ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); + ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); Application application = applicationManager.getApplicationByRelease(applicationUUID); List deviceList = new ArrayList<>(); for (String user : userList) { @@ -121,7 +121,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (log.isDebugEnabled()) { log.debug("Install application: " + applicationUUID + " to " + roleList.size() + " roles."); } - ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); + ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); Application application = applicationManager.getApplicationByRelease(applicationUUID); List deviceList = new ArrayList<>(); for (String role : roleList) { @@ -162,7 +162,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (log.isDebugEnabled()) { log.debug("Install application: " + applicationUUID + " to " + deviceGroupList.size() + " groups."); } - ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); + ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); Application application = applicationManager.getApplicationByRelease(applicationUUID); GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService(); List groupList = new ArrayList<>(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ServiceComponent.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java similarity index 89% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ServiceComponent.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java index e2224b2c30..cf891d5d1c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ServiceComponent.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -63,21 +63,26 @@ import java.util.List; * bind="setDataSourceService" * unbind="unsetDataSourceService" */ -public class ServiceComponent { +public class ApplicationManagementServiceComponent { - private static Log log = LogFactory.getLog(ServiceComponent.class); + private static Log log = LogFactory.getLog(ApplicationManagementServiceComponent.class); - protected void activate(ComponentContext componentContext) throws NamingException { + @SuppressWarnings("unused") + protected void activate(ComponentContext componentContext) { + + log.info("CALLING ACTIVATE ............."); BundleContext bundleContext = componentContext.getBundleContext(); try { - String datasourceName = ConfigurationManager.getInstance().getConfiguration().getDatasourceName(); + String dataSourceName = ConfigurationManager.getInstance().getConfiguration().getDatasourceName(); + ApplicationManagementDAOFactory.init(dataSourceName); +// ApplicationManagementDAOFactory.initDatabases(); ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); DataHolder.getInstance().setApplicationManager(applicationManager); bundleContext.registerService(ApplicationManager.class.getName(), applicationManager, null); - ReviewManager reviewManager = ApplicationManagementUtil.getCommentsManagerInstance(); + ReviewManager reviewManager = ApplicationManagementUtil.getReviewManagerInstance(); DataHolder.getInstance().setReviewManager(reviewManager); bundleContext.registerService(ReviewManager.class.getName(), reviewManager, null); @@ -94,19 +99,14 @@ public class ServiceComponent { DataHolder.getInstance().setApplicationStorageManager(applicationStorageManager); bundleContext.registerService(ApplicationStorageManager.class.getName(), applicationStorageManager, null); - ApplicationManagementDAOFactory.init(datasourceName); - ApplicationManagementDAOFactory.initDatabases(); - List lifecycleStates = ConfigurationManager.getInstance(). getConfiguration().getLifecycleStates(); LifecycleStateManger lifecycleStateManger = new LifecycleStateManger(lifecycleStates); DataHolder.getInstance().setLifecycleStateManger(lifecycleStateManger); log.info("ApplicationManagement core bundle has been successfully initialized"); - } catch (InvalidConfigurationException e) { - log.error("Error while activating Application Management core component. ", e); - } catch (ApplicationManagementDAOException e) { - log.error("Error while activating Application Management core component.Failed to create the database ", e); + } catch (Throwable e) { + log.error("Error occurred while initializing app management core bundle", e); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java index 4127696e30..488f8147b5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java @@ -45,9 +45,9 @@ public class ApplicationManagementUtil { return getInstance(extension, ApplicationManager.class); } - public static ReviewManager getCommentsManagerInstance() throws InvalidConfigurationException { + public static ReviewManager getReviewManagerInstance() throws InvalidConfigurationException { ConfigurationManager configurationManager = ConfigurationManager.getInstance(); - Extension extension = configurationManager.getExtension(Extension.Name.CommentsManager); + Extension extension = configurationManager.getExtension(Extension.Name.ReviewManager); return getInstance(extension, ReviewManager.class); } 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 65decec77f..fccdc8a86c 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 @@ -149,6 +149,9 @@ public class DeviceManagementServiceComponent { @SuppressWarnings("unused") protected void activate(ComponentContext componentContext) { + + log.info("CALLING Crazy ............."); + try { if (log.isDebugEnabled()) { log.debug("Initializing device management core bundle"); diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml index f70e66d542..ac05f5cac1 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml @@ -30,6 +30,7 @@ org.wso2.carbon.device.application.mgt.server.feature pom 3.1.40-SNAPSHOT + WSO2 Carbon - Application Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Application Management functionality @@ -44,6 +45,18 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.application.mgt.core + + com.googlecode.plist + dd-plist + ${googlecode.plist.version} + + + + commons-validator + commons-validator + ${commons-validator.version} + + @@ -122,6 +135,12 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.application.mgt.core:${carbon.device.mgt.version} + + com.googlecode.plist:dd-plist:${googlecode.plist.version} + + + commons-validator:commons-validator:${commons-validator.version} + @@ -136,4 +155,7 @@ + + 1.6 + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index cfe2145e56..9bcbcf4fa4 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -31,8 +31,8 @@ org.wso2.carbon.device.application.mgt.core.impl.CategoryManagerImpl - - org.wso2.carbon.device.application.mgt.core.impl.CommentsManagerImpl + + org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl org.wso2.carbon.device.application.mgt.core.impl.LifecycleStateManagerImpl diff --git a/pom.xml b/pom.xml index de54d16244..b96ebfe0fc 100644 --- a/pom.xml +++ b/pom.xml @@ -1840,7 +1840,7 @@ org.apache.felix maven-bundle-plugin - 2.3.5 + 2.5.3 true NONE