From 2505d4907a0ea49761412bf7aff43d1053a45711 Mon Sep 17 00:00:00 2001 From: kamidu Date: Fri, 29 Dec 2017 10:33:03 +0530 Subject: [PATCH 1/4] Fixing https://github.com/wso2/product-iots/issues/1565 --- .../config/policy/PolicyConfiguration.java | 10 +++ .../mgt/core/enforcement/DelegationTask.java | 9 ++- .../impl/PolicyAdministratorPointImpl.java | 62 ++++++++++++++----- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 49 ++++++++++++--- .../repository/conf/cdm-config.xml | 1 + 5 files changed, 107 insertions(+), 24 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java index 1f52150f3f7..0e85e9d10cf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java @@ -34,6 +34,7 @@ public class PolicyConfiguration { private int minRetriesToMarkInactive; private List platforms; private String policyEvaluationPoint; + private boolean cacheEnable; @XmlElement(name = "MonitoringClass", required = true) public String getMonitoringClass() { @@ -108,4 +109,13 @@ public class PolicyConfiguration { this.policyEvaluationPoint = policyEvaluationPointName; } + @XmlElement(name = "CacheEnable", required = true) + public boolean getCacheEnable() { + return cacheEnable; + } + + public void setCacheEnable(boolean cacheEnable) { + this.cacheEnable = cacheEnable; + } + } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java index bd014817ffa..e941312da1d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java @@ -23,6 +23,8 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ntask.core.Task; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; @@ -39,6 +41,7 @@ import java.util.Map; public class DelegationTask implements Task { private static final Log log = LogFactory.getLog(DelegationTask.class); + private PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration(); @Override public void setProperties(Map map) { @@ -57,9 +60,9 @@ public class DelegationTask implements Task { PolicyManager policyManager = new PolicyManagerImpl(); UpdatedPolicyDeviceListBean updatedPolicyDeviceList = policyManager.applyChangesMadeToPolicies(); List deviceTypes = updatedPolicyDeviceList.getChangedDeviceTypes(); - - PolicyCacheManagerImpl.getInstance().rePopulateCache(); - + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } if (log.isDebugEnabled()) { log.debug("Number of device types which policies are changed .......... : " + deviceTypes.size()); } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index d595a3c4eb3..9cbd11aefce 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -24,6 +24,8 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; @@ -53,6 +55,7 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { private ProfileManager profileManager; private FeatureManager featureManager; private PolicyCacheManager cacheManager; + private PolicyConfiguration policyConfiguration; // private PolicyEnforcementDelegator delegator; public PolicyAdministratorPointImpl() { @@ -60,6 +63,7 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { this.profileManager = new ProfileManagerImpl(); this.featureManager = new FeatureManagerImpl(); this.cacheManager = PolicyCacheManagerImpl.getInstance(); + this.policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration(); // this.delegator = new PolicyEnforcementDelegatorImpl(); } @@ -71,7 +75,9 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { // } catch (PolicyDelegationException e) { // throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e); // } - PolicyCacheManagerImpl.getInstance().rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } return resultantPolicy; } @@ -83,42 +89,54 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { // } catch (PolicyDelegationException e) { // throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e); // } - PolicyCacheManagerImpl.getInstance().rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } return resultantPolicy; } @Override public boolean updatePolicyPriorities(List policies) throws PolicyManagementException { boolean bool = policyManager.updatePolicyPriorities(policies); - PolicyCacheManagerImpl.getInstance().rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } return bool; } @Override public void activatePolicy(int policyId) throws PolicyManagementException { policyManager.activatePolicy(policyId); - PolicyCacheManagerImpl.getInstance().rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } } @Override public void inactivatePolicy(int policyId) throws PolicyManagementException { policyManager.inactivatePolicy(policyId); - PolicyCacheManagerImpl.getInstance().rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } } @Override public boolean deletePolicy(Policy policy) throws PolicyManagementException { boolean bool = policyManager.deletePolicy(policy); - PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance(); - policyCacheManager.rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance(); + policyCacheManager.rePopulateCache(); + } return bool; } @Override public boolean deletePolicy(int policyId) throws PolicyManagementException { boolean bool = policyManager.deletePolicy(policyId); - PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance(); - policyCacheManager.rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance(); + policyCacheManager.rePopulateCache(); + } return bool; } @@ -222,25 +240,37 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { public Policy addPolicyToDevice(List deviceIdentifierList, Policy policy) throws PolicyManagementException { policy = policyManager.addPolicyToDevice(deviceIdentifierList, policy); - PolicyCacheManagerImpl.getInstance().rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } return policy; } @Override public Policy addPolicyToRole(List roleNames, Policy policy) throws PolicyManagementException { policy = policyManager.addPolicyToRole(roleNames, policy); - PolicyCacheManagerImpl.getInstance().rePopulateCache(); + if (policyConfiguration.getCacheEnable()) { + PolicyCacheManagerImpl.getInstance().rePopulateCache(); + } return policy; } @Override public List getPolicies() throws PolicyManagementException { - return PolicyCacheManagerImpl.getInstance().getAllPolicies(); + if (policyConfiguration.getCacheEnable()) { + return PolicyCacheManagerImpl.getInstance().getAllPolicies(); + } else { + return policyManager.getPolicies(); + } } @Override public Policy getPolicy(int policyId) throws PolicyManagementException { - return PolicyCacheManagerImpl.getInstance().getPolicy(policyId); + if (policyConfiguration.getCacheEnable()) { + return PolicyCacheManagerImpl.getInstance().getPolicy(policyId); + } else { + return policyManager.getPolicy(policyId); + } } @Override @@ -340,7 +370,11 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { @Override public int getPolicyCount() throws PolicyManagementException { - return PolicyCacheManagerImpl.getInstance().getAllPolicies().size(); + if (policyConfiguration.getCacheEnable()) { + return PolicyCacheManagerImpl.getInstance().getAllPolicies().size(); + } else { + return policyManager.getPolicyCount(); + } } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 79626eb4854..e00e1adcc9b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -33,6 +33,8 @@ import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion; import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; @@ -58,16 +60,20 @@ import java.util.*; public class PolicyManagerImpl implements PolicyManager { private PolicyDAO policyDAO; + private PolicyManager policyManager; private ProfileDAO profileDAO; private FeatureDAO featureDAO; private ProfileManager profileManager; + private PolicyConfiguration policyConfiguration; private static Log log = LogFactory.getLog(PolicyManagerImpl.class); public PolicyManagerImpl() { this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); this.profileDAO = PolicyManagementDAOFactory.getProfileDAO(); this.featureDAO = PolicyManagementDAOFactory.getFeatureDAO(); + this.policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration(); this.profileManager = new ProfileManagerImpl(); + this.policyManager = new PolicyManagerImpl(); } @Override @@ -272,7 +278,12 @@ public class PolicyManagerImpl implements PolicyManager { boolean bool; try { // List existingPolicies = this.getPolicies(); - List existingPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + List existingPolicies; + if (policyConfiguration.getCacheEnable()) { + existingPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + } else { + existingPolicies = policyManager.getPolicies(); + } PolicyManagementDAOFactory.beginTransaction(); bool = policyDAO.updatePolicyPriorities(policies); @@ -683,7 +694,12 @@ public class PolicyManagerImpl implements PolicyManager { } // List tempPolicyList = this.getPolicies(); - List tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + List tempPolicyList; + if (policyConfiguration.getCacheEnable()) { + tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + } else { + tempPolicyList = policyManager.getPolicies(); + } for (Policy policy : tempPolicyList) { for (Integer i : policyIdList) { @@ -703,7 +719,12 @@ public class PolicyManagerImpl implements PolicyManager { // try { // List profileList = profileManager.getProfilesOfDeviceType(deviceTypeName); // List allPolicies = this.getPolicies(); - List allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + List allPolicies; + if (policyConfiguration.getCacheEnable()) { + allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + } else { + allPolicies = policyManager.getPolicies(); + } for (Policy policy : allPolicies) { if (policy.getProfile().getDeviceType().equalsIgnoreCase(deviceTypeName)) { @@ -745,7 +766,12 @@ public class PolicyManagerImpl implements PolicyManager { } // List tempPolicyList = this.getPolicies(); - List tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + List tempPolicyList; + if (policyConfiguration.getCacheEnable()) { + tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + } else { + tempPolicyList = policyManager.getPolicies(); + } for (Policy policy : tempPolicyList) { for (Integer i : policyIdList) { @@ -775,7 +801,12 @@ public class PolicyManagerImpl implements PolicyManager { PolicyManagementDAOFactory.closeConnection(); } // List tempPolicyList = this.getPolicies(); - List tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + List tempPolicyList; + if (policyConfiguration.getCacheEnable()) { + tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + } else { + tempPolicyList = policyManager.getPolicies(); + } for (Policy policy : tempPolicyList) { for (Integer i : policyIdList) { @@ -868,8 +899,12 @@ public class PolicyManagerImpl implements PolicyManager { // List inactivePolicies = new ArrayList<>(); // List allPolicies = this.getPolicies(); - List allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); - + List allPolicies; + if (policyConfiguration.getCacheEnable()) { + allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); + } else { + allPolicies = policyDAO.getAllPolicies(); + } for (Policy policy : allPolicies) { if (policy.isUpdated()) { updatedPolicies.add(policy); diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml index 7306778af1e..e3075334ee5 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -49,6 +49,7 @@ org.wso2.carbon.policy.mgt true + true 60000 5 8 From 33b27234a0bfa4e2760937b4d4502128d0bc5fcf Mon Sep 17 00:00:00 2001 From: kamidu Date: Wed, 3 Jan 2018 15:03:08 +0530 Subject: [PATCH 2/4] Enable the new configuration for testing --- .../carbon-home/repository/conf/cdm-config.xml | 1 + .../carbon-home/repository/conf/cdm-config.xml | 1 + .../resources/config/operation/cdm-config.xml | 1 + .../carbon-home/repository/conf/cdm-config.xml | 1 + .../mgt/core/mgt/impl/PolicyManagerImpl.java | 15 +++++---------- .../carbon-home/repository/conf/cdm-config.xml | 1 + .../src/main/resources/conf/cdm-config.xml | 1 + 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml index bc996646e14..9a71d330b0e 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -39,6 +39,7 @@ org.wso2.carbon.policy.mgt true + true 60000 5 8 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml index ff6b302002b..a6fac0d5a7f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -49,6 +49,7 @@ org.wso2.carbon.policy.mgt true + true 60000 5 8 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml index d4e1acb1397..4e72c2a0788 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml @@ -49,6 +49,7 @@ org.wso2.carbon.policy.mgt true + true 60000 5 8 diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml index bc48130dd52..a6e56949b83 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -54,6 +54,7 @@ org.wso2.carbon.policy.mgt true + true 60000 5 8 diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index e00e1adcc9b..7f4f48415fb 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -44,9 +44,6 @@ import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImp import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.core.cache.impl.PolicyCacheManagerImpl; import org.wso2.carbon.policy.mgt.core.dao.*; -import org.wso2.carbon.policy.mgt.core.enforcement.PolicyDelegationException; -import org.wso2.carbon.policy.mgt.core.enforcement.PolicyEnforcementDelegator; -import org.wso2.carbon.policy.mgt.core.enforcement.PolicyEnforcementDelegatorImpl; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager; @@ -60,7 +57,6 @@ import java.util.*; public class PolicyManagerImpl implements PolicyManager { private PolicyDAO policyDAO; - private PolicyManager policyManager; private ProfileDAO profileDAO; private FeatureDAO featureDAO; private ProfileManager profileManager; @@ -73,7 +69,6 @@ public class PolicyManagerImpl implements PolicyManager { this.featureDAO = PolicyManagementDAOFactory.getFeatureDAO(); this.policyConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration(); this.profileManager = new ProfileManagerImpl(); - this.policyManager = new PolicyManagerImpl(); } @Override @@ -282,7 +277,7 @@ public class PolicyManagerImpl implements PolicyManager { if (policyConfiguration.getCacheEnable()) { existingPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); } else { - existingPolicies = policyManager.getPolicies(); + existingPolicies = this.getPolicies(); } PolicyManagementDAOFactory.beginTransaction(); bool = policyDAO.updatePolicyPriorities(policies); @@ -698,7 +693,7 @@ public class PolicyManagerImpl implements PolicyManager { if (policyConfiguration.getCacheEnable()) { tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); } else { - tempPolicyList = policyManager.getPolicies(); + tempPolicyList = this.getPolicies(); } for (Policy policy : tempPolicyList) { @@ -723,7 +718,7 @@ public class PolicyManagerImpl implements PolicyManager { if (policyConfiguration.getCacheEnable()) { allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); } else { - allPolicies = policyManager.getPolicies(); + allPolicies = this.getPolicies(); } for (Policy policy : allPolicies) { @@ -770,7 +765,7 @@ public class PolicyManagerImpl implements PolicyManager { if (policyConfiguration.getCacheEnable()) { tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); } else { - tempPolicyList = policyManager.getPolicies(); + tempPolicyList = this.getPolicies(); } for (Policy policy : tempPolicyList) { @@ -805,7 +800,7 @@ public class PolicyManagerImpl implements PolicyManager { if (policyConfiguration.getCacheEnable()) { tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies(); } else { - tempPolicyList = policyManager.getPolicies(); + tempPolicyList = this.getPolicies(); } for (Policy policy : tempPolicyList) { 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 df960ed64ec..9213b378270 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 @@ -39,6 +39,7 @@ org.wso2.carbon.policy.mgt true + true 60000 5 8 diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index 81dd4812194..59ce0c0c9af 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -54,6 +54,7 @@ org.wso2.carbon.policy.mgt true + true 60000 5 8 From 6daf95b78d77199b8f71788854ab7a42cace9097 Mon Sep 17 00:00:00 2001 From: kamidu Date: Wed, 3 Jan 2018 16:27:09 +0530 Subject: [PATCH 3/4] Change the config placement for improve the separatability --- .../test/resources/carbon-home/repository/conf/cdm-config.xml | 2 +- .../test/resources/carbon-home/repository/conf/cdm-config.xml | 2 +- .../src/test/resources/config/operation/cdm-config.xml | 2 +- .../test/resources/carbon-home/repository/conf/cdm-config.xml | 2 +- .../test/resources/carbon-home/repository/conf/cdm-config.xml | 2 +- .../test/resources/carbon-home/repository/conf/cdm-config.xml | 2 +- .../src/main/resources/conf/cdm-config.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml index 9a71d330b0e..37dbaed8cd0 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -39,13 +39,13 @@ org.wso2.carbon.policy.mgt true - true 60000 5 8 20 Simple + true diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml index a6fac0d5a7f..fa199542e56 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -49,7 +49,6 @@ org.wso2.carbon.policy.mgt true - true 60000 5 8 @@ -58,6 +57,7 @@ Simple + true diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml index 4e72c2a0788..64b646890b1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/config/operation/cdm-config.xml @@ -49,7 +49,6 @@ org.wso2.carbon.policy.mgt true - true 60000 5 8 @@ -58,6 +57,7 @@ Simple + true diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml index a6e56949b83..9d3e2828074 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -54,7 +54,6 @@ org.wso2.carbon.policy.mgt true - true 60000 5 8 @@ -63,6 +62,7 @@ Simple + true 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 9213b378270..c84ae10bba1 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 @@ -39,13 +39,13 @@ org.wso2.carbon.policy.mgt true - true 60000 5 8 20 Simple + true diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml index e3075334ee5..ea0f23c08ea 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -49,7 +49,6 @@ org.wso2.carbon.policy.mgt true - true 60000 5 8 @@ -58,6 +57,7 @@ Simple + true diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index 59ce0c0c9af..e17b5c5839a 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -54,7 +54,6 @@ org.wso2.carbon.policy.mgt true - true 60000 5 8 @@ -63,6 +62,7 @@ Simple + true From 09f395660adf70c72a9de3394ee0458e4aa1cee5 Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 4 Jan 2018 12:38:17 +0530 Subject: [PATCH 4/4] Fixing the DAO layer acess to maintain the consistancy on implimentation --- .../wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 7f4f48415fb..a656b66ea85 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -898,7 +898,7 @@ public class PolicyManagerImpl implements PolicyManager { if (policyConfiguration.getCacheEnable()) { allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies(); } else { - allPolicies = policyDAO.getAllPolicies(); + allPolicies = this.getPolicies(); } for (Policy policy : allPolicies) { if (policy.isUpdated()) {