ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [2/2] git commit: ARGUS-58: updates per review comments (to not cache ID of public group)
Date Mon, 15 Sep 2014 23:08:43 GMT
ARGUS-58: updates per review comments (to not cache ID of public group)

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

Branch: refs/heads/master
Commit: d3e9ad6d10419ffd31039150c54b167464bf8a59
Parents: 40b8233
Author: mneethiraj <mneethiraj@hortonworks.com>
Authored: Mon Sep 15 15:58:57 2014 -0700
Committer: mneethiraj <mneethiraj@hortonworks.com>
Committed: Mon Sep 15 15:58:57 2014 -0700

----------------------------------------------------------------------
 .../src/main/java/com/xasecure/biz/XABizUtil.java   | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/d3e9ad6d/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java b/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
index 464c265..ece660f 100644
--- a/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
+++ b/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
@@ -96,7 +96,6 @@ public class XABizUtil {
 	private static final String PATH_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst0123456789-_.";
 	private static char[] PATH_CHAR_SET = PATH_CHARS.toCharArray();
 	private static int PATH_CHAR_SET_LEN = PATH_CHAR_SET.length;
-	private static Long sGroupIdPublic = null;
 
 	public XABizUtil() {
 		maxFirstNameLength = Integer.parseInt(PropertiesUtil.getProperty(
@@ -1019,12 +1018,13 @@ public class XABizUtil {
 		List<XXPermMap> permMapList = new ArrayList<XXPermMap>();
 		userGroups = daoManager.getXXGroup().findByUserId(xUserId);
 		permMapList = daoManager.getXXPermMap().findByResourceId(resourceId);
+		Long publicGroupId = getPublicGroupId();
 		boolean matchFound = false;
 		for (XXPermMap permMap : permMapList) {
 			if (permMap.getPermType() == permission) {
 				if (permMap.getPermFor() == AppConstants.XA_PERM_FOR_GROUP) {
 					// check whether permission is enabled for public group or a group to which user belongs
-					matchFound = isPublicGroupId(permMap.getGroupId()) || isGroupInList(permMap.getGroupId(),
userGroups);
+					matchFound = (publicGroupId != null && publicGroupId == permMap.getGroupId())
|| isGroupInList(permMap.getGroupId(), userGroups);
 				} else if (permMap.getPermFor() == AppConstants.XA_PERM_FOR_USER) {
 					// check whether permission is enabled to user
 					matchFound = permMap.getUserId().equals(xUserId);
@@ -1037,18 +1037,10 @@ public class XABizUtil {
 		return matchFound;
 	}
 	
-	public boolean isPublicGroupId(Long groupId) {
-		return groupId != null && groupId == getPublicGroupId();
-	}
-	
 	public Long getPublicGroupId() {
-		if(sGroupIdPublic == null) {
-			XXGroup xXGroupPublic = daoManager.getXXGroup().findByGroupName(XAConstants.GROUP_PUBLIC);
-
-			sGroupIdPublic = xXGroupPublic != null ? xXGroupPublic.getId() : null;
-		}
+		XXGroup xXGroupPublic = daoManager.getXXGroup().findByGroupName(XAConstants.GROUP_PUBLIC);
 
-		return sGroupIdPublic;
+		return xXGroupPublic != null ? xXGroupPublic.getId() : null;
 	}
 
 	/**


Mime
View raw message