|
|
@ -18,16 +18,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.wso2.carbon.device.application.mgt.store.api.services.impl.admin;
|
|
|
|
package org.wso2.carbon.device.application.mgt.store.api.services.impl.admin;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
|
|
import org.apache.http.HttpStatus;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
|
|
|
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.common.services.SubscriptionManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
|
|
|
|
import org.wso2.carbon.device.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI;
|
|
|
|
import org.wso2.carbon.device.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.Size;
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
import javax.ws.rs.DefaultValue;
|
|
|
|
import javax.ws.rs.DefaultValue;
|
|
|
|
import javax.ws.rs.GET;
|
|
|
|
import javax.ws.rs.GET;
|
|
|
@ -36,6 +41,7 @@ import javax.ws.rs.PathParam;
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Implementation of Subscription Management related APIs.
|
|
|
|
* Implementation of Subscription Management related APIs.
|
|
|
@ -51,6 +57,10 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
|
|
|
|
@Produces("application/json")
|
|
|
|
@Produces("application/json")
|
|
|
|
@Path("/{uuid}")
|
|
|
|
@Path("/{uuid}")
|
|
|
|
public Response getAppInstalledDevices(
|
|
|
|
public Response getAppInstalledDevices(
|
|
|
|
|
|
|
|
@QueryParam("name") String name,
|
|
|
|
|
|
|
|
@QueryParam("user") String user,
|
|
|
|
|
|
|
|
@QueryParam("actionStatus") String actionStatus,
|
|
|
|
|
|
|
|
@QueryParam("status") List<String> status,
|
|
|
|
@PathParam("uuid") String uuid,
|
|
|
|
@PathParam("uuid") String uuid,
|
|
|
|
@DefaultValue("0")
|
|
|
|
@DefaultValue("0")
|
|
|
|
@QueryParam("offset") int offset,
|
|
|
|
@QueryParam("offset") int offset,
|
|
|
@ -58,9 +68,48 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
|
|
|
|
@QueryParam("limit") int limit) {
|
|
|
|
@QueryParam("limit") int limit) {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
PaginationRequest request = new PaginationRequest(offset, limit);
|
|
|
|
|
|
|
|
if (name != null && !name.isEmpty()) {
|
|
|
|
|
|
|
|
request.setDeviceName(name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (user != null && !user.isEmpty()) {
|
|
|
|
|
|
|
|
request.setOwner(user);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (status != null && !status.isEmpty()) {
|
|
|
|
|
|
|
|
// boolean isStatusEmpty = true;
|
|
|
|
|
|
|
|
// for (String statusString : status){
|
|
|
|
|
|
|
|
// if (StringUtils.isNotBlank(statusString)){
|
|
|
|
|
|
|
|
// isStatusEmpty = false;
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (!isStatusEmpty) {
|
|
|
|
|
|
|
|
// for (String status_ : status) {
|
|
|
|
|
|
|
|
// switch (status_) {
|
|
|
|
|
|
|
|
// case "ACTIVE":
|
|
|
|
|
|
|
|
// case "INACTIVE":
|
|
|
|
|
|
|
|
// case "UNCLAIMED":
|
|
|
|
|
|
|
|
// case "UNREACHABLE":
|
|
|
|
|
|
|
|
// case "SUSPENDED":
|
|
|
|
|
|
|
|
// case "DISENROLLMENT_REQUESTED":
|
|
|
|
|
|
|
|
// case "REMOVED":
|
|
|
|
|
|
|
|
// case "BLOCKED":
|
|
|
|
|
|
|
|
// case "CREATED":
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// default:
|
|
|
|
|
|
|
|
// String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types are " +
|
|
|
|
|
|
|
|
// "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " +
|
|
|
|
|
|
|
|
// "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED";
|
|
|
|
|
|
|
|
// log.error(msg);
|
|
|
|
|
|
|
|
// return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// request.setStatusList(status);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
|
|
|
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
|
|
|
PaginationResult subscriptionData = subscriptionManager
|
|
|
|
PaginationResult subscriptionData = subscriptionManager
|
|
|
|
.getAppSubscriptionDetails(offset, limit, uuid);
|
|
|
|
.getAppSubscriptionDetails(request, uuid, status, actionStatus);
|
|
|
|
return Response.status(Response.Status.OK).entity(subscriptionData).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(subscriptionData).build();
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
} catch (NotFoundException e) {
|
|
|
|
String msg = "Application with application release UUID: " + uuid + " is not found";
|
|
|
|
String msg = "Application with application release UUID: " + uuid + " is not found";
|
|
|
|