From d25e1b2421c4786a3e74ed5d411c8e8c929ae5a8 Mon Sep 17 00:00:00 2001 From: Chatura Dilan Date: Fri, 27 May 2016 22:43:03 +0530 Subject: [PATCH] Fixed Android APIs --- .../DeviceTypeConfigurationService.java | 17 +++++++ .../impl/DeviceManagementServiceImpl.java | 4 +- .../DeviceTypeConfigurationServiceImpl.java | 20 ++++++++ .../src/main/webapp/META-INF/permissions.xml | 50 ++++++++++++++----- 4 files changed, 78 insertions(+), 13 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/services/DeviceTypeConfigurationService.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/DeviceTypeConfigurationService.java index 46b38d30a..74b22065a 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/DeviceTypeConfigurationService.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/DeviceTypeConfigurationService.java @@ -76,4 +76,21 @@ public interface DeviceTypeConfigurationService { Response updateConfiguration(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") PlatformConfiguration configuration) throws AndroidAgentException; + @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") + }) + Response 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/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/impl/DeviceManagementServiceImpl.java index c7111459c..35a03a399 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/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/impl/DeviceManagementServiceImpl.java @@ -71,7 +71,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } - @GET + + + @PUT @Path("/{id}/pending-operations") @Override public Response getPendingOperations(@PathParam("id") String id, List resultOperations) { 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/impl/DeviceTypeConfigurationServiceImpl.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/impl/DeviceTypeConfigurationServiceImpl.java index 3b4a24f80..4de171d9b 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/impl/DeviceTypeConfigurationServiceImpl.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/impl/DeviceTypeConfigurationServiceImpl.java @@ -158,4 +158,24 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati return Response.status(Response.Status.CREATED).entity(responseMsg).build(); } + + @GET + @Path("license") + @Produces("text/html") + public Response getLicense() throws AndroidAgentException { + License license = null; + + 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); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + return Response.status(Response.Status.OK).entity((license == null) ? null : license.getText()).build(); + } + } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml index 1fd0c7c66..4ce7a039b 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml @@ -30,13 +30,7 @@ - - Get Pending Operation - /device-mgt/android/operations/poll - /operation/* - PUT - emm_android_agent - + Lock @@ -273,7 +267,7 @@ View license /device-mgt/android/license/view - /device/license + /configuration/license GET emm_android_agent @@ -282,19 +276,51 @@ Enroll device /device-mgt/android/devices/enroll - /enrollment + /devices POST emm_android_agent - Get Enrollment Status - /device-mgt/android/devices/enroll - /enrollment/* + Devices related Operations + /device-mgt/android/devices + /devices/* GET emm_android_agent + + Device is enrolled + /device-mgt/android/devices + /devices/*/status + GET + emm_android_agent + + + + Devices related Operations + /device-mgt/android/devices/operations + /devices/*/pending-operations + PUT + emm_android_agent + + + + Modify devices + /device-mgt/android/devices/operations + /devices/* + PUT + emm_android_agent + + + + Delete devices + /device-mgt/android/devices/operations + /devices/* + DELETE + emm_android_agent + + Update Enrollment /device-mgt/android/devices/enroll