From eb0fd6dc3137c436f0a137ce5263b71268b3e925 Mon Sep 17 00:00:00 2001 From: harshanL Date: Wed, 21 Jan 2015 12:29:06 +0530 Subject: [PATCH] Added operation support for Android --- .../datasource/MobileDataSourceConfig.java | 3 +- .../dao/MobileDeviceManagementDAOFactory.java | 165 +++++++------ .../impl/MobileDeviceOperationDAOImpl.java | 10 +- .../dao/impl/MobileOperationDAOImpl.java | 4 +- .../util/MobileDeviceManagementDAOUtil.java | 55 ----- .../AndroidMobileOperationManager.java | 8 +- ...obileDeviceManagementServiceComponent.java | 219 ++++++++++-------- .../modules/distribution/src/assembly/bin.xml | 12 +- .../repository/database/WSO2MobileDM_DB.h2.db | Bin 0 -> 2109440 bytes .../src/repository/dbscripts/cdm/h2.sql | 2 +- .../repository/dbscripts/cdm/plugins/h2.sql | 13 +- .../repository/dbscripts/cdm/plugins/h2.sql~ | 38 ++- .../mobileservices/android/Enrollment.java | 217 ++++++++--------- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 5 +- 14 files changed, 377 insertions(+), 374 deletions(-) create mode 100644 product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java index 2b9c570c9f..b8f6a8a3ca 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java @@ -28,12 +28,11 @@ public class MobileDataSourceConfig { private JNDILookupDefinition jndiLookupDefinition; @XmlElement(name = "JndiLookupDefinition", nillable = true) - public JNDILookupDefinition getJndiLookupDefintion() { + public JNDILookupDefinition getJndiLookupDefinition() { return jndiLookupDefinition; } public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) { this.jndiLookupDefinition = jndiLookupDefinition; } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java index ddaf0adf82..c014f9d6b9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java @@ -19,81 +19,108 @@ package org.wso2.carbon.device.mgt.mobile.dao; 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.mobile.DataSourceListener; +import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.dao.impl.*; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator; import javax.sql.DataSource; +import java.util.Hashtable; +import java.util.List; /** * Factory class used to create MobileDeviceManagement related DAO objects. */ -public class MobileDeviceManagementDAOFactory implements DataSourceListener { - - private static DataSource dataSource; - private static MobileDataSourceConfig mobileDataSourceConfig; - private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class); - - public MobileDeviceManagementDAOFactory() { - - } - - public void init() throws DeviceManagementException { - dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); - if (dataSource != null) { - MobileDeviceManagementDAOUtil.createDataSource(dataSource); - } else { - MobileDeviceManagementBundleActivator.registerDataSourceListener(this); - } - } - - public static MobileDeviceDAO getMobileDeviceDAO() { - return new MobileDeviceDAOImpl(dataSource); - } - - public static MobileOperationDAO getMobileOperationDAO() { - return new MobileOperationDAOImpl(dataSource); - } - - public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() { - return new MobileOperationPropertyDAOImpl(dataSource); - } - - public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() { - return new MobileDeviceOperationDAOImpl(dataSource); - } - - public static FeatureDAO getFeatureDAO() { - return new FeatureDAOImpl(dataSource); - } - - public static FeaturePropertyDAO getFeaturePropertyDAO() { - return new FeaturePropertyDAOImpl(dataSource); - } - - public static MobileDataSourceConfig getMobileDeviceManagementConfig() { - return mobileDataSourceConfig; - } - - public static void setMobileDataSourceConfig( - MobileDataSourceConfig mobileDataSourceConfig) { - MobileDeviceManagementDAOFactory.mobileDataSourceConfig = - mobileDataSourceConfig; - } - - public static DataSource getDataSource() { - return dataSource; - } - - @Override - public void notifyObserver() { - try { - dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); - MobileDeviceManagementDAOUtil.createDataSource(dataSource); - } catch (DeviceManagementException e) { - log.error("Error occurred while resolving mobile device management metadata repository data source", e); - } - } -} +public class MobileDeviceManagementDAOFactory { + + private static DataSource dataSource; + private static MobileDataSourceConfig mobileDataSourceConfig; + private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class); + + public MobileDeviceManagementDAOFactory() { + + } + + public static void init() { + try { + dataSource = MobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfig); + } catch (DeviceManagementException e) { + log.error("Exception occurred while initializing the mobile datasource.",e); + } + } + + /** + * Resolve data source from the data source definition. + * + * @param config Mobile data source configuration + * @return data source resolved from the data source definition + */ + private static DataSource resolveDataSource(MobileDataSourceConfig config) + throws DeviceManagementException { + DataSource dataSource = null; + if (config == null) { + throw new RuntimeException("Device Management Repository data source configuration " + + "is null and thus, is not initialized"); + } + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); + if (jndiConfig != null) { + if (log.isDebugEnabled()) { + log.debug("Initializing Device Management Repository data source using the JNDI " + + "Lookup Definition"); + } + List jndiPropertyList = + jndiConfig.getJndiProperties(); + if (jndiPropertyList != null) { + Hashtable jndiProperties = new Hashtable(); + for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { + jndiProperties.put(prop.getName(), prop.getValue()); + } + dataSource = + MobileDeviceManagementDAOUtil + .lookupDataSource(jndiConfig.getJndiName(), jndiProperties); + } else { + dataSource = MobileDeviceManagementDAOUtil + .lookupDataSource(jndiConfig.getJndiName(), null); + } + } + return dataSource; + } + + public static MobileDeviceDAO getMobileDeviceDAO() { + return new MobileDeviceDAOImpl(dataSource); + } + + public static MobileOperationDAO getMobileOperationDAO() { + return new MobileOperationDAOImpl(dataSource); + } + + public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() { + return new MobileOperationPropertyDAOImpl(dataSource); + } + + public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() { + return new MobileDeviceOperationDAOImpl(dataSource); + } + + public static FeatureDAO getFeatureDAO() { + return new FeatureDAOImpl(dataSource); + } + + public static FeaturePropertyDAO getFeaturePropertyDAO() { + return new FeaturePropertyDAOImpl(dataSource); + } + + public static MobileDataSourceConfig getMobileDeviceManagementConfig() { + return mobileDataSourceConfig; + } + + public static void setMobileDataSourceConfig( + MobileDataSourceConfig mobileDataSourceConfig) { + MobileDeviceManagementDAOFactory.mobileDataSourceConfig = + mobileDataSourceConfig; + } + + public static DataSource getDataSource() { + return dataSource; + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java index e2d24e5e9b..25b13a5904 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java @@ -52,7 +52,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_DEVICE_OPERATION(DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)"; + "INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, deviceOperation.getDeviceId()); @@ -86,7 +86,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setLong(1, deviceOperation.getSentDate()); stmt.setLong(2, deviceOperation.getReceivedDate()); @@ -117,7 +117,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setString(1, deviceId); stmt.setInt(2, operationId); @@ -146,7 +146,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, deviceId); stmt.setInt(2, operationId); @@ -181,7 +181,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ?"; + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, deviceId); 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 01612098a1..e2fb47b732 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 @@ -138,11 +138,13 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { String selectDBQuery = "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, operation.getOperationId()); + stmt.setInt(1, operationId); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { operation = new MobileOperation(); operation.setOperationId(resultSet.getInt(1)); + operation.setFeatureCode(resultSet.getString(2)); + operation.setCreatedDate(resultSet.getLong(3)); break; } } catch (SQLException e) { 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 146a33bcbf..af181b321b 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 @@ -39,40 +39,6 @@ public class MobileDeviceManagementDAOUtil { private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class); - /** - * Resolve data source from the data source definition. - * - * @param config Mobile data source configuration - * @return data source resolved from the data source definition - */ - public static DataSource resolveDataSource(MobileDataSourceConfig config) throws DeviceManagementException { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = - MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } - public static DataSource lookupDataSource(String dataSourceName, final Hashtable jndiProperties) throws DeviceManagementException { @@ -113,27 +79,6 @@ public class MobileDeviceManagementDAOUtil { } } - /** - * Initializes the creation of mobile device management schema if -Dsetup has provided. - * - * @param dataSource Mobile data source - */ - public static void createDataSource(DataSource dataSource) { - String setupOption = System.getProperty("setup"); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug( - "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + - "to begin"); - } - try { - MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(dataSource); - } catch (DeviceManagementException e) { - log.error("Exception occurred while initializing mobile device management database schema", e); - } - } - } - /** * 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/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 f04bba9a94..76c6332434 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 @@ -58,7 +58,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage mobileDeviceOperation.setDeviceId(deviceIdentifier.getId()); status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() .addMobileDeviceOperation( - new MobileDeviceOperation()); + mobileDeviceOperation); } } } catch (MobileDeviceManagementDAOException e) { @@ -75,6 +75,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage throws OperationManagementException { List operations = new ArrayList(); List mobileDeviceOperations = null; + List operationProperties = null; MobileOperation mobileOperation = null; try { mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() @@ -88,6 +89,11 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO() .getMobileOperation( operationId); + operationProperties = + MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO() + .getAllMobileOperationPropertiesOfOperation( + operationId); + mobileOperation.setProperties(operationProperties); operations.add(MobileDeviceManagementUtil .convertMobileOperationToOperation(mobileOperation)); } 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 195929bb2f..28606783db 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 @@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService; import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService; import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService; @@ -54,112 +55,134 @@ import java.util.List; */ public class MobileDeviceManagementServiceComponent { - private ServiceRegistration androidServiceRegRef; - private ServiceRegistration iOSServiceRegRef; - private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration androidServiceRegRef; + private ServiceRegistration iOSServiceRegRef; + private ServiceRegistration windowsServiceRegRef; - private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); + private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); - protected void activate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("Activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); + protected void activate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Activating Mobile Device Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); /* Initialize the datasource configuration */ - MobileDeviceConfigurationManager.getInstance().initConfig(); - MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() - .getMobileDeviceManagementConfig(); - MobileDataSourceConfig dsConfig = - config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); - - MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); - - androidServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new AndroidDeviceManagerService(), null); - iOSServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new IOSDeviceManagerService(), null); - windowsServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new WindowsDeviceManagerService(), null); + MobileDeviceConfigurationManager.getInstance().initConfig(); + MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() + .getMobileDeviceManagementConfig(); + MobileDataSourceConfig dsConfig = + config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); + + MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); + MobileDeviceManagementDAOFactory.init(); + String setupOption = System.getProperty("setup"); + if (setupOption != null) { + if (log.isDebugEnabled()) { + log.debug( + "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + + "to begin"); + } + try { + MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema( + MobileDeviceManagementDAOFactory.getDataSource()); + } catch (DeviceManagementException e) { + log.error( + "Exception occurred while initializing mobile device management database schema", + e); + } + } + + androidServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new AndroidDeviceManagerService(), null); + iOSServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new IOSDeviceManagerService(), null); + windowsServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new WindowsDeviceManagerService(), null); /* Initialize all API configurations with corresponding API Providers */ - this.initAPIConfigs(); - /* Publish all mobile device management related JAX-RS services as APIs */ - this.publishAPIs(); - - if (log.isDebugEnabled()) { - log.debug("Mobile Device Management Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error("Error occurred while activating Mobile Device Management Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - - androidServiceRegRef.unregister(); - iOSServiceRegRef.unregister(); - windowsServiceRegRef.unregister(); + this.initAPIConfigs(); + /* Publish all mobile device management related JAX-RS services as APIs */ + this.publishAPIs(); + + if (log.isDebugEnabled()) { + log.debug( + "Mobile Device Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Mobile Device Management Service Component", + e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating Mobile Device Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); + + androidServiceRegRef.unregister(); + iOSServiceRegRef.unregister(); + windowsServiceRegRef.unregister(); /* Removing all APIs published upon start-up for mobile device management related JAX-RS services */ - this.removeAPIs(); - if (log.isDebugEnabled()) { - log.debug("Mobile Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error("Error occurred while de-activating Mobile Device Management bundle", e); - } - } - - private void initAPIConfigs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - try { - APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner()); - apiConfig.init(provider); - } catch (APIManagementException e) { - throw new DeviceManagementException("Error occurred while initializing API Config '" + - apiConfig.getName() + "'", e); - } - } - } - - private void publishAPIs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); - } - } - - private void removeAPIs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); - } - } - - protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - - protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } + this.removeAPIs(); + if (log.isDebugEnabled()) { + log.debug( + "Mobile Device Management Service Component has been successfully de-activated"); + } + } catch (Throwable e) { + log.error("Error occurred while de-activating Mobile Device Management bundle", e); + } + } + + private void initAPIConfigs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + try { + APIProvider provider = + APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner()); + apiConfig.init(provider); + } catch (APIManagementException e) { + throw new DeviceManagementException( + "Error occurred while initializing API Config '" + + apiConfig.getName() + "'", e); + } + } + } + + private void publishAPIs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); + } + } + + private void removeAPIs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); + } + } + + protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } + + protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } } diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index 1478107e94..e1eb407829 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -210,7 +210,7 @@ - ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm + ../distribution/src/repository/dbscripts/cdm wso2cdm-${project.version}/dbscripts/cdm */** @@ -460,5 +460,15 @@ 644 + + + + ../distribution/src/repository/database/WSO2MobileDM_DB.h2.db + + ${pom.artifactId}-${pom.version}/repository/database + WSO2MobileDM_DB.h2.db + 644 + + diff --git a/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db b/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db new file mode 100644 index 0000000000000000000000000000000000000000..219f5ea3fba3982c9681e889a3317060a2cbbeb2 GIT binary patch literal 2109440 zcmeI&2Y8kB-N#`P4yahFh!)YJPqad)K@&1ax@^V?q=W=BP`ZvFV7J|^U0PS`9^HHI z-P*nP-h1!8_pa|ZA?JjkA+&w3_qyKp&gDnoX&=l=hm5pm6$V#C^^`K0!fdx|w{ zibZLkf1Wq*zd@5cy0FsuAAEZQhu#V3(~@=$NWNo009C72>b^M zxc>hKE~<}2fB*pk1PBlyK!5-N0t5&UAV7cs0RsQ^0tXy?hZs!!m4E)~zrL>Sule1? zU;ZDE4onB7Md{#lle9S9G#!!-O-s^YX=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5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ gfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF{I?7I4=6ua!vFvP literal 0 HcmV?d00001 diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql index 783acaa8de..3ceea15a02 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql +++ b/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql @@ -23,4 +23,4 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- TO:DO - Remove this INSERT sql statement. -Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android'); +Insert into DM_DEVICE_TYPE (NAME) VALUES ('android'); diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql index fd239aa58f..39610edd9a 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql +++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql @@ -31,13 +31,8 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( CREATE TABLE IF NOT EXISTS `MBL_OPERATION` ( `OPERATION_ID` INT NOT NULL AUTO_INCREMENT , `FEATURE_CODE` VARCHAR(45) NOT NULL , - `CREATED_DATE` INT NULL , - PRIMARY KEY (`OPERATION_ID`) , - CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1` - FOREIGN KEY (`FEATURE_CODE` ) - REFERENCES `MBL_FEATURE` (`CODE` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION); + `CREATED_DATE` BIGINT NULL , + PRIMARY KEY (`OPERATION_ID`)); -- ----------------------------------------------------- -- Table `MBL_DEVICE_OPERATION_MAPPING` @@ -45,8 +40,8 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` ( CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` ( `DEVICE_ID` VARCHAR(45) NOT NULL , `OPERATION_ID` INT NOT NULL , - `SENT_DATE` INT NULL , - `RECEIVED_DATE` INT NULL , + `SENT_DATE` BIGINT NULL , + `RECEIVED_DATE` BIGINT NULL , PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) , CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE` FOREIGN KEY (`DEVICE_ID` ) diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~ index 85304414bf..31ae8bd724 100644 --- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~ +++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~ @@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( `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, PRIMARY KEY (`MOBILE_DEVICE_ID`) ); @@ -18,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( `FEATURE_ID` INT NOT NULL AUTO_INCREMENT , - `CODE` VARCHAR(45) NULL , + `CODE` VARCHAR(45) NOT NULL , `NAME` VARCHAR(100) NULL , `DESCRIPTION` VARCHAR(200) NULL , PRIMARY KEY (`FEATURE_ID`) ); @@ -28,23 +30,18 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `MBL_OPERATION` ( `OPERATION_ID` INT NOT NULL AUTO_INCREMENT , - `FEATURE_CODE` VARCHAR(45) NULL , - `CREATED_DATE` INT NULL , - PRIMARY KEY (`OPERATION_ID`) , - CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1` - FOREIGN KEY (`FEATURE_CODE` ) - REFERENCES `MBL_FEATURE` (`CODE` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION); + `FEATURE_CODE` VARCHAR(45) NOT NULL , + `CREATED_DATE` LONG NULL , + PRIMARY KEY (`OPERATION_ID`)); -- ----------------------------------------------------- --- Table `MBL_DEVICE_OPERATION_MAPING` +-- Table `MBL_DEVICE_OPERATION_MAPPING` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` ( +CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` ( `DEVICE_ID` VARCHAR(45) NOT NULL , `OPERATION_ID` INT NOT NULL , - `SENT_DATE` INT NULL , - `RECEIVED_DATE` INT NULL , + `SENT_DATE` LONG NULL , + `RECEIVED_DATE` LONG NULL , PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) , CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE` FOREIGN KEY (`DEVICE_ID` ) @@ -61,11 +58,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` ( -- Table `MBL_OPERATION_PROPERTY` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` ( - `OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT , - `OPERATION_ID` INT NULL , - `PROPERTY_ID` INT NULL , + `OPERATION_ID` INT NOT NULL , + `PROPERTY` VARCHAR(45) NOT NULL , `VALUE` TEXT NULL , - PRIMARY KEY (`OPERATION_PROPERTY_ID`) , + PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) , CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1` FOREIGN KEY (`OPERATION_ID` ) REFERENCES `MBL_OPERATION` (`OPERATION_ID` ) @@ -76,13 +72,11 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` ( -- Table `MBL_FEATURE_PROPERTY` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` ( - `PROPERTY_ID` INT NOT NULL AUTO_INCREMENT , - `PROPERTY` VARCHAR(100) NULL , - `FEATURE_ID` VARCHAR(45) NULL , - PRIMARY KEY (`PROPERTY_ID`) , + `PROPERTY` VARCHAR(45) NOT NULL , + `FEATURE_ID` VARCHAR(45) NOT NULL , + PRIMARY KEY (`PROPERTY`) , CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1` FOREIGN KEY (`FEATURE_ID` ) REFERENCES `MBL_FEATURE` (`FEATURE_ID` ) ON DELETE NO ACTION ON UPDATE NO ACTION); - diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java index a5fb3b8de7..d2e2438f8f 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Enrollment.java @@ -39,112 +39,113 @@ import javax.ws.rs.core.Response; @Consumes({ "application/json", "application/xml" }) public class Enrollment { - private static Log log = LogFactory.getLog(Enrollment.class); - - @POST - public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException { - - Message responseMsg = new Message(); - - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); - Response.status(Response.Status.CREATED); - responseMsg.setResponseMessage("Device enrollment succeeded"); - return responseMsg; - } catch (DeviceManagementServiceException deviceServiceMgtEx) { - String errorMsg = "Device management service error"; - log.error(errorMsg, deviceServiceMgtEx); - throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); - } catch (DeviceManagementException deviceMgtEx) { - String errorMsg = "Error occurred while enrolling the device"; - log.error(errorMsg, deviceMgtEx); - throw new AndroidAgentException(errorMsg, deviceMgtEx); - } - } - - @GET - @Path("{id}") - public Message isEnrolled(@PathParam("id") String id) throws AndroidAgentException { - - boolean result; - Message responseMsg = new Message(); - DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); - - try { - result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier); - if (result) { - responseMsg.setResponseMessage("Device has already enrolled"); - } else { - Response.status(Response.Status.NOT_FOUND); - responseMsg.setResponseMessage("Device not found"); - } - return responseMsg; - } catch (DeviceManagementServiceException deviceServiceMgtEx) { - String errorMsg = "Device management service error"; - log.error(errorMsg, deviceServiceMgtEx); - throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); - } catch (DeviceManagementException deviceMgtEx) { - String errorMsg = "Error occurred while enrollment of the device."; - log.error(errorMsg, deviceMgtEx); - throw new AndroidAgentException(errorMsg, deviceMgtEx); - } - } - - @PUT - @Path("{id}") - public Message modifyEnrollment(@PathParam("id") String id, org.wso2.carbon.device.mgt.common.Device device) - throws AndroidAgentException { - - boolean result; - Message responseMsg = new Message(); - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device); - if (result) { - responseMsg.setResponseMessage("Device enrollment has updated successfully"); - Response.status(Response.Status.ACCEPTED); - } else { - responseMsg.setResponseMessage("Device not found for enrollment"); - Response.status(Response.Status.NOT_MODIFIED); - } - return responseMsg; - } catch (DeviceManagementServiceException deviceServiceMgtEx) { - String errorMsg = "Device management service error"; - log.error(errorMsg, deviceServiceMgtEx); - throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); - } catch (DeviceManagementException deviceMgtEx) { - String errorMsg = "Error occurred while modifying enrollment of the device"; - log.error(errorMsg, deviceMgtEx); - throw new AndroidAgentException(errorMsg, deviceMgtEx); - } - } - - @DELETE - @Path("{id}") - public Message disEnrollDevice(@PathParam("id") String id) throws AndroidAgentException { - - Message responseMsg = new Message(); - boolean result; - DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); - - try { - result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); - if (result) { - responseMsg.setResponseMessage("Device has removed successfully"); - } else { - responseMsg.setResponseMessage("Device not found"); - Response.status(Response.Status.NOT_FOUND); - } - return responseMsg; - } catch (DeviceManagementServiceException deviceServiceMgtEx) { - String errorMsg = "Device management service error"; - log.error(errorMsg, deviceServiceMgtEx); - throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); - } catch (DeviceManagementException deviceMgtEx) { - String errorMsg = "Error occurred while dis enrolling the device"; - log.error(errorMsg, deviceMgtEx); - throw new AndroidAgentException(errorMsg, deviceMgtEx); - } - } + private static Log log = LogFactory.getLog(Enrollment.class); + + @POST + public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) + throws AndroidAgentException { + + Message responseMsg = new Message(); + + try { + device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); + Response.status(Response.Status.CREATED); + responseMsg.setResponseMessage("Device enrollment succeeded"); + return responseMsg; + } catch (DeviceManagementServiceException deviceServiceMgtEx) { + String errorMsg = "Device management service error"; + log.error(errorMsg, deviceServiceMgtEx); + throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); + } catch (DeviceManagementException deviceMgtEx) { + String errorMsg = "Error occurred while enrolling the device"; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); + } + } + + @GET + @Path("{id}") + public Message isEnrolled(@PathParam("id") String id) throws AndroidAgentException { + + boolean result; + Message responseMsg = new Message(); + DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); + + try { + result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier); + if (result) { + responseMsg.setResponseMessage("Device has already enrolled"); + } else { + Response.status(Response.Status.NOT_FOUND); + responseMsg.setResponseMessage("Device not found"); + } + return responseMsg; + } catch (DeviceManagementServiceException deviceServiceMgtEx) { + String errorMsg = "Device management service error"; + log.error(errorMsg, deviceServiceMgtEx); + throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); + } catch (DeviceManagementException deviceMgtEx) { + String errorMsg = "Error occurred while enrollment of the device."; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); + } + } + + @PUT + @Path("{id}") + public Message modifyEnrollment(@PathParam("id") String id, + org.wso2.carbon.device.mgt.common.Device device) + throws AndroidAgentException { + + boolean result; + Message responseMsg = new Message(); + try { + device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device); + if (result) { + responseMsg.setResponseMessage("Device enrollment has updated successfully"); + Response.status(Response.Status.ACCEPTED); + } else { + responseMsg.setResponseMessage("Device not found for enrollment"); + Response.status(Response.Status.NOT_MODIFIED); + } + return responseMsg; + } catch (DeviceManagementServiceException deviceServiceMgtEx) { + String errorMsg = "Device management service error"; + log.error(errorMsg, deviceServiceMgtEx); + throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); + } catch (DeviceManagementException deviceMgtEx) { + String errorMsg = "Error occurred while modifying enrollment of the device"; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); + } + } + + @DELETE + @Path("{id}") + public Message disEnrollDevice(@PathParam("id") String id) throws AndroidAgentException { + Message responseMsg = new Message(); + boolean result; + DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); + + try { + result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); + if (result) { + responseMsg.setResponseMessage("Device has removed successfully"); + } else { + responseMsg.setResponseMessage("Device not found"); + Response.status(Response.Status.NOT_FOUND); + } + return responseMsg; + } catch (DeviceManagementServiceException deviceServiceMgtEx) { + String errorMsg = "Device management service error"; + log.error(errorMsg, deviceServiceMgtEx); + throw new AndroidAgentException(errorMsg, deviceServiceMgtEx); + } catch (DeviceManagementException deviceMgtEx) { + String errorMsg = "Error occurred while dis enrolling the device"; + log.error(errorMsg, deviceMgtEx); + throw new AndroidAgentException(errorMsg, deviceMgtEx); + } + } } diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml index a58b5fc254..5b0c46836a 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -23,9 +23,9 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> - + - + @@ -53,6 +53,7 @@ +