ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-ranger git commit: RANGER-661: fixed policy-download to return error, instead of empty policy-list, on failure in retrieving policies from DB
Date Thu, 24 Sep 2015 20:44:49 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master baf0ddd6f -> 5b371c7a6


RANGER-661: fixed policy-download to return error, instead of empty policy-list, on failure
in retrieving policies from DB


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

Branch: refs/heads/master
Commit: 5b371c7a6666bf1504b84ce59caaaa44d49e46e6
Parents: baf0ddd
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Thu Sep 24 00:20:01 2015 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Thu Sep 24 13:44:00 2015 -0700

----------------------------------------------------------------------
 .../org/apache/ranger/biz/ServiceDBStore.java   | 32 ++++++--------------
 .../apache/ranger/biz/TestServiceDBStore.java   |  6 ++--
 2 files changed, 13 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5b371c7a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
index d62c645..a5ac557 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
@@ -1582,19 +1582,13 @@ public class ServiceDBStore implements ServiceStore {
 			LOG.debug("==> ServiceDBStore.getServicePolicies(" + serviceName + ")");
 		}
 
-		List<RangerPolicy> ret = new ArrayList<RangerPolicy>();
-
-		try {
-			if(filter == null) {
-				filter = new SearchFilter();
-			}
+		if(filter == null) {
+			filter = new SearchFilter();
+		}
 
-			filter.setParam(SearchFilter.SERVICE_NAME, serviceName);
+		filter.setParam(SearchFilter.SERVICE_NAME, serviceName);
 
-			ret = getPolicies(filter);
-		} catch(Exception excp) {
-			LOG.error("ServiceDBStore.getServicePolicies(" + serviceName + "): failed to read policies",
excp);
-		}
+		List<RangerPolicy> ret = getPolicies(filter);
 
 		if(LOG.isDebugEnabled()) {
 			LOG.debug("<== ServiceDBStore.getServicePolicies(" + serviceName + "): count=" + ((ret
== null) ? 0 : ret.size()));
@@ -1608,19 +1602,13 @@ public class ServiceDBStore implements ServiceStore {
 			LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceName + ")");
 		}
 
-		RangerPolicyList ret = null;
-
-		try {
-			if (filter == null) {
-				filter = new SearchFilter();
-			}
+		if (filter == null) {
+			filter = new SearchFilter();
+		}
 
-			filter.setParam(SearchFilter.SERVICE_NAME, serviceName);
+		filter.setParam(SearchFilter.SERVICE_NAME, serviceName);
 
-			ret = getPaginatedPolicies(filter);
-		} catch (Exception excp) {
-			LOG.error("ServiceDBStore.getPaginatedServicePolicies(" + serviceName + "): failed to
read policies", excp);
-		}
+		RangerPolicyList ret = getPaginatedPolicies(filter);
 
 		if (LOG.isDebugEnabled()) {
 			LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceName + "): count="

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5b371c7a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
index 70e89a3..bd4e9d4 100644
--- a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
+++ b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
@@ -2430,9 +2430,9 @@ public class TestServiceDBStore {
 		Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
 		Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
 
+		thrown.expect(Exception.class);
 		List<RangerPolicy> dbRangerPolicy = serviceDBStore.getServicePolicies(
 				Id, filter);
-		Assert.assertNotNull(dbRangerPolicy);
 		Mockito.verify(daoManager).getXXService();
 	}
 
@@ -2533,9 +2533,9 @@ public class TestServiceDBStore {
 		Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
 		Mockito.when(xServiceDao.getById(Id)).thenReturn(xService);
 
+		thrown.expect(Exception.class);
 		RangerPolicyList dbRangerPolicyList = serviceDBStore
 				.getPaginatedServicePolicies(rangerService.getId(), filter);
-		Assert.assertNull(dbRangerPolicyList);
 		Mockito.verify(daoManager).getXXService();
 	}
 
@@ -2602,4 +2602,4 @@ public class TestServiceDBStore {
 		Assert.assertNotNull(policyList);
 		Mockito.verify(daoManager).getXXPolicy();
 	}
-}
\ No newline at end of file
+}


Mime
View raw message