ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [4/7] incubator-ranger git commit: RANGER-531: fix for error in legacy clients downloading policies
Date Sat, 06 Jun 2015 02:08:32 GMT
RANGER-531: fix for error in legacy clients downloading policies


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

Branch: refs/heads/tag-policy
Commit: 5a743e0aee657e6ddadf60b920df50ff580d99bf
Parents: 83583db
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Fri Jun 5 09:47:03 2015 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Fri Jun 5 09:47:03 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/ranger/rest/AssetREST.java   | 19 ++++++++++++++-----
 .../java/org/apache/ranger/rest/ServiceREST.java |  3 +++
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5a743e0a/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java b/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java
index 12046d5..16528bd 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java
@@ -54,6 +54,7 @@ import org.apache.ranger.plugin.model.RangerPolicy;
 import org.apache.ranger.plugin.model.RangerService;
 import org.apache.ranger.plugin.util.GrantRevokeRequest;
 import org.apache.ranger.plugin.util.SearchFilter;
+import org.apache.ranger.plugin.util.ServicePolicies;
 import org.apache.ranger.service.XAccessAuditService;
 import org.apache.ranger.service.XAgentService;
 import org.apache.ranger.service.XAssetService;
@@ -508,6 +509,7 @@ public class AssetREST {
 		boolean           isSecure    = request.isSecure();
 		String            policyCount = request.getParameter("policyCount");
 		String            agentId     = request.getParameter("agentId");
+		Long              lastKnowPolicyVersion = new Long(-1);
 
 		if (ipAddress == null) {  
 			ipAddress = request.getRemoteAddr();
@@ -515,12 +517,19 @@ public class AssetREST {
 
 		boolean httpEnabled = PropertiesUtil.getBooleanProperty("ranger.service.http.enabled",true);
 
-		RangerService      service  = serviceREST.getServiceByName(repository);
-		List<RangerPolicy> policies = serviceREST.getServicePolicies(repository, request).getPolicies();
+		ServicePolicies servicePolicies = null;
 
-		long             policyUpdTime = (service != null && service.getPolicyUpdateTime()
!= null) ? service.getPolicyUpdateTime().getTime() : 0l;
-		VXAsset          vAsset        = serviceUtil.toVXAsset(service);
-		List<VXResource> vResourceList = new ArrayList<VXResource>();
+		try {
+			servicePolicies = serviceREST.getServicePoliciesIfUpdated(repository, lastKnowPolicyVersion,
agentId, request);
+		} catch(Exception excp) {
+			logger.error("failed to retrieve policies for repository " + repository, excp);
+		}
+
+		RangerService      service       = serviceREST.getServiceByName(repository);
+		List<RangerPolicy> policies      = servicePolicies != null ? servicePolicies.getPolicies()
: null;
+		long               policyUpdTime = (servicePolicies != null && servicePolicies.getPolicyUpdateTime()
!= null) ? servicePolicies.getPolicyUpdateTime().getTime() : 0l;
+		VXAsset            vAsset        = serviceUtil.toVXAsset(service);
+		List<VXResource>   vResourceList = new ArrayList<VXResource>();
 		
 		if(policies != null) {
 			for(RangerPolicy policy : policies) {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5a743e0a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
index 4423633..f9464ec 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
@@ -1197,6 +1197,9 @@ public class ServiceREST {
 		String          logMsg   = null;
 
 		if (serviceUtil.isValidateHttpsAuthentication(serviceName, request)) {
+			if(lastKnownVersion == null) {
+				lastKnownVersion = new Long(-1);
+			}
 			
 			try {
 				ret = svcStore.getServicePoliciesIfUpdated(serviceName, lastKnownVersion);


Mime
View raw message