Code modified

revert-70ac1926
MalshaPiumini 4 years ago
parent c2940a4568
commit 605168e770

@ -133,8 +133,7 @@ public interface SubscriptionManager {
* @return deviceDetails - device details for given application release.
* @throws {@link ApplicationManagementException} Exception of the application management
*/
PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID,
List<String> status) throws ApplicationManagementException;
PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID) throws ApplicationManagementException;
/***
* This method used to get category details.
@ -153,7 +152,6 @@ public interface SubscriptionManager {
* This method is responsible to provide application subscription data for given application release UUID.
*
* @param request paginated request object.
* @param status status of the devices.
* @param actionStatus status of the operation.
* @param appUUID application release UUID
* @return {@link PaginationResult}
@ -161,6 +159,6 @@ public interface SubscriptionManager {
* application release for given UUID, if an error occurred while getting device details of subscribed device ids,
* if an error occurred while getting subscription details of given application release UUID.
*/
PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, List<String> status,String actionStatus)
PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus)
throws ApplicationManagementException;
}

@ -1219,7 +1219,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@Override
public PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID, List<String> status)
public PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID)
throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
@ -1259,7 +1259,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
//pass the device id list to device manager service method
try {
PaginationResult deviceDetails = deviceManagementProviderService.getAppSubscribedDevices
(request, deviceIdList, status);
(request, deviceIdList);
if (deviceDetails == null) {
String msg = "Couldn't found an subscribed devices details for device ids: " + deviceIdList;
@ -1338,7 +1338,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@Override
public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, List<String> status,String actionStatus)
public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus)
throws ApplicationManagementException {
int limitValue = request.getRowCount();
int offsetValue = request.getStartIndex();
@ -1375,8 +1375,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
.collect(Collectors.toList());
try {
//pass the device id list to device manager service method
PaginationResult paginationResult = deviceManagementProviderService
.getAppSubscribedDevices(request, deviceIdList, status);
PaginationResult paginationResult = deviceManagementProviderService.getAppSubscribedDevices
(request, deviceIdList);
List<DeviceSubscriptionData> deviceSubscriptionDataList = new ArrayList<>();
if (!paginationResult.getData().isEmpty()) {

@ -295,39 +295,39 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
if (ownership != null && !ownership.isEmpty()) {
request.setOwnership(ownership);
}
// 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);
// }
// }
PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid, status);
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);
}
}
PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid);
DeviceList devices = new DeviceList();
devices.setList((List<Device>) subscribedDeviceDetails.getData());
devices.setCount(subscribedDeviceDetails.getRecordsTotal());

@ -75,41 +75,62 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
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);
// }
// }
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);
}
}
if (actionStatus != null && !actionStatus.isEmpty()) {
if (StringUtils.isNotBlank(actionStatus)) {
switch (actionStatus) {
case "PENDING":
case "ERROR":
case "IN_PROGRESS":
case "NOTNOW":
case "COMPLETED":
case "REPEATED":
break;
default:
String msg = "Invalid enrollment action status type: " + actionStatus + ". " +
"\nValid action status types are PENDING | ERROR | IN_PROGRESS | NOTNOW | " +
"COMPLETED | REPEATED";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
}
}
}
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
PaginationResult subscriptionData = subscriptionManager
.getAppSubscriptionDetails(request, uuid, status, actionStatus);
PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails
(request, uuid, actionStatus);
return Response.status(Response.Status.OK).entity(subscriptionData).build();
} catch (NotFoundException e) {
String msg = "Application with application release UUID: " + uuid + " is not found";

@ -654,12 +654,11 @@ public interface DeviceDAO {
* @param deviceIds device ids of the subscribed devices.
* @param tenantId Id of the current tenant.
* @param request paginated request object.
* @param status status of the devices.
* @return devices - subscribed device details list
* @throws DeviceManagementDAOException if connections establishment fails.
*/
List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId,
List<String> status) throws DeviceManagementDAOException;
List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
throws DeviceManagementDAOException;
/**
* @param deviceIds device ids of the subscribed devices.

@ -877,12 +877,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
}
@Override
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId,
List<String> status)
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
int limitValue = request.getRowCount();
int offsetValue = request.getStartIndex();
List<String> status = request.getStatusList();
String name = request.getDeviceName();
String user = request.getOwner();
String ownership = request.getOwnership();

@ -847,12 +847,12 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
}
@Override
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId,
List<String> status)
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
int limitValue = request.getRowCount();
int offsetValue = request.getStartIndex();
List<String> status = request.getStatusList();
String name = request.getDeviceName();
String user = request.getOwner();
String ownership = request.getOwnership();

@ -827,12 +827,12 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
}
@Override
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId,
List<String> status)
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
int limitValue = request.getRowCount();
int offsetValue = request.getStartIndex();
List<String> status = request.getStatusList();
String name = request.getDeviceName();
String user = request.getOwner();
String ownership = request.getOwnership();

@ -693,12 +693,12 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
}
@Override
public List<Device> getSubscribedDevices(PaginationRequest request,
List<Integer> deviceIds, int tenantId, List<String> status)
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
throws DeviceManagementDAOException {
Connection conn;
int limitValue = request.getRowCount();
int offsetValue = request.getStartIndex();
List<String> status = request.getStatusList();
String name = request.getDeviceName();
String user = request.getOwner();
String ownership = request.getOwnership();

@ -910,7 +910,7 @@ public interface DeviceManagementProviderService {
* @return {@link PaginationResult}
* @throws DeviceManagementException if any service level or DAO level error occurs.
*/
PaginationResult getAppSubscribedDevices(PaginationRequest request, List<Integer> devicesIds, List<String> status)
PaginationResult getAppSubscribedDevices(PaginationRequest request, List<Integer> devicesIds)
throws DeviceManagementException;
/**

@ -4156,8 +4156,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
@Override
public PaginationResult getAppSubscribedDevices(PaginationRequest request, List<Integer> devicesIds,
List<String> status) throws DeviceManagementException {
public PaginationResult getAppSubscribedDevices(PaginationRequest request, List<Integer> devicesIds) throws DeviceManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (log.isDebugEnabled()) {
log.debug("Getting all devices details for device ids: " + devicesIds);
@ -4166,14 +4165,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
List<Device> subscribedDeviceDetails;
try {
DeviceManagementDAOFactory.openConnection();
subscribedDeviceDetails = deviceDAO.getSubscribedDevices(request, devicesIds, tenantId, status);
subscribedDeviceDetails = deviceDAO.getSubscribedDevices(request, devicesIds, tenantId);
if (subscribedDeviceDetails.isEmpty()) {
paginationResult.setData(new ArrayList<>());
paginationResult.setRecordsFiltered(0);
paginationResult.setRecordsTotal(0);
return paginationResult;
}
int count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, status);
int count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, request.getStatusList());
paginationResult.setRecordsFiltered(count);
paginationResult.setRecordsTotal(count);
} catch (DeviceManagementDAOException e) {

Loading…
Cancel
Save