Fixing the applicationMgtAdminService for returing activity

revert-70aa11f8
geethkokila 9 years ago
parent fbf213f77c
commit 3defcfe20d

@ -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.",

@ -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);

Loading…
Cancel
Save