ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [26/50] [abbrv] incubator-ranger git commit: RANGER-643 : Audit page - filter by Tags column not working
Date Wed, 28 Oct 2015 16:00:02 GMT
RANGER-643 : Audit page - filter by Tags column not working

Signed-off-by: Madhan Neethiraj <madhan@apache.org>


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

Branch: refs/heads/master
Commit: b6728b7c22313798fa103db8d9e0a1d6e16337fc
Parents: 53ec707
Author: Gautam Borad <gborad@gmail.com>
Authored: Mon Sep 28 10:34:14 2015 +0530
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Mon Sep 28 20:45:50 2015 -0700

----------------------------------------------------------------------
 .../apache/ranger/solr/SolrAccessAuditsService.java   |  2 +-
 .../main/java/org/apache/ranger/solr/SolrUtil.java    | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b6728b7c/security-admin/src/main/java/org/apache/ranger/solr/SolrAccessAuditsService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/solr/SolrAccessAuditsService.java
b/security-admin/src/main/java/org/apache/ranger/solr/SolrAccessAuditsService.java
index 2b3cd09..0d6eefa 100644
--- a/security-admin/src/main/java/org/apache/ranger/solr/SolrAccessAuditsService.java
+++ b/security-admin/src/main/java/org/apache/ranger/solr/SolrAccessAuditsService.java
@@ -114,7 +114,7 @@ public class SolrAccessAuditsService {
 		searchFields.add(new SearchField("endDate", "evtTime", DATA_TYPE.DATE,
 				SEARCH_TYPE.LESS_EQUAL_THAN));
 
-		searchFields.add(new SearchField("tags", "obj.tags", DATA_TYPE.STR_LIST, SEARCH_TYPE.PARTIAL));
+		searchFields.add(new SearchField("tags", "tags", DATA_TYPE.STRING, SEARCH_TYPE.PARTIAL));
 
 		sortFields.add(new SortField("eventTime", "evtTime", true,
 				SORT_ORDER.DESC));

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/b6728b7c/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java b/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
index 2ce63a7..ebf416d 100644
--- a/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
+++ b/security-admin/src/main/java/org/apache/ranger/solr/SolrUtil.java
@@ -22,7 +22,6 @@ package org.apache.ranger.solr;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.TimeZone;
 
@@ -38,7 +37,6 @@ import org.apache.ranger.common.SearchField.SEARCH_TYPE;
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrQuery.ORDER;
-import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.util.ClientUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -127,6 +125,11 @@ public class SolrUtil {
 					// TODO: Need to handle range here
 				} else {
 					String fq = setField(fieldName, paramValue);
+
+					if (searchField.getSearchType() == SEARCH_TYPE.PARTIAL) {
+						fq = setFieldForPartialSearch(fieldName, paramValue);
+					}
+
 					if (fq != null) {
 						query.addFilterQuery(fq);
 					}
@@ -160,6 +163,13 @@ public class SolrUtil {
 		return response;
 	}
 
+	private String setFieldForPartialSearch(String fieldName, Object value) {
+		if (value == null || value.toString().trim().length() == 0) {
+			return null;
+		}
+		return fieldName + ":*" + ClientUtils.escapeQueryChars(value.toString().trim().toLowerCase())
+ "*";
+	}
+
 	public String setField(String fieldName, Object value) {
 		if (value == null || value.toString().trim().length() == 0) {
 			return null;


Mime
View raw message