From 20ca76640d7fd58d2f5fa58488d861cbe59ae1af Mon Sep 17 00:00:00 2001 From: geethkokila Date: Thu, 1 Dec 2016 16:35:59 +0530 Subject: [PATCH] Adding changes for the grouping and ownership changes --- .../wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java | 7 +++++-- .../policy/mgt/core/impl/PolicyInformationPointImpl.java | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java index bb2edf3586..18cf7a1560 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java @@ -76,7 +76,7 @@ public class PolicyFilterImpl implements PolicyFilter { continue; } else { for (DeviceGroupWrapper deviceGroupWrapper : wrappers) { - if (groupMap.containsKey(deviceGroupWrapper.getId()) && policyMap.containsKey(policy.getId())) { + if (groupMap.containsKey(deviceGroupWrapper.getId()) && !policyMap.containsKey(policy.getId())) { temp.add(policy); policyMap.put(policy.getId(), policy); } @@ -140,6 +140,9 @@ public class PolicyFilterImpl implements PolicyFilter { @Override public List filterOwnershipTypeBasedPolicies(String ownershipType, List policies) { + if (ownershipType == null) { + return policies; + } if (log.isDebugEnabled()) { log.debug("No of policies went in to filterOwnershipTypeBasedPolicies : " + policies.size()); log.debug("Ownership type : " + ownershipType); @@ -150,7 +153,7 @@ public class PolicyFilterImpl implements PolicyFilter { List temp = new ArrayList(); for (Policy policy : policies) { - if (ownershipType.equalsIgnoreCase(policy.getOwnershipType()) || + if (policy.getOwnershipType() == null || ownershipType.equalsIgnoreCase(policy.getOwnershipType()) || PolicyManagementConstants.ANY.equalsIgnoreCase(policy.getOwnershipType())) { temp.add(policy); } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java index 4da09fbb09..d39822cb2c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java @@ -128,6 +128,12 @@ public class PolicyInformationPointImpl implements PolicyInformationPoint { } if (pipDevice.getDeviceGroups() != null && !pipDevice.getDeviceGroups().isEmpty()) { + Map groupMap = new HashMap<>(); + List groups = pipDevice.getDeviceGroups(); + for(DeviceGroup gr: groups){ + groupMap.put(gr.getGroupId(), gr); + } + policies = policyFilter.filterDeviceGroupsPolicies(groupMap, policies); } if (log.isDebugEnabled()) {