ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject git commit: ARGUS-75:PatternSyntaxException on Windows while creating HDFS policy
Date Tue, 23 Sep 2014 01:32:49 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 6ad612029 -> 7bfb3cb9d


ARGUS-75:PatternSyntaxException on Windows while creating HDFS policy

Signed-off-by: sneethiraj <sneethir@apache.org>


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

Branch: refs/heads/master
Commit: 7bfb3cb9d14eb762bcb65bd17d81891fd520be54
Parents: 6ad6120
Author: vperiasamy <vperiasamy@hortonworks.com>
Authored: Mon Sep 22 17:13:06 2014 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Mon Sep 22 21:31:07 2014 -0400

----------------------------------------------------------------------
 .../main/java/com/xasecure/biz/XABizUtil.java   | 23 +++++++++++---------
 .../com/xasecure/service/XResourceService.java  | 11 +++++++---
 .../src/main/resources/xa_system.properties     |  3 +++
 3 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7bfb3cb9/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 0a3aa00..6dc21a4 100644
--- a/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
+++ b/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
@@ -96,6 +96,9 @@ 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;
+	
+	static String fileSeparator = PropertiesUtil.getProperty(
+			"xa.file.separator", "/");
 
 	public XABizUtil() {
 		maxFirstNameLength = Integer.parseInt(PropertiesUtil.getProperty(
@@ -627,7 +630,7 @@ public class XABizUtil {
 			return false;
 		}
 
-		String[] splittedResources = stringUtil.split(resourceName, File.separator);
+		String[] splittedResources = stringUtil.split(resourceName, fileSeparator);
 		if (splittedResources.length < 1 || splittedResources.length > 3) {
 			logger.debug("Invalid resourceName name : " + resourceName);
 			return false;
@@ -705,7 +708,7 @@ public class XABizUtil {
 			return false;
 		}
 
-		String[] splittedResources = stringUtil.split(resourceName, File.separator);// get list
of resources
+		String[] splittedResources = stringUtil.split(resourceName, fileSeparator);// get list
of resources
 		if (splittedResources.length < 1 || splittedResources.length > 3) {
 			logger.debug("Invalid resource name : " + resourceName);
 			return false;
@@ -802,7 +805,7 @@ public class XABizUtil {
 			int permission) {
 
 		String[] splittedResources = stringUtil.split(resourceName,
-				File.separator);
+				fileSeparator);
 		int numberOfResources = splittedResources.length;
 		if (numberOfResources < 1 || numberOfResources > 3) {
 			logger.debug("Invalid policy name : " + resourceName);
@@ -888,7 +891,7 @@ public class XABizUtil {
  			int permission) {
  
  		String[] splittedResources = stringUtil.split(resourceName,
- 				File.separator);
+ 				fileSeparator);
  		int numberOfResources = splittedResources.length;
  		if (numberOfResources < 1 || numberOfResources > 3) {
  			logger.debug("Invalid policy name : " + resourceName);
@@ -1076,18 +1079,18 @@ public class XABizUtil {
 	public boolean isRecursiveWildCardMatch(String pathToCheck,
 			String wildcardPath) {
 		if (pathToCheck != null) {
-			if (wildcardPath != null && wildcardPath.equals(File.separator)) {
+			if (wildcardPath != null && wildcardPath.equals(fileSeparator)) {
 				return true;
 			}
 			StringBuilder sb = new StringBuilder();
-			for (String p : pathToCheck.split(File.separator)) {
+			for (String p : pathToCheck.split(fileSeparator)) {
 				sb.append(p);
 				boolean matchFound = FilenameUtils.wildcardMatch(sb.toString(),
 						wildcardPath);
 				if (matchFound) {
 					return true;
 				}
-				sb.append(File.separator);
+				sb.append(fileSeparator);
 			}
 			sb = null;
 		}
@@ -1141,7 +1144,7 @@ public class XABizUtil {
 	 * @return
 	 */
 	public boolean comparePathsForExactMatch(String path1, String path2) {
-		String pathSeparator = File.separator;
+		String pathSeparator = fileSeparator;
 		if (!path1.endsWith(pathSeparator)) {
 			path1 = path1.concat(pathSeparator);
 		}
@@ -1166,10 +1169,10 @@ public class XABizUtil {
 			List<String> pathToCheckArray = new ArrayList<String>();
 			List<String> wildcardPathArray = new ArrayList<String>();
 
-			for (String p : pathToCheck.split(File.separator)) {
+			for (String p : pathToCheck.split(fileSeparator)) {
 				pathToCheckArray.add(p);
 			}
-			for (String w : wildcardPath.split(File.separator)) {
+			for (String w : wildcardPath.split(fileSeparator)) {
 				wildcardPathArray.add(w);
 			}
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7bfb3cb9/security-admin/src/main/java/com/xasecure/service/XResourceService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XResourceService.java b/security-admin/src/main/java/com/xasecure/service/XResourceService.java
index 0dd09d0..1cf5973 100644
--- a/security-admin/src/main/java/com/xasecure/service/XResourceService.java
+++ b/security-admin/src/main/java/com/xasecure/service/XResourceService.java
@@ -29,6 +29,7 @@ import java.util.Map.Entry;
 
 import com.xasecure.common.ContextUtil;
 import com.xasecure.common.MessageEnums;
+import com.xasecure.common.PropertiesUtil;
 import com.xasecure.common.SearchCriteria;
 import com.xasecure.common.SearchField;
 import com.xasecure.common.SearchField.DATA_TYPE;
@@ -78,6 +79,10 @@ public class XResourceService extends
 	XAEnumUtil xaEnumUtil;
 
 	static HashMap<String, VTrxLogAttr> trxLogAttrs = new HashMap<String, VTrxLogAttr>();
+	
+	static String fileSeparator = PropertiesUtil.getProperty(
+			"xa.file.separator", "/");
+	
 	static {
 		trxLogAttrs.put("name", new VTrxLogAttr("name", "Resource Path", false));
 		trxLogAttrs.put("description", new VTrxLogAttr("description", "Policy Description", false));
@@ -486,15 +491,15 @@ public class XResourceService extends
 		
 		for (String resourceName : resourceList) {
 			String policyPath = resourceName;
-			String[] policyPathParts = policyPath.split(File.separator);
+			String[] policyPathParts = policyPath.split(fileSeparator);
 			
 			if(policyPathParts.length>1){
-				pathList.add(File.separator);
+				pathList.add(fileSeparator);
 			}
 			
 			StringBuffer path = new StringBuffer();
 			for (int i = 1; i < policyPathParts.length - 1; i++) {
-				path.append(File.separator + policyPathParts[i]);
+				path.append(fileSeparator + policyPathParts[i]);
 				pathList.add(path.toString());
 			}
 			if(path!=null){

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7bfb3cb9/security-admin/src/main/resources/xa_system.properties
----------------------------------------------------------------------
diff --git a/security-admin/src/main/resources/xa_system.properties b/security-admin/src/main/resources/xa_system.properties
index afaf396..0995c0b 100644
--- a/security-admin/src/main/resources/xa_system.properties
+++ b/security-admin/src/main/resources/xa_system.properties
@@ -45,3 +45,6 @@ xa.cli.password=admin
 
 # Maven Project Version
 maven.project.version=${project.version}
+
+# File Separator
+xa.file.separator=/
\ No newline at end of file


Mime
View raw message