From cd4d90563a1d61ddda8c65a3b0b1eb641ca8928a Mon Sep 17 00:00:00 2001 From: Shabirmean Date: Wed, 9 Dec 2015 11:52:39 +0530 Subject: [PATCH] Correction to the dbscripts location path of IoTDevices, which is searched for when -Dsetup property is set --- .../statistics/IoTUsageStatisticsClient.java | 18 +----------------- .../IotDeviceManagementServiceComponent.java | 2 +- .../dao/util/IotDeviceManagementDAOUtil.java | 4 ++-- .../IotDeviceManagementSchemaInitializer.java | 14 +++++++++++--- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/analytics/statistics/IoTUsageStatisticsClient.java b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/analytics/statistics/IoTUsageStatisticsClient.java index 24014ea78f..ee514b0421 100644 --- a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/analytics/statistics/IoTUsageStatisticsClient.java +++ b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/analytics/statistics/IoTUsageStatisticsClient.java @@ -16,23 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.analytics.statistics;/* -*Copyright (c) 2005-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.iot.analytics.statistics; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java index d39446b204..4c204abb04 100644 --- a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java +++ b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/internal/IotDeviceManagementServiceComponent.java @@ -104,7 +104,7 @@ public class IotDeviceManagementServiceComponent { IotDeviceManagementDAOUtil .setupIotDeviceManagementSchema( IotDeviceManagementDAOFactory.getDataSourceMap - ().get(pluginType)); + ().get(pluginType), pluginType); } } catch (IotDeviceMgtPluginException e) { log.error( diff --git a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/dao/util/IotDeviceManagementDAOUtil.java b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/dao/util/IotDeviceManagementDAOUtil.java index 92852f95c3..19a95904c0 100644 --- a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/dao/util/IotDeviceManagementDAOUtil.java +++ b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/dao/util/IotDeviceManagementDAOUtil.java @@ -70,10 +70,10 @@ public class IotDeviceManagementDAOUtil { * * @param dataSource Iot data source */ - public static void setupIotDeviceManagementSchema(DataSource dataSource) throws + public static void setupIotDeviceManagementSchema(DataSource dataSource, String pluginType) throws IotDeviceMgtPluginException { IotDeviceManagementSchemaInitializer initializer = - new IotDeviceManagementSchemaInitializer(dataSource); + new IotDeviceManagementSchemaInitializer(dataSource, pluginType); log.info("Initializing iot device management repository database schema"); try { initializer.createRegistryDatabase(); diff --git a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/util/IotDeviceManagementSchemaInitializer.java b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/util/IotDeviceManagementSchemaInitializer.java index e67228a44e..5aa06ecef8 100644 --- a/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/util/IotDeviceManagementSchemaInitializer.java +++ b/components/device-mgt-iot/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/util/iotdevice/util/IotDeviceManagementSchemaInitializer.java @@ -40,18 +40,26 @@ public final class IotDeviceManagementSchemaInitializer extends DatabaseCreator CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + IotPluginConstants.IOT_DB_SCRIPTS_FOLDER + File.separator + "plugins" + File.separator; + private String pluginType; - public IotDeviceManagementSchemaInitializer(DataSource dataSource) { + public String getPluginType() { + return pluginType; + } + + public IotDeviceManagementSchemaInitializer(DataSource dataSource, String pType) { super(dataSource); + this.pluginType = pType; } protected String getDbScriptLocation(String databaseType) { String scriptName = databaseType + ".sql"; + String scriptLocation = setupSQLScriptBaseLocation + this.getPluginType() + File.separator + scriptName; if (log.isDebugEnabled()) { - log.debug("Loading database script from :" + scriptName); + log.debug("Loading database script from :" + scriptLocation); } //TODO:test - return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName; +// return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName; + return scriptLocation; } }