From 3defcfe20d993b4118a251abf94314ba00da318b Mon Sep 17 00:00:00 2001 From: geethkokila Date: Tue, 31 May 2016 11:25:11 +0530 Subject: [PATCH] Fixing the applicationMgtAdminService for returing activity --- .../ApplicationManagementAdminService.java | 9 ++++++-- ...ApplicationManagementAdminServiceImpl.java | 21 ++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java index c7e2c1a26a..23b6cba5ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api.admin; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; @@ -48,11 +49,13 @@ public interface ApplicationManagementAdminService { httpMethod = "POST", value = "Application installation API.(Internal API)", notes = "This is an internal API used for application installation on a device.", + response = Activity.class, tags = "Application Management Administrative Service") @ApiResponses(value = { @ApiResponse( code = 202, - message = "OK. \n Install application operation will be delivered to the given devices"), + message = "OK. \n Install application operation will be delivered to the given devices", + response = Activity.class), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", @@ -84,11 +87,13 @@ public interface ApplicationManagementAdminService { httpMethod = "POST", value = "Application un-installation API.(Internal API)", notes = "This is an internal API used for application un-installation on a device.", + response = Activity.class, tags = "Application Management Administrative Service") @ApiResponses(value = { @ApiResponse( code = 202, - message = "OK. \n Uninstall application operation will be delivered to the provided devices"), + message = "OK. \n Uninstall application operation will be delivered to the provided devices", + response = Activity.class), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java index e669c73dcb..bfa8f3a875 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java @@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Platform; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.exception.UnknownApplicationTypeException; @@ -57,6 +58,7 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem public Response installApplication(ApplicationWrapper applicationWrapper) { ApplicationManager appManagerConnector; Operation operation = null; + Activity activity = null; RequestValidationUtil.validateApplicationInstallationContext(applicationWrapper); try { @@ -72,20 +74,19 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem } } if (applicationWrapper.getRoleNameList() != null && applicationWrapper.getRoleNameList().size() > 0) { - appManagerConnector.installApplicationForUserRoles(operation, applicationWrapper.getRoleNameList()); + activity = appManagerConnector.installApplicationForUserRoles(operation, applicationWrapper.getRoleNameList()); } else if (applicationWrapper.getUserNameList() != null && applicationWrapper.getUserNameList().size() > 0) { - appManagerConnector.installApplicationForUsers(operation, applicationWrapper.getUserNameList()); + activity = appManagerConnector.installApplicationForUsers(operation, applicationWrapper.getUserNameList()); } else if (applicationWrapper.getDeviceIdentifiers() != null && applicationWrapper.getDeviceIdentifiers().size() > 0) { - appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); + activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); } else { throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage( "No application installation criteria i.e. user/role/device is given").build()); } } - return Response.status(Response.Status.ACCEPTED).entity("Application installation request has been sent " + - "to the device(s)").build(); + return Response.status(Response.Status.ACCEPTED).entity(activity).build(); } catch (ApplicationManagementException e) { String msg = "ErrorResponse occurred while processing application installation request"; log.error(msg, e); @@ -105,6 +106,7 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem public Response uninstallApplication(ApplicationWrapper applicationWrapper) { ApplicationManager appManagerConnector; org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation = null; + Activity activity = null; RequestValidationUtil.validateApplicationInstallationContext(applicationWrapper); try { @@ -120,20 +122,19 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem } } if (applicationWrapper.getRoleNameList() != null && applicationWrapper.getRoleNameList().size() > 0) { - appManagerConnector.installApplicationForUserRoles(operation, applicationWrapper.getRoleNameList()); + activity = appManagerConnector.installApplicationForUserRoles(operation, applicationWrapper.getRoleNameList()); } else if (applicationWrapper.getUserNameList() != null && applicationWrapper.getUserNameList().size() > 0) { - appManagerConnector.installApplicationForUsers(operation, applicationWrapper.getUserNameList()); + activity = appManagerConnector.installApplicationForUsers(operation, applicationWrapper.getUserNameList()); } else if (applicationWrapper.getDeviceIdentifiers() != null && applicationWrapper.getDeviceIdentifiers().size() > 0) { - appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); + activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); } else { throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage( "No application un-installation criteria i.e. user/role/device is given").build()); } } - return Response.status(Response.Status.ACCEPTED).entity("Application un-installation request has " + - "been sent to the given device(s)").build(); + return Response.status(Response.Status.ACCEPTED).entity(activity).build(); } catch (ApplicationManagementException e) { String msg = "ErrorResponse occurred while processing application un-installation request"; log.error(msg, e);