From 93d29e064b1259381bdb6c16f4d3cc1b1328c161 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Mon, 27 May 2019 17:57:36 +0530 Subject: [PATCH] Improve APP subscription API --- .../mgt/core/impl/SubscriptionManagerImpl.java | 7 +++++++ .../services/impl/SubscriptionManagementAPIImpl.java | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index ad026e1326..f866b5b5a6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -64,6 +64,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; +import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -93,6 +94,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.debug("Install application which has UUID: " + applicationUUID + " to " + deviceIdentifiers.size() + "devices."); } + if (deviceIdentifiers.isEmpty()){ + String msg = "In order to install application release which has UUID " + applicationUUID + ", you should " + + "provide list of device identifiers. But found an empty list of identifiers."; + log.error(msg); + throw new BadRequestException(msg); + } DeviceManagementProviderService deviceManagementProviderService = HelperUtil .getDeviceManagementProviderService(); ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index 184ac2d87f..a009b83fa9 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -17,17 +17,13 @@ */ package org.wso2.carbon.device.application.mgt.store.api.services.impl; -import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse; -import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponseTmp; -import org.wso2.carbon.device.application.mgt.common.EnterpriseInstallationDetails; import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException; import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import org.wso2.carbon.device.application.mgt.store.api.services.SubscriptionManagementAPI; -import org.wso2.carbon.device.application.mgt.common.InstallationDetails; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; import org.wso2.carbon.device.application.mgt.core.util.APIUtil; @@ -56,12 +52,6 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ public Response installApplicationForDevices( @PathParam("uuid") String uuid, @Valid List deviceIdentifiers) { - if (deviceIdentifiers.isEmpty()){ - String msg = "In order to install application release which has UUID " + uuid + ", you should provide list " - + "of device identifiers. But found an empty list of identifiers."; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } try { SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); ApplicationInstallResponse response = subscriptionManager @@ -121,6 +111,8 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ } } + //todo remove following unwanted APIs + @Override @POST @Path("/install/{uuid}/users")