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));