From c91da9219d3ef5c2e8094bb7f85349681d86f0a6 Mon Sep 17 00:00:00 2001 From: Supun94 Date: Fri, 4 Nov 2016 22:01:51 +0530 Subject: [PATCH] fixed policy conflicts --- .../mgt/core/PolicyManagerServiceImpl.java | 17 ++++++++++++----- .../decision/point/SimpleEvaluationPoint.java | 5 +++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java index da127b70a9..89c244f55a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java @@ -91,11 +91,18 @@ public class PolicyManagerServiceImpl implements PolicyManagerService { @Override public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException { try { - Policy policy = PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint(). - getEffectivePolicy(deviceIdentifier); - - if (policy == null) { - return null; + PolicyEvaluationPoint policyEvaluationPoint = PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint(); + Policy policy; + + if (policyEvaluationPoint != null) { + policy = policyEvaluationPoint. + getEffectivePolicy(deviceIdentifier); + if (policy == null) { + return null; + } + } else { + throw new PolicyEvaluationException("Error occurred while getting the policy evaluation point " + + deviceIdentifier.getId() + " - " + deviceIdentifier.getType()); } List deviceIdentifiers = new ArrayList(); deviceIdentifiers.add(deviceIdentifier); diff --git a/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/SimpleEvaluationPoint.java b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/SimpleEvaluationPoint.java index b2b81076ed..1519fea1c5 100644 --- a/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/SimpleEvaluationPoint.java +++ b/components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/SimpleEvaluationPoint.java @@ -72,6 +72,11 @@ public class SimpleEvaluationPoint implements PolicyEvaluationPoint { @Override public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException { + + if (policyManagerService == null || policyList.size() == 0) { + return null; + } + Policy policy = new Policy(); Profile profile = new Profile(); profile.setProfileFeaturesList(getEffectiveFeatures(deviceIdentifier));