mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
This commit is contained in:
commit
0fe827ca9f
@ -221,14 +221,22 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
RequestValidationUtil.validatePolicyIds(policyIds);
|
RequestValidationUtil.validatePolicyIds(policyIds);
|
||||||
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
||||||
boolean policyDeleted = true;
|
boolean policyDeleted = true;
|
||||||
|
String invalidPolicyIds = "";
|
||||||
try {
|
try {
|
||||||
PolicyAdministratorPoint pap = policyManagementService.getPAP();
|
PolicyAdministratorPoint pap = policyManagementService.getPAP();
|
||||||
for (int i : policyIds) {
|
for (int i : policyIds) {
|
||||||
Policy policy = pap.getPolicy(i);
|
Policy policy = pap.getPolicy(i);
|
||||||
if (policy == null || !pap.deletePolicy(policy)) {
|
if (policy == null) {
|
||||||
|
invalidPolicyIds += i + ",";
|
||||||
policyDeleted = false;
|
policyDeleted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(policyDeleted) {
|
||||||
|
for(int i : policyIds) {
|
||||||
|
Policy policy = pap.getPolicy(i);
|
||||||
|
pap.deletePolicy(policy);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "ErrorResponse occurred while removing policies";
|
String msg = "ErrorResponse occurred while removing policies";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
@ -239,8 +247,10 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
return Response.status(Response.Status.OK).entity("Policies have been successfully deleted").build();
|
return Response.status(Response.Status.OK).entity("Policies have been successfully deleted").build();
|
||||||
} else {
|
} else {
|
||||||
//TODO:Check of this logic is correct
|
//TODO:Check of this logic is correct
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity(
|
String ModifiedInvalidPolicyIds = invalidPolicyIds.substring(0, invalidPolicyIds.length()-1);
|
||||||
new ErrorResponse.ErrorResponseBuilder().setMessage("Policy doesn't exist").build()).build();
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Policies with the policy ID " +
|
||||||
|
ModifiedInvalidPolicyIds + " doesn't exist").build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -420,7 +420,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
|||||||
"ON feom.OPERATION_ID = o.ID LEFT OUTER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, " +
|
"ON feom.OPERATION_ID = o.ID LEFT OUTER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, " +
|
||||||
"OPERATION_RESPONSE, MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP " +
|
"OPERATION_RESPONSE, MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP " +
|
||||||
"FROM DM_DEVICE_OPERATION_RESPONSE GROUP BY ENROLMENT_ID , OPERATION_ID) orsp " +
|
"FROM DM_DEVICE_OPERATION_RESPONSE GROUP BY ENROLMENT_ID , OPERATION_ID) orsp " +
|
||||||
"ON o.ID = orsp.OPERATION_ID AND feom.ENROLMENT_ID = orsp.ENROLMENT_ID GROUP BY feom.ENROLMENT_ID";
|
"ON o.ID = orsp.OPERATION_ID AND feom.ENROLMENT_ID = orsp.ENROLMENT_ID GROUP BY feom.ENROLMENT_ID, " +
|
||||||
|
"feom.OPERATION_ID";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user