Repository: incubator-ranger
Updated Branches:
  refs/heads/tag-policy 747105c0b -> 28a48c07c


RANGER-274: Fixed issues from changing TaggedResource key

Signed-off-by: Madhan Neethiraj <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/28a48c07
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/28a48c07
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/28a48c07

Branch: refs/heads/tag-policy
Commit: 28a48c07c22f272cc4d96a3b614eba845dc8dc04
Parents: 747105c
Author: Abhay Kulkarni <[email protected]>
Authored: Thu Jul 9 14:32:42 2015 -0700
Committer: Madhan Neethiraj <[email protected]>
Committed: Fri Jul 10 08:09:39 2015 +0530

----------------------------------------------------------------------
 .../plugin/contextenricher/RangerAdminTagRetriever.java   |  5 +++--
 .../ranger/plugin/contextenricher/RangerTagProvider.java  |  2 +-
 .../plugin/policyengine/RangerPolicyEngineImpl.java       |  2 +-
 .../plugin/policyengine/RangerPolicyRepository.java       | 10 +++++++---
 4 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/28a48c07/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerAdminTagRetriever.java
----------------------------------------------------------------------
diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerAdminTagRetriever.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerAdminTagRetriever.java
index 3d7ef1c..f66da35 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerAdminTagRetriever.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerAdminTagRetriever.java
@@ -24,6 +24,7 @@ import org.apache.commons.collections.MapUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ranger.admin.client.RangerAdminClient;
+import org.apache.ranger.plugin.model.RangerServiceDef;
 import org.apache.ranger.plugin.model.RangerTaggedResource;
 import org.apache.ranger.plugin.service.RangerBasePlugin;
 import org.apache.ranger.plugin.util.TagServiceResources;
@@ -45,11 +46,11 @@ public class RangerAdminTagRetriever extends 
RangerTagRefresher {
        private RangerAdminClient adminClient;
        private Long lastTimestamp;
 
-       public RangerAdminTagRetriever(final String serviceName, final long 
pollingIntervalMs, final RangerTagReceiver enricher) {
+       public RangerAdminTagRetriever(final String serviceName, final 
RangerServiceDef serviceDef, final long pollingIntervalMs, final 
RangerTagReceiver enricher) {
                super(pollingIntervalMs);
                this.serviceName = serviceName;
                setReceiver(enricher);
-               propertyPrefix = propertyPrefixPreamble + serviceName;
+               propertyPrefix = propertyPrefixPreamble + serviceDef.getName();
                this.lastTimestamp = 0L;
        }
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/28a48c07/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerTagProvider.java
----------------------------------------------------------------------
diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerTagProvider.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerTagProvider.java
index a5833e4..8297121 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerTagProvider.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/contextenricher/RangerTagProvider.java
@@ -64,7 +64,7 @@ public class RangerTagProvider extends 
RangerAbstractContextEnricher implements
                        tagRefresher = new 
RangerTagFileStoreRetriever(serviceName, pollingIntervalMs, this);
                        tagProviderType = 
TagProviderTypeEnum.FILESTORE_BASED_TAG_PROVIDER;
                } else if 
(tagProviderTypeString.equals(TagProviderTypeEnum.RANGER_ADMIN_TAG_PROVIDER.toString()))
 {
-                       tagRefresher = new RangerAdminTagRetriever(serviceName, 
pollingIntervalMs, this);
+                       tagRefresher = new RangerAdminTagRetriever(serviceName, 
serviceDef, pollingIntervalMs, this);
                        tagProviderType = 
TagProviderTypeEnum.RANGER_ADMIN_TAG_PROVIDER;
                } else if 
(tagProviderTypeString.equals(TagProviderTypeEnum.EXTERNAL_SYSTEM_TAG_PROVIDER.toString()))
 {
                        // TODO

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/28a48c07/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
----------------------------------------------------------------------
diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
index c72e313..dd8dd7d 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
@@ -64,7 +64,7 @@ public class RangerPolicyEngineImpl implements 
RangerPolicyEngine {
                                LOG.debug("RangerPolicyEngineImpl : Building 
tag-policy-repository for tag-service " + tagPolicies.getServiceName());
                        }
 
-                       tagPolicyRepository = new 
RangerPolicyRepository(tagPolicies, options, servicePolicies.getServiceDef());
+                       tagPolicyRepository = new 
RangerPolicyRepository(tagPolicies, options, servicePolicies.getServiceDef(), 
servicePolicies.getServiceName());
 
                } else {
                        if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/28a48c07/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
----------------------------------------------------------------------
diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
index ed315fd..84b3b1d 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
@@ -46,12 +46,13 @@ public class RangerPolicyRepository {
     private List<RangerPolicyEvaluator>       policyEvaluators;
     private final Map<String, Boolean>        accessAuditCache;
 
+    private final String                      componentServiceName;
     private final RangerServiceDef            componentServiceDef;
 
     RangerPolicyRepository(ServicePolicies servicePolicies, 
RangerPolicyEngineOptions options) {
         super();
 
-        this.serviceName = servicePolicies.getServiceName();
+        this.componentServiceName = this.serviceName = 
servicePolicies.getServiceName();
         this.componentServiceDef = this.serviceDef = 
servicePolicies.getServiceDef();
         this.policies = 
Collections.unmodifiableList(servicePolicies.getPolicies());
         this.policyVersion = servicePolicies.getPolicyVersion() != null ? 
servicePolicies.getPolicyVersion() : -1;
@@ -76,12 +77,15 @@ public class RangerPolicyRepository {
     }
 
     RangerPolicyRepository(ServicePolicies.TagPolicies tagPolicies, 
RangerPolicyEngineOptions options,
-                           RangerServiceDef componentServiceDef) {
+                           RangerServiceDef componentServiceDef, String 
componentServiceName) {
         super();
+
         this.serviceName = tagPolicies.getServiceName();
+        this.componentServiceName = componentServiceName;
 
         this.serviceDef = normalizeAccessTypeDefs(tagPolicies.getServiceDef(), 
componentServiceDef.getName());
         this.componentServiceDef = componentServiceDef;
+
         this.policies = 
Collections.unmodifiableList(normalizePolicyItemAccesses(tagPolicies.getPolicies(),
 componentServiceDef.getName()));
         this.policyVersion = tagPolicies.getPolicyVersion() != null ? 
tagPolicies.getPolicyVersion() : -1;
         this.accessAuditCache = null;
@@ -287,7 +291,7 @@ public class RangerPolicyRepository {
 
         if(ret != null) {
                ret.setContextEnricherDef(enricherDef);
-            ret.setContextServiceName(serviceName);
+            ret.setContextServiceName(componentServiceName);
             ret.setContextServiceDef(componentServiceDef);
             ret.init();
         }

Reply via email to