From f0669887fb427968dfc8d2ff76258408941044b5 Mon Sep 17 00:00:00 2001 From: Kasun Delgolla Date: Wed, 16 Dec 2015 14:40:44 +0530 Subject: [PATCH] Committing policy compliance monitoring issue --- .../android/AndroidPolicyMonitoringService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java index 6a03fa962..0a87cd668 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java @@ -62,14 +62,16 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { return complianceData; } List complianceFeatures = new ArrayList(); - + List nonComplianceFeatures = new ArrayList<>(); + String compliancePayloadString = new Gson().toJson(compliancePayload); // Parsing json string to get compliance features. JsonElement jsonElement; - if (compliancePayload instanceof String) { - jsonElement = new JsonParser().parse((String) compliancePayload); + if (compliancePayloadString instanceof String) { + jsonElement = new JsonParser().parse(compliancePayloadString); } else { throw new PolicyComplianceException("Invalid policy compliance payload"); } + JsonArray jsonArray = jsonElement.getAsJsonArray(); Gson gson = new Gson(); ComplianceFeature complianceFeature; @@ -79,14 +81,15 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { complianceFeatures.add(complianceFeature); } - complianceData.setComplianceFeatures(complianceFeatures); - for (ComplianceFeature cf : complianceFeatures) { if (!cf.isCompliant()) { complianceData.setStatus(false); + nonComplianceFeatures.add(cf); break; } } + + complianceData.setComplianceFeatures(nonComplianceFeatures); return complianceData; }