From 02fb952cc08d614b075a52677f427cafab2aa310 Mon Sep 17 00:00:00 2001 From: Supun94 Date: Thu, 10 Nov 2016 10:51:50 +0530 Subject: [PATCH] Minor refactoring on policy decision point --- .../simple/PolicyEvaluationServiceImpl.java | 16 ++-------------- .../point/simple/SimpleEvaluationImpl.java | 6 ------ .../mgt/core/PolicyManagerServiceImpl.java | 1 - .../internal/PolicyManagementDataHolder.java | 2 -- .../carbon-home/repository/conf/cdm-config.xml | 4 ++-- .../src/main/resources/conf/cdm-config.xml | 4 ++-- 6 files changed, 6 insertions(+), 27 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java index 7229bfc747..24ec30dc84 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java @@ -40,23 +40,11 @@ public class PolicyEvaluationServiceImpl implements PolicyEvaluationPoint { } @Override - public List getEffectiveFeatures(List policyList, DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException { + public List getEffectiveFeatures(List policyList, DeviceIdentifier deviceIdentifier) + throws PolicyEvaluationException { List effectiveFeatures = evaluation.getEffectivePolicy(deviceIdentifier). getProfile().getProfileFeaturesList(); - -/* PolicyOperation policyOperation = new PolicyOperation(); - - List profileOperationList = new ArrayList(); - for (ProfileFeature feature : effectiveFeatures) { - ProfileOperation operation = new ProfileOperation(); - - operation.setCode(feature.getFeatureCode()); - operation.setPayLoad(feature.getContent()); - profileOperationList.add(operation); - } - policyOperation.setProfileOperations(profileOperationList); - policyOperation.setCode(PolicyManagementConstants.POLICY_BUNDLE);*/ return effectiveFeatures; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java index aa1d02e58f..f8c75e3105 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java @@ -32,14 +32,9 @@ import java.util.List; public class SimpleEvaluationImpl implements SimpleEvaluation { private static final Log log = LogFactory.getLog(SimpleEvaluationImpl.class); - //TODO : to revove the stale reference private PolicyManagerService policyManagerService; private List policyList = new ArrayList(); -// public SimpleEvaluationImpl() { -// policyManagerService = PolicyDecisionPointDataHolder.getInstance().getPolicyManagerService(); -// } - @Override public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException { Policy policy = new Policy(); @@ -74,7 +69,6 @@ public class SimpleEvaluationImpl implements SimpleEvaluation { return policy; } - @Override public void sortPolicies() throws PolicyEvaluationException { Collections.sort(policyList); 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 24659bb421..1cd88a72d0 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 @@ -173,7 +173,6 @@ public class PolicyManagerServiceImpl implements PolicyManagerService { @Override public PolicyEvaluationPoint getPEP() throws PolicyManagementException { - PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint(); return PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint(); } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java index f089d81185..5809468694 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java @@ -99,12 +99,10 @@ public class PolicyManagementDataHolder { public void putPolicyEvaluationPoint(String name, PolicyEvaluationPoint policyEvaluationPoint) { policyEvaluationPoints.put(name,policyEvaluationPoint); -// this.policyEvaluationPoint = policyEvaluationPoint; } public void removePolicyEvaluationPoint(PolicyEvaluationPoint policyEvaluationPoint) { policyEvaluationPoints.put(policyEvaluationPoint.getName(), this.policyEvaluationPoint); -// this.policyEvaluationPoint = policyEvaluationPoint; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml index 5dbad500c4..559cc3edd5 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -42,8 +42,8 @@ 5 8 20 - SimplePolicyEvaluationServiceComponent - + + MergedPolicyEvaluationServiceComponent diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index d115d0b74f..9e326a4f03 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -43,8 +43,8 @@ 5 8 20 - SimplePolicyEvaluationServiceComponent - + + MergedPolicyEvaluationServiceComponent android ios