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 bb2edf3586c..18cf7a15601 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 4da09fbb099..d39822cb2c7 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()) {