Merge pull request #283 from ayyoob/transport

fixed db related jiras
merge-requests/1/head
Milan Perera 9 years ago
commit 23c404260e

@ -67,7 +67,8 @@
org.wso2.carbon.core,
org.wso2.carbon.core.util,
org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception
org.wso2.carbon.event.output.adapter.core.exception,
org.wso2.carbon.ndatasource.core
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.iot.androidsense.plugin.internal,

@ -43,7 +43,7 @@ public class AndroidSenseDAOUtil {
Context ctx = new InitialContext();
dataSource = (DataSource) ctx.lookup(AndroidSenseConstants.DATA_SOURCE_NAME);
} catch (NamingException e) {
log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME, e);
}
}

@ -85,13 +85,12 @@ public class AndroidSenseUtils {
try {
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup(AndroidSenseConstants.DATA_SOURCE_NAME);
DeviceSchemaInitializer initializer =
new DeviceSchemaInitializer(dataSource);
DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
log.info("Initializing device management repository database schema");
initializer.createRegistryDatabase();
} catch (NamingException e) {
log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + AndroidSenseConstants.DATA_SOURCE_NAME, e);
} catch (Exception e) {
throw new AndroidSenseDeviceMgtPluginException("Error occurred while initializing Iot Device " +
"Management database schema", e);

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{
private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
+ File.separator + "cdm" + File.separator + "plugins" + File.separator;
+ File.separator + "cdm" + File.separator + "plugins" + File.separator + AndroidSenseConstants.DEVICE_TYPE
+ File.separator;
public DeviceSchemaInitializer(DataSource dataSource) {
super(dataSource);

@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.AndroidSenseManag
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.util.AndroidSenseStartupListener;
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.impl.util.AndroidSenseUtils;
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
import org.wso2.carbon.ndatasource.core.DataSourceService;
/**
* @scr.component name="org.wso2.carbon.device.mgt.iot.android.internal.AndroidSenseManagementServiceComponent"
@ -38,6 +39,12 @@ import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
* policy="dynamic"
* bind="setOutputEventAdapterService"
* unbind="unsetOutputEventAdapterService"
* @scr.reference name="org.wso2.carbon.ndatasource"
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDataSourceService"
* unbind="unsetDataSourceService"
*/
public class AndroidSenseManagementServiceComponent {
@ -57,8 +64,7 @@ public class AndroidSenseManagementServiceComponent {
String setupOption = System.getProperty("setup");
if (setupOption != null) {
if (log.isDebugEnabled()) {
log.debug(
"-Dsetup is enabled. Iot Device management repository schema initialization is about " +
log.debug("-Dsetup is enabled. Iot Device management repository schema initialization is about " +
"to begin");
}
try {
@ -108,4 +114,16 @@ public class AndroidSenseManagementServiceComponent {
protected void unsetOutputEventAdapterService(OutputEventAdapterService outputEventAdapterService) {
AndroidSenseManagementDataHolder.getInstance().setOutputEventAdapterService(null);
}
protected void setDataSourceService(DataSourceService dataSourceService) {
/* This is to avoid mobile device management component getting initialized before the underlying datasources
are registered */
if (log.isDebugEnabled()) {
log.debug("Data source service set to service component");
}
}
protected void unsetDataSourceService(DataSourceService dataSourceService) {
//do nothing
}
}

@ -69,7 +69,8 @@
org.wso2.carbon.device.mgt.common,
org.wso2.carbon.device.mgt.iot.*,
org.wso2.carbon.device.mgt.extensions.feature.mgt.*,
org.wso2.carbon.utils.*
org.wso2.carbon.utils.*,
org.wso2.carbon.ndatasource.core
</Import-Package>
<Export-Package>

@ -45,7 +45,7 @@ public class ArduinoDAOUtil {
Context ctx = new InitialContext();
dataSource = (DataSource) ctx.lookup(ArduinoConstants.DATA_SOURCE_NAME);
} catch (NamingException e) {
log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME, e);
}
}

@ -97,13 +97,12 @@ public class ArduinoUtils {
try {
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup(ArduinoConstants.DATA_SOURCE_NAME);
DeviceSchemaInitializer initializer =
new DeviceSchemaInitializer(dataSource);
DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
log.info("Initializing device management repository database schema");
initializer.createRegistryDatabase();
} catch (NamingException e) {
log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + ArduinoConstants.DATA_SOURCE_NAME, e);
} catch (Exception e) {
throw new ArduinoDeviceMgtPluginException("Error occurred while initializing Iot Device " +
"Management database schema", e);

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.iot.arduino.plugin.constants.ArduinoConstants;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{
private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
+ File.separator + "cdm" + File.separator + "plugins" + File.separator;
+ File.separator + "cdm" + File.separator + "plugins" + File.separator + ArduinoConstants.DEVICE_TYPE
+ File.separator;
public DeviceSchemaInitializer(DataSource dataSource) {
super(dataSource);

@ -27,9 +27,17 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.iot.arduino.plugin.exception.ArduinoDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.ArduinoManagerService;
import org.wso2.carbon.device.mgt.iot.arduino.plugin.impl.util.ArduinoUtils;
import org.wso2.carbon.ndatasource.core.DataSourceService;
/**
* @scr.component name="org.wso2.carbon.device.mgt.iot.arduino.internal.ArduinoManagementServiceComponent"
* immediate="true"
* @scr.reference name="org.wso2.carbon.ndatasource"
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDataSourceService"
* unbind="unsetDataSourceService"
*/
public class ArduinoManagementServiceComponent {
@ -83,4 +91,16 @@ public class ArduinoManagementServiceComponent {
log.error("Error occurred while de-activating Arduino Device Management bundle", e);
}
}
protected void setDataSourceService(DataSourceService dataSourceService) {
/* This is to avoid mobile device management component getting initialized before the underlying datasources
are registered */
if (log.isDebugEnabled()) {
log.debug("Data source service set to service component");
}
}
protected void unsetDataSourceService(DataSourceService dataSourceService) {
//do nothing
}
}

@ -76,7 +76,8 @@
org.wso2.carbon.core,
org.wso2.carbon.core.util,
org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception
org.wso2.carbon.event.output.adapter.core.exception,
org.wso2.carbon.ndatasource.core
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal,

@ -49,7 +49,7 @@ public class RaspberrypiDAOUtil {
Context ctx = new InitialContext();
dataSource = (DataSource) ctx.lookup(RaspberrypiConstants.DATA_SOURCE_NAME);
} catch (NamingException e) {
log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME, e);
}
}

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{
private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
+ File.separator + "cdm" + File.separator + "plugins" + File.separator;
+ File.separator + "cdm" + File.separator + "plugins" + File.separator + RaspberrypiConstants.DEVICE_TYPE
+ File.separator;
public DeviceSchemaInitializer(DataSource dataSource) {
super(dataSource);

@ -87,12 +87,11 @@ public class RaspberrypiUtils {
try {
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup(RaspberrypiConstants.DATA_SOURCE_NAME);
DeviceSchemaInitializer initializer =
new DeviceSchemaInitializer(dataSource);
DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
log.info("Initializing device management repository database schema");
initializer.createRegistryDatabase();
} catch (NamingException e) {
log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + RaspberrypiConstants.DATA_SOURCE_NAME, e);
} catch (Exception e) {
throw new RaspberrypiDeviceMgtPluginException("Error occurred while initializing Iot Device " +
"Management database schema", e);

@ -30,6 +30,7 @@ import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.RaspberrypiManager
import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util.RaspberrypiStartupListener;
import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.impl.util.RaspberrypiUtils;
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
import org.wso2.carbon.ndatasource.core.DataSourceService;
/**
* @scr.component name="org.wso2.carbon.device.mgt.iot.raspberrypi.internal.RaspberrypiManagementServiceComponent"
@ -40,6 +41,12 @@ import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
* policy="dynamic"
* bind="setOutputEventAdapterService"
* unbind="unsetOutputEventAdapterService"
* @scr.reference name="org.wso2.carbon.ndatasource"
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDataSourceService"
* unbind="unsetDataSourceService"
*/
public class RaspberrypiManagementServiceComponent {
@ -110,4 +117,16 @@ public class RaspberrypiManagementServiceComponent {
RaspberrypiManagementDataHolder.getInstance().setOutputEventAdapterService(null);
}
protected void setDataSourceService(DataSourceService dataSourceService) {
/* This is to avoid mobile device management component getting initialized before the underlying datasources
are registered */
if (log.isDebugEnabled()) {
log.debug("Data source service set to service component");
}
}
protected void unsetDataSourceService(DataSourceService dataSourceService) {
//do nothing
}
}

@ -91,7 +91,7 @@
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.parsers,
org.w3c.dom
org.w3c.dom,
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal,

@ -45,7 +45,7 @@ public class VirtualFireAlarmDAOUtil {
Context ctx = new InitialContext();
dataSource = (DataSource) ctx.lookup(VirtualFireAlarmConstants.DATA_SOURCE_NAME);
} catch (NamingException e) {
log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME, e);
}
}

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
@ -33,7 +34,8 @@ public class DeviceSchemaInitializer extends DatabaseCreator{
private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
+ File.separator + "cdm" + File.separator + "plugins" + File.separator;
+ File.separator + "cdm" + File.separator + "plugins" + File.separator
+ VirtualFireAlarmConstants.DEVICE_TYPE + File.separator;
public DeviceSchemaInitializer(DataSource dataSource) {
super(dataSource);

@ -100,12 +100,11 @@ public class VirtualFireAlarmUtils {
try {
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup(VirtualFireAlarmConstants.DATA_SOURCE_NAME);
DeviceSchemaInitializer initializer =
new DeviceSchemaInitializer(dataSource);
DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
log.info("Initializing device management repository database schema");
initializer.createRegistryDatabase();
} catch (NamingException e) {
log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME);
log.error("Error while looking up the data source: " + VirtualFireAlarmConstants.DATA_SOURCE_NAME, e);
} catch (Exception e) {
throw new VirtualFirealarmDeviceMgtPluginException("Error occurred while initializing Iot Device " +
"Management database schema", e);

@ -2,7 +2,7 @@
-- -----------------------------------------------------
-- Table `ANDROID_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS ANDROID_SENSE_DEVICE (
CREATE TABLE ANDROID_SENSE_DEVICE (
ANDROID_DEVICE_ID VARCHAR(45) NOT NULL ,
DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (ANDROID_DEVICE_ID) );

@ -2,7 +2,7 @@
-- -----------------------------------------------------
-- Table for `ARDUINO_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS ARDUINO_DEVICE (
CREATE TABLE ARDUINO_DEVICE (
ARDUINO_DEVICE_ID VARCHAR(45) NOT NULL ,
DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (ARDUINO_DEVICE_ID) );

@ -2,7 +2,7 @@
-- -----------------------------------------------------
-- Table `RASPBERRYPI_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS RASPBERRYPI_DEVICE (
CREATE TABLE RASPBERRYPI_DEVICE (
RASPBERRYPI_DEVICE_ID VARCHAR(45) NOT NULL ,
DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (RASPBERRYPI_DEVICE_ID) );

@ -2,7 +2,7 @@
-- -----------------------------------------------------
-- Table `FIREALARM_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS VIRTUAL_FIREALARM_DEVICE (
CREATE TABLE VIRTUAL_FIREALARM_DEVICE (
VIRTUAL_FIREALARM_DEVICE_ID VARCHAR(45) NOT NULL ,
DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (VIRTUAL_FIREALARM_DEVICE_ID) );

Loading…
Cancel
Save