diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java index 719a38b1a..5a63eef8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java @@ -28,15 +28,13 @@ import java.util.List; public abstract class AbstractMobileOperationManager implements OperationManager { @Override - public List getOperations(DeviceIdentifier deviceIdentifier) - throws OperationManagementException { + public List getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException { return null; } @Override public boolean addOperation(Operation operation, - List devices) - throws OperationManagementException { + List devices) throws OperationManagementException { return true; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java index a74e4b383..b06ec3265 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java @@ -54,7 +54,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { conn = this.getConnection(); String selectDBQuery = "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + - "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE" + + "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE" + " WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, mblDeviceId); @@ -98,7 +98,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION," + + "INSERT INTO AD_DEVICE(MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION," + "DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, " + "UNLOCK_TOKEN) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; @@ -144,7 +144,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_DEVICE SET PUSH_TOKEN = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," + + "UPDATE AD_DEVICE SET PUSH_TOKEN = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," + "DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ?, CHALLENGE = ?," + "SERIAL = ?, TOKEN = ?, UNLOCK_TOKEN = ? WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); @@ -188,7 +188,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; + "DELETE FROM AD_DEVICE WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setString(1, mblDeviceId); int rows = stmt.executeUpdate(); @@ -219,7 +219,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { conn = this.getConnection(); String selectDBQuery = "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR," + - "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE"; + "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE"; stmt = conn.prepareStatement(selectDBQuery); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java index 9738f1f60..9058df9ae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java @@ -55,7 +55,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, " + + "INSERT INTO AD_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, " + "RECEIVED_DATE, STATUS) VALUES (?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); @@ -77,7 +77,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio String msg = "Error occurred while adding device id - '" + mblDeviceOperationMapping.getDeviceId() + " and operation id - " + mblDeviceOperationMapping.getOperationId() + - " to mapping table MBL_DEVICE_OPERATION"; + " to mapping table AD_DEVICE_OPERATION"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -95,7 +95,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " + + "UPDATE AD_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " + "STATUS = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setLong(1, mblDeviceOperation.getSentDate()); @@ -132,7 +132,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, STATUS = ? " + + "UPDATE AD_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, STATUS = ? " + "WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setLong(1, new Date().getTime()); @@ -170,7 +170,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " + + "UPDATE AD_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " + "WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setLong(1, new Date().getTime()); @@ -207,7 +207,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " + + "DELETE FROM AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setString(1, mblDeviceId); @@ -222,7 +222,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio } } catch (SQLException e) { String msg = - "Error occurred while deleting the table entry MBL_DEVICE_OPERATION with " + + "Error occurred while deleting the table entry AD_DEVICE_OPERATION with " + " device id - '" + mblDeviceId + " and operation id - " + operationId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); @@ -243,7 +243,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio conn = this.getConnection(); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + - "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; + "AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, mblDeviceId); stmt.setInt(2, operationId); @@ -285,7 +285,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio conn = this.getConnection(); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + - "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; + "AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, mblDeviceId); ResultSet resultSet = stmt.executeQuery(); @@ -327,7 +327,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio conn = this.getConnection(); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM" + - " MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = ?"; + " AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, mblDeviceId); stmt.setString(2, MobileDeviceOperationMapping.Status.NEW.name()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java index 66081becd..a19c61e5f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java @@ -54,7 +54,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION, DEVICE_TYPE) VALUES (?, ?, ?, ?)"; + "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION, DEVICE_TYPE) VALUES (?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mobileFeature.getCode()); @@ -67,7 +67,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { if (rs != null && rs.next()) { status = rs.getInt(1); } - if (log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the" + " MDM database."); } @@ -92,7 +92,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ?" + + "UPDATE AD_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ?" + " WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setString(1, mobileFeature.getCode()); @@ -127,7 +127,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_FEATURE WHERE CODE = ?"; + "DELETE FROM AD_FEATURE WHERE CODE = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setString(1, mblFeatureCode); int rows = stmt.executeUpdate(); @@ -157,7 +157,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_FEATURE WHERE FEATURE_ID = ?"; + "DELETE FROM AD_FEATURE WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setInt(1, mblFeatureId); int rows = stmt.executeUpdate(); @@ -187,7 +187,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE " + + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE " + "WHERE CODE = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, mblFeatureCode); @@ -224,7 +224,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" + + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" + " WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setInt(1, mblFeatureId); @@ -261,7 +261,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE"; + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE"; stmt = conn.prepareStatement(selectDBQuery); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { @@ -296,7 +296,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" + + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" + " WHERE DEVICE_TYPE = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, deviceType); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java index d768dbd44..e3edfc324 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java @@ -54,7 +54,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)"; + "INSERT INTO AD_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mblFeatureProperty.getProperty()); @@ -87,7 +87,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?"; + "UPDATE AD_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setInt(1, mblFeatureProperty.getFeatureID()); stmt.setString(2, mblFeatureProperty.getProperty()); @@ -118,7 +118,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?"; + "DELETE FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setString(1, property); int rows = stmt.executeUpdate(); @@ -148,7 +148,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; + "DELETE FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setInt(1, mblFeatureId); int rows = stmt.executeUpdate(); @@ -179,7 +179,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?"; + "SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, property); ResultSet resultSet = stmt.executeQuery(); @@ -213,7 +213,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; + "SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setInt(1, mblFeatureId); ResultSet resultSet = stmt.executeQuery(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java index bd7e8b3c3..9d5694a3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java @@ -53,7 +53,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)"; + "INSERT INTO AD_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)"; stmt = conn.prepareStatement(createDBQuery, new String[] { COLUMN_OPERATION_ID }); stmt.setString(1, mblOperation.getFeatureCode()); stmt.setLong(2, mblOperation.getCreatedDate()); @@ -88,7 +88,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " + + "UPDATE AD_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setString(1, mblOperation.getFeatureCode()); @@ -123,7 +123,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; + "DELETE FROM AD_OPERATION WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setInt(1, mblOperationId); int rows = stmt.executeUpdate(); @@ -153,7 +153,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE " + + "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setInt(1, mblOperationId); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java index c4553862f..0542e6347 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java @@ -54,7 +54,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " + + "INSERT INTO AD_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " + "VALUES ( ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setInt(1, mblOperationProperty.getOperationId()); @@ -90,7 +90,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA try { conn = this.getConnection(); String createDBQuery = - "UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " + + "UPDATE AD_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " + "PROPERTY = ?"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mblOperationProperty.getValue()); @@ -125,7 +125,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?"; + "DELETE FROM AD_OPERATION_PROPERTY WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setInt(1, mblOperationId); int rows = stmt.executeUpdate(); @@ -158,7 +158,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA try { conn = this.getConnection(); String selectDBQuery = - "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " + + "SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE " + "OPERATION_ID = ? AND PROPERTY = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setInt(1, mblOperationId); @@ -197,7 +197,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA try { conn = this.getConnection(); String selectDBQuery = - "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " + + "SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setInt(1, mblOperationId); 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 8091ae186..6209ab6d2 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 @@ -78,6 +78,10 @@ public class MobileDeviceManagementDAOUtil { } } + public static void cleanupResources(PreparedStatement stmt, ResultSet rs) { + cleanupResources(null, stmt, rs); + } + /** * Creates the mobile device management schema. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java index be371bf34..3a1d22550 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java @@ -18,6 +18,8 @@ */ package org.wso2.carbon.device.mgt.mobile.impl.android; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.FeatureManagementException; @@ -31,6 +33,7 @@ import java.util.List; public class AndroidFeatureManager implements FeatureManager { private FeatureDAO featureDAO; + private static final Log log = LogFactory.getLog(AndroidFeatureManager.class); public AndroidFeatureManager() { this.featureDAO = FeatureManagementDAOFactory.getFeatureDAO(); @@ -39,9 +42,16 @@ public class AndroidFeatureManager implements FeatureManager { @Override public boolean addFeature(Feature feature) throws DeviceManagementException { try { + FeatureManagementDAOFactory.beginTransaction(); featureDAO.addFeature(feature); + FeatureManagementDAOFactory.commitTransaction(); return true; } catch (FeatureManagementDAOException e) { + try { + FeatureManagementDAOFactory.rollbackTransaction(); + } catch (FeatureManagementDAOException e1) { + log.warn("Error occurred while roll-backing the transaction", e); + } throw new DeviceManagementException("Error occurred while adding the feature", e); } } @@ -49,8 +59,16 @@ public class AndroidFeatureManager implements FeatureManager { @Override public Feature getFeature(String name) throws DeviceManagementException { try { - return featureDAO.getFeature(name); + FeatureManagementDAOFactory.beginTransaction(); + Feature feature = featureDAO.getFeature(name); + FeatureManagementDAOFactory.commitTransaction(); + return feature; } catch (FeatureManagementDAOException e) { + try { + FeatureManagementDAOFactory.rollbackTransaction(); + } catch (FeatureManagementDAOException e1) { + log.warn("Error occurred while roll-backing the transaction", e); + } throw new DeviceManagementException("Error occurred while retrieving the feature", e); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java index 4981295ad..6dc07b6ec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java @@ -144,6 +144,11 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage return operations; } + @Override + public Operation getPendingOperation(DeviceIdentifier deviceIdentifier) throws OperationManagementException { + return null; + } + public List getFeatures(String deviceType) throws FeatureManagementException { MobileFeatureDAO featureDAO = MobileDeviceManagementDAOFactory.getFeatureDAO(); MobileFeaturePropertyDAO featurePropertyDAO = diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java index 17b347b1f..1aa3289c4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java @@ -19,7 +19,6 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.dao; import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.FeatureManagementException; import java.util.List; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOException.java index 24d02f939..607240350 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOException.java @@ -19,4 +19,59 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.dao; public class FeatureManagementDAOException extends Exception { + + private String message; + private static final long serialVersionUID = 2021891706072918865L; + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified detail message and + * nested exception. + * + * @param message error message + * @param nestedException exception + */ + public FeatureManagementDAOException(String message, Exception nestedException) { + super(message, nestedException); + setErrorMessage(message); + } + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified detail message + * and cause. + * + * @param message the detail message. + * @param cause the cause of this exception. + */ + public FeatureManagementDAOException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified detail message. + * + * @param message the detail message. + */ + public FeatureManagementDAOException(String message) { + super(message); + setErrorMessage(message); + } + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified and cause. + * + * @param cause the cause of this exception. + */ + public FeatureManagementDAOException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + + public void setErrorMessage(String errorMessage) { + this.message = errorMessage; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOFactory.java index 08c207d94..a4f4db082 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOFactory.java @@ -18,12 +18,76 @@ */ package org.wso2.carbon.device.mgt.mobile.impl.android.dao; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.FeatureDAOImpl; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; + public class FeatureManagementDAOFactory { + private static DataSource dataSource; + private static ThreadLocal currentConnection = new ThreadLocal(); + private static final Log log = LogFactory.getLog(FeatureManagementDAOFactory.class); + public static FeatureDAO getFeatureDAO() { return new FeatureDAOImpl(); } + public static void init(DataSource dtSource) { + dataSource = dtSource; + } + + public static void beginTransaction() throws FeatureManagementDAOException { + try { + Connection conn = dataSource.getConnection(); + conn.setAutoCommit(false); + currentConnection.set(conn); + } catch (SQLException e) { + throw new FeatureManagementDAOException("Error occurred while retrieving datasource connection", e); + } + } + + public static Connection getConnection() { + return currentConnection.get(); + } + + public static void commitTransaction() throws FeatureManagementDAOException { + try { + Connection conn = currentConnection.get(); + if (conn != null) { + conn.commit(); + } else { + if (log.isDebugEnabled()) { + log.debug("Datasource connection associated with the current thread is null, hence commit " + + "has not been attempted"); + } + } + } catch (SQLException e) { + throw new FeatureManagementDAOException("Error occurred while committing the transaction", e); + } + } + + public static void rollbackTransaction() throws FeatureManagementDAOException { + try { + Connection conn = currentConnection.get(); + if (conn != null) { + conn.rollback(); + } else { + if (log.isDebugEnabled()) { + log.debug("Datasource connection associated with the current thread is null, hence rollback " + + "has not been attempted"); + } + } + } catch (SQLException e) { + throw new FeatureManagementDAOException("Error occurred while rollbacking the transaction", e); + } + } + + public static DataSource getDataSource() { + return dataSource; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/FeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/FeatureDAOImpl.java index d966b0304..0641350cf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/FeatureDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/FeatureDAOImpl.java @@ -19,31 +19,110 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl; import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureDAO; import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOFactory; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; public class FeatureDAOImpl implements FeatureDAO { @Override public void addFeature(Feature feature) throws FeatureManagementDAOException { - + PreparedStatement stmt = null; + try { + Connection conn = FeatureManagementDAOFactory.getConnection(); + String sql = "INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; + stmt = conn.prepareStatement(sql); + stmt.setString(1, feature.getCode()); + stmt.setString(2, feature.getName()); + stmt.setString(3, feature.getDescription()); + stmt.executeUpdate(); + } catch (SQLException e) { + throw new FeatureManagementDAOException("Error occurred while adding feature '" + + feature.getName() + "' into the metadata repository", e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); + } } @Override - public void removeFeature(String name) throws FeatureManagementDAOException { - + public void removeFeature(String code) throws FeatureManagementDAOException { + PreparedStatement stmt = null; + try { + Connection conn = FeatureManagementDAOFactory.getConnection(); + String sql = "DELETE FROM MBL_FEATURE WHERE CODE = ?"; + stmt = conn.prepareStatement(sql); + stmt.setString(1, code); + stmt.execute(); + } catch (SQLException e) { + throw new FeatureManagementDAOException("Error occurred while adding feature '" + + code + "' into the metadata repository", e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); + } } @Override - public Feature getFeature(String name) throws FeatureManagementDAOException { - return null; + public Feature getFeature(String code) throws FeatureManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs = null; + try { + Connection conn = FeatureManagementDAOFactory.getConnection(); + String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?"; + stmt = conn.prepareStatement(sql); + stmt.setString(1, code); + rs = stmt.executeQuery(); + + Feature feature = null; + if (rs.next()) { + feature = new Feature(); + feature.setId(rs.getInt("ID")); + feature.setCode(rs.getString("CODE")); + feature.setName(rs.getString("NAME")); + feature.setDescription(rs.getString("DESCRIPTION")); + } + return feature; + } catch (SQLException e) { + throw new FeatureManagementDAOException("Error occurred while retrieving feature metadata '" + + code + "' from the feature metadata repository", e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); + } } @Override public List getFeatures() throws FeatureManagementDAOException { - return null; + PreparedStatement stmt = null; + ResultSet rs = null; + List features = new ArrayList(); + try { + Connection conn = FeatureManagementDAOFactory.getConnection(); + String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE"; + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + + while (rs.next()) { + Feature feature = new Feature(); + feature.setId(rs.getInt("ID")); + feature.setCode(rs.getString("CODE")); + feature.setName(rs.getString("NAME")); + feature.setDescription(rs.getString("DESCRIPTION")); + } + return features; + } catch (SQLException e) { + throw new FeatureManagementDAOException("Error occurred while retrieving all feature metadata from the " + + "feature metadata repository", e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); + } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java index 38280e2a7..08f42568f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java @@ -20,8 +20,6 @@ package org.wso2.carbon.device.mgt.mobile.impl.ios; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.FeatureManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager; @@ -118,4 +116,9 @@ public class IOSMobileOperationManager extends AbstractMobileOperationManager { return operations; } + @Override + public Operation getPendingOperation(DeviceIdentifier deviceIdentifier) throws OperationManagementException { + return null; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/resources/sql/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/resources/sql/h2.sql index e69de29bb..dbcc64dac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/resources/sql/h2.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/resources/sql/h2.sql @@ -0,0 +1,98 @@ +-- ----------------------------------------------------- +-- Table AD_DEVICE +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS AD_FEATURE( + ID INTEGER NOT NULL, + CODE VARCHAR(50) NOT NULL, + NAME VARCHAR(100) NOT NULL, + DESCRIPTION VARCHAR(200) NOT NULL, +) + +-- ----------------------------------------------------- +-- Table AD_DEVICE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_DEVICE ( + MOBILE_DEVICE_ID VARCHAR(45) NOT NULL , + PUSH_TOKEN VARCHAR(45) NULL DEFAULT NULL , + IMEI VARCHAR(45) NULL DEFAULT NULL , + IMSI VARCHAR(45) NULL DEFAULT NULL , + OS_VERSION VARCHAR(45) NULL DEFAULT NULL , + DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL , + VENDOR VARCHAR(45) NULL DEFAULT NULL , + LATITUDE VARCHAR(45) NULL DEFAULT NULL, + LONGITUDE VARCHAR(45) NULL DEFAULT NULL, + CHALLENGE VARCHAR(45) NULL DEFAULT NULL, + TOKEN VARCHAR(500) NULL DEFAULT NULL, + UNLOCK_TOKEN VARCHAR(500) NULL DEFAULT NULL, + SERIAL VARCHAR(45) NULL DEFAULT NULL, + PRIMARY KEY (MOBILE_DEVICE_ID) ); + + +-- ----------------------------------------------------- +-- Table AD_FEATURE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_FEATURE ( + FEATURE_ID INT NOT NULL AUTO_INCREMENT , + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NULL , + DESCRIPTION VARCHAR(200) NULL , + DEVICE_TYPE VARCHAR(50) NULL , + PRIMARY KEY (FEATURE_ID) ); + +-- ----------------------------------------------------- +-- Table AD_OPERATION +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_OPERATION ( + OPERATION_ID INT NOT NULL AUTO_INCREMENT , + FEATURE_CODE VARCHAR(45) NOT NULL , + CREATED_DATE BIGINT NULL , + PRIMARY KEY (OPERATION_ID)); + +-- ----------------------------------------------------- +-- Table AD_DEVICE_OPERATION_MAPPING +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_DEVICE_OPERATION_MAPPING ( + DEVICE_ID VARCHAR(45) NOT NULL , + OPERATION_ID INT NOT NULL , + SENT_DATE BIGINT NULL , + RECEIVED_DATE BIGINT NULL , + STATUS VARCHAR(10) NOT NULL , + PRIMARY KEY (DEVICE_ID, OPERATION_ID) , + CONSTRAINT fk_AD_DEVICE_OPERATION_AD_DEVICE + FOREIGN KEY (DEVICE_ID ) + REFERENCES AD_DEVICE (MOBILE_DEVICE_ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT fk_AD_DEVICE_OPERATION_AD_OPERATION1 + FOREIGN KEY (OPERATION_ID ) + REFERENCES AD_OPERATION (OPERATION_ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +-- ----------------------------------------------------- +-- Table AD_OPERATION_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_OPERATION_PROPERTY ( + OPERATION_ID INT NOT NULL , + PROPERTY VARCHAR(45) NOT NULL , + VALUE TEXT NULL , + PRIMARY KEY (OPERATION_ID, PROPERTY) , + CONSTRAINT fk_AD_OPERATION_PROPERTY_AD_OPERATION1 + FOREIGN KEY (OPERATION_ID ) + REFERENCES AD_OPERATION (OPERATION_ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +-- ----------------------------------------------------- +-- Table AD_FEATURE_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_FEATURE_PROPERTY ( + PROPERTY VARCHAR(45) NOT NULL , + FEATURE_ID INT NOT NULL , + PRIMARY KEY (PROPERTY) , + CONSTRAINT fk_AD_FEATURE_PROPERTY_AD_FEATURE1 + FOREIGN KEY (FEATURE_ID ) + REFERENCES AD_FEATURE (FEATURE_ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java index f148d4794..ccafbc769 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java @@ -85,8 +85,7 @@ public class MobileDeviceDAOTestSuite { } @Test - public void addMobileDeviceTest() - throws MobileDeviceManagementDAOException { + public void addMobileDeviceTest() throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement preparedStatement = null; @@ -111,7 +110,7 @@ public class MobileDeviceDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + - "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " + + "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE " + "WHERE MOBILE_DEVICE_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); @@ -209,8 +208,7 @@ public class MobileDeviceDAOTestSuite { @Test(dependsOnMethods = { "addMobileDeviceTest", "getMobileDeviceTest", "getAllMobileDevicesTest" }) - public void updateMobileDeviceTest() - throws MobileDeviceManagementDAOException { + public void updateMobileDeviceTest() throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement preparedStatement = null; @@ -235,7 +233,7 @@ public class MobileDeviceDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + - "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " + + "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE " + "WHERE MOBILE_DEVICE_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); @@ -279,7 +277,7 @@ public class MobileDeviceDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + - "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " + + "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE " + "WHERE MOBILE_DEVICE_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); @@ -296,4 +294,5 @@ public class MobileDeviceDAOTestSuite { } Assert.assertTrue(deleted, "MobileDevice has deleted "); } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationMappingDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationMappingDAOTestSuite.java index 6c39be232..ea679f060 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationMappingDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationMappingDAOTestSuite.java @@ -155,7 +155,7 @@ public class MobileDeviceOperationMappingDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + - "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; + "AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); ResultSet resultSet = preparedStatement.executeQuery(); @@ -252,7 +252,7 @@ public class MobileDeviceOperationMappingDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, STATUS FROM " + - "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; + "AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setInt(2, mblOperationId1); @@ -296,7 +296,7 @@ public class MobileDeviceOperationMappingDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, RECEIVED_DATE, STATUS FROM " + - "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; + "AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setInt(2, mblOperationId1); @@ -348,7 +348,7 @@ public class MobileDeviceOperationMappingDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, RECEIVED_DATE, SENT_DATE, STATUS FROM " + - "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; + "AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setInt(2, mblOperationId1); @@ -422,7 +422,7 @@ public class MobileDeviceOperationMappingDAOTestSuite { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = "SELECT DEVICE_ID, OPERATION_ID, RECEIVED_DATE, SENT_DATE, STATUS FROM " + - "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; + "AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setInt(2, mblOperationId1); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java index 5d1d57672..ef0b40efd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java @@ -91,7 +91,7 @@ public class MobileFeatureDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String query = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE WHERE CODE = ?"; + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE WHERE CODE = ?"; preparedStatement = conn.prepareStatement(query); preparedStatement.setString(1, MBL_FEATURE_CODE); ResultSet resultSet = preparedStatement.executeQuery(); @@ -174,7 +174,7 @@ public class MobileFeatureDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String query = - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = ?"; + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?"; stmt = conn.prepareStatement(query); stmt.setString(1, MBL_FEATURE_UPDATED_CODE); ResultSet resultSet = stmt.executeQuery(); @@ -207,7 +207,7 @@ public class MobileFeatureDAOTestSuite { boolean status = mblFeatureDAO.deleteMobileFeatureById(mblFeatureId); try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); - String query = "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE FEATURE_ID = ?"; + String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(query); stmt.setInt(1, mblFeatureId); ResultSet resultSet = stmt.executeQuery(); @@ -240,7 +240,7 @@ public class MobileFeatureDAOTestSuite { boolean status = mblFeatureDAO.deleteMobileFeatureByCode(MBL_FEATURE_CODE); try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); - String query = "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE CODE = ?"; + String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE CODE = ?"; preparedStatement = conn.prepareStatement(query); preparedStatement.setString(1, MBL_FEATURE_CODE); ResultSet resultSet = preparedStatement.executeQuery(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeaturePropertyDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeaturePropertyDAOTestSuite.java index 95af28f41..bf5d44ed4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeaturePropertyDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeaturePropertyDAOTestSuite.java @@ -107,7 +107,7 @@ public class MobileFeaturePropertyDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String query = - "SELECT FEATURE_ID, PROPERTY FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; + "SELECT FEATURE_ID, PROPERTY FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; preparedStatement = conn.prepareStatement(query); preparedStatement.setInt(1, mblFeatureId); ResultSet resultSet = preparedStatement.executeQuery(); @@ -187,7 +187,7 @@ public class MobileFeaturePropertyDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String query = - "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?"; + "SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?"; preparedStatement = conn.prepareStatement(query); preparedStatement.setString(1, MBL_FEATURE_PROP_2); ResultSet resultSet = preparedStatement.executeQuery(); @@ -217,7 +217,7 @@ public class MobileFeaturePropertyDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String query = - "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; + "SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; preparedStatement = conn.prepareStatement(query); preparedStatement.setInt(1, mblFeatureId); ResultSet resultSet = preparedStatement.executeQuery(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java index d6b03e07e..3b05d09b3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java @@ -83,7 +83,7 @@ public class MobileOperationDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = - "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; + "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setInt(1, mblOperationId); ResultSet resultSet = preparedStatement.executeQuery(); @@ -133,7 +133,7 @@ public class MobileOperationDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = - "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; + "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setInt(1, mblOperationId); ResultSet resultSet = preparedStatement.executeQuery(); @@ -167,7 +167,7 @@ public class MobileOperationDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = - "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; + "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setInt(1, mblOperationId); ResultSet resultSet = preparedStatement.executeQuery(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java index 161a6e4e6..1342d6104 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java @@ -111,7 +111,7 @@ public class MobileOperationPropertyDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = - "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?"; + "SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setInt(1, mblOperationId); ResultSet resultSet = preparedStatement.executeQuery(); @@ -181,7 +181,7 @@ public class MobileOperationPropertyDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = - "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE" + + "SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE" + " OPERATION_ID = ? AND PROPERTY = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setInt(1, mblOperationId); @@ -217,7 +217,7 @@ public class MobileOperationPropertyDAOTestSuite { try { conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); String selectDBQuery = - "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE" + + "SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE" + " OPERATION_ID = ?"; preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement.setInt(1, mblOperationId); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java index cd4f45a24..f454f6f06 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java @@ -103,7 +103,7 @@ public class MobileDatabaseUtils { Class.forName(testDBConf.getDriverClassName()); conn = DriverManager.getConnection(testDBConf.getConnectionURL()); stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/h2.sql'"); } finally { cleanupResources(conn, stmt, null); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/h2.sql index e69de29bb..c0c2cebba 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/h2.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/h2.sql @@ -0,0 +1,88 @@ + +-- ----------------------------------------------------- +-- Table `MBL_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( + `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL , + `PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL , + `IMEI` VARCHAR(45) NULL DEFAULT NULL , + `IMSI` VARCHAR(45) NULL DEFAULT NULL , + `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL , + `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL , + `VENDOR` VARCHAR(45) NULL DEFAULT NULL , + `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, + `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, + `CHALLENGE` VARCHAR(45) NULL DEFAULT NULL, + `TOKEN` VARCHAR(500) NULL DEFAULT NULL, + `UNLOCK_TOKEN` VARCHAR(500) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NULL DEFAULT NULL, + PRIMARY KEY (`MOBILE_DEVICE_ID`) ); + + +-- ----------------------------------------------------- +-- Table `AD_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( + `FEATURE_ID` INT NOT NULL AUTO_INCREMENT , + `CODE` VARCHAR(45) NOT NULL, + `NAME` VARCHAR(100) NULL , + `DESCRIPTION` VARCHAR(200) NULL , + `DEVICE_TYPE` VARCHAR(50) NULL , + PRIMARY KEY (`FEATURE_ID`) ); + +-- ----------------------------------------------------- +-- Table `AD_OPERATION` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_OPERATION` ( + `OPERATION_ID` INT NOT NULL AUTO_INCREMENT , + `FEATURE_CODE` VARCHAR(45) NOT NULL , + `CREATED_DATE` BIGINT NULL , + PRIMARY KEY (`OPERATION_ID`)); + +-- ----------------------------------------------------- +-- Table `AD_DEVICE_OPERATION_MAPPING` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_DEVICE_OPERATION_MAPPING` ( + `DEVICE_ID` VARCHAR(45) NOT NULL , + `OPERATION_ID` INT NOT NULL , + `SENT_DATE` BIGINT NULL , + `RECEIVED_DATE` BIGINT NULL , + `STATUS` VARCHAR(10) NOT NULL , + PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) , + CONSTRAINT `fk_AD_DEVICE_OPERATION_AD_DEVICE` + FOREIGN KEY (`DEVICE_ID` ) + REFERENCES `AD_DEVICE` (`MOBILE_DEVICE_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_AD_DEVICE_OPERATION_AD_OPERATION1` + FOREIGN KEY (`OPERATION_ID` ) + REFERENCES `AD_OPERATION` (`OPERATION_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +-- ----------------------------------------------------- +-- Table `AD_OPERATION_PROPERTY` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_OPERATION_PROPERTY` ( + `OPERATION_ID` INT NOT NULL , + `PROPERTY` VARCHAR(45) NOT NULL , + `VALUE` TEXT NULL , + PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) , + CONSTRAINT `fk_AD_OPERATION_PROPERTY_AD_OPERATION1` + FOREIGN KEY (`OPERATION_ID` ) + REFERENCES `AD_OPERATION` (`OPERATION_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +-- ----------------------------------------------------- +-- Table `AD_FEATURE_PROPERTY` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AD_FEATURE_PROPERTY` ( + `PROPERTY` VARCHAR(45) NOT NULL , + `FEATURE_ID` INT NOT NULL , + PRIMARY KEY (`PROPERTY`) , + CONSTRAINT `fk_AD_FEATURE_PROPERTY_AD_FEATURE1` + FOREIGN KEY (`FEATURE_ID` ) + REFERENCES `AD_FEATURE` (`FEATURE_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); diff --git a/test.out b/test.out new file mode 100644 index 000000000..3a045791a --- /dev/null +++ b/test.out @@ -0,0 +1,47 @@ +diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +index 719a38b..5a63eef 100644 +--- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java ++++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +@@ -28,15 +28,13 @@ import java.util.List; + public abstract class AbstractMobileOperationManager implements OperationManager { + + @Override +- public List getOperations(DeviceIdentifier deviceIdentifier) +- throws OperationManagementException { ++ public List getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException { + return null; + } + + @Override + public boolean addOperation(Operation operation, +- List devices) +- throws OperationManagementException { ++ List devices) throws OperationManagementException { + return true; + } + +diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java +index 17b347b..1aa3289 100644 +--- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java ++++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java +@@ -19,7 +19,6 @@ + package org.wso2.carbon.device.mgt.mobile.impl.android.dao; + + import org.wso2.carbon.device.mgt.common.Feature; +-import org.wso2.carbon.device.mgt.common.FeatureManagementException; + + import java.util.List; + +diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java +index 38280e2..6607600 100644 +--- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java ++++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java +@@ -20,8 +20,6 @@ package org.wso2.carbon.device.mgt.mobile.impl.ios; + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; + import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +-import org.wso2.carbon.device.mgt.common.Feature; +-import org.wso2.carbon.device.mgt.common.FeatureManagementException; + import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; + import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; + import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;