From c47ace254c3296936c8b51a6c89a77197b6fdef7 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Thu, 22 Oct 2015 14:10:34 +0530 Subject: [PATCH] Fixing the -Dsetup issue in mobile device database setup --- .../dao/util/MobileDeviceManagementDAOUtil.java | 4 ++-- .../MobileDeviceManagementServiceComponent.java | 2 +- .../MobileDeviceManagementSchemaInitializer.java | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java index 5d8e0a9cde..6f5601eae7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java @@ -90,9 +90,9 @@ public class MobileDeviceManagementDAOUtil { * * @param dataSource Mobile data source */ - public static void setupMobileDeviceManagementSchema(DataSource dataSource) throws MobileDeviceMgtPluginException { + public static void setupMobileDeviceManagementSchema(DataSource dataSource, String pluginType) throws MobileDeviceMgtPluginException { MobileDeviceManagementSchemaInitializer initializer = - new MobileDeviceManagementSchemaInitializer(dataSource); + new MobileDeviceManagementSchemaInitializer(dataSource, pluginType); log.info("Initializing mobile device management repository database schema"); try { initializer.createRegistryDatabase(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index a35d8df1a4..e8325e084a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -92,7 +92,7 @@ public class MobileDeviceManagementServiceComponent { for (String pluginType : dsConfigMap.keySet()) { MobileDeviceManagementDAOUtil .setupMobileDeviceManagementSchema(MobileDeviceManagementDAOFactory.getDataSourceMap - ().get(pluginType)); + ().get(pluginType), pluginType); } } catch (MobileDeviceMgtPluginException e) { log.error("Exception occurred while initializing mobile device management database schema", e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java index a4ed5011e5..6af99b1e97 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java @@ -39,13 +39,23 @@ public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreat CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + MobilePluginConstants.MOBILE_DB_SCRIPTS_FOLDER + File.separator + "plugins" + File.separator; + private String pluginType; - public MobileDeviceManagementSchemaInitializer(DataSource dataSource) { + public String getPluginType() { + return pluginType; + } + + public void setPluginType(String pluginType) { + this.pluginType = pluginType; + } + + public MobileDeviceManagementSchemaInitializer(DataSource dataSource, String pType) { super(dataSource); + this.pluginType = pType; } protected String getDbScriptLocation(String databaseType) { - String scriptName = databaseType + ".sql"; + String scriptName = databaseType + "_" + getPluginType() + ".sql"; if (log.isDebugEnabled()) { log.debug("Loading database script from :" + scriptName); }