From dff526b27237cf52d1a9f70f75bd6664c2c8b4b9 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Wed, 2 Sep 2015 15:02:33 +0530 Subject: [PATCH] Removing the unnessary commets and imports --- .../cache/impl/PolicyCacheManagerImpl.java | 107 ------------------ .../mgt/core/util/PolicyManagerUtil.java | 4 - 2 files changed, 111 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java index 28096de9c1..624b5ac9d4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java @@ -21,7 +21,6 @@ package org.wso2.carbon.policy.mgt.core.cache.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.cache.PolicyCacheManager; @@ -31,7 +30,6 @@ import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants; import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil; import javax.cache.Cache; -import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -39,14 +37,8 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { private static final Log log = LogFactory.getLog(PolicyCacheManagerImpl.class); - private static HashMap> tenantedPolicyMap = new HashMap<>(); - private static PolicyCacheManagerImpl policyCacheManager; -// private static Cache getPolicyCache() { -// return PolicyManagerUtil.getPolicyCache(PolicyManagementConstants.DM_CACHE); -// } - private static Cache> getPolicyListCache() { return PolicyManagerUtil.getPolicyListCache(PolicyManagementConstants.DM_CACHE_LIST); } @@ -67,15 +59,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public void addAllPolicies(List policies) { - // HashMap map = this.getTenantRelatedMap(); - -// Cache cache = getPolicyCache(); -// if (cache.isEmpty()) { - -// for (Policy policy : policies) { -// cache.put(policy.getId(), policy); -// } -// } Cache> lCache = getPolicyListCache(); lCache.put(1, policies); @@ -83,16 +66,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public void updateAllPolicies(List policies) { -//// HashMap map = this.getTenantRelatedMap(); -// Cache cache = getPolicyCache(); -// cache.removeAll(); -//// map.clear(); -//// if (map.isEmpty()) { -// for (Policy policy : policies) { -//// map.put(policy.getId(), policy); -// cache.put(policy.getId(), policy); -// } -//// } Cache> lCache = getPolicyListCache(); lCache.removeAll(); @@ -101,43 +74,12 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public List getAllPolicies() throws PolicyManagementException { -// // HashMap map = this.getTenantRelatedMap(); -// Cache cache = getPolicyCache(); -// Iterator iterator = cache.iterator(); -//// iterator.hasNext() -// if (!iterator.hasNext()) { -// PolicyManager policyManager = new PolicyManagerImpl(); -// this.addAllPolicies(policyManager.getPolicies()); -// } -// if (log.isDebugEnabled()) { -// //log.debug("No of policies stored in the cache .. : " + map.size()); -// -// //Set keySet = map.keySet(); -// Iterator iterator2 = cache.iterator(); -// while (iterator2.hasNext()) { -// org.wso2.carbon.caching.impl.CacheEntry thisEntry = (org.wso2.carbon.caching.impl.CacheEntry) -// iterator2.next(); -// log.debug("Policy id in maps .. : " + thisEntry.getKey() + " policy name : " + ((Policy) thisEntry -// .getValue()). -// getPolicyName() + " Activated : " + ((Policy) thisEntry.getValue()).isActive()); -// } -// } -// -// List policies = new ArrayList<>(); -// while (iterator.hasNext()){ -// CacheEntry thisEntry = (CacheEntry) iterator.next(); -// policies.add((Policy) thisEntry.getValue()); -// } -// -// return policies; -//// return new ArrayList<>(map.values()); Cache> lCache = getPolicyListCache(); if (!lCache.containsKey(1)) { PolicyManager policyManager = new PolicyManagerImpl(); this.addAllPolicies(policyManager.getPolicies()); } - if (log.isDebugEnabled()) { List cachedPolicy = lCache.get(1); for (Policy policy : cachedPolicy) { @@ -145,7 +87,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { getPolicyName() + " Activated : " + policy.isActive()); } } - return lCache.get(1); } @@ -159,10 +100,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public void removeAllPolicies() { -// Cache cache = getPolicyCache(); -// cache.removeAll(); - //HashMap map = this.getTenantRelatedMap(); - //map.clear(); Cache> lCache = getPolicyListCache(); lCache.removeAll(); @@ -170,13 +107,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public void addPolicy(Policy policy) { - //HashMap map = this.getTenantRelatedMap(); -// Cache cache = getPolicyCache(); -// if (!cache.containsKey(policy.getId())) { -// cache.put(policy.getId(), policy); -// } else { -// log.warn("Policy id (" + policy.getId() + ") already exist in the map. hence not attempted to store."); -// } Cache> lCache = getPolicyListCache(); if (lCache.containsKey(1)) { @@ -194,12 +124,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public void updatePolicy(Policy policy) { - // HashMap map = this.getTenantRelatedMap(); -// Cache cache = getPolicyCache(); -// if (cache.containsKey(policy.getId())) { -// cache.remove(policy.getId()); -// cache.put(policy.getId(), policy); -// } Cache> lCache = getPolicyListCache(); if (lCache.containsKey(1)) { @@ -220,14 +144,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public void updatePolicy(int policyId) throws PolicyManagementException { - // HashMap map = this.getTenantRelatedMap(); -// Cache cache = getPolicyCache(); -// if (cache.containsKey(policyId)) { -// this.removePolicy(policyId); -// } -// PolicyManager policyManager = new PolicyManagerImpl(); -// Policy policy = policyManager.getPolicy(policyId); -// cache.put(policyId, policy); Cache> lCache = getPolicyListCache(); if (lCache.containsKey(1)) { @@ -240,13 +156,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public void removePolicy(int policyId) { - // HashMap map = this.getTenantRelatedMap(); -// Cache cache = getPolicyCache(); -// if (cache.containsKey(policyId)) { -// cache.remove(policyId); -// } else { -// log.warn("Policy id (" + policyId + ") does not exist in the cache. Hence not removed."); -// } Cache> lCache = getPolicyListCache(); if (lCache.containsKey(1)) { @@ -265,13 +174,6 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { @Override public Policy getPolicy(int policyId) throws PolicyManagementException { - //HashMap map = this.getTenantRelatedMap(); -// Cache cache = getPolicyCache(); -// if (!cache.containsKey(policyId)) { -// this.removeAllPolicies(); -// this.getAllPolicies(); -// } -// return cache.get(policyId); Cache> lCache = getPolicyListCache(); if (!lCache.containsKey(1)) { @@ -306,13 +208,4 @@ public class PolicyCacheManagerImpl implements PolicyCacheManager { return 0; } - private HashMap getTenantRelatedMap() { - - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - if (!tenantedPolicyMap.containsKey(tenantId)) { - HashMap policyMap = new HashMap<>(); - tenantedPolicyMap.put(tenantId, policyMap); - } - return tenantedPolicyMap.get(tenantId); - } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java index ed14a3c6ea..982b3859a7 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java @@ -31,10 +31,6 @@ import org.wso2.carbon.policy.mgt.common.ProfileFeature; import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; -import org.wso2.carbon.registry.api.GhostResource; -import org.wso2.carbon.registry.core.RegistryConstants; -import org.wso2.carbon.registry.core.caching.RegistryCacheEntry; -import org.wso2.carbon.registry.core.caching.RegistryCacheKey; import javax.cache.Cache; import javax.cache.CacheManager;