From 78f0ba2cdf844fafc5c2e6a0f1d643295e680e3e Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 28 Oct 2015 20:07:03 +0530 Subject: [PATCH] Added feature addition to the plugin initialization. --- ...leDeviceManagementDAOFactoryInterface.java | 2 +- .../mgt/mobile/dao/MobileFeatureDAO.java | 11 +- .../mobile/dao/impl/MobileFeatureDAOImpl.java | 5 + .../impl/android/AndroidDeviceManager.java | 7 +- .../impl/android/AndroidFeatureManager.java | 142 +++++++++++++++++- .../impl/android/dao/AndroidDAOFactory.java | 3 +- .../dao/impl/AndroidFeatureDAOImpl.java | 53 +++++-- .../impl/windows/WindowsFeatureManager.java | 14 +- .../impl/windows/dao/WindowsDAOFactory.java | 2 +- .../util/MobileDeviceManagementUtil.java | 15 ++ .../src/main/resources/conf/mobile-config.xml | 60 ++------ 11 files changed, 238 insertions(+), 76 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactoryInterface.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactoryInterface.java index 3dd2336ef..946aa6d73 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactoryInterface.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactoryInterface.java @@ -30,7 +30,7 @@ public interface MobileDeviceManagementDAOFactoryInterface { public MobileDeviceOperationMappingDAO getMobileDeviceOperationDAO(); - public MobileFeatureDAO getMobileFeatureDao(); + public MobileFeatureDAO getMobileFeatureDAO(); public MobileFeaturePropertyDAO getFeaturePropertyDAO(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java index 627a670bd..55c77424b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java @@ -32,11 +32,20 @@ public interface MobileFeatureDAO { * Adds a new MobileFeature to Mobile-Feature table. * * @param mobileFeature MobileFeature object that holds data related to the feature to be inserted. - * @return The id of inserted MobileFeature. + * @return boolean status of the operation. * @throws MobileDeviceManagementDAOException */ boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; + /** + * Adda a list of MobileFeatures to Mobile-Feature table. + * + * @param mobileFeatures List of MobileFeature objects. + * @return boolean status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException; + /** * Updates a MobileFeature in Mobile-Feature table. * 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 666e33e2d..ed5540af7 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 @@ -81,6 +81,11 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { return status; } + @Override + public boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException { + return false; + } + @Override public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java index 73b3d9835..4bccafb46 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java @@ -62,10 +62,13 @@ public class AndroidDeviceManager implements DeviceManager { try { licenseManager .addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense); + featureManager.addSupportedFeaturesToDB(); } catch (LicenseManagementException e) { log.error("Error occurred while adding default license for Android devices", e); - } - } + } catch (DeviceManagementException e) { + log.error("Error occurred while adding supported device features for Android platform", e); + } + } @Override public FeatureManager getFeatureManager() { 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 999dfb655..ed23a360d 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 @@ -41,12 +41,11 @@ public class AndroidFeatureManager implements FeatureManager { public AndroidFeatureManager() { mobileDeviceManagementDAOFactory = new AndroidDAOFactory(); - this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDao(); + this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDAO(); } @Override public boolean addFeature(Feature feature) throws DeviceManagementException { - try { AndroidDAOFactory.beginTransaction(); MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature); @@ -63,11 +62,32 @@ public class AndroidFeatureManager implements FeatureManager { } } + @Override + public boolean addFeatures(List features) throws DeviceManagementException { + List mobileFeatures = new ArrayList(); + for (Feature feature:features) { + mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature)); + } + try { + AndroidDAOFactory.beginTransaction(); + featureDAO.addFeatures(mobileFeatures); + AndroidDAOFactory.commitTransaction(); + return true; + } catch (MobileDeviceManagementDAOException e) { + try { + AndroidDAOFactory.rollbackTransaction(); + } catch (MobileDeviceManagementDAOException e1) { + log.warn("Error occurred while roll-backing the transaction", e); + } + throw new DeviceManagementException("Error occurred while adding the features", e); + } + } + @Override public Feature getFeature(String name) throws DeviceManagementException { try { MobileFeature mobileFeature = featureDAO.getFeatureByCode(name); - Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature); + Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature); return feature; } catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while retrieving the feature", e); @@ -76,7 +96,6 @@ public class AndroidFeatureManager implements FeatureManager { @Override public List getFeatures() throws DeviceManagementException { - List featureList = new ArrayList(); try { List mobileFeatures = featureDAO.getAllFeatures(); @@ -86,13 +105,13 @@ public class AndroidFeatureManager implements FeatureManager { return featureList; } catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " + - "Android platform", e); + "Android platform", e); } } @Override public boolean removeFeature(String code) throws DeviceManagementException { - boolean status = false; + boolean status; try { AndroidDAOFactory.beginTransaction(); featureDAO.deleteFeatureByCode(code); @@ -109,4 +128,115 @@ public class AndroidFeatureManager implements FeatureManager { return status; } + @Override + public boolean addSupportedFeaturesToDB() throws DeviceManagementException { + synchronized (this) { + List supportedFeatures = getSupportedFeatures(); + List existingFeatures = this.getFeatures(); + List missingFeatures = MobileDeviceManagementUtil. + getMissingFeatures(supportedFeatures, existingFeatures); + return this.addFeatures(missingFeatures); + } + } + + //Get the supported feature list. + private static List getSupportedFeatures() { + List supportedFeatures = new ArrayList(); + Feature feature = new Feature(); + feature.setCode("DEVICE_LOCK"); + feature.setName("Device Lock"); + feature.setDescription("Lock the device"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("DEVICE_LOCATION"); + feature.setName("Location"); + feature.setDescription("Request coordinates of device location"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("WIFI"); + feature.setName("wifi"); + feature.setDescription("Setting up wifi configuration"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("CAMERA"); + feature.setName("camera"); + feature.setDescription("Enable or disable camera"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("EMAIL"); + feature.setName("Email"); + feature.setDescription("Configure email settings"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("DEVICE_MUTE"); + feature.setName("mute"); + feature.setDescription("Enable mute in the device"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("DEVICE_INFO"); + feature.setName("Device info"); + feature.setDescription("Request device information"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("ENTERPRISE_WIPE"); + feature.setName("Enterprise Wipe"); + feature.setDescription("Remove enterprise applications"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("CLEAR_PASSWORD"); + feature.setName("Clear Password"); + feature.setDescription("Clear current password"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("WIPE_DATA"); + feature.setName("Wipe Data"); + feature.setDescription("Factory reset the device"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("APPLICATION_LIST"); + feature.setName("Application List"); + feature.setDescription("Request list of current installed applications"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("CHANGE_LOCK_CODE"); + feature.setName("Change Lock-code"); + feature.setDescription("Change current lock code"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("INSTALL_APPLICATION"); + feature.setName("Install App"); + feature.setDescription("Install Enterprise or Market application"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("UNINSTALL_APPLICATION"); + feature.setName("Uninstall App"); + feature.setDescription("Uninstall application"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("BLACKLIST_APPLICATIONS"); + feature.setName("Blacklist app"); + feature.setDescription("Blacklist applications"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("ENCRYPT_STORAGE"); + feature.setName("Encrypt storage"); + feature.setDescription("Encrypt storage"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("DEVICE_RING"); + feature.setName("Ring"); + feature.setDescription("Ring the device"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("PASSCODE_POLICY"); + feature.setName("Password Policy"); + feature.setDescription("Set passcode policy"); + supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("NOTIFICATION"); + feature.setName("Message"); + feature.setDescription("Send message"); + supportedFeatures.add(feature); + return supportedFeatures; + } } \ 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/impl/android/dao/AndroidDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java index dd116e519..9e2317c84 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java @@ -60,7 +60,8 @@ public class AndroidDAOFactory extends MobileDeviceManagementDAOFactory return null; } - @Override public MobileFeatureDAO getMobileFeatureDao() { + @Override + public MobileFeatureDAO getMobileFeatureDAO() { return new AndroidFeatureDAOImpl(); } 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/AndroidFeatureDAOImpl.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/AndroidFeatureDAOImpl.java index d597d3a5d..4ebb8b55e 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/AndroidFeatureDAOImpl.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/AndroidFeatureDAOImpl.java @@ -48,10 +48,9 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { @Override public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; boolean status = false; - Connection conn = null; + Connection conn; try { conn = AndroidDAOFactory.getConnection(); String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; @@ -61,11 +60,37 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { stmt.setString(3, mobileFeature.getDescription()); stmt.executeUpdate(); status = true; - status = true; } catch (SQLException e) { throw new AndroidFeatureManagementDAOException( "Error occurred while adding android feature '" + - mobileFeature.getName() + "' into the metadata repository", e); + mobileFeature.getName() + "' into the metadata repository", e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + + @Override + public boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException { + PreparedStatement stmt = null; + MobileFeature mobileFeature; + boolean status = false; + Connection conn; + try { + conn = AndroidDAOFactory.getConnection(); + stmt = conn.prepareStatement("INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"); + for (int i = 0; i < mobileFeatures.size(); i++) { + mobileFeature = mobileFeatures.get(i); + stmt.setString(1, mobileFeature.getCode()); + stmt.setString(2, mobileFeature.getName()); + stmt.setString(3, mobileFeature.getDescription()); + stmt.addBatch(); + } + stmt.executeBatch(); + status = true; + } catch (SQLException e) { + throw new AndroidFeatureManagementDAOException( + "Error occurred while adding android features into the metadata repository", e); } finally { MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); } @@ -75,7 +100,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { @Override public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { boolean status = false; - Connection conn = null; + Connection conn; PreparedStatement stmt = null; try { conn = AndroidDAOFactory.getConnection(); @@ -112,7 +137,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { PreparedStatement stmt = null; boolean status = false; - Connection conn = null; + Connection conn; try { conn = AndroidDAOFactory.getConnection(); String sql = "DELETE FROM AD_FEATURE WHERE ID = ?"; @@ -135,7 +160,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { MobileDeviceManagementDAOException { PreparedStatement stmt = null; boolean status = false; - Connection conn = null; + Connection conn; try { conn = AndroidDAOFactory.getConnection(); String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?"; @@ -146,7 +171,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { } catch (SQLException e) { throw new AndroidFeatureManagementDAOException( "Error occurred while deleting android feature '" + - mblFeatureCode + "' from Android database.", e); + mblFeatureCode + "' from Android database.", e); } finally { MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); } @@ -158,7 +183,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { MobileDeviceManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; - Connection conn = null; + Connection conn; try { conn = AndroidDAOFactory.getConnection(); String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE ID = ?"; @@ -193,7 +218,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { MobileDeviceManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; - Connection conn = null; + Connection conn; try { conn = AndroidDAOFactory.getConnection(); @@ -217,7 +242,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { } catch (SQLException e) { throw new AndroidFeatureManagementDAOException( "Error occurred while retrieving android feature '" + - mblFeatureCode + "' from the Android database.", e); + mblFeatureCode + "' from the Android database.", e); } finally { MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); AndroidDAOFactory.closeConnection(); @@ -235,7 +260,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { PreparedStatement stmt = null; ResultSet rs = null; - Connection conn = null; + Connection conn; List features = new ArrayList(); try { @@ -259,10 +284,10 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO { return features; } catch (SQLException e) { throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all " + - "android features from the android database.", e); + "android features from the android database.", e); } finally { MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); AndroidDAOFactory.closeConnection(); } } -} +} \ 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/impl/windows/WindowsFeatureManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java index 99067b7eb..3bee4d2d0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java @@ -41,7 +41,7 @@ public class WindowsFeatureManager implements FeatureManager { public WindowsFeatureManager() { mobileDeviceManagementDAOFactory = new WindowsDAOFactory(); - this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDao(); + this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDAO(); } @Override @@ -59,6 +59,11 @@ public class WindowsFeatureManager implements FeatureManager { } } + @Override + public boolean addFeatures(List list) throws DeviceManagementException { + return false; + } + @Override public Feature getFeature(String name) throws DeviceManagementException { try { @@ -88,7 +93,7 @@ public class WindowsFeatureManager implements FeatureManager { @Override public boolean removeFeature(String code) throws DeviceManagementException { - boolean status = false; + boolean status; try { WindowsDAOFactory.beginTransaction(); featureDAO.deleteFeatureByCode(code); @@ -101,4 +106,9 @@ public class WindowsFeatureManager implements FeatureManager { return status; } + @Override + public boolean addSupportedFeaturesToDB() throws DeviceManagementException { + return false; + } + } \ 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/impl/windows/dao/WindowsDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java index 3c1ba0424..fa39d2ae0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java @@ -60,7 +60,7 @@ public class WindowsDAOFactory extends MobileDeviceManagementDAOFactory } @Override - public MobileFeatureDAO getMobileFeatureDao() { + public MobileFeatureDAO getMobileFeatureDAO() { return null; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index 768c55d4c..dcb4688b3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -298,4 +298,19 @@ public class MobileDeviceManagementUtil { e.getMessage(), e); } } + + public static List getMissingFeatures(List supportedFeatures, List existingFeatures) { + HashMap featureHashMap = new HashMap(); + for (Feature feature: existingFeatures) { + featureHashMap.put(feature.getCode(),feature); + } + List missingFeatures = new ArrayList(); + for (Feature supportedFeature : supportedFeatures) { + if (featureHashMap.get(supportedFeature.getCode()) != null) { + continue; + } + missingFeatures.add(supportedFeature); + } + return missingFeatures; + } } diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml index c4c5c8f0e..06076bbcb 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml @@ -19,53 +19,17 @@ - - - - jdbc/MobileAndroidDM_DS - - - - - jdbc/MobileWindowsDM_DS - - - + + + + jdbc/MobileAndroidDM_DS + + + + + jdbc/MobileWindowsDM_DS + + + - - - - appmanager - admin - /devices - 1.0.0 - http://localhost:9763/test/app - http,https - - - enrol - admin - /enroll - 1.0.0 - http://localhost:9763/mdm-android-agent/enrollment - http,https - - - license - admin - /license - 1.0.0 - http://localhost:9763/mdm-android-agent/devices/license - http,https - - - operation - admin - /operation - 1.0.0 - http://localhost:9763/mdm-android-agent/operations - http,https - - -