From 4e4e660fa1adc27181dd540dca747c71d8688c6d Mon Sep 17 00:00:00 2001 From: geethkokila Date: Fri, 13 May 2016 01:09:56 +0530 Subject: [PATCH] Adding the swagger documentation to the activity id resource --- .../carbon/device/mgt/jaxrs/api/Operation.java | 16 ++++++++++++++++ .../mgt/jaxrs/api/impl/OperationImpl.java | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java index 131eef9b2da..da1da349d8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Operation.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.api; import io.swagger.annotations.*; import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.app.mgt.Application; +import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.context.DeviceOperationContext; import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload; import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper; @@ -155,4 +156,19 @@ public interface Operation { "{tenantDomain}. The default tenant domain " + "of WSO2 EMM is carbon.super.", required = true) @PathParam("tenantDomain") String tenantDomain); + + + @GET + @Path("activity/{id}") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, + produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, + httpMethod = "POST", + value = "Retrieving the operation details.", + notes = "This will return the operation details including the responses from the devices") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Activity details provided successfully.."), + @ApiResponse(code = 500, message = "Error occurred while fetching the activity for the supplied id.") }) + Response getActivity(@ApiParam(name = "id", value = "Provide activity id {id} as ACTIVITY_(number)", + required = true) @PathParam("id") String id) + throws MDMAPIException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/OperationImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/OperationImpl.java index bdca4c54915..83066826685 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/OperationImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/OperationImpl.java @@ -224,4 +224,22 @@ public class OperationImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Opera return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } + + @Override + @GET + @Path("activity/{id}") + public Response getActivity(@PathParam("id") String id) + throws MDMAPIException { + org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation; + DeviceManagementProviderService dmService; + try { + dmService = DeviceMgtAPIUtils.getDeviceManagementService(); + operation = dmService.getOperationByActivityId(id); + } catch (OperationManagementException e) { + String msg = "Error occurred while fetching the activity for the supplied id."; + log.error(msg, e); + throw new MDMAPIException(msg, e); + } + return Response.status(Response.Status.OK).entity(operation).build(); + } } \ No newline at end of file