App-mgt store response refactor

4.x.x
amalhub 7 years ago
parent ae80bd8ba8
commit 137d970fc7

@ -31,6 +31,8 @@ import javax.validation.Valid;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Variant;
import java.util.HashMap;
import java.util.List;
/**
@ -45,23 +47,25 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
@Override
public Response installApplication(@ApiParam(name = "installationDetails", value = "The application ID and list" +
" the devices/users/roles", required = true) @Valid InstallationDetails installationDetails) {
Object response;
Object result;
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
try {
String applicationUUTD = installationDetails.getApplicationUUID();
String applicationUUID = installationDetails.getApplicationUUID();
if (!installationDetails.getDeviceIdentifiers().isEmpty()) {
List<DeviceIdentifier> deviceList = installationDetails.getDeviceIdentifiers();
response = subscriptionManager.installApplicationForDevices(applicationUUTD, deviceList);
result = subscriptionManager.installApplicationForDevices(applicationUUID, deviceList);
} else if (!installationDetails.getUserNameList().isEmpty()) {
List<String> userList = installationDetails.getUserNameList();
response = subscriptionManager.installApplicationForUsers(applicationUUTD, userList);
result = subscriptionManager.installApplicationForUsers(applicationUUID, userList);
} else if (!installationDetails.getRoleNameList().isEmpty()) {
List<String> roleList = installationDetails.getRoleNameList();
response = subscriptionManager.installApplicationForRoles(applicationUUTD, roleList);
result = subscriptionManager.installApplicationForRoles(applicationUUID, roleList);
} else {
response = "Missing request data!";
return Response.status(Response.Status.BAD_REQUEST).entity(response).build();
result = "Missing request data!";
return Response.status(Response.Status.BAD_REQUEST).entity(result).build();
}
HashMap<String, Object> response = new HashMap<>();
response.put("failedDevices", result);
return Response.status(Response.Status.OK).entity(response).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while installing the application";

@ -31,7 +31,7 @@ public interface SubscriptionManager {
* To install an application to given list of devices.
* @param applicationUUID Application ID
* @param deviceList Device list
* @return DeviceList which the application has been installed
* @return Failed Device List which the application was unable to install
* @throws ApplicationManagementException Application Management Exception
*/
List<DeviceIdentifier> installApplicationForDevices(String applicationUUID,
@ -42,7 +42,7 @@ public interface SubscriptionManager {
* To install an application to given list of users.
* @param applicationUUID Application ID
* @param userList User list
* @return User list which the application has been installed
* @return Failed User List which the application was unable to install
* @throws ApplicationManagementException Application Management Exception
*/
List<String> installApplicationForUsers(String applicationUUID,
@ -53,7 +53,7 @@ public interface SubscriptionManager {
* To install an application to given list of users.
* @param applicationUUID Application ID
* @param roleList Role list
* @return Role list which the application has been installed
* @return Failed Role List which the application was unable to install
* @throws ApplicationManagementException Application Management Exception
*/
List<String> installApplicationForRoles(String applicationUUID,
@ -64,7 +64,7 @@ public interface SubscriptionManager {
* To uninstall an application from a given list of devices.
* @param applicationUUID Application ID
* @param deviceList Device list
* @return DeviceList which the application has been uninstalled
* @return Failed Device List which the application was unable to uninstall
* @throws ApplicationManagementException Application Management Exception
*/
List<DeviceIdentifier> uninstallApplication(String applicationUUID,

Loading…
Cancel
Save