From 69299b69e8ddfba9945c8367feb058f8a748a5a6 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Tue, 2 Feb 2016 18:00:01 +0530 Subject: [PATCH 01/19] fixed code issues --- .../impl/windows/WindowsFeatureManager.java | 2 +- .../impl/windows/dao/WindowsDAOFactory.java | 3 +- .../dao/impl/WindowsDeviceDAOImpl.java | 23 ++----------- .../impl/windows/util/WindowsUtils.java | 34 ++++++++++++++++++- 4 files changed, 39 insertions(+), 23 deletions(-) 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 00e1d5e009..8bd2bac391 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 @@ -116,13 +116,13 @@ public class WindowsFeatureManager implements FeatureManager { featureDAO.deleteFeatureByCode(code); WindowsDAOFactory.commitTransaction(); status = true; + return status; } catch (MobileDeviceManagementDAOException e) { WindowsDAOFactory.rollbackTransaction(); throw new DeviceManagementException("Error occurred while removing the feature", e); } finally { WindowsDAOFactory.closeConnection(); } - return status; } @Override 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 40f8cc46e9..7fd0461c43 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 @@ -39,7 +39,8 @@ public class WindowsDAOFactory extends AbstractMobileDeviceManagementDAOFactory private static ThreadLocal currentConnection = new ThreadLocal<>(); public WindowsDAOFactory() { - this.dataSource = getDataSourceMap().get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + this.dataSource = getDataSourceMap().get( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); } @Override 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/impl/WindowsDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java index 478942b03f..c65e01e1f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java @@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsPluginConstants; +import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsUtils; import java.sql.Connection; import java.sql.PreparedStatement; @@ -60,17 +61,7 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO { rs = stmt.executeQuery(); while (rs.next()) { - mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.DEVICE_ID)); - mobileDevice.setImei(rs.getString(WindowsPluginConstants.IMEI)); - mobileDevice.setImsi(rs.getString(WindowsPluginConstants.IMSI)); - mobileDevice.setModel(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); - mobileDevice.setVendor(rs.getString(WindowsPluginConstants.VENDOR)); - mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.LATITUDE)); - mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.LONGITUDE)); - mobileDevice.setSerial(rs.getString(WindowsPluginConstants.SERIAL)); - mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); - + mobileDevice = WindowsUtils.loadMobileDevices(rs); Map propertyMap = new HashMap<>(); propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI)); propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO)); @@ -225,15 +216,7 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO { rs = stmt.executeQuery(); while (rs.next()) { - mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.DEVICE_ID)); - mobileDevice.setVendor(rs.getString(WindowsPluginConstants.IMEI)); - mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.IMSI)); - mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.OS_VERSION)); - mobileDevice.setImei(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); - mobileDevice.setImsi(rs.getString(WindowsPluginConstants.VENDOR)); - mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); - + mobileDevice = WindowsUtils.loadMatchingMobileDevices(rs); Map propertyMap = new HashMap<>(); propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI)); propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java index fabcbc70e6..346be69de1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java @@ -18,12 +18,17 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows.util; +import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; + +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.Map; /** - * Contains utility methods used by Windows plugin. + * Contains utility methods which are used by Windows plugin. */ public class WindowsUtils { + public static String getDeviceProperty(Map deviceProperties, String property) { String deviceProperty = deviceProperties.get(property); @@ -32,4 +37,31 @@ public class WindowsUtils { } return deviceProperty; } + + public static MobileDevice loadMobileDevices(ResultSet rs) throws SQLException { + + MobileDevice mobileDevice = new MobileDevice(); + mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.DEVICE_ID)); + mobileDevice.setImei(rs.getString(WindowsPluginConstants.IMEI)); + mobileDevice.setImsi(rs.getString(WindowsPluginConstants.IMSI)); + mobileDevice.setModel(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); + mobileDevice.setVendor(rs.getString(WindowsPluginConstants.VENDOR)); + mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.LATITUDE)); + mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.LONGITUDE)); + mobileDevice.setSerial(rs.getString(WindowsPluginConstants.SERIAL)); + mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); + return mobileDevice; + } + + public static MobileDevice loadMatchingMobileDevices(ResultSet rs) throws SQLException { + MobileDevice mobileDevice = new MobileDevice(); + mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.DEVICE_ID)); + mobileDevice.setVendor(rs.getString(WindowsPluginConstants.IMEI)); + mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.IMSI)); + mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.OS_VERSION)); + mobileDevice.setImei(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); + mobileDevice.setImsi(rs.getString(WindowsPluginConstants.VENDOR)); + mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); + return mobileDevice; + } } From 4205ad18dd0d678fe194db22e6ffbed04985167b Mon Sep 17 00:00:00 2001 From: hasuniea Date: Tue, 2 Feb 2016 18:10:54 +0530 Subject: [PATCH 02/19] fixed issue in windowsUtil --- .../impl/windows/dao/impl/WindowsDeviceDAOImpl.java | 2 +- .../mgt/mobile/impl/windows/util/WindowsUtils.java | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) 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/impl/WindowsDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java index c65e01e1f3..d8039f67f7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java @@ -216,7 +216,7 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO { rs = stmt.executeQuery(); while (rs.next()) { - mobileDevice = WindowsUtils.loadMatchingMobileDevices(rs); + mobileDevice = WindowsUtils.loadMobileDevices(rs); Map propertyMap = new HashMap<>(); propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI)); propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java index 346be69de1..2adb82daf5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java @@ -52,16 +52,4 @@ public class WindowsUtils { mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); return mobileDevice; } - - public static MobileDevice loadMatchingMobileDevices(ResultSet rs) throws SQLException { - MobileDevice mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.DEVICE_ID)); - mobileDevice.setVendor(rs.getString(WindowsPluginConstants.IMEI)); - mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.IMSI)); - mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.OS_VERSION)); - mobileDevice.setImei(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); - mobileDevice.setImsi(rs.getString(WindowsPluginConstants.VENDOR)); - mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); - return mobileDevice; - } } From f32bdf40219eb6dcbe0e9ac4c87496f0b6edb264 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Tue, 2 Feb 2016 18:24:27 +0530 Subject: [PATCH 03/19] fixed code issues --- .../mgt/mobile/impl/windows/WindowsDeviceManager.java | 5 ++--- .../mgt/mobile/impl/windows/util/WindowsUtils.java | 11 ----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index a5378f0fd4..ef58d96c45 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -298,9 +298,8 @@ public class WindowsDeviceManager implements DeviceManager { } } catch (MobileDeviceManagementDAOException e) { WindowsDAOFactory.rollbackTransaction(); - String msg = - "Error while enrolling the windows device : " + device.getDeviceIdentifier(); - throw new DeviceManagementException(msg, e); + throw new DeviceManagementException("Error while enrolling the windows device : " + + device.getDeviceIdentifier(), e); } return status; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java index 2adb82daf5..2df597f91d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java @@ -22,24 +22,13 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Map; /** * Contains utility methods which are used by Windows plugin. */ public class WindowsUtils { - public static String getDeviceProperty(Map deviceProperties, String property) { - - String deviceProperty = deviceProperties.get(property); - if (deviceProperty == null) { - return null; - } - return deviceProperty; - } - public static MobileDevice loadMobileDevices(ResultSet rs) throws SQLException { - MobileDevice mobileDevice = new MobileDevice(); mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.DEVICE_ID)); mobileDevice.setImei(rs.getString(WindowsPluginConstants.IMEI)); From 7aeecf73452ecb9d8f44f0355ece96a28ba59082 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Wed, 10 Feb 2016 18:10:00 +0530 Subject: [PATCH 04/19] refactored code issues --- .../impl/windows/WindowsDeviceManager.java | 44 +++++++++++-------- .../impl/windows/WindowsFeatureManager.java | 22 +++++----- .../WindowsFeatureManagementDAOException.java | 2 +- .../dao/impl/WindowsFeatureDAOImpl.java | 4 -- .../impl/windows/util/WindowsUtils.java | 5 +++ 5 files changed, 43 insertions(+), 34 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index ef58d96c45..2cc1575d1d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -69,7 +69,7 @@ public class WindowsDeviceManager implements DeviceManager { } catch (LicenseManagementException e) { log.error("Error occurred while adding default license for Windows devices", e); } catch (DeviceManagementException e) { - log.error("Error occurred while adding supported device features for Windows platform", e); + throw new IllegalStateException("Error occurred while adding windows features to the DB."); } } @@ -79,8 +79,7 @@ public class WindowsDeviceManager implements DeviceManager { } @Override - public boolean saveConfiguration(TenantConfiguration tenantConfiguration) - throws DeviceManagementException { + public boolean saveConfiguration(TenantConfiguration tenantConfiguration) throws DeviceManagementException { boolean status; Resource resource; try { @@ -88,8 +87,7 @@ public class WindowsDeviceManager implements DeviceManager { log.debug("Persisting windows configurations in Registry"); } String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath( - DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); StringWriter writer = new StringWriter(); JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); Marshaller marshaller = context.createMarshaller(); @@ -143,14 +141,16 @@ public class WindowsDeviceManager implements DeviceManager { @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status; + boolean status = false; MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); try { if (log.isDebugEnabled()) { log.debug("Modifying the Windows device enrollment data"); } WindowsDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice); + if (daoFactory.getMobileDeviceDAO() != null) { + status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice); + } WindowsDAOFactory.commitTransaction(); } catch (MobileDeviceManagementDAOException e) { WindowsDAOFactory.rollbackTransaction(); @@ -170,22 +170,21 @@ public class WindowsDeviceManager implements DeviceManager { @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean isEnrolled = false; + MobileDevice mobileDevice; try { if (log.isDebugEnabled()) { log.debug("Checking the enrollment of Windows device : " + deviceId.getId()); } - MobileDevice mobileDevice = - daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId()); - if (mobileDevice != null) { - isEnrolled = true; + if (daoFactory.getMobileDeviceDAO() != null) { + mobileDevice = daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId()); + } else { + throw new DeviceManagementException("Error occurred while getting DAO object."); } } catch (MobileDeviceManagementDAOException e) { - String msg = "Error while checking the enrollment status of Windows device : " + - deviceId.getId(); + String msg = "Error occurred while checking the enrollment status of Windows device : " + deviceId.getId(); throw new DeviceManagementException(msg, e); } - return isEnrolled; + return (mobileDevice != null); } @Override @@ -201,12 +200,15 @@ public class WindowsDeviceManager implements DeviceManager { public List getAllDevices() throws DeviceManagementException { List devices = null; + List mobileDevices = null; try { if (log.isDebugEnabled()) { log.debug("Fetching the details of all Windows devices"); } WindowsDAOFactory.openConnection(); - List mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices(); + if (daoFactory.getMobileDeviceDAO() != null) { + mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices(); + } if (mobileDevices != null) { devices = new ArrayList<>(mobileDevices.size()); for (MobileDevice mobileDevice : mobileDevices) { @@ -224,13 +226,15 @@ public class WindowsDeviceManager implements DeviceManager { @Override public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { Device device = null; + MobileDevice mobileDevice = null; try { if (log.isDebugEnabled()) { log.debug("Getting the details of Windows device : '" + deviceId.getId() + "'"); } WindowsDAOFactory.openConnection(); - MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO(). - getMobileDevice(deviceId.getId()); + if (daoFactory.getMobileDeviceDAO() != null) { + mobileDevice = daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId()); + } device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); } catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException( @@ -293,7 +297,9 @@ public class WindowsDeviceManager implements DeviceManager { this.modifyEnrollment(device); } else { WindowsDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice); + if (daoFactory.getMobileDeviceDAO() != null) { + status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice); + } WindowsDAOFactory.commitTransaction(); } } catch (MobileDeviceManagementDAOException e) { 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 8bd2bac391..cdca8334c8 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 @@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; +import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsUtils; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import java.util.ArrayList; @@ -145,48 +146,49 @@ public class WindowsFeatureManager implements FeatureManager { * @return Supported features. */ public static List getSupportedFeatures() { - List supportedFeatures = new ArrayList(); - Feature feature = new Feature(); + List supportedFeatures = new ArrayList<>(); + Feature feature; + feature = WindowsUtils.getMobileFeature(); feature.setCode("DEVICE_LOCK"); feature.setName("Device Lock"); feature.setDescription("Lock the device"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("CAMERA"); feature.setName("camera"); feature.setDescription("Enable or disable camera"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("DEVICE_INFO"); feature.setName("Device info"); feature.setDescription("Request device information"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("WIPE_DATA"); feature.setName("Wipe Data"); feature.setDescription("Factory reset the device"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("ENCRYPT_STORAGE"); feature.setName("Encrypt storage"); feature.setDescription("Encrypt storage"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("DEVICE_RING"); feature.setName("Ring"); feature.setDescription("Ring the device"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("PASSCODE_POLICY"); feature.setName("Password Policy"); feature.setDescription("Set passcode policy"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("DISENROLL"); feature.setName("DisEnroll"); feature.setDescription("DisEnroll the device"); supportedFeatures.add(feature); - feature = new Feature(); + feature = WindowsUtils.getMobileFeature(); feature.setCode("LOCK_RESET"); feature.setName("LockReset"); feature.setDescription("Lock Reset device"); 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/WindowsFeatureManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsFeatureManagementDAOException.java index 5444fd2239..7596b39562 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsFeatureManagementDAOException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsFeatureManagementDAOException.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows.dao; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; /** - * Implement Exception class for Windows Device Features. + * This class responsible for wrapping exceptions related on Windows device features. */ public class WindowsFeatureManagementDAOException extends MobileDeviceManagementDAOException { 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/impl/WindowsFeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsFeatureDAOImpl.java index c52cf72a8e..007eedb789 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsFeatureDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsFeatureDAOImpl.java @@ -43,10 +43,6 @@ public class WindowsFeatureDAOImpl implements MobileFeatureDAO { private static final Log log = LogFactory.getLog(WindowsFeatureDAOImpl.class); - public WindowsFeatureDAOImpl() { - - } - @Override public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { PreparedStatement stmt = null; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java index 2df597f91d..040395c52b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows.util; +import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import java.sql.ResultSet; @@ -41,4 +42,8 @@ public class WindowsUtils { mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); return mobileDevice; } + public static Feature getMobileFeature() { + Feature feature = new Feature(); + return feature; + } } From d5ec50c4e6be32f2c305a40ac27f8ddbd5f666b9 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Fri, 12 Feb 2016 13:53:32 +0530 Subject: [PATCH 05/19] fixed code issue --- .../carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java index 040395c52b..e4ba56346b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsUtils.java @@ -42,6 +42,7 @@ public class WindowsUtils { mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); return mobileDevice; } + public static Feature getMobileFeature() { Feature feature = new Feature(); return feature; From 9c1b34b891a57be65d251998c84569d22d96e3c7 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Sat, 13 Feb 2016 18:24:03 +0530 Subject: [PATCH 06/19] fixed code line issue --- .../device/mgt/mobile/impl/windows/WindowsDeviceManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 2cc1575d1d..192bfbc3c1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -115,9 +115,8 @@ public class WindowsDeviceManager implements DeviceManager { public TenantConfiguration getConfiguration() throws DeviceManagementException { Resource resource; try { - String windowsTenantRegistryPath = - MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + String windowsTenantRegistryPath = MobileDeviceManagementUtil. + getPlatformConfigPath(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); resource = MobileDeviceManagementUtil.getRegistryResource(windowsTenantRegistryPath); if (resource != null) { JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); From e8a47a52397a79573b3fb2dce95dbc9ce8fe0db8 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Mon, 15 Feb 2016 10:46:29 +0530 Subject: [PATCH 07/19] refactored code issues --- .../mgt/mobile/impl/windows/WindowsDeviceManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 192bfbc3c1..7e75cb63bf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -121,8 +121,8 @@ public class WindowsDeviceManager implements DeviceManager { if (resource != null) { JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); Unmarshaller unmarshaller = context.createUnmarshaller(); - return (TenantConfiguration) unmarshaller.unmarshal( - new StringReader(new String((byte[]) resource.getContent(), Charset. + return (TenantConfiguration) unmarshaller.unmarshal(new StringReader( + new String((byte[]) resource.getContent(), Charset. forName(MobilePluginConstants.CHARSET_UTF8)))); } return null; @@ -134,7 +134,8 @@ public class WindowsDeviceManager implements DeviceManager { "Error occurred while parsing the Windows configuration : " + e.getMessage(), e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Windows configuration : " + e.getMessage(), e); + "Error occurred while retrieving the Registry resource of Windows configuration : " + + e.getMessage(), e); } } From 77dc0f257c3dd2b7ac7a4b4947c387b5336e0933 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Wed, 17 Feb 2016 12:05:58 +0530 Subject: [PATCH 08/19] refactored code issues --- .../mobile/impl/android/AndroidDeviceManager.java | 15 ++++++++------- .../mobile/impl/windows/WindowsDeviceManager.java | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-) 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 472589e6cb..2764df3c8e 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 @@ -69,7 +69,7 @@ public class AndroidDeviceManager implements DeviceManager { } 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); + throw new IllegalStateException("Error occurred while adding Android features to the DB."); } } @@ -101,13 +101,14 @@ public class AndroidDeviceManager implements DeviceManager { status = true; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); + "Error occurred while retrieving the Registry instance : ", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Android Configuration : " + e.getMessage(), e); + "Error occurred while persisting the Registry resource of Android Configuration : " + + e.getMessage(), e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : " + e.getMessage(), e); + "Error occurred while parsing the Android configuration : ", e); } return status; } @@ -130,13 +131,13 @@ public class AndroidDeviceManager implements DeviceManager { return null; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); + "Error occurred while retrieving the Registry instance : ", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : " + e.getMessage(), e); + "Error occurred while parsing the Android configuration : ", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Android Configuration : " + e.getMessage(), e); + "Error occurred while retrieving the Registry resource of Android Configuration : ", e); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 7e75cb63bf..531be5c23b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -100,13 +100,13 @@ public class WindowsDeviceManager implements DeviceManager { status = true; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); + "Error occurred while retrieving the Registry instance : ", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Windows configuration : " + e.getMessage(), e); + "Error occurred while persisting the Registry resource of Windows configuration : ", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration : " + e.getMessage(), e); + "Error occurred while parsing the Windows configuration : ", e); } return status; } @@ -128,10 +128,10 @@ public class WindowsDeviceManager implements DeviceManager { return null; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); + "Error occurred while retrieving the Registry instance : ", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration : " + e.getMessage(), e); + "Error occurred while parsing the Windows configuration : ", e); } catch (RegistryException e) { throw new DeviceManagementException( "Error occurred while retrieving the Registry resource of Windows configuration : " + From 9ff91085c81574e2c1f15faa751548ba91bc1706 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Wed, 17 Feb 2016 17:54:52 +0530 Subject: [PATCH 09/19] refactored code issue --- .../device/mgt/mobile/impl/android/AndroidDeviceManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 2764df3c8e..9ea888a98c 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 @@ -104,8 +104,7 @@ public class AndroidDeviceManager implements DeviceManager { "Error occurred while retrieving the Registry instance : ", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Android Configuration : " - + e.getMessage(), e); + "Error occurred while persisting the Registry resource of Android Configuration : ", e); } catch (JAXBException e) { throw new DeviceManagementException( "Error occurred while parsing the Android configuration : ", e); From 5690dec4b74dc3e63bedd9e52be7d2adb7b79fc1 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Wed, 17 Feb 2016 18:00:28 +0530 Subject: [PATCH 10/19] refactored code issues --- .../device/mgt/mobile/impl/windows/WindowsDeviceManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 531be5c23b..6afb793b0b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -134,8 +134,7 @@ public class WindowsDeviceManager implements DeviceManager { "Error occurred while parsing the Windows configuration : ", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Windows configuration : " + - e.getMessage(), e); + "Error occurred while retrieving the Registry resource of Windows configuration : ", e); } } From 79e143d236954dd2966e9b402be9257ba6f1b3a1 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Fri, 19 Feb 2016 06:44:08 +0530 Subject: [PATCH 11/19] refactored code comments --- .../impl/android/AndroidDeviceManager.java | 40 +++++++------------ .../impl/windows/WindowsDeviceManager.java | 18 ++++----- 2 files changed, 24 insertions(+), 34 deletions(-) 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 9ea888a98c..5b24d2c8e3 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 @@ -101,13 +101,13 @@ public class AndroidDeviceManager implements DeviceManager { status = true; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Android Configuration : ", e); + "Error occurred while persisting the Registry resource of Android Configuration", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : ", e); + "Error occurred while parsing the Android configuration", e); } return status; } @@ -130,13 +130,13 @@ public class AndroidDeviceManager implements DeviceManager { return null; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : ", e); + "Error occurred while parsing the Android configuration", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Android Configuration : ", e); + "Error occurred while retrieving the Registry resource of Android Configuration", e); } } @@ -161,12 +161,10 @@ public class AndroidDeviceManager implements DeviceManager { try { AndroidDAOFactory.rollbackTransaction(); } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the device enrol transaction :" + - device.toString(); + String msg = "Error occurred while roll back the device enrol transaction :" + device.toString(); log.warn(msg, mobileDAOEx); } - String msg = - "Error while enrolling the Android device : " + device.getDeviceIdentifier(); + String msg = "Error occurred while enrolling the Android device : " + device.getDeviceIdentifier(); throw new DeviceManagementException(msg, e); } return status; @@ -187,11 +185,10 @@ public class AndroidDeviceManager implements DeviceManager { try { AndroidDAOFactory.rollbackTransaction(); } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the update device transaction :" + - device.toString(); + String msg = "Error occurred while roll back the update device transaction :" + device.toString(); log.warn(msg, mobileDAOEx); } - String msg = "Error while updating the enrollment of the Android device : " + + String msg = "Error occurred while updating the enrollment of the Android device : " + device.getDeviceIdentifier(); throw new DeviceManagementException(msg, e); } @@ -217,8 +214,7 @@ public class AndroidDeviceManager implements DeviceManager { isEnrolled = true; } } catch (MobileDeviceManagementDAOException e) { - String msg = "Error while checking the enrollment status of Android device : " + - deviceId.getId(); + String msg = "Error occurred while checking the enrollment status of Android device : " + deviceId.getId(); throw new DeviceManagementException(msg, e); } return isEnrolled; @@ -247,8 +243,7 @@ public class AndroidDeviceManager implements DeviceManager { device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); } catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException( - "Error occurred while fetching the Android device: '" + - deviceId.getId() + "'", e); + "Error occurred while fetching the Android device: '" + deviceId.getId() + "'", e); } return device; } @@ -292,12 +287,9 @@ public class AndroidDeviceManager implements DeviceManager { boolean status; Device existingDevice = this.getDevice(deviceIdentifier); // This object holds the current persisted device object - MobileDevice existingMobileDevice = - MobileDeviceManagementUtil.convertToMobileDevice(existingDevice); - + MobileDevice existingMobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(existingDevice); // This object holds the newly received device object from response MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - // Updating current object features using newer ones existingMobileDevice.setLatitude(mobileDevice.getLatitude()); existingMobileDevice.setLongitude(mobileDevice.getLongitude()); @@ -319,8 +311,7 @@ public class AndroidDeviceManager implements DeviceManager { device.toString() + "'", e1); } throw new DeviceManagementException( - "Error occurred while updating the Android device: '" + - device.getDeviceIdentifier() + "'", e); + "Error occurred while updating the Android device: '" + device.getDeviceIdentifier() + "'", e); } return status; } @@ -341,8 +332,7 @@ public class AndroidDeviceManager implements DeviceManager { } } } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while fetching all Android devices", - e); + throw new DeviceManagementException("Error occurred while fetching all Android devices", e); } return devices; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 6afb793b0b..b9f03cf491 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -100,13 +100,13 @@ public class WindowsDeviceManager implements DeviceManager { status = true; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Windows configuration : ", e); + "Error occurred while persisting the Registry resource of Windows configuration", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration : ", e); + "Error occurred while parsing the Windows configuration", e); } return status; } @@ -128,13 +128,13 @@ public class WindowsDeviceManager implements DeviceManager { return null; } catch (MobileDeviceMgtPluginException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : ", e); + "Error occurred while retrieving the Registry instance", e); } catch (JAXBException e) { throw new DeviceManagementException( - "Error occurred while parsing the Windows configuration : ", e); + "Error occurred while parsing the Windows configuration", e); } catch (RegistryException e) { throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Windows configuration : ", e); + "Error occurred while retrieving the Registry resource of Windows configuration", e); } } @@ -153,8 +153,8 @@ public class WindowsDeviceManager implements DeviceManager { WindowsDAOFactory.commitTransaction(); } catch (MobileDeviceManagementDAOException e) { WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error while updating the enrollment of the Windows device : " + - device.getDeviceIdentifier(), e); + throw new DeviceManagementException("Error occurred while updating the enrollment of the " + + "Windows device : " + device.getDeviceIdentifier(), e); } finally { WindowsDAOFactory.closeConnection(); } @@ -303,7 +303,7 @@ public class WindowsDeviceManager implements DeviceManager { } } catch (MobileDeviceManagementDAOException e) { WindowsDAOFactory.rollbackTransaction(); - throw new DeviceManagementException("Error while enrolling the windows device : " + throw new DeviceManagementException("Error occurred while enrolling the windows device : " + device.getDeviceIdentifier(), e); } return status; From 92973efc0c678b882590e40f02950d8474d6591d Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 11 May 2016 15:29:15 +0530 Subject: [PATCH 12/19] Fix invalid values in cep query --- .../src/main/resources/advanced_agent/cep_query.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt index 17546ece2c..6e66340818 100644 --- a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt @@ -1,11 +1,11 @@ define stream fireAlarmEventStream (deviceID string, temp int); -from fireAlarmEventStream#window.time(7886776 sec) +from fireAlarmEventStream#window.time(10 sec) select deviceID, max(temp) as maxValue group by deviceID insert into analyzeStream for expired-events; -from analyzeStream[maxValue < 88] +from analyzeStream[maxValue < 60] select maxValue insert into bulbOnStream; -from fireAlarmEventStream[temp > 1093] +from fireAlarmEventStream[temp > 60] select deviceID, temp insert into bulbOffStream; \ No newline at end of file From ffcbea842156f165db874a81911e27d7d0f05745 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 11 May 2016 16:00:05 +0530 Subject: [PATCH 13/19] Fixed https://wso2.org/jira/browse/IOTS-104 --- .../private/config.json | 6 + .../private/config.json | 7 + .../units/iot.unit.ui.header.logo/logo.json | 2 +- .../private/config.json | 7 + .../private/config.json | 7 + .../private/config.json | 0 .../private/config.json | 0 .../main/resources/configs/android_sense.json | 120 ------------------ .../src/main/resources/p2.inf | 3 - .../src/main/resources/configs/arduino.json | 20 --- .../src/main/resources/p2.inf | 3 - .../main/resources/configs/raspberrypi.json | 20 --- .../src/main/resources/p2.inf | 3 - .../resources/configs/virtual_firealarm.json | 20 --- .../src/main/resources/p2.inf | 3 - .../src/main/resources/p2.inf | 3 - .../src/main/resources/p2.inf | 3 - 17 files changed, 28 insertions(+), 199 deletions(-) create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json create mode 100644 components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json create mode 100644 components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json create mode 100644 components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json rename features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/configs/android.json => components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json (100%) rename features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/configs/windows.json => components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/private/config.json (100%) delete mode 100644 features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/configs/android_sense.json delete mode 100644 features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json delete mode 100644 features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/configs/raspberrypi.json delete mode 100644 features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/configs/virtual_firealarm.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json new file mode 100644 index 0000000000..7975a2cbab --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json @@ -0,0 +1,6 @@ +{ + "deviceType": { + "label": "Android Sense", + "category": "iot" + } +} \ No newline at end of file diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json new file mode 100644 index 0000000000..73294d4ecc --- /dev/null +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json @@ -0,0 +1,7 @@ +{ + "deviceType": { + "label": "Arduino", + "category": "iot", + "downloadAgentUri": "arduino/enrollment/devices/download" + } +} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json index 4e30bc0747..56b5c044de 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json @@ -1,5 +1,5 @@ { "version": "1.0.0", "index": 29, - "extends": "mdm.unit.ui.header.logo" + "extends": "uuf.unit.header.logo" } \ No newline at end of file diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json new file mode 100644 index 0000000000..99f710bd89 --- /dev/null +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json @@ -0,0 +1,7 @@ +{ + "deviceType": { + "label": "Raspberry Pi", + "category": "iot", + "downloadAgentUri": "raspberrypi/enrollment/devices/download" + } +} \ No newline at end of file diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json new file mode 100644 index 0000000000..b8435cd39b --- /dev/null +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json @@ -0,0 +1,7 @@ +{ + "deviceType": { + "label": "Virtual Firealarm", + "category": "virtual", + "downloadAgentUri": "virtual_firealarm/enrollment/devices/download" + } +} \ No newline at end of file diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/configs/android.json b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json similarity index 100% rename from features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/configs/android.json rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/configs/windows.json b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/private/config.json similarity index 100% rename from features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/configs/windows.json rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/private/config.json diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/configs/android_sense.json b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/configs/android_sense.json deleted file mode 100644 index f3ab98a9bd..0000000000 --- a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/configs/android_sense.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "deviceType": { - "label": "Android Sense", - "category": "iot" - }, - "analyticStreams": [ - { - "name": "Accelerometer", - "table": "DEVICE_ACCELEROMETER_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"ACCELEROMETER", "label":"Accelerometer", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "Battery", - "table": "DEVICE_BATTERY_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"BATTERY", "label":"Battery Level", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "GPS", - "table": "DEVICE_GPS_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.google-map", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"time"}}, - {"column": {"name":"LATITUDE", "label":"Latitude", "ui-mapping":"lat"}}, - {"column": {"name":"LONGITUDE", "label":"Longitude", "ui-mapping":"lat"}} - ] - } - }, - { - "name": "Gravity", - "table": "DEVICE_GRAVITY_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"GRAVITY", "label":"Gravity", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "Gyroscope", - "table": "DEVICE_GYROSCOPE_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"GYROSCOPE", "label":"Gyroscope", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "Light", - "table": "DEVICE_LIGHT_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"LIGHT", "label":"Light", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "Magnetic", - "table": "DEVICE_MAGNETIC_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"MAGNETIC", "label":"Magnetic", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "Pressure", - "table": "DEVICE_PRESSURE_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"PRESSURE", "label":"Pressure", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "Proximity", - "table": "DEVICE_PROXIMITY_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.bar-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"PROXIMITY", "label":"Proximity", "ui-mapping":"y-axis"}} - ] - } - }, - { - "name": "Rotation", - "table": "DEVICE_ROTATION_SUMMARY", - "ui_unit": "cdmf.unit.analytics.line-chart", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"ROTATION", "label":"Rotation", "ui-mapping":"y-axis"}} - ] - } - } - ] -} \ No newline at end of file diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf index e17c807e33..4ee9278fef 100644 --- a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf +++ b/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf @@ -1,6 +1,4 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\ @@ -13,7 +11,6 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../data org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ instructions.unconfigure = \ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/android_sense.json);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android_sense);\ diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json deleted file mode 100644 index 98a8faa018..0000000000 --- a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/configs/arduino.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "deviceType": { - "label": "Arduino", - "category": "iot", - "downloadAgentUri": "arduino/enrollment/devices/download" - }, - "analyticStreams": [ - { - "name": "Temperature", - "table": "DEVICE_TEMPERATURE_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"TEMPERATURE", "label":"temperature", "ui-mapping":"y-axis"}} - ] - } - } - ] -} \ No newline at end of file diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf index 557c3872db..9d52b358a0 100644 --- a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf +++ b/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf @@ -1,6 +1,4 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ @@ -14,7 +12,6 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../data org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ instructions.unconfigure = \ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/arduino.json);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/arduino.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/arduino);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/arduino);\ diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/configs/raspberrypi.json b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/configs/raspberrypi.json deleted file mode 100644 index 93e2efe548..0000000000 --- a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/configs/raspberrypi.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "deviceType": { - "label": "RaspberryPi", - "category": "iot", - "downloadAgentUri": "raspberrypi/enrollment/devices/download" - }, - "analyticStreams": [ - { - "name": "Temperature", - "table": "DEVICE_TEMPERATURE_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"TEMPERATURE", "label":"Temperature", "ui-mapping":"y-axis"}} - ] - } - } - ] -} \ No newline at end of file diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf index f1eefb1a96..088a6edca3 100644 --- a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf +++ b/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf @@ -1,6 +1,4 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ @@ -14,7 +12,6 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../data org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ instructions.unconfigure = \ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/raspberrypi.json);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/raspberrypi.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/raspberrypi);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/raspberrypi);\ diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/configs/virtual_firealarm.json b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/configs/virtual_firealarm.json deleted file mode 100644 index a878ee05a5..0000000000 --- a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/configs/virtual_firealarm.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "deviceType": { - "label": "Virtual Firealarm", - "category": "virtual", - "downloadAgentUri": "virtual_firealarm/enrollment/devices/download" - }, - "analyticStreams": [ - { - "name": "Temperature", - "table": "DEVICE_TEMPERATURE_SUMMARY", - "ui_unit": { - "name": "cdmf.unit.analytics.line-chart", - "data":[ - {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, - {"column": {"name":"TEMPERATURE", "label":"Temperature", "ui-mapping":"y-axis"}} - ] - } - } - ] -} \ No newline at end of file diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf index 1cf4d078d2..314176c77d 100644 --- a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf +++ b/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf @@ -1,6 +1,4 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ @@ -18,7 +16,6 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../reso org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/certs/,target:${installFolder}/../../resources/security/,overwrite:true);\ instructions.unconfigure = \ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/virtual_firealarm.json);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/virtual_firealarm.war);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/virtual_firealarm);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/virtual_firealarm_scep.war);\ diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf index 8e4ff513b9..9c79e2fbd7 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -1,6 +1,4 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ @@ -18,5 +16,4 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/android.json);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\ \ No newline at end of file diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf index 16757950a6..92ebf24627 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf @@ -1,6 +1,4 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ @@ -17,5 +15,4 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-wizard);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/windows);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/windows.json);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileWindows_DB.h2.db);\ \ No newline at end of file From 70d47f96c1d369dec1676daf0291adc8e6b14753 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 11 May 2016 19:59:01 +0530 Subject: [PATCH 14/19] Fix header title --- .../devicemgt/app/units/iot.unit.ui.header.logo/logo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json index 56b5c044de..98b47e9b87 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json @@ -1,5 +1,5 @@ { "version": "1.0.0", "index": 29, - "extends": "uuf.unit.header.logo" + "extends": "cdmf.unit.ui.header.logo" } \ No newline at end of file From 3cdb49090859fcc0600ae4536b76b685e1ab2ef4 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Thu, 12 May 2016 21:41:49 +0530 Subject: [PATCH 15/19] added swagger annotations --- .../pom.xml | 6 + .../android/ConfigurationMgtService.java | 161 ------- .../android/DeviceManagementService.java | 183 -------- .../services/android/EnrollmentService.java | 153 ------- .../android/bean/ApplicationInstallation.java | 10 + .../ApplicationInstallationBeanWrapper.java | 8 + .../ApplicationUninstallationBeanWrapper.java | 7 + .../ConfigurationMgtService.java | 81 ++++ .../impl/ConfigurationMgtServiceImpl.java | 162 +++++++ .../devicemgt/DeviceManagementService.java | 147 +++++++ .../impl/DeviceManagementServiceImpl.java | 184 ++++++++ .../enrollment/EnrollmentService.java | 99 +++++ .../impl/EnrollmentServiceImpl.java | 158 +++++++ .../operationmgt/OperationMgtService.java | 414 ++++++++++++++++++ .../impl/OperationMgtServiceImpl.java} | 49 +-- .../services/policymgt/PolicyMgtService.java | 73 +++ .../policymgt/impl/PolicyMgtServiceImpl.java} | 17 +- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 10 +- pom.xml | 9 + 19 files changed, 1393 insertions(+), 538 deletions(-) delete mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/ConfigurationMgtService.java delete mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/DeviceManagementService.java delete mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/EnrollmentService.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/impl/DeviceManagementServiceImpl.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/impl/EnrollmentServiceImpl.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java rename components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/{OperationMgtService.java => services/operationmgt/impl/OperationMgtServiceImpl.java} (96%) create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java rename components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/{PolicyMgtService.java => services/policymgt/impl/PolicyMgtServiceImpl.java} (92%) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 867cac00e1..f1a1d9f2d5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -172,6 +172,12 @@ provided + + io.swagger + swagger-annotations + provided + + com.google.code.gson gson diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/ConfigurationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/ConfigurationMgtService.java deleted file mode 100644 index 8413f64b52..0000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/ConfigurationMgtService.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.mdm.services.android; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.Message; - -import javax.jws.WebService; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -/** - * Android Platform Configuration REST-API implementation. - * All end points supports JSON, XMl with content negotiation. - */ -@WebService -@Produces({ "application/json", "application/xml" }) -@Consumes({ "application/json", "application/xml" }) -public class ConfigurationMgtService { - - private static Log log = LogFactory.getLog(ConfigurationMgtService.class); - - @POST - public Message configureSettings(TenantConfiguration configuration) - throws AndroidAgentException { - - Message responseMsg = new Message(); - String msg; - ConfigurationEntry licenseEntry = null; - try { - configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - List configs = configuration.getConfiguration(); - for(ConfigurationEntry entry : configs){ - if(AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())){ - License license = new License(); - license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US); - license.setVersion("1.0.0"); - license.setText(entry.getValue().toString()); - AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license); - licenseEntry = entry; - break; - } - } - - if(licenseEntry != null) { - configs.remove(licenseEntry); - } - configuration.setConfiguration(configs); - AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); - Response.status(Response.Status.CREATED); - responseMsg.setResponseMessage("Android platform configuration saved successfully."); - responseMsg.setResponseCode(Response.Status.CREATED.toString()); - } catch (DeviceManagementException e) { - msg = "Error occurred while configuring the android platform"; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMsg; - } - - @GET - public TenantConfiguration getConfiguration() throws AndroidAgentException { - String msg; - TenantConfiguration tenantConfiguration; - List configs; - try { - tenantConfiguration = AndroidAPIUtils.getDeviceManagementService(). - getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - if(tenantConfiguration != null) { - configs = tenantConfiguration.getConfiguration(); - } else { - tenantConfiguration = new TenantConfiguration(); - configs = new ArrayList(); - } - - ConfigurationEntry entry = new ConfigurationEntry(); - License license = AndroidAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants. - TenantConfigProperties.LANGUAGE_US); - - if(license != null && configs != null) { - entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); - entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY); - entry.setValue(license.getText()); - configs.add(entry); - tenantConfiguration.setConfiguration(configs); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while retrieving the Android tenant configuration"; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return tenantConfiguration; - } - - @PUT - public Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException { - String msg; - Message responseMsg = new Message(); - ConfigurationEntry licenseEntry = null; - try { - configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - List configs = configuration.getConfiguration(); - for(ConfigurationEntry entry : configs){ - if(AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())){ - License license = new License(); - license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US); - license.setVersion("1.0.0"); - license.setText(entry.getValue().toString()); - AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license); - licenseEntry = entry; - } - } - - if(licenseEntry != null) { - configs.remove(licenseEntry); - } - configuration.setConfiguration(configs); - AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); - Response.status(Response.Status.ACCEPTED); - responseMsg.setResponseMessage("Android platform configuration has updated successfully."); - responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); - } catch (DeviceManagementException e) { - msg = "Error occurred while modifying configuration settings of Android platform"; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMsg; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/DeviceManagementService.java deleted file mode 100644 index 3ff7694124..0000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/DeviceManagementService.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.mdm.services.android; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.Message; - -import javax.jws.WebService; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * Android Device Management REST-API implementation. - * All end points supports JSON, XMl with content negotiation. - */ -@WebService -@Produces({ "application/json", "application/xml" }) -@Consumes({ "application/json", "application/xml" }) -public class DeviceManagementService { - - private static Log log = LogFactory.getLog(DeviceManagementService.class); - - /** - * Get all devices.Returns list of Android devices registered in MDM. - * - * @return Device List - * @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException - */ - @GET - public List getAllDevices() - throws AndroidAgentException { - String msg; - List devices; - - try { - devices = AndroidAPIUtils.getDeviceManagementService(). - getAllDevices(DeviceManagementConstants.MobileDeviceTypes. - MOBILE_DEVICE_TYPE_ANDROID); - } catch (DeviceManagementException e) { - msg = "Error occurred while fetching the device list."; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return devices; - } - - /** - * Fetch Android device details of a given device Id. - * - * @param id Device Id - * @return Device - * @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException - */ - @GET - @Path("{id}") - public org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id) - throws AndroidAgentException { - - String msg; - org.wso2.carbon.device.mgt.common.Device device; - - try { - DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); - device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (device == null) { - Response.status(Response.Status.NOT_FOUND); - } - } catch (DeviceManagementException deviceMgtEx) { - msg = "Error occurred while fetching the device information."; - log.error(msg, deviceMgtEx); - throw new AndroidAgentException(msg, deviceMgtEx); - } - return device; - } - - /** - * Update Android device details of given device id. - * - * @param id Device Id - * @param device Device Details - * @return Message - * @throws AndroidAgentException - */ - @PUT - @Path("{id}") - public Message updateDevice(@PathParam("id") String id, Device device) - throws AndroidAgentException { - String msg; - Message responseMessage = new Message(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); - deviceIdentifier - .setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - boolean result; - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - result = AndroidAPIUtils.getDeviceManagementService() - .updateDeviceInfo(deviceIdentifier, device); - if (result) { - Response.status(Response.Status.ACCEPTED); - responseMessage.setResponseMessage("Device information has modified successfully."); - } else { - Response.status(Response.Status.NOT_MODIFIED); - responseMessage.setResponseMessage("Device not found for the update."); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while modifying the device information."; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMessage; - } - - @POST - @Path("appList/{id}") - public Message updateApplicationList(@PathParam("id") String id, List applications) - throws - AndroidAgentException { - - Message responseMessage = new Message(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); - deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - try { - AndroidAPIUtils.getApplicationManagerService(). - updateApplicationListInstalledInDevice(deviceIdentifier, applications); - Response.status(Response.Status.ACCEPTED); - responseMessage.setResponseMessage("Device information has modified successfully."); - - } catch (ApplicationManagementException e) { - String msg = "Error occurred while modifying the application list."; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMessage; - } - - @GET - @Path("license") - @Produces("text/html") - public String getLicense() throws AndroidAgentException { - License license; - - try { - license = - AndroidAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, - DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); - } catch (DeviceManagementException e) { - String msg = "Error occurred while retrieving the license configured for Android device enrolment"; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return (license == null) ? null : license.getText(); - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/EnrollmentService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/EnrollmentService.java deleted file mode 100644 index 49e0bf788d..0000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/EnrollmentService.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.mdm.services.android; - -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.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.Message; - -import javax.jws.WebService; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -/** - * Android Device Enrollment REST-API implementation. - * All end points supports JSON, XMl with content negotiation. - */ -@WebService -@Produces({ "application/json", "application/xml" }) -@Consumes({ "application/json", "application/xml" }) -public class EnrollmentService { - - private static Log log = LogFactory.getLog(EnrollmentService.class); - - @POST - public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) - throws AndroidAgentException { - - Message responseMsg = new Message(); - String msg; - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); - boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); - if (status) { - Response.status(Response.Status.CREATED); - responseMsg.setResponseMessage("Device enrollment succeeded."); - responseMsg.setResponseCode(Response.Status.CREATED.toString()); - } else { - Response.status(Response.Status.INTERNAL_SERVER_ERROR); - responseMsg.setResponseMessage("Device enrollment failed."); - responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while enrolling the device"; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMsg; - } - - @GET - @Path("{deviceId}") - public Message isEnrolled(@PathParam("deviceId") String id) throws AndroidAgentException { - String msg; - 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"); - responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); - Response.status(Response.Status.ACCEPTED); - } else { - responseMsg.setResponseMessage("Device not found"); - responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString()); - Response.status(Response.Status.NOT_FOUND); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while enrollment of the device."; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMsg; - } - - @PUT - @Path("{deviceId}") - public Message modifyEnrollment(@PathParam("deviceId") String id, - org.wso2.carbon.device.mgt.common.Device device) - throws AndroidAgentException { - String msg; - 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"); - responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); - Response.status(Response.Status.ACCEPTED); - } else { - responseMsg.setResponseMessage("Device not found for enrollment"); - responseMsg.setResponseCode(Response.Status.NOT_MODIFIED.toString()); - Response.status(Response.Status.NOT_MODIFIED); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while modifying enrollment of the device"; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMsg; - } - - @DELETE - @Path("{deviceId}") - public Message disEnrollDevice(@PathParam("deviceId") String id) throws AndroidAgentException { - Message responseMsg = new Message(); - boolean result; - String msg; - DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); - - try { - result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); - if (result) { - responseMsg.setResponseMessage("Device has removed successfully"); - responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); - Response.status(Response.Status.ACCEPTED); - } else { - responseMsg.setResponseMessage("Device not found"); - responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString()); - Response.status(Response.Status.NOT_FOUND); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while dis enrolling the device"; - log.error(msg, e); - throw new AndroidAgentException(msg, e); - } - return responseMsg; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java index b57cf22c59..c7583ad7ad 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java @@ -18,15 +18,25 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of install application operation. */ +@ApiModel(value = "ApplicationInstallation", + description = "This class carries all information related to install application") public class ApplicationInstallation extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "appIdentifier", value = "DeviceIdentifier", required = true) private String appIdentifier; + + @ApiModelProperty(name = "type", value = "Application type(Enterprise/Web/public)", required = true) private String type; + + @ApiModelProperty(name = "url", value = "Application URL", required = true) private String url; public String getAppIdentifier() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java index 82243a185f..2d4ea4d00f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; import java.util.List; @@ -24,9 +26,15 @@ import java.util.List; /** * This class is used to wrap the InstallApplication bean with devices. */ + +@ApiModel(value = "ApplicationInstallationBeanWrapper", + description = "This class carries all information related to a InstallApplication") public class ApplicationInstallationBeanWrapper { + @ApiModelProperty(name = "deviceIDs", value = "List of Devices", required = true) private List deviceIDs; + + @ApiModelProperty(name = "operation", value = "App Installation property", required = true) private ApplicationInstallation operation; public List getDeviceIDs() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java index c0f1aa0d26..568b85f0c7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; import java.util.List; @@ -24,9 +26,14 @@ import java.util.List; /** * This class is used to wrap the UninstallApplication bean with devices. */ +@ApiModel(value = "ApplicationUninstallationBeanWrapper", + description = "This class carries all information related to Uninstall Application") public class ApplicationUninstallationBeanWrapper { + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; + + @ApiModelProperty(name = "operation", value = "Name of the device", required = true) private ApplicationUninstallation operation; public List getDeviceIDs() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java new file mode 100644 index 0000000000..ca51ac6aef --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.configuration; + +import io.swagger.annotations.*; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.util.Message; + +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + +/** + * Android Platform Configuration REST-API implementation. + * All end points supports JSON, XMl with content negotiation. + */ +@Api(value = "ConfigurationMgtService") +@WebService +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public interface ConfigurationMgtService { + + @POST + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Configuring Android Platform Settings", + notes = "Configure the Android platform settings using this REST API" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Android platform configuration saved successfully"), + @ApiResponse(code = 500, message = "Internal Server Error") + }) + Message configureSettings(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") + TenantConfiguration configuration) throws AndroidAgentException; + + @GET + @ApiOperation( + httpMethod = "GET", + value = "Getting Android Platform Configurations", + notes = "Get the Android platform configuration details using this REST API", + response = TenantConfiguration.class + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Get Android Configurations"), + @ApiResponse(code = 500, message = "Server Error") + }) + TenantConfiguration getConfiguration() throws AndroidAgentException; + + @PUT + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Updating Android Platform Configurations", + notes = "Update the Android platform configurations using this REST API" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " + + "Android platform") + }) + Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java new file mode 100644 index 0000000000..caf138e38d --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/impl/ConfigurationMgtServiceImpl.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.configuration.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.mdm.services.android.services.configuration.ConfigurationMgtService; +import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; +import org.wso2.carbon.mdm.services.android.util.AndroidConstants; +import org.wso2.carbon.mdm.services.android.util.Message; + +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +/** + * Android Platform Configuration REST-API implementation. + * All end points supports JSON, XMl with content negotiation. + */ +@WebService +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { + private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class); + + @POST + public Message configureSettings(TenantConfiguration configuration) + throws AndroidAgentException { + + Message responseMsg = new Message(); + String msg; + ConfigurationEntry licenseEntry = null; + try { + configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + List configs = configuration.getConfiguration(); + for (ConfigurationEntry entry : configs) { + if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { + License license = new License(); + license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US); + license.setVersion("1.0.0"); + license.setText(entry.getValue().toString()); + AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. + MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license); + licenseEntry = entry; + break; + } + } + + if (licenseEntry != null) { + configs.remove(licenseEntry); + } + configuration.setConfiguration(configs); + AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); + Response.status(Response.Status.CREATED); + responseMsg.setResponseMessage("Android platform configuration saved successfully."); + responseMsg.setResponseCode(Response.Status.CREATED.toString()); + } catch (DeviceManagementException e) { + msg = "Error occurred while configuring the android platform"; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMsg; + } + + @GET + public TenantConfiguration getConfiguration() throws AndroidAgentException { + String msg; + TenantConfiguration tenantConfiguration; + List configs; + try { + tenantConfiguration = AndroidAPIUtils.getDeviceManagementService(). + getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + if (tenantConfiguration != null) { + configs = tenantConfiguration.getConfiguration(); + } else { + tenantConfiguration = new TenantConfiguration(); + configs = new ArrayList(); + } + + ConfigurationEntry entry = new ConfigurationEntry(); + License license = AndroidAPIUtils.getDeviceManagementService().getLicense( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants. + TenantConfigProperties.LANGUAGE_US); + + if (license != null && configs != null) { + entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); + entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY); + entry.setValue(license.getText()); + configs.add(entry); + tenantConfiguration.setConfiguration(configs); + } + } catch (DeviceManagementException e) { + msg = "Error occurred while retrieving the Android tenant configuration"; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return tenantConfiguration; + } + + @PUT + public Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException { + String msg; + Message responseMsg = new Message(); + ConfigurationEntry licenseEntry = null; + try { + configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + List configs = configuration.getConfiguration(); + for (ConfigurationEntry entry : configs) { + if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { + License license = new License(); + license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US); + license.setVersion("1.0.0"); + license.setText(entry.getValue().toString()); + AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. + MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license); + licenseEntry = entry; + } + } + + if (licenseEntry != null) { + configs.remove(licenseEntry); + } + configuration.setConfiguration(configs); + AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); + Response.status(Response.Status.ACCEPTED); + responseMsg.setResponseMessage("Android platform configuration has updated successfully."); + responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); + } catch (DeviceManagementException e) { + msg = "Error occurred while modifying configuration settings of Android platform"; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMsg; + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java new file mode 100644 index 0000000000..d6eae7eb11 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.devicemgt; + +import io.swagger.annotations.*; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.app.mgt.Application; +import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.util.Message; + +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.util.List; + +/** + * Android Device Management REST-API implementation. + * All end points supports JSON, XMl with content negotiation. + */ + +@Api(value = "DeviceManagementService") +@WebService +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public interface DeviceManagementService { + + + /** + * Get all devices.Returns list of Android devices registered in MDM. + * + * @return Device List + * @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException + */ + @GET + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting Details of All Android Devices", + notes = "Use this REST API to retrieve the details " + + "(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " + + "(IMEI), owner, version, model etc.) of all Android devices that are registered with WSO2 EMM.", + response = Device.class, + responseContainer = "List" + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "List of Devices"), + @ApiResponse(code = 500, message = "Error occurred while fetching the device list") + }) + List getAllDevices() throws AndroidAgentException; + + /** + * Fetch Android device details of a given device Id. + * + * @param id Device Id + * @return Device + * @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException + */ + @GET + @Path("{id}") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting Details of an Android Device", + notes = "Use this REST API to retrieve the details " + + "(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " + + "(IMEI), owner, version, model etc.) of a specific Android device that is registered with WSO2 EMM", + response = Device.class + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Information of the given device"), + @ApiResponse(code = 500, message = "Error occurred while fetching the device information") + }) + org.wso2.carbon.device.mgt.common.Device getDevice(@ApiParam(name = "id", value = "deviceIdentifier") + @PathParam("id") String id) throws AndroidAgentException; + + /** + * Update Android device details of given device id. + * + * @param id Device Id + * @param device Device Details + * @return Message + * @throws AndroidAgentException + */ + @PUT + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Updating the Details of an Android Device", + notes = "Use this REST API to update the details of an Android device" + ) + @ApiResponses(value = { + @ApiResponse(code = 202, message = "The device enrollment details has been updated successfully"), + @ApiResponse(code = 500, message = "Error occurred while modifying the device information"), + @ApiResponse(code = 304, message = "Device not found for the update") + }) + @Path("{id}") + Message updateDevice(@ApiParam(name = "id", value = "deviceIdentifier") + @PathParam("id") String id, @ApiParam(name = "device", value = "deviceIdentifier") + Device device) throws AndroidAgentException; + + @POST + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Updating an ApplicationList", + notes = "Update application list in server side." + ) + @ApiResponses(value = { + @ApiResponse(code = 202, message = "Device information has modified successfully"), + @ApiResponse(code = 500, message = "Error occurred while modifying the application list") + }) + Message updateApplicationList(@ApiParam(name = "id", value = "deviceIdentifier") @PathParam("id") String id, + @ApiParam(name = "applications", value = "updatable applications") + List applications); + + @GET + @Path("license") + @Produces("text/html") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting the License Agreement for Android Device Registration", + notes = "Use this REST API to retrieve the license agreement that is used for the Android device " + + "registration process", + response = String.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Licence agreement"), + @ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Android " + + "device enrolment")}) + String getLicense() throws AndroidAgentException; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/impl/DeviceManagementServiceImpl.java new file mode 100644 index 0000000000..f1cb678df8 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/impl/DeviceManagementServiceImpl.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.devicemgt.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.app.mgt.Application; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; +import org.wso2.carbon.mdm.services.android.util.Message; + +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import java.util.List; + +/** + * Android Device Management REST-API implementation. + * All end points supports JSON, XMl with content negotiation. + */ +@WebService +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public class DeviceManagementServiceImpl { + + private static Log log = LogFactory.getLog(DeviceManagementServiceImpl.class); + + /** + * Get all devices.Returns list of Android devices registered in MDM. + * + * @return Device List + * @throws AndroidAgentException + */ + @GET + public List getAllDevices() + throws AndroidAgentException { + String msg; + List devices; + + try { + devices = AndroidAPIUtils.getDeviceManagementService(). + getAllDevices(DeviceManagementConstants.MobileDeviceTypes. + MOBILE_DEVICE_TYPE_ANDROID); + } catch (DeviceManagementException e) { + msg = "Error occurred while fetching the device list."; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return devices; + } + + /** + * Fetch Android device details of a given device Id. + * + * @param id Device Id + * @return Device + * @throws AndroidAgentException + */ + @GET + @Path("{id}") + public Device getDevice(@PathParam("id") String id) + throws AndroidAgentException { + + String msg; + Device device; + + try { + DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); + device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); + if (device == null) { + Response.status(Response.Status.NOT_FOUND); + } + } catch (DeviceManagementException deviceMgtEx) { + msg = "Error occurred while fetching the device information."; + log.error(msg, deviceMgtEx); + throw new AndroidAgentException(msg, deviceMgtEx); + } + return device; + } + + /** + * Update Android device details of given device id. + * + * @param id Device Id + * @param device Device Details + * @return Message + * @throws AndroidAgentException + */ + @PUT + @Path("{id}") + public Message updateDevice(@PathParam("id") String id, Device device) + throws AndroidAgentException { + String msg; + Message responseMessage = new Message(); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(id); + deviceIdentifier + .setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + boolean result; + try { + device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + result = AndroidAPIUtils.getDeviceManagementService() + .updateDeviceInfo(deviceIdentifier, device); + if (result) { + Response.status(Response.Status.ACCEPTED); + responseMessage.setResponseMessage("Device information has modified successfully."); + } else { + Response.status(Response.Status.NOT_MODIFIED); + responseMessage.setResponseMessage("Device not found for the update."); + } + } catch (DeviceManagementException e) { + msg = "Error occurred while modifying the device information."; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMessage; + } + + @POST + @Path("appList/{id}") + public Message updateApplicationList(@PathParam("id") String id, List applications) + throws + AndroidAgentException { + + Message responseMessage = new Message(); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(id); + deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + try { + AndroidAPIUtils.getApplicationManagerService(). + updateApplicationListInstalledInDevice(deviceIdentifier, applications); + Response.status(Response.Status.ACCEPTED); + responseMessage.setResponseMessage("Device information has modified successfully."); + + } catch (ApplicationManagementException e) { + String msg = "Error occurred while modifying the application list."; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMessage; + } + + @GET + @Path("license") + @Produces("text/html") + public String getLicense() throws AndroidAgentException { + License license; + + try { + license = + AndroidAPIUtils.getDeviceManagementService().getLicense( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, + DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); + } catch (DeviceManagementException e) { + String msg = "Error occurred while retrieving the license configured for Android device enrolment"; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return (license == null) ? null : license.getText(); + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java new file mode 100644 index 0000000000..28cc416f78 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.enrollment; + +import io.swagger.annotations.*; +import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.util.Message; + +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + +/** + * Android Device Enrollment REST-API implementation. + * All end points supports JSON, XMl with content negotiation. + */ +@Api(value = "EnrollmentService") +@WebService +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public interface EnrollmentService { + + @POST + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Registering an Android Device", + notes = "When carrying out device registration via an Android device, you need to initially install" + + " an Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," + + " you can use this REST API to register an Android device with WSO2 EMM, without having to install" + + " an Android Agent on the respective device" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Device enrollment succeeded"), + @ApiResponse(code = 500, message = "Device enrollment failed"), + }) + Message enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") + org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException; + + @GET + @Path("{deviceId}") + @ApiOperation( + httpMethod = "GET", + value = "Getting the Registration Status of an Android Device", + notes = "Use this REST API to retrieve the registration status of an Android device" + ) + @ApiResponses(value = { + @ApiResponse(code = 202, message = "Device has already enrolled"), + @ApiResponse(code = 404, message = "Device not found") + }) + Message isEnrolled(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id) + throws AndroidAgentException; + + @PUT + @Path("{deviceId}") + @ApiOperation( + httpMethod = "PUT", + value = "Updating the Registration Details of an Android Device", + notes = "Use this REST API to update the registration details of an Android device" + ) + @ApiResponses(value = { + @ApiResponse(code = 202, message = "Device enrollment has updated successfully"), + @ApiResponse(code = 404, message = "Device not found for enrollment") + }) + Message modifyEnrollment(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id, + @ApiParam(name = "device", value = "Device information to be modify") + org.wso2.carbon.device.mgt.common.Device device) + throws AndroidAgentException; + + @DELETE + @ApiOperation( + httpMethod = "DELETE", + value = "Un-registering an Android Device", + notes = "Use this REST API to unregister a specific Android device" + ) + @ApiResponses(value = { + @ApiResponse(code = 202, message = "Device has removed successfully"), + @ApiResponse(code = 404, message = "Device not found") + }) + @Path("{deviceId}") + Message disEnrollDevice(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id) + throws AndroidAgentException; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/impl/EnrollmentServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/impl/EnrollmentServiceImpl.java new file mode 100644 index 0000000000..3283770470 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/impl/EnrollmentServiceImpl.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.enrollment.impl; + +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.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.services.enrollment.EnrollmentService; +import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; +import org.wso2.carbon.mdm.services.android.util.Message; + +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +/** + * Android Device Enrollment REST-API implementation. + * All end points supports JSON, XMl with content negotiation. + */ +@WebService +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public class EnrollmentServiceImpl implements EnrollmentService { + + private static Log log = LogFactory.getLog(EnrollmentService.class); + + @POST + public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device) + throws AndroidAgentException { + + Message responseMsg = new Message(); + String msg; + try { + device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); + boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); + if (status) { + Response.status(Response.Status.CREATED); + responseMsg.setResponseMessage("Device enrollment succeeded."); + responseMsg.setResponseCode(Response.Status.CREATED.toString()); + } else { + Response.status(Response.Status.INTERNAL_SERVER_ERROR); + responseMsg.setResponseMessage("Device enrollment failed."); + responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()); + } + } catch (DeviceManagementException e) { + msg = "Error occurred while enrolling the device"; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMsg; + } + + @GET + @Path("{deviceId}") + public Message isEnrolled(@PathParam("deviceId") String id) throws AndroidAgentException { + String msg; + 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"); + responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); + Response.status(Response.Status.ACCEPTED); + } else { + responseMsg.setResponseMessage("Device not found"); + responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString()); + Response.status(Response.Status.NOT_FOUND); + } + } catch (DeviceManagementException e) { + msg = "Error occurred while checking enrollment status of the device."; + responseMsg.setResponseMessage(msg); + responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()); + Response.status(Response.Status.INTERNAL_SERVER_ERROR); + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMsg; + } + + @PUT + @Path("{deviceId}") + public Message modifyEnrollment(@PathParam("deviceId") String id, + org.wso2.carbon.device.mgt.common.Device device) + throws AndroidAgentException { + String msg; + 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"); + responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); + Response.status(Response.Status.ACCEPTED); + } else { + responseMsg.setResponseMessage("Device not found for enrollment"); + responseMsg.setResponseCode(Response.Status.NOT_MODIFIED.toString()); + Response.status(Response.Status.NOT_MODIFIED); + } + } catch (DeviceManagementException e) { + msg = "Error occurred while modifying enrollment of the device"; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMsg; + } + + @DELETE + @Path("{deviceId}") + public Message disEnrollDevice(@PathParam("deviceId") String id) throws AndroidAgentException { + Message responseMsg = new Message(); + boolean result; + String msg; + DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); + + try { + result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); + if (result) { + responseMsg.setResponseMessage("Device has removed successfully"); + responseMsg.setResponseCode(Response.Status.ACCEPTED.toString()); + Response.status(Response.Status.ACCEPTED); + } else { + responseMsg.setResponseMessage("Device not found"); + responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString()); + Response.status(Response.Status.NOT_FOUND); + } + } catch (DeviceManagementException e) { + msg = "Error occurred while dis enrolling the device"; + log.error(msg, e); + throw new AndroidAgentException(msg, e); + } + return responseMsg; + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java new file mode 100644 index 0000000000..8c0cc0ff6d --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java @@ -0,0 +1,414 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.operationmgt; + +import io.swagger.annotations.*; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.mdm.services.android.bean.wrapper.*; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.List; + +/** + * Android Device Operation REST-API implementation. + */ + +@Api("OperationMgtService") +public interface OperationMgtService { + String ACCEPT = "Accept"; + + @PUT + @Path("{id}") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Getting Pending Android Device Operations", + responseContainer = "List", + notes = "The Android agent communicates with the server to get the operations that are queued up " + + "at the server end for a given device using this REST API", + response = Operation.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "List of pending operations"), + @ApiResponse(code = 500, message = "Issue in retrieving operation management service instance") + }) + List getPendingOperations( + @ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam(ACCEPT) String acceptHeader, + @ApiParam(name = "id", value = "DeviceIdentifier") @PathParam("id") String id, + @ApiParam(name = "resultOperations", value = "Device Operation Status") + List resultOperations); + + @POST + @Path("lock") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Adding a Device Lock on Android Devices", + responseContainer = "List", + notes = "Using this API you have the option of hard locking an Android device, where the Administrator " + + "permanently locks the device or screen locking an Android device", + response = String.class) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response configureDeviceLock(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", value = + "DeviceIds to be enable device lock operation") + List deviceIDs); + + + @POST + @Path("location") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Requesting Location Coordinates of Android Devices", + responseContainer = "List", + notes = "Request location coordinates of Android devices", + response = String.class) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Requested Device Coordinates"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance")}) + Response getDeviceLocation(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", + value = "DeviceIDs to be requested to get device location") + List deviceIDs); + + @POST + @Path("clear-password") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Clearing the Password on Android Devices", + notes = "Clear the password on Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response removePassword(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", + value = "DeviceIds to be requested to remove password") + List deviceIDs); + + @POST + @Path("camera") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Enabling or Disabling the Camera on Android Devices", + notes = "Enable or disable the camera on Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in creating a new camera instance") + }) + Response configureCamera(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "cameraBeanWrapper", + value = "Camera enable/disable configurations with device IDs") CameraBeanWrapper cameraBeanWrapper); + + @POST + @Path("device-info") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Requesting Information from Android Devices", + notes = "Using this REST API you are able to request for Android device details. Once this REST API is" + + " executed it will be in the Android operation queue until the device calls the server to retrieve " + + "the list of operations that needs to be executed on the device" + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Device Information"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response getDeviceInformation(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIds", + value = "Device IDs to be requested to get device information") + List deviceIDs); + + @POST + @Path("enterprise-wipe") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Enterprise Wiping Android Devices", + notes = "Enterprise wipe is the process of deleting enterprise related data on a device while keeping the " + + "personal data intact. You are able to enterprise wipe Android devices using this REST API" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance" + )}) + Response wipeDevice(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", + value = "Device IDs to be requested to done enterprise-wipe") + List deviceIDs); + + @POST + @Path("wipe-data") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Factory Resetting an Android Device", + notes = "Factory rest or erases all the data stored in the Android devices " + + "to restore them back to the original system" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance")}) + Response wipeData(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "wipeDataBeanWrapper", + value = "Configurations and DeviceIds to be need to done wipe-data") + WipeDataBeanWrapper wipeDataBeanWrapper); + + @POST + @Path("application-list") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Requesting the List of Installed Applications on Android Devices", + notes = "Using this REST API the server requests for the list of applications that are installed on" + + " the Android devices. Once this REST API is executed it will be in the Android operation queue " + + "until the device calls the server to retrieve the list of operations that needs to be executed " + + "on the device" + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "List of applications for specific deviceIdentifier"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response getApplications(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", + value = "Device Ids to be need to get applications which already installed") + List deviceIDs); + + @POST + @Path("ring-device") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Ringing Android Devices", + notes = "Ring Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response ringDevice(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", + value = "Device Ids needs to be ring") List deviceIDs); + + @POST + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Muting Android Devices", + notes = "Mute Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + @Path("mute") + Response muteDevice(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, + @ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted") List deviceIDs); + + @POST + @Path("install-application") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Installing an Application on Android Devices", + notes = "Install an application on an Android device. If the device you are installing the application" + + " on has the WSO2 system service installed, the application installation will happen in silent " + + "mode, else the device user's consent will be required" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response installApplication(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, + @ApiParam(name = "applicationInstallationBeanWrapper", + value = "Properties of installed apps and device IDs") + ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); + + @POST + @Path("uninstall-application") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Uninstalling an Application from Android Devices", + notes = "Uninstall an application from Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response uninstallApplication(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, + @ApiParam(name = "applicationUninstallationBeanWrapper", + value = "applicationUninstallationConfigs and Device Ids") + ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper); + + @POST + @Path("blacklist-applications") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Get BlackListed Applications", + notes = "Getting BlackListed Applications" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response blacklistApplications(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, + @ApiParam(name = "blacklistApplicationsBeanWrapper", + value = "BlacklistApplications Configuration and DeviceIds") + BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper); + + @POST + @Path("notification") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Sending a Notification to Android Devices", + notes = "Send a notification to Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response sendNotification(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, + @ApiParam(name = "notificationBeanWrapper", + value = "Notification Configurations and device Ids") + NotificationBeanWrapper notificationBeanWrapper); + + @POST + @Path("wifi") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Configuring Wi-Fi on Android Devices", + notes = "Configure Wi-Fi on Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response configureWifi(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "wifiBeanWrapper", + value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper); + + @POST + @Path("encrypt") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Encrypting Storage on Android Devices", + notes = "Encrypt the data stored on Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response encryptStorage(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "encryptionBeanWrapper", + value = "Configurations and deviceIds need to be done data encryption") + EncryptionBeanWrapper encryptionBeanWrapper); + + @POST + @Path("change-lock-code") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Changing the Lock Code on Android Devices", + notes = "Change the lock code on Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response changeLockCode(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "lockCodeBeanWrapper", + value = "Configurations and device Ids need to be done change lock code") + LockCodeBeanWrapper lockCodeBeanWrapper); + + @POST + @Path("password-policy") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Setting a Passcode Policy on Android Devices", + notes = "Set a password policy on Android devices" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "created"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response setPasswordPolicy(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "passwordPolicyBeanWrapper", + value = "Password Policy Configurations and Device Ids") + PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); + + @POST + @Path("webclip") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Setting a Web Clip on Android Devices", + notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Accepted"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response setWebClip(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "webClipBeanWrapper", + value = "Configurations to need set web clip on device and device Ids") + WebClipBeanWrapper webClipBeanWrapper); + + @POST + @Path("disenroll") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Un-Register The Device from the EMM server", + notes = "unregister the given device" + ) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Accepted"), + @ApiResponse(code = 500, message = "Issue in retrieving device management service instance") + }) + Response setDisenrollment(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam(ACCEPT) String acceptHeader, + @ApiParam(name = "disenrollmentBeanWrapper", value = "Dis-enrollment configurations") + DisenrollmentBeanWrapper disenrollmentBeanWrapper); +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/impl/OperationMgtServiceImpl.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/impl/OperationMgtServiceImpl.java index 18d8f84c5d..f85f218a89 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/impl/OperationMgtServiceImpl.java @@ -16,22 +16,22 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android; +package org.wso2.carbon.mdm.services.android.services.operationmgt.impl; 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.DeviceManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.notification.mgt.*; +import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; 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.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.mdm.services.android.bean.*; -import org.wso2.carbon.mdm.services.android.bean.Notification; import org.wso2.carbon.mdm.services.android.bean.wrapper.*; import org.wso2.carbon.mdm.services.android.exception.AndroidOperationException; +import org.wso2.carbon.mdm.services.android.services.operationmgt.OperationMgtService; import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; @@ -43,15 +43,12 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; -/** - * Android Device Operation REST-API implementation. - */ -public class OperationMgtService { +public class OperationMgtServiceImpl { private static Log log = LogFactory.getLog(OperationMgtService.class); private static final String ACCEPT = "Accept"; - private static final String OPERATION_ERROR_STATUS = "ERROR"; - private static final String DEVICE_TYPE_ANDROID = "android"; + private static final String OPERATION_ERROR_STATUS = "ERROR"; + private static final String DEVICE_TYPE_ANDROID = "android"; @PUT @Path("{id}") @@ -93,7 +90,7 @@ public class OperationMgtService { } catch (ApplicationManagementException e) { log.error("Issue in retrieving application management service instance", e); } catch (NotificationManagementException e) { - log.error("Issue in retrieving Notification management service instance", e); + log.error("Issue in retrieving Notification management service instance", e); } List pendingOperations; @@ -268,7 +265,7 @@ public class OperationMgtService { CommandOperation operation = new CommandOperation(); operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); operation.setType(Operation.Type.COMMAND); - getApplications(acceptHeader, deviceIDs); + getApplications(acceptHeader, deviceIDs); return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType); } catch (OperationManagementException e) { @@ -908,21 +905,21 @@ public class OperationMgtService { ApplicationManagementException, NotificationManagementException, DeviceManagementException { for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) { AndroidAPIUtils.updateOperation(deviceId, operation); - if(operation.getStatus().equals(OPERATION_ERROR_STATUS)){ - org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new - org.wso2.carbon.device.mgt.common.notification.mgt.Notification(); - DeviceIdentifier id = new DeviceIdentifier(); - id.setId(deviceId); - id.setType(DEVICE_TYPE_ANDROID); - String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id).getName(); - notification.setOperationId(operation.getId()); - notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. - Status.NEW.toString()); - notification.setDeviceIdentifier(id); - notification.setDescription("Operation " + operation.getCode() + " failed to execute on device "+ - deviceName+". Device ID : " + deviceId); - AndroidAPIUtils.getNotificationManagementService().addNotification(notification); - } + if (operation.getStatus().equals(OPERATION_ERROR_STATUS)) { + org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new + org.wso2.carbon.device.mgt.common.notification.mgt.Notification(); + DeviceIdentifier id = new DeviceIdentifier(); + id.setId(deviceId); + id.setType(DEVICE_TYPE_ANDROID); + String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id).getName(); + notification.setOperationId(operation.getId()); + notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. + Status.NEW.toString()); + notification.setDeviceIdentifier(id); + notification.setDescription("Operation " + operation.getCode() + " failed to execute on device " + + deviceName + ". Device ID : " + deviceId); + AndroidAPIUtils.getNotificationManagementService().addNotification(notification); + } if (log.isDebugEnabled()) { log.debug("Updating operation '" + operation.toString() + "'"); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java new file mode 100644 index 0000000000..7d36987c93 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.services.policymgt; + +import io.swagger.annotations.*; +import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.util.Message; +import org.wso2.carbon.policy.mgt.common.ProfileFeature; + +import javax.jws.WebService; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.util.List; + +@Api("PolicyMgtService") +@WebService +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +public interface PolicyMgtService { + + @GET + @Path("{deviceId}") + @ApiOperation( + httpMethod = "GET", + value = "Identifying whether a Policy is Enforced on an Android Device", + notes = "When a device registers with WSO2 EMM, a policy is enforced on the device based on the policy " + + "enforcement criteria. Using this API you are able to identify if a specific device has a policy " + + "enforced or if no policy is enforced on the device." + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Effective policy added to operation"), + @ApiResponse(code = 204, message = "No effective policy found") + }) + Message getEffectivePolicy(@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam("Accept") + String acceptHeader, + @ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") + String id) throws AndroidAgentException; + + @GET + @Path("/features/{deviceId}") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Get Effective Features", + responseContainer = "List", + notes = "Get already applied features for given device Identifier", + response = ProfileFeature.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Effective Feature List"), + @ApiResponse(code = 404, message = "Not Found"), + @ApiResponse(code = 500, message = "Error occurred while getting the features") + }) + List getEffectiveFeatures(@ApiParam(name = "acceptHeader", value = "Accept Header") + @HeaderParam("Accept") String acceptHeader, + @ApiParam(name = "deviceId", value = "DeviceIdentifier") + @PathParam("deviceId") String id) throws AndroidAgentException; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/impl/PolicyMgtServiceImpl.java similarity index 92% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/impl/PolicyMgtServiceImpl.java index af756ed866..eed8626838 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/impl/PolicyMgtServiceImpl.java @@ -16,14 +16,13 @@ * under the License. */ - -package org.wso2.carbon.mdm.services.android; - +package org.wso2.carbon.mdm.services.android.services.policymgt.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +import org.wso2.carbon.mdm.services.android.services.policymgt.PolicyMgtService; import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.Message; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; @@ -32,16 +31,14 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.common.ProfileFeature; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; -import javax.jws.WebService; -import javax.ws.rs.*; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; import java.util.List; -@WebService -@Produces({"application/json", "application/xml"}) -@Consumes({"application/json", "application/xml"}) -public class PolicyMgtService { - +public class PolicyMgtServiceImpl { private static Log log = LogFactory.getLog(PolicyMgtService.class); @GET diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml index a2b102d60c..010d83ff66 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -69,11 +69,11 @@ - - - - - + + + + + diff --git a/pom.xml b/pom.xml index 646be5d211..64b4818f62 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,12 @@ + + + io.swagger + swagger-annotations + ${swagger.version} + @@ -1063,6 +1069,9 @@ 8.1.3.v20120416 + + 1.5.8 + 5.0.11 [5.0.11,6.0.0) From f66aad9e0e4f2160534df3accf631aa1f4a3b6d3 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 13 May 2016 02:39:30 +0530 Subject: [PATCH 16/19] Adding swagger annotations --- .../android/bean/ApplicationInstallation.java | 2 +- .../android/bean/ApplicationUninstallation.java | 13 +++++++++++++ .../android/bean/BlacklistApplications.java | 7 +++++++ .../carbon/mdm/services/android/bean/Camera.java | 7 +++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java index c7583ad7ad..b0ed373779 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java @@ -30,7 +30,7 @@ import java.io.Serializable; description = "This class carries all information related to install application") public class ApplicationInstallation extends AndroidOperation implements Serializable { - @ApiModelProperty(name = "appIdentifier", value = "DeviceIdentifier", required = true) + @ApiModelProperty(name = "appIdentifier", value = "Application Identifier", required = true) private String appIdentifier; @ApiModelProperty(name = "type", value = "Application type(Enterprise/Web/public)", required = true) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java index 5efb16a5b7..a946eedc72 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java @@ -18,16 +18,29 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of uninstall application operation. */ +@ApiModel(value = "ApplicationUninstallation", + description = "This class carries all information related to application uninstallation.") public class ApplicationUninstallation extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "appIdentifier", value = "The package name of the application to be uninstalled.", required = true) private String appIdentifier; + + @ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " + + "are supported: enterprise, public and webapp.", required = true) private String type; + + @ApiModelProperty(name = "url", value = "The URL of the application.", required = true) private String url; + + @ApiModelProperty(name = "name", value = "The name of the application.", required = true) private String name; public String getAppIdentifier() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java index c66dbe89a6..665735b519 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java @@ -18,14 +18,21 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; import java.util.List; /** * This class represents the blacklist applications information. */ +@ApiModel(value = "BlacklistApplications", + description = "This class represents the blacklist applications information.") public class BlacklistApplications extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "appIdentifiers", value = "A list of application package names to be blacklisted.", + required = true) private List appIdentifiers; public List getAppIdentifier() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java index 77c0773c1e..0dad70364a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java @@ -18,13 +18,20 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of camera operation. */ +@ApiModel(value = "Camera", + description = "This class represents the information of camera operation.") public class Camera extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "enabled", value = "Disable the camera on the device by assigning false as the value or " + + "enable the camera on the device to function by defining true as the value.", required = true) private boolean enabled; public boolean isEnabled() { From 0d8010c25aa7a9c91bbbd8eb979e75be58bd2e43 Mon Sep 17 00:00:00 2001 From: Madhawa Perera Date: Fri, 13 May 2016 02:43:23 +0530 Subject: [PATCH 17/19] Adding swagger annotations to beans --- .../services/android/bean/PasscodePolicy.java | 23 +++++++++++++++++++ .../mdm/services/android/bean/WebClip.java | 9 ++++++++ .../mdm/services/android/bean/Wifi.java | 8 +++++++ .../mdm/services/android/bean/WipeData.java | 5 ++++ 4 files changed, 45 insertions(+) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java index 488d7a011f..0b1f93743a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java @@ -18,19 +18,42 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of setting up password policy. */ +@ApiModel(value = "PasscodePolicy", description = "This class represents the information of setting up " + + "password policy") public class PasscodePolicy extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "maxFailedAttempts", value = "The maximum number of times the end-user can enter" + + " his/her device passcode incorrectly. EMM will take different courses of action based on the" + + " OS when the failed attempts exceed the maximum failed attempts. Android devices will be " + + "automatically reset to the original factory settings", required = true) private int maxFailedAttempts; + @ApiModelProperty(name = "minLength", value = "The minimum number of alphanumerical values that the " + + "end-user can enter as his/her passcode", required = true) private int minLength; + @ApiModelProperty(name = "pinHistory", value = "The end-user will not be allowed to reuse a passcode that" + + " he/she previously entered until he/she exceeds the set pin history length", required = true) private int pinHistory; + @ApiModelProperty(name = "minComplexChars", value = "The minimum number of special characters that the " + + "end-user will have to enter in his/her passcode", required = true) private int minComplexChars; + @ApiModelProperty(name = "maxPINAgeInDays", value = "The number of days after which the device owner has" + + " to change his/her passcode", required = true) private int maxPINAgeInDays; + @ApiModelProperty(name = "requireAlphanumeric", value = "Whether or not it is mandatory for the end-user" + + " to have a mix of digits and characters in his/her passcode", required = true) private boolean requireAlphanumeric; + @ApiModelProperty(name = "allowSimple", value = "If this field is set to 'true', the device owner will be" + + " able to have a simple passcode and the following criteria in the passcode policy will not be" + + " applicable:\n" + + "Minimum length\n" + "Minimum complex characters", required = true) private boolean allowSimple; public int getMaxFailedAttempts() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java index 8adf05b1d9..cf39b10703 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java @@ -18,15 +18,24 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of setting up webclip. */ +@ApiModel(value = "WebClip", description = "This class represents the information of setting up webclip") public class WebClip extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "identity", value = "The URL of the application", required = true) private String identity; + @ApiModelProperty(name = "title", value = "The name of the web application", required = true) private String title; + @ApiModelProperty(name = "type", value = "The type of the operation. Following are the possible operation" + + " types: install and uninstall. If the operation type is install, the web clip is added, and " + + "if the operation type is uninstall, the existing web clip is removed", required = true) private String type; public String getIdentity() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java index aa0246c0a9..8cdf3c58bb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java @@ -18,14 +18,22 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of configuring wifi operation. */ +@ApiModel(value = "Wifi", description = "This class represents the information of configuring wifi operation") public class Wifi extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "ssid", value = "The name of the Wifi network that you wish to configure", + required = true) private String ssid; + @ApiModelProperty(name = "password", value = "The password to connect to the specified Wifi network", + required = true) private String password; public String getSsid() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java index a3ce49c0b9..83efddc126 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java @@ -18,13 +18,18 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of wipedata operation. */ +@ApiModel(value = "WipeData", description = "This class represents the information of wipedata operation") public class WipeData extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "pin", value = "PIN number to proceed with the data wipe", required = true) private String pin; public String getPin() { From afc7be590e4faa0ec8e89bd1bc76698559abc323 Mon Sep 17 00:00:00 2001 From: inosh-perera Date: Fri, 13 May 2016 02:50:17 +0530 Subject: [PATCH 18/19] adding swagger annotations for Android APIs --- .../carbon/mdm/services/android/bean/DeviceEncryption.java | 7 +++++++ .../carbon/mdm/services/android/bean/Disenrollment.java | 5 +++++ .../wso2/carbon/mdm/services/android/bean/LockCode.java | 6 ++++++ .../carbon/mdm/services/android/bean/Notification.java | 6 ++++++ .../bean/wrapper/BlacklistApplicationsBeanWrapper.java | 6 ++++++ .../services/android/bean/wrapper/CameraBeanWrapper.java | 7 +++++++ .../android/bean/wrapper/DisenrollmentBeanWrapper.java | 5 +++++ .../android/bean/wrapper/EncryptionBeanWrapper.java | 6 ++++++ .../services/android/bean/wrapper/LockCodeBeanWrapper.java | 7 +++++++ .../android/bean/wrapper/NotificationBeanWrapper.java | 7 +++++++ .../android/bean/wrapper/PasswordPolicyBeanWrapper.java | 7 +++++++ .../services/android/bean/wrapper/WebClipBeanWrapper.java | 7 +++++++ .../mdm/services/android/bean/wrapper/WifiBeanWrapper.java | 6 ++++++ .../services/android/bean/wrapper/WipeDataBeanWrapper.java | 6 ++++++ .../services/configuration/ConfigurationMgtService.java | 3 ++- .../services/devicemgt/DeviceManagementService.java | 2 +- .../android/services/enrollment/EnrollmentService.java | 3 ++- .../android/services/operationmgt/OperationMgtService.java | 2 +- .../android/services/policymgt/PolicyMgtService.java | 2 +- 19 files changed, 95 insertions(+), 5 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java index 2fa0890bc7..68ab6ae947 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java @@ -18,13 +18,20 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of encrypt operation. */ + +@ApiModel(value = "DeviceEncryption", + description = "Details related device encryption.") public class DeviceEncryption extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "encrypted", value = "Whether to enable encryption or not.", required = true) private boolean encrypted; public boolean isEncrypted() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java index c1e2c48365..c591d2ae0a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java @@ -18,11 +18,16 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import java.io.Serializable; +@ApiModel(value = "Disenrollment", + description = "Details related to disenrolling a device.") public class Disenrollment extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "enabled", value = "Whether to enable disenrollment or not.", required = true) private boolean enabled; public boolean isEnabled() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java index 8c95f33ecc..4c2764dade 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java @@ -18,13 +18,19 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of changing lock code operation. */ +@ApiModel(value = "LockCode", + description = "Details related to lock code sent on device.") public class LockCode extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "lockCode", value = "The lock code to be sent to the device.", required = true) private String lockCode; public String getLockCode() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java index 2d45ad957a..e7cdb5788a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java @@ -18,13 +18,19 @@ package org.wso2.carbon.mdm.services.android.bean; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; /** * This class represents the information of sending notification operation. */ +@ApiModel(value = "Notification", + description = "Details related to notifications passed to device.") public class Notification extends AndroidOperation implements Serializable { + @ApiModelProperty(name = "message", value = "The message to be sent to the device.", required = true) private String message; public String getMessage() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java index 91c62b435b..1f824661df 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; import java.util.List; @@ -24,9 +26,13 @@ import java.util.List; /** * This class is used to wrap the BlacklistApplications bean with devices. */ +@ApiModel(value = "BlacklistApplicationsBeanWrapper", + description = "Mapping between blacklist application and the device ids.") public class BlacklistApplicationsBeanWrapper { + @ApiModelProperty(name = "operation", value = "Blacklist applications information", required = true) private BlacklistApplications operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public BlacklistApplications getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java index bbf1970f8f..9f9a014f2c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.Camera; import java.util.List; @@ -24,9 +26,14 @@ import java.util.List; /** * This class is used to wrap the Camera bean with devices. */ + +@ApiModel(value = "CameraBeanWrapper", + description = "Mapping between camera operation and device list to be applied.") public class CameraBeanWrapper { + @ApiModelProperty(name = "operation", value = "Information of camera operation", required = true) private Camera operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public Camera getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java index d1370633d6..86e7fb3afa 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java @@ -17,13 +17,18 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.Disenrollment; import java.util.List; +@ApiModel(value = "DisenrollmentBeanWrapper", description = "Disenrollment details are mapped to devices list.") public class DisenrollmentBeanWrapper { + @ApiModelProperty(name = "operation", value = "Disenrollment operation.", required = true) private Disenrollment operation; + @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) private List deviceIDs; public Disenrollment getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java index 31de3f20a6..aeb01400aa 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; import java.util.List; @@ -24,9 +26,13 @@ import java.util.List; /** * This class is used to wrap the Encrypt bean with devices. */ +@ApiModel(value = "EncryptionBeanWrapper", + description = "Mapping between encryption operation and device list to be applied.") public class EncryptionBeanWrapper { + @ApiModelProperty(name = "operation", value = "The information of encrypt operation", required = true) private DeviceEncryption operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public DeviceEncryption getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java index 828aebb00f..364fd39d28 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.LockCode; import java.util.List; @@ -24,9 +26,14 @@ import java.util.List; /** * This class is used to wrap the LockCode bean with devices. */ + +@ApiModel(value = "LockCodeBeanWrapper", + description = "Mapping between lock operation and device list to be applied.") public class LockCodeBeanWrapper { + @ApiModelProperty(name = "operation", value = "The information of device lock operation", required = true) private LockCode operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public LockCode getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java index a9c6a50d65..573e2affc8 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.Notification; import java.util.List; @@ -24,9 +26,14 @@ import java.util.List; /** * This class is used to wrap the Notification bean with devices. */ + +@ApiModel(value = "NotificationBeanWrapper", + description = "Mapping between notification operation and device list to be applied.") public class NotificationBeanWrapper { + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; + @ApiModelProperty(name = "operation", value = "The information of notification operation", required = true) private Notification operation; public List getDeviceIDs() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java index a4a55ecbb5..e47ece1c5a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; import java.util.List; @@ -24,9 +26,14 @@ import java.util.List; /** * This class is used to wrap the PasswordPolicy bean with devices. */ + +@ApiModel(value = "PasswordPolicyBeanWrapper", + description = "Mapping between passcode policy and device list to be applied.") public class PasswordPolicyBeanWrapper { + @ApiModelProperty(name = "operation", value = "The information of setting up password policy", required = true) private PasscodePolicy operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public PasscodePolicy getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java index 61479b521f..098a518bb3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.WebClip; import java.util.List; @@ -24,9 +26,14 @@ import java.util.List; /** * This class is used to wrap the WebClip bean with devices. */ + +@ApiModel(value = "WebClipBeanWrapper", + description = "Mapping between web clip operation and device list to be applied.") public class WebClipBeanWrapper { + @ApiModelProperty(name = "operation", value = "the information of setting up webclip", required = true) private WebClip operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public WebClip getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java index 1d3adcb70f..2d63a27d9c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.Wifi; import java.util.List; @@ -24,9 +26,13 @@ import java.util.List; /** * This class is used to wrap the Wifi bean with devices. */ +@ApiModel(value = "WifiBeanWrapper", + description = "Mapping between wifi operation and device list to be applied.") public class WifiBeanWrapper { + @ApiModelProperty(name = "operation", value = "Information of configuring wifi operation", required = true) private Wifi operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public Wifi getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java index a9d65485e2..1c72af45b4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.mdm.services.android.bean.wrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.mdm.services.android.bean.WipeData; import java.util.List; @@ -24,9 +26,13 @@ import java.util.List; /** * This class is used to wrap the WipeData bean with devices. */ +@ApiModel(value = "WipeDataBeanWrapper", + description = "Mapping between wipe operation and device list to be applied.") public class WipeDataBeanWrapper { + @ApiModelProperty(name = "operation", value = "The information of wipedata operation", required = true) private WipeData operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) private List deviceIDs; public WipeData getOperation() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java index ca51ac6aef..3a378d9e7a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/configuration/ConfigurationMgtService.java @@ -77,5 +77,6 @@ public interface ConfigurationMgtService { @ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " + "Android platform") }) - Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException; + Message updateConfiguration(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") + TenantConfiguration configuration) throws AndroidAgentException; } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java index d6eae7eb11..b7036dd083 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/devicemgt/DeviceManagementService.java @@ -34,7 +34,7 @@ import java.util.List; * All end points supports JSON, XMl with content negotiation. */ -@Api(value = "DeviceManagementService") +@Api(value = "DeviceManagementService", description = "Android Device Management REST-API implementation.") @WebService @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java index 28cc416f78..6c6aa2e378 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/enrollment/EnrollmentService.java @@ -30,7 +30,8 @@ import javax.ws.rs.core.MediaType; * Android Device Enrollment REST-API implementation. * All end points supports JSON, XMl with content negotiation. */ -@Api(value = "EnrollmentService") + +@Api(value = "EnrollmentService", description = "Android Device Enrollment REST-API implementation.") @WebService @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java index 8c0cc0ff6d..d89b977c61 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java @@ -31,7 +31,7 @@ import java.util.List; * Android Device Operation REST-API implementation. */ -@Api("OperationMgtService") +@Api(value = "OperationMgtService", description = "Android Device Operation REST-API implementation.") public interface OperationMgtService { String ACCEPT = "Accept"; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java index 7d36987c93..e35f08b23e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/PolicyMgtService.java @@ -28,7 +28,7 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.List; -@Api("PolicyMgtService") +@Api(value = "PolicyMgtService", description = "Policy management related REST-API implementation.") @WebService @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) From 2dabfa02fa6d5a41c6ab10cd5880e15fd188afb3 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 13 May 2016 02:56:15 +0530 Subject: [PATCH 19/19] Adding swagger annotations --- .../android/services/operationmgt/OperationMgtService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java index 8c0cc0ff6d..2613d641a4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/OperationMgtService.java @@ -86,7 +86,7 @@ public interface OperationMgtService { notes = "Request location coordinates of Android devices", response = String.class) @ApiResponses(value = { - @ApiResponse(code = 201, message = "Requested Device Coordinates"), + @ApiResponse(code = 200, message = "Requested Device Coordinates"), @ApiResponse(code = 500, message = "Issue in retrieving device management service instance")}) Response getDeviceLocation(@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",