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/VpnBeanWrapper.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/VpnBeanWrapper.java index bfdbd43da3..e71270d229 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/VpnBeanWrapper.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/VpnBeanWrapper.java @@ -30,7 +30,7 @@ import java.util.List; description = "Information related to VPN Configuration.") public class VpnBeanWrapper { @ApiModelProperty(name = "operation", - value = "List of device Ids to be need to execute UpgradeFirmware operation.", required = true) + value = "List of device Ids to be need to execute VPN operation.", required = true) private Vpn operation; @ApiModelProperty(name = "deviceIDs", value = "List of device Ids to be need to execute VPN operation.", 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/services/DeviceManagementAdminService.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/DeviceManagementAdminService.java index 3e504e52c3..2ac904d752 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/DeviceManagementAdminService.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/DeviceManagementAdminService.java @@ -353,6 +353,61 @@ public interface DeviceManagementAdminService { @ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device information") List deviceIDs); + @POST + @Path("/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", + response = Activity.class, + tags = "Android Device Management Administrative Service" + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Device logcat operation has successfully been scheduled", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n Source can be retrieved from the URL specified at the Location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The entity of the request was in a not supported format."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a new device logcat operation.") + }) + Response getDeviceLogcat( + @ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device logcat") + List deviceIDs); + @POST @Path("/enterprise-wipe") @ApiOperation( 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/DeviceManagementAdminServiceImpl.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/DeviceManagementAdminServiceImpl.java index 468882aa9a..68f52f1a8c 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/DeviceManagementAdminServiceImpl.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/DeviceManagementAdminServiceImpl.java @@ -221,6 +221,31 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } } + @POST + @Path("/logcat") + @Override + public Response getDeviceLogcat(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking get Android device logcat operation"); + } + + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.LOGCAT); + operation.setType(Operation.Type.COMMAND); + return AndroidAPIUtils.getOperationResponse(deviceIDs, operation); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); + } catch (DeviceManagementException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } + } + @POST @Path("/enterprise-wipe") @Override @@ -568,24 +593,24 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe @POST @Path("/configure-vpn") @Override - public Response configureVPN(VpnBeanWrapper vpnBeanWrapper) { + public Response configureVPN(VpnBeanWrapper vpnConfiguration) { if (log.isDebugEnabled()) { log.debug("Invoking Android VPN device operation"); } try { - if (vpnBeanWrapper == null || vpnBeanWrapper.getOperation() == null) { + if (vpnConfiguration == null || vpnConfiguration.getOperation() == null) { String errorMessage = "The payload of the VPN operation is incorrect"; log.error(errorMessage); throw new BadRequestException( new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); } - Vpn vpn = vpnBeanWrapper.getOperation(); + Vpn vpn = vpnConfiguration.getOperation(); ProfileOperation operation = new ProfileOperation(); operation.setCode(AndroidConstants.OperationCodes.VPN); operation.setType(Operation.Type.PROFILE); operation.setPayLoad(vpn.toJSON()); - return AndroidAPIUtils.getOperationResponse(vpnBeanWrapper.getDeviceIDs(), + return AndroidAPIUtils.getOperationResponse(vpnConfiguration.getDeviceIDs(), operation); } catch (OperationManagementException e) { String errorMessage = "Issue in retrieving operation management service instance"; 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/util/AndroidConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java index 58519bb83e..16192aea02 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java @@ -96,6 +96,7 @@ public final class AndroidConstants { public static final String DISENROLL = "DISENROLL"; public static final String MONITOR = "MONITOR"; public static final String VPN = "VPN"; + public static final String LOGCAT = "LOGCAT"; public static final String APP_RESTRICTION = "APP-RESTRICTION"; public static final String WORK_PROFILE = "WORK_PROFILE"; } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java index 3863552081..7f2eea9b20 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java @@ -457,6 +457,12 @@ public class AndroidFeatureManager implements FeatureManager { feature.setDescription("remove device owner"); supportedFeatures.add(feature); + feature = new Feature(); + feature.setCode("LOGCAT"); + feature.setName("Fetch Logcat"); + feature.setDescription("Fetch device logcat"); + supportedFeatures.add(feature); + return supportedFeatures; } } \ No newline at end of file