ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject incubator-argus git commit: ARGUS-183:Fix for search policies API failing in Oracle
Date Fri, 14 Nov 2014 00:22:02 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master f446cbe9b -> 1d9ffb4f7


ARGUS-183:Fix for search policies API failing in Oracle

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/1d9ffb4f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/1d9ffb4f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/1d9ffb4f

Branch: refs/heads/master
Commit: 1d9ffb4f7a0c6b3de7f728a9fa772d2981c0601b
Parents: f446cbe
Author: vperiasamy <vperiasamy@hortonworks.com>
Authored: Thu Nov 13 18:34:11 2014 -0500
Committer: sneethiraj <sneethir@apache.org>
Committed: Thu Nov 13 19:21:22 2014 -0500

----------------------------------------------------------------------
 .../main/java/com/xasecure/biz/XABizUtil.java   | 36 +++++++++++++++++
 .../java/com/xasecure/common/AppConstants.java  | 42 ++++++++++++++++++++
 .../com/xasecure/common/SearchCriteria.java     | 12 ++++++
 .../main/java/com/xasecure/rest/AssetREST.java  |  2 +-
 4 files changed, 91 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/1d9ffb4f/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 6dc21a4..5a071c4 100644
--- a/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
+++ b/security-admin/src/main/java/com/xasecure/biz/XABizUtil.java
@@ -1277,4 +1277,40 @@ public class XABizUtil {
 			daoManager.getXXTrxLog().create(xTrxLog);
 		}
 	}
+
+	public static int getDBFlavor() {
+
+		String dbFlavor = "";
+		boolean dbFlavorPropFound = true;
+
+		dbFlavor = PropertiesUtil.getProperty("xa.db.flavor");
+		if (dbFlavor == null || dbFlavor.trim().isEmpty()) {
+			dbFlavor = PropertiesUtil.getProperty("jdbc.dialect");
+			dbFlavorPropFound = false;
+		}
+
+		if (dbFlavor != null && !dbFlavor.trim().isEmpty()) {
+			if (dbFlavorPropFound) {
+				if ("MYSQL".equalsIgnoreCase(dbFlavor)) {
+					return AppConstants.DB_FLAVOR_MYSQL;
+				} else if ("ORACLE".equalsIgnoreCase(dbFlavor)) {
+					return AppConstants.DB_FLAVOR_ORACLE;
+				} else {
+					return AppConstants.DB_FLAVOR_UNKNOWN;
+				}
+			} else {
+				if (dbFlavor.toUpperCase().contains("MYSQL")) {
+					return AppConstants.DB_FLAVOR_MYSQL;
+				} else if (dbFlavor.toUpperCase().contains("ORACLE")) {
+					return AppConstants.DB_FLAVOR_ORACLE;
+				} else {
+					return AppConstants.DB_FLAVOR_UNKNOWN;
+				}
+			}
+		} else {
+			logger.error("Property : xa.db.flavor or jdbc.dialect, not found");
+			return AppConstants.DB_FLAVOR_UNKNOWN;
+		}
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/1d9ffb4f/security-admin/src/main/java/com/xasecure/common/AppConstants.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/common/AppConstants.java b/security-admin/src/main/java/com/xasecure/common/AppConstants.java
index 86ba6da..c4e5991 100644
--- a/security-admin/src/main/java/com/xasecure/common/AppConstants.java
+++ b/security-admin/src/main/java/com/xasecure/common/AppConstants.java
@@ -351,6 +351,22 @@ public class AppConstants extends XACommonEnums {
 	 */
 	public static final int XAPermType_MAX = 31;
 
+	/***************************************************************
+	 * Enum values for DatabaseFavor
+	 **************************************************************/
+	/**
+	 * DB Favor Unknown
+	 */
+	public static final int DB_FLAVOR_UNKNOWN = 0;
+	/**
+	 * DB Favor MySql
+	 */
+	public static final int DB_FLAVOR_MYSQL = 1;
+	/**
+	 * DB Favor Oracle
+	 */
+	public static final int DB_FLAVOR_ORACLE = 2;
+
 
 	/***************************************************************
 	 * Enum values for ClassTypes
@@ -908,5 +924,31 @@ public class AppConstants extends XACommonEnums {
 		return 0;
 	}
 
+	static public int getEnumFor_DatabaseFlavor(String label) {
+		if (label == null) {
+			return DB_FLAVOR_UNKNOWN; // DB_FLAVOR_UNKNOWN
+		}
+		if ("MYSQL".equalsIgnoreCase(label)) {
+			return DB_FLAVOR_MYSQL; // DB_FLAVOR_MYSQL
+		}
+		if ("ORACLE".equalsIgnoreCase(label)) {
+			return DB_FLAVOR_ORACLE; // DB_FLAVOR_ORACLE
+		}
+		return DB_FLAVOR_UNKNOWN;
+	}
+
+	static public String getLabelFor_DatabaseFlavor(int elementValue) {
+		if (elementValue == DB_FLAVOR_UNKNOWN) {
+			return "UNKNOWN"; // Unknown
+		}
+		if (elementValue == DB_FLAVOR_MYSQL) {
+			return "MYSQL"; // MYSQL
+		}
+		if (elementValue == DB_FLAVOR_ORACLE) {
+			return "ORACLE"; // ORACLE
+		}
+		return null;
+	}
+
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/1d9ffb4f/security-admin/src/main/java/com/xasecure/common/SearchCriteria.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/common/SearchCriteria.java b/security-admin/src/main/java/com/xasecure/common/SearchCriteria.java
index bb85fe4..c1df00f 100644
--- a/security-admin/src/main/java/com/xasecure/common/SearchCriteria.java
+++ b/security-admin/src/main/java/com/xasecure/common/SearchCriteria.java
@@ -28,8 +28,13 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.log4j.Logger;
+
+import com.xasecure.biz.XABizUtil;
+
 
 public class SearchCriteria {
+	Logger logger = Logger.getLogger(SearchCriteria.class);
 
 	int startIndex = 0;
 	int maxRows = Integer.MAX_VALUE;
@@ -182,6 +187,13 @@ public class SearchCriteria {
 	 *            the isDistinct to set
 	 */
 	public void setDistinct(boolean isDistinct) {
+
+		int dbFlavor = XABizUtil.getDBFlavor();
+		if (isDistinct && dbFlavor == AppConstants.DB_FLAVOR_ORACLE) {
+			isDistinct = false;
+			logger.debug("Database flavor is `ORACLE` so ignoring DISTINCT "
+					+ "clause from select statement.");
+		}
 		this.isDistinct = isDistinct;
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/1d9ffb4f/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/rest/AssetREST.java b/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
index e187a78..2662409 100644
--- a/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
+++ b/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
@@ -334,7 +334,7 @@ public class AssetREST {
 		// searchUtil.addSearchGroup(searchCriteria, outerGroup);
 		//
 		// }
-		//searchCriteria.setDistinct(true);
+		searchCriteria.setDistinct(true);
 
 		return assetMgr.searchXResources(searchCriteria);
 	}


Mime
View raw message