ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [16/50] [abbrv] ambari git commit: AMBARI-18227. Add unit tests for Log Search components and refactor them as needed - Vol 1. (Miklos Gergely via oleewere)
Date Wed, 07 Sep 2016 23:38:06 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbc40ba/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java
index 257f04d..9baccce 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java
@@ -36,7 +36,6 @@ import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.core.Response;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
@@ -62,6 +61,8 @@ import org.apache.ambari.logsearch.view.VNode;
 import org.apache.ambari.logsearch.view.VNodeList;
 import org.apache.ambari.logsearch.view.VSolrLogList;
 import org.apache.ambari.logsearch.view.VSummary;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
@@ -83,29 +84,24 @@ import com.google.common.collect.Lists;
 
 @Component
 public class LogsMgr extends MgrBase {
-  private static Logger logger = Logger.getLogger(LogsMgr.class);
+  private static final Logger logger = Logger.getLogger(LogsMgr.class);
 
-  public static List<String> cancelByDate = new CopyOnWriteArrayList<String>();
+  private static List<String> cancelByDate = new CopyOnWriteArrayList<String>();
 
-  public static Map<String, String> mapUniqueId = new ConcurrentHashMap<String, String>();
-
-  public static enum CONDITION {
+  private static Map<String, String> mapUniqueId = new ConcurrentHashMap<String, String>();
+  
+  private static enum CONDITION {
     OR, AND
   }
 
   @Autowired
-  ServiceLogsSolrDao serviceLogsSolrDao;
-
+  private ServiceLogsSolrDao serviceLogsSolrDao;
   @Autowired
-  BizUtil bizUtil;
-
+  private BizUtil bizUtil;
   @Autowired
-  FileUtil fileUtil;
-
-
+  private FileUtil fileUtil;
   @Autowired
-  GraphDataGenerator graphDataGenerator;
-
+  private GraphDataGenerator graphDataGenerator;
 
   public String searchLogs(SearchCriteria searchCriteria) {
     String keyword = (String) searchCriteria.getParamValue("keyword");
@@ -113,7 +109,7 @@ public class LogsMgr extends MgrBase {
     String lastPage = (String)  searchCriteria.getParamValue("isLastPage");
     Boolean isLastPage = Boolean.parseBoolean(lastPage);
 
-    if (!stringUtil.isEmpty(keyword)) {
+    if (!StringUtils.isBlank(keyword)) {
       try {
         return getPageByKeyword(searchCriteria);
       } catch (SolrException | SolrServerException e) {
@@ -121,7 +117,7 @@ public class LogsMgr extends MgrBase {
         throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
             .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
-    } else if (!stringUtil.isEmpty(logId)) {
+    } else if (!StringUtils.isBlank(logId)) {
       try {
         return getPageByLogId(searchCriteria);
       } catch (SolrException e) {
@@ -148,11 +144,11 @@ public class LogsMgr extends MgrBase {
     }
   }
 
-  public String getHosts(SearchCriteria searchCriteria) {
-    return getFields(searchCriteria, LogSearchConstants.SOLR_HOST);
+  public String getHosts() {
+    return getFields(LogSearchConstants.SOLR_HOST);
   }
-
-  public String getFields(SearchCriteria searchCriteria,String field){
+  
+  private String getFields(String field){
 
     SolrQuery solrQuery = new SolrQuery();
     VGroupList collection = new VGroupList();
@@ -200,8 +196,8 @@ public class LogsMgr extends MgrBase {
 
   }
 
-  public String getComponents(SearchCriteria searchCriteria) {
-    return getFields(searchCriteria, LogSearchConstants.SOLR_COMPONENT);
+  public String getComponents() {
+    return getFields(LogSearchConstants.SOLR_COMPONENT);
   }
 
   public String getAggregatedInfo(SearchCriteria searchCriteria) {
@@ -255,7 +251,7 @@ public class LogsMgr extends MgrBase {
     return logList;
   }
 
-  public VCountList getFieldCount(SearchCriteria searchCriteria, String field){
+  public VCountList getFieldCount(String field){
     VCountList collection = new VCountList();
     List<VCount> vCounts = new ArrayList<VCount>();
     SolrQuery solrQuery = new SolrQuery();
@@ -297,17 +293,17 @@ public class LogsMgr extends MgrBase {
     collection.setCounts(vCounts);
     return collection;
   }
-
-  public VCountList getLogLevelCount(SearchCriteria searchCriteria) {
-    return getFieldCount(searchCriteria, LogSearchConstants.SOLR_LEVEL);
+  
+  public VCountList getLogLevelCount() {
+    return getFieldCount(LogSearchConstants.SOLR_LEVEL);
   }
 
-  public VCountList getComponentsCount(SearchCriteria searchCriteria) {
-    return getFieldCount(searchCriteria, LogSearchConstants.SOLR_COMPONENT);
+  public VCountList getComponentsCount() {
+    return getFieldCount(LogSearchConstants.SOLR_COMPONENT);
   }
 
-  public VCountList getHostsCount(SearchCriteria searchCriteria) {
-    return getFieldCount(searchCriteria, LogSearchConstants.SOLR_HOST);
+  public VCountList getHostsCount() {
+    return getFieldCount(LogSearchConstants.SOLR_HOST);
   }
 
   public List<VNode> buidTreeData(List<PivotField> pivotFields,
@@ -322,13 +318,13 @@ public class LogsMgr extends MgrBase {
           VNode hostNode = new VNode();
           String name = (pivotHost.getValue() == null ? "" : ""+ pivotHost.getValue());
           String value = "" + pivotHost.getCount();
-          if(!stringUtil.isEmpty(name)){
+          if(!StringUtils.isBlank(name)){
             hostNode.setName(name);
           }
-          if(!stringUtil.isEmpty(value)){
+          if(!StringUtils.isBlank(value)){
             hostNode.setValue(value);
           }
-          if(!stringUtil.isEmpty(firstPriority)){
+          if(!StringUtils.isBlank(firstPriority)){
             hostNode.setType(firstPriority);
           }
 
@@ -336,7 +332,7 @@ public class LogsMgr extends MgrBase {
           hostNode.setRoot(true);
           PivotField hostPivot = null;
           for (PivotField searchHost : pivotFieldHost) {
-            if (!stringUtil.isEmpty(hostNode.getName())
+            if (!StringUtils.isBlank(hostNode.getName())
                 && hostNode.getName().equals(searchHost.getValue())) {
               hostPivot = searchHost;
               break;
@@ -369,7 +365,7 @@ public class LogsMgr extends MgrBase {
                 String compName = (pivotComp.getValue() == null ? "" : ""
                     + pivotComp.getValue());
                 compNode.setName(compName);
-                if (!stringUtil.isEmpty(secondPriority)) {
+                if (!StringUtils.isBlank(secondPriority)) {
                   compNode.setType(secondPriority);
                 }
                 compNode.setValue("" + pivotComp.getCount());
@@ -414,7 +410,7 @@ public class LogsMgr extends MgrBase {
     String hostName = ""
       + ((searchCriteria.getParamValue("hostName") == null) ? ""
       : searchCriteria.getParamValue("hostName"));
-    if (!stringUtil.isEmpty(hostName)){
+    if (!StringUtils.isBlank(hostName)){
       solrQuery.addFilterQuery(LogSearchConstants.SOLR_HOST + ":*"
         + hostName + "*");
     }
@@ -478,7 +474,7 @@ public class LogsMgr extends MgrBase {
     String componentName = ""
       + ((searchCriteria.getParamValue("componentName") == null) ? ""
       : searchCriteria.getParamValue("componentName"));
-    if (!stringUtil.isEmpty(componentName)){
+    if (!StringUtils.isBlank(componentName)){
       solrQuery.addFilterQuery(LogSearchConstants.SOLR_COMPONENT + ":"
         + componentName);
     } else {
@@ -552,7 +548,7 @@ public class LogsMgr extends MgrBase {
       for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
         VNameValue nameValue = new VNameValue();
         String value = map.get(level);
-        if (stringUtil.isEmpty(value)) {
+        if (StringUtils.isBlank(value)) {
           value = defalutValue;
         }
         nameValue.setName(level);
@@ -590,7 +586,7 @@ public class LogsMgr extends MgrBase {
     String defaultChoice = "0";
 
     String key = (String) searchCriteria.getParamValue("keyword");
-    if(stringUtil.isEmpty(key)){
+    if(StringUtils.isBlank(key)){
       throw restErrorUtil.createRESTException("Keyword was not given",
           MessageEnums.DATA_NOT_FOUND);
     }
@@ -651,7 +647,7 @@ public class LogsMgr extends MgrBase {
         nextPageLogID = ""
           + solrDoc.get(LogSearchConstants.ID);
 
-        if (stringUtil.isEmpty(nextPageLogID)){
+        if (StringUtils.isBlank(nextPageLogID)){
           nextPageLogID = "0";
         }
 
@@ -698,13 +694,13 @@ public class LogsMgr extends MgrBase {
         logTimeThroughRangeQuery.remove("start");
         logTimeThroughRangeQuery.remove("rows");
         logTimeThroughRangeQuery.setRows(1);
-        if (!stringUtil.isEmpty(filterQueryListIds)){
+        if (!StringUtils.isBlank(filterQueryListIds)){
           logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
         }
 
         String sortByType = searchCriteria.getSortType();
 
-        if (!stringUtil.isEmpty(sortByType) && sortByType
+        if (!StringUtils.isBlank(sortByType) && sortByType
           .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
 
           queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
@@ -759,16 +755,16 @@ public class LogsMgr extends MgrBase {
         rangeLogQuery.remove("start");
         rangeLogQuery.remove("rows");
 
-        if (!stringUtil.isEmpty(sortByType) && sortByType
+        if (!StringUtils.isBlank(sortByType) && sortByType
           .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
-          keywordLogDate = dateUtil.addMilliSecondsToDate(keywordLogDate, 1);
+          keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, 1);
           String keywordDateTime = dateUtil
             .convertDateWithMillisecondsToSolrDate(keywordLogDate);
           queryGenerator.setSingleRangeFilter(rangeLogQuery,
             LogSearchConstants.LOGTIME, startTime,
             keywordDateTime);
         } else {
-          keywordLogDate = dateUtil.addMilliSecondsToDate(keywordLogDate, -1);
+          keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, -1);
           String keywordDateTime = dateUtil
             .convertDateWithMillisecondsToSolrDate(keywordLogDate);
           queryGenerator.setSingleRangeFilter(rangeLogQuery,
@@ -795,8 +791,8 @@ public class LogsMgr extends MgrBase {
             String id = (String) solrDocumenent
               .getFieldValue(LogSearchConstants.ID);
             countNumberLogs++;
-
-            if (stringUtil.isEmpty(id) && id.equals(keywordId)){
+           
+            if (StringUtils.isBlank(id) && id.equals(keywordId)){
               break;
             }
           }
@@ -910,11 +906,11 @@ public class LogsMgr extends MgrBase {
         logTimeThroughRangeQuery.setRows(1);
         queryGenerator.setSingleExcludeFilter(logTimeThroughRangeQuery,
           LogSearchConstants.ID, lastLogsLogId);
-        if (!stringUtil.isEmpty(filterQueryListIds)){
+        if (!StringUtils.isBlank(filterQueryListIds)){
           logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
         }
 
-        if (!stringUtil.isEmpty(sortByType) && sortByType
+        if (!StringUtils.isBlank(sortByType) && sortByType
           .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
 
           logTimeThroughRangeQuery.remove(LogSearchConstants.SORT);
@@ -974,7 +970,7 @@ public class LogsMgr extends MgrBase {
         rangeLogQuery.remove("start");
         rangeLogQuery.remove("rows");
 
-        if (!stringUtil.isEmpty(sortByType) && sortByType
+        if (!StringUtils.isBlank(sortByType) && sortByType
           .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
        //   keywordLogDate = dateUtil.addMilliSecondsToDate(keywordLogDate, 1);
           String keywordDateTime = dateUtil
@@ -1010,7 +1006,7 @@ public class LogsMgr extends MgrBase {
               String id = (String) solrDocumenent
                   .getFieldValue(LogSearchConstants.ID);
               countNumberLogs++;
-              if ( stringUtil.isEmpty(id) && id.equals(keywordId)) {
+              if ( StringUtils.isBlank(id) && id.equals(keywordId)) {
                 break;
               }
             }
@@ -1039,13 +1035,13 @@ public class LogsMgr extends MgrBase {
   private String getPageByLogId(SearchCriteria searchCriteria) {
     VSolrLogList vSolrLogList = new VSolrLogList();
     String endLogTime = (String) searchCriteria.getParamValue("to");
-    if(stringUtil.isEmpty(endLogTime)){
+    if(StringUtils.isBlank(endLogTime)){
       return convertObjToString(vSolrLogList);
     }
     long startIndex = 0l;
 
     String logId = (String) searchCriteria.getParamValue("sourceLogId");
-    if(stringUtil.isEmpty(logId)){
+    if(StringUtils.isBlank(logId)){
       return convertObjToString(vSolrLogList);
     }
     SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
@@ -1078,7 +1074,7 @@ public class LogsMgr extends MgrBase {
 
       if (dateOfLogId != null) {
         logTime = dateUtil.convertDateWithMillisecondsToSolrDate(dateOfLogId);
-        Date endDate = dateUtil.addMilliSecondsToDate(dateOfLogId, 1);
+        Date endDate = DateUtils.addMilliseconds(dateOfLogId, 1);
         endTimeMinusOneMilli = (String) dateUtil
             .convertDateWithMillisecondsToSolrDate(endDate);
       }
@@ -1111,7 +1107,7 @@ public class LogsMgr extends MgrBase {
         String id = (String) solrDocumenent
             .getFieldValue(LogSearchConstants.ID);
         startIndex++;
-        if (!stringUtil.isEmpty(id)) {
+        if (!StringUtils.isBlank(id)) {
           if (id.equals(logId)) {
             break;
           }
@@ -1280,7 +1276,7 @@ public class LogsMgr extends MgrBase {
   }
 
   public String cancelFindRequestByDate(String uniqueId) {
-    if (stringUtil.isEmpty(uniqueId)) {
+    if (StringUtils.isEmpty(uniqueId)) {
       logger.error("Unique id is Empty");
       throw restErrorUtil.createRESTException("Unique id is Empty",
         MessageEnums.DATA_NOT_FOUND);
@@ -1294,7 +1290,7 @@ public class LogsMgr extends MgrBase {
   }
 
   public boolean cancelRequest(String uniqueId) {
-    if (stringUtil.isEmpty(uniqueId)) {
+    if (StringUtils.isBlank(uniqueId)) {
       logger.error("Unique id is Empty");
       throw restErrorUtil.createRESTException("Unique id is Empty",
         MessageEnums.DATA_NOT_FOUND);
@@ -1317,8 +1313,8 @@ public class LogsMgr extends MgrBase {
 
     format = defaultFormat.equalsIgnoreCase(format) && format != null ? ".txt"
         : ".json";
-
-    if(stringUtil.isEmpty(utcOffset)){
+    
+    if(StringUtils.isBlank(utcOffset)){
       utcOffset = "0";
     }
 
@@ -1368,7 +1364,7 @@ public class LogsMgr extends MgrBase {
       vsummary.setTo(to);
 
       String includeString = (String) searchCriteria.getParamValue("iMessage");
-      if (stringUtil.isEmpty(includeString)) {
+      if (StringUtils.isBlank(includeString)) {
         includeString = "";
       }
 
@@ -1378,7 +1374,7 @@ public class LogsMgr extends MgrBase {
         includeString = includeString + ",\"" + inc + "\"";
       }
       includeString = includeString.replaceFirst(",", "");
-      if (!stringUtil.isEmpty(includeString)) {
+      if (!StringUtils.isBlank(includeString)) {
         vsummary.setIncludeString(includeString);
       }
 
@@ -1386,7 +1382,7 @@ public class LogsMgr extends MgrBase {
       boolean isNormalExcluded = false;
 
       excludeString = (String) searchCriteria.getParamValue("eMessage");
-      if (stringUtil.isEmpty(excludeString)) {
+      if (StringUtils.isBlank(excludeString)) {
         excludeString = "";
       }
 
@@ -1396,14 +1392,14 @@ public class LogsMgr extends MgrBase {
       }
 
       excludeString = excludeString.replaceFirst(",", "");
-      if (!stringUtil.isEmpty(excludeString)) {
+      if (!StringUtils.isBlank(excludeString)) {
         vsummary.setExcludeString(excludeString);
         isNormalExcluded = true;
       }
 
       String globalExcludeString = (String) searchCriteria
           .getParamValue("gEMessage");
-      if (stringUtil.isEmpty(globalExcludeString)) {
+      if (StringUtils.isBlank(globalExcludeString)) {
         globalExcludeString = "";
       }
 
@@ -1414,7 +1410,7 @@ public class LogsMgr extends MgrBase {
         excludeString = excludeString + ",\"" + exc + "\"";
       }
 
-      if (!stringUtil.isEmpty(excludeString)) {
+      if (!StringUtils.isBlank(excludeString)) {
         if (!isNormalExcluded) {
           excludeString = excludeString.replaceFirst(",", "");
         }
@@ -1513,7 +1509,7 @@ public class LogsMgr extends MgrBase {
     try {
       String bundelId = (String) searchCriteria
         .getParamValue(LogSearchConstants.BUNDLE_ID);
-      if(stringUtil.isEmpty(bundelId)){
+      if(StringUtils.isBlank(bundelId)){
         bundelId = "";
       }
 
@@ -1709,18 +1705,18 @@ public class LogsMgr extends MgrBase {
     SolrDocumentList docList = null;
     String id = (String) searchCriteria
       .getParamValue(LogSearchConstants.ID);
-    if (stringUtil.isEmpty(id)) {
+    if (StringUtils.isBlank(id)) {
       return convertObjToString(vSolrLogList);
 
     }
     String maxRows = "";
 
     maxRows = (String) searchCriteria.getParamValue("numberRows");
-    if (stringUtil.isEmpty(maxRows)){
+    if (StringUtils.isBlank(maxRows)){
       maxRows = ""+maxRows;
     }
     String scrollType = (String) searchCriteria.getParamValue("scrollType");
-    if(stringUtil.isEmpty(scrollType)){
+    if(StringUtils.isBlank(scrollType)){
       scrollType = "";
     }
 
@@ -1744,7 +1740,7 @@ public class LogsMgr extends MgrBase {
           + docList.get(0).getFieldValue(
           LogSearchConstants.SEQUNCE_ID);
       }
-      if (stringUtil.isEmpty(logTime)) {
+      if (StringUtils.isBlank(logTime)) {
         return convertObjToString(vSolrLogList);
       }
     } catch (SolrServerException | SolrException | IOException e) {
@@ -1874,10 +1870,10 @@ public class LogsMgr extends MgrBase {
     TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
     GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
     utc.setTimeInMillis(new Date().getTime());
-    utc.set(GregorianCalendar.HOUR, 0);
-    utc.set(GregorianCalendar.MINUTE, 0);
-    utc.set(GregorianCalendar.MILLISECOND, 001);
-    utc.set(GregorianCalendar.SECOND, 0);
+    utc.set(Calendar.HOUR, 0);
+    utc.set(Calendar.MINUTE, 0);
+    utc.set(Calendar.MILLISECOND, 001);
+    utc.set(Calendar.SECOND, 0);
     dateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
     String from = dateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
     utc.set(Calendar.MILLISECOND, 999);
@@ -1889,7 +1885,7 @@ public class LogsMgr extends MgrBase {
         LogSearchConstants.LOGTIME, from,to);
     String level = LogSearchConstants.FATAL+","+LogSearchConstants.ERROR+","+LogSearchConstants.WARN;
     queryGenerator.setFilterClauseWithFieldName(solrQuery, level,
-        LogSearchConstants.SOLR_LEVEL, "", QueryGenerationBase.CONDITION.OR);
+        LogSearchConstants.SOLR_LEVEL, "", QueryGenerationBase.Condition.OR);
     try {
       serviceLogsSolrDao.process(solrQuery);
     } catch (SolrServerException | IOException e) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbc40ba/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java
index 99eb9f2..02e2e69 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java
@@ -35,8 +35,8 @@ import org.apache.ambari.logsearch.util.DateUtil;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.util.StringUtil;
 import org.apache.ambari.logsearch.view.VSolrLogList;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
@@ -57,53 +57,46 @@ import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 
 public class MgrBase {
-  static private Logger logger = Logger.getLogger(MgrBase.class);
+  private static final Logger logger = Logger.getLogger(MgrBase.class);
 
   @Autowired
-  SolrUtil solrUtil;
+  protected SolrUtil solrUtil;
 
   @Autowired
-  JSONUtil jsonUtil;
+  protected JSONUtil jsonUtil;
 
   @Autowired
-  QueryGeneration queryGenerator;
+  protected QueryGeneration queryGenerator;
 
   @Autowired
-  StringUtil stringUtil;
+  protected RESTErrorUtil restErrorUtil;
 
   @Autowired
-  RESTErrorUtil restErrorUtil;
+  protected DateUtil dateUtil;
 
-  @Autowired
-  DateUtil dateUtil;
-
-  JsonSerializer<Date> jsonDateSerialiazer = null;
-  JsonDeserializer<Date> jsonDateDeserialiazer = null;
+  private JsonSerializer<Date> jsonDateSerialiazer = null;
+  private JsonDeserializer<Date> jsonDateDeserialiazer = null;
 
-  public enum LOG_TYPE {
-    SERVICE {
-      @Override
-      public String getLabel() {
-        return "Service";
-      }
-    },
-    AUDIT {
-      @Override
-      public String getLabel() {
-        return "Audit";
-      }
-    };
-    public abstract String getLabel();
+  public enum LogType {
+    SERVICE("Service"),
+    AUDIT("Audit");
+    
+    private String label;
+    
+    private LogType(String label) {
+      this.label = label;
+    }
+    
+    public String getLabel() {
+      return label;
+    }
   }
 
   public MgrBase() {
     jsonDateSerialiazer = new JsonSerializer<Date>() {
 
       @Override
-      public JsonElement serialize(Date paramT,
-          java.lang.reflect.Type paramType,
-          JsonSerializationContext paramJsonSerializationContext) {
-
+      public JsonElement serialize(Date paramT, java.lang.reflect.Type paramType, JsonSerializationContext paramJsonSerializationContext) {
         return paramT == null ? null : new JsonPrimitive(paramT.getTime());
       }
     };
@@ -111,15 +104,15 @@ public class MgrBase {
     jsonDateDeserialiazer = new JsonDeserializer<Date>() {
 
       @Override
-      public Date deserialize(JsonElement json, java.lang.reflect.Type typeOfT,
-          JsonDeserializationContext context) throws JsonParseException {
+      public Date deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context)
+          throws JsonParseException {
         return json == null ? null : new Date(json.getAsLong());
       }
 
     };
   }
 
-  public String convertObjToString(Object obj) {
+  protected String convertObjToString(Object obj) {
     if (obj == null) {
       return "";
     }
@@ -136,8 +129,7 @@ public class MgrBase {
 
     // Get file from resources folder
     ClassLoader classLoader = getClass().getClassLoader();
-    File file = new File(classLoader.getResource("HadoopServiceConfig.json")
-        .getFile());
+    File file = new File(classLoader.getResource("HadoopServiceConfig.json").getFile());
 
     try (Scanner scanner = new Scanner(file)) {
 
@@ -150,26 +142,25 @@ public class MgrBase {
 
     } catch (IOException e) {
       logger.error("Unable to read HadoopServiceConfig.json", e);
-      throw restErrorUtil.createRESTException(e.getMessage(),
-          MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(e.getMessage(), MessageEnums.ERROR_SYSTEM);
     }
 
     String hadoopServiceConfig = result.toString();
     if (jsonUtil.isJSONValid(hadoopServiceConfig)) {
       return hadoopServiceConfig;
     }
-    throw restErrorUtil.createRESTException("Improper JSON",
-        MessageEnums.ERROR_SYSTEM);
+    throw restErrorUtil.createRESTException("Improper JSON", MessageEnums.ERROR_SYSTEM);
 
   }
   
-  protected VSolrLogList getLastPage(SearchCriteria searchCriteria,String logTimeField,SolrDaoBase solrDoaBase,SolrQuery lastPageQuery){
+  protected VSolrLogList getLastPage(SearchCriteria searchCriteria, String logTimeField, SolrDaoBase solrDoaBase,
+      SolrQuery lastPageQuery) {
     
     Integer maxRows = searchCriteria.getMaxRows();
     String givenSortType = searchCriteria.getSortType();
     searchCriteria = new SearchCriteria();
     searchCriteria.setSortBy(logTimeField);
-    if(givenSortType == null || givenSortType.equals(LogSearchConstants.DESCENDING_ORDER)){
+    if (givenSortType == null || givenSortType.equals(LogSearchConstants.DESCENDING_ORDER)) {
       lastPageQuery.removeSort(LogSearchConstants.LOGTIME);
       searchCriteria.setSortType(LogSearchConstants.ASCENDING_ORDER);
     } else {
@@ -185,8 +176,7 @@ public class MgrBase {
     try {
       queryGenerator.setStart(lastPageQuery, 0);
       queryGenerator.setRowCount(lastPageQuery, maxRows);
-      collection = getLogAsPaginationProvided(lastPageQuery,
-          solrDoaBase);
+      collection = getLogAsPaginationProvided(lastPageQuery, solrDoaBase);
       totalLogs = countQuery(lastPageQuery,solrDoaBase);
       if(maxRows != null){
         startIndex = Integer.parseInt("" + ((totalLogs/maxRows) * maxRows));
@@ -209,14 +199,12 @@ public class MgrBase {
 
     } catch (SolrException | SolrServerException | IOException | NumberFormatException e) {
       logger.error("Count Query was not executed successfully",e);
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
     return collection;
   }
 
-  public VSolrLogList getLogAsPaginationProvided(SolrQuery solrQuery,
-      SolrDaoBase solrDaoBase) {
+  protected VSolrLogList getLogAsPaginationProvided(SolrQuery solrQuery, SolrDaoBase solrDaoBase) {
     try {
       QueryResponse response = solrDaoBase.process(solrQuery);
       VSolrLogList collection = new VSolrLogList();
@@ -235,14 +223,11 @@ public class MgrBase {
       return collection;
     } catch (SolrException | SolrServerException | IOException e) {
       logger.error("Error during solrQuery=" + solrQuery, e);
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
-
   }
   
-  public Long countQuery(SolrQuery query,SolrDaoBase solrDaoBase) throws SolrException,
- SolrServerException, IOException {
+  protected Long countQuery(SolrQuery query,SolrDaoBase solrDaoBase) throws SolrException, SolrServerException, IOException {
     query.setRows(0);
     QueryResponse response = solrDaoBase.process(query);
     if (response == null) {
@@ -256,14 +241,14 @@ public class MgrBase {
   }
 
   protected String getUnit(String unit) {
-    if (stringUtil.isEmpty(unit)) {
+    if (StringUtils.isBlank(unit)) {
       unit = "+1HOUR";
     }
     return unit;
   }
 
   protected String getFrom(String from) {
-    if (stringUtil.isEmpty(from)) {
+    if (StringUtils.isBlank(from)) {
       Date date =  dateUtil.getTodayFromDate();
       try {
         from = dateUtil.convertGivenDateFormatToSolrDateFormat(date);
@@ -275,7 +260,7 @@ public class MgrBase {
   }
 
   protected String getTo(String to) {
-    if (stringUtil.isEmpty(to)) {
+    if (StringUtils.isBlank(to)) {
       to = "NOW";
     }
     return to;

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbc40ba/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java
index 0dccb74..398d270 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java
@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
 @Component
 public class PublicMgr extends MgrBase {
   @Autowired
-  LogsearchSimpleAuthenticationProvider simpleAuthenticationProvider;
+  private LogsearchSimpleAuthenticationProvider simpleAuthenticationProvider;
 
   public String getGeneralConfig() {
     VNameValueList nameValueList = new VNameValueList();

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbc40ba/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java
index dbc14e1..c6f7dc5 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java
@@ -18,11 +18,7 @@
  */
 package org.apache.ambari.logsearch.manager;
 
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.ambari.logsearch.common.UserSessionInfo;
-import org.apache.ambari.logsearch.security.context.LogsearchContextHolder;
-import org.apache.ambari.logsearch.security.context.LogsearchSecurityContext;
+import org.apache.ambari.logsearch.common.LogSearchContext;
 import org.apache.ambari.logsearch.web.model.User;
 import org.apache.log4j.Logger;
 import org.springframework.security.core.Authentication;
@@ -33,38 +29,28 @@ import org.springframework.stereotype.Component;
 @Component
 public class SessionMgr {
 
-  static final Logger logger = Logger.getLogger(SessionMgr.class);
+  private static final Logger logger = Logger.getLogger(SessionMgr.class);
 
   public SessionMgr() {
     logger.debug("SessionManager created");
   }
 
-  public UserSessionInfo processSuccessLogin(int authType, String userAgent) {
-    return processSuccessLogin(authType, userAgent, null);
-  }
-
-  public UserSessionInfo processSuccessLogin(int authType, String userAgent, HttpServletRequest httpRequest) {
+  public User processSuccessLogin() {
     boolean newSessionCreation = true;
-    UserSessionInfo userSession = null;
-    LogsearchSecurityContext context = LogsearchContextHolder.getSecurityContext();
-    if (context != null) {
-      userSession = context.getUserSession();
-    }
     Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
     WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails();
     String currentLoginId = authentication.getName();
-    if (userSession != null) {
-      if (validateUserSession(userSession, currentLoginId)) {
+    LogSearchContext context = LogSearchContext.getContext();
+    User user = context.getUser();
+    if (user != null) {
+      if (validateUser(user, currentLoginId)) {
         newSessionCreation = false;
       }
     }
     //
     if (newSessionCreation) {
-      // // Need to build the UserSession
-      userSession = new UserSessionInfo();
-      User user = new User();
+      user = new User();
       user.setUsername(currentLoginId);
-      userSession.setUser(user);
       if (details != null) {
         logger.info("Login Success: loginId=" + currentLoginId + ", sessionId=" + details.getSessionId()
           + ", requestId=" + details.getRemoteAddress());
@@ -74,15 +60,15 @@ public class SessionMgr {
 
     }
 
-    return userSession;
+    return user;
   }
 
-  protected boolean validateUserSession(UserSessionInfo userSession, String currentUsername) {
-    if (currentUsername.equalsIgnoreCase(userSession.getUser().getUsername())) {
+  private boolean validateUser(User user, String currentUsername) {
+    if (currentUsername.equalsIgnoreCase(user.getUsername())) {
       return true;
     } else {
       logger.info("loginId doesn't match loginId from HTTPSession. Will create new session. loginId="
-        + currentUsername + ", userSession=" + userSession, new Exception());
+        + currentUsername + ", user=" + user, new Exception());
       return false;
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbc40ba/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java
index c4fbd9f..28f806c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java
@@ -31,10 +31,10 @@ import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
 import org.apache.ambari.logsearch.query.QueryGeneration;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.util.StringUtil;
 import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
 import org.apache.ambari.logsearch.view.VUserConfig;
 import org.apache.ambari.logsearch.view.VUserConfigList;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
@@ -50,35 +50,26 @@ import org.springframework.stereotype.Component;
 @Component
 public class UserConfigMgr extends MgrBase {
 
-  static Logger logger = Logger.getLogger(UserConfigMgr.class);
+  private static final Logger logger = Logger.getLogger(UserConfigMgr.class);
 
   @Autowired
-  UserConfigSolrDao userConfigSolrDao;
-
-  @Autowired
-  SolrUtil solrUtil;
-
+  private UserConfigSolrDao userConfigSolrDao;
   @Autowired
-  RESTErrorUtil restErrorUtil;
-
+  private SolrUtil solrUtil;
   @Autowired
-  QueryGeneration queryGenerator;
-
+  private RESTErrorUtil restErrorUtil;
   @Autowired
-  StringUtil stringUtil;
+  private QueryGeneration queryGenerator;
 
   public String saveUserConfig(VUserConfig vHistory) {
 
     SolrInputDocument solrInputDoc = new SolrInputDocument();
     if (!isValid(vHistory)) {
-      throw restErrorUtil.createRESTException("No FilterName Specified",
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA);
     }
 
     if (isNotUnique(vHistory) && !vHistory.isOverwrite()) {
-      throw restErrorUtil.createRESTException(
-          "Name '" + vHistory.getFiltername() + "' already exists",
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException( "Name '" + vHistory.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
     }
     String loggedInUserName = vHistory.getUserName();
     String filterName = vHistory.getFiltername();
@@ -95,25 +86,20 @@ public class UserConfigMgr extends MgrBase {
     // Check whether the Filter Name exists in solr
     SolrQuery solrQuery = new SolrQuery();
     queryGenerator.setMainQuery(solrQuery, null);
-    queryGenerator.setSingleIncludeFilter(solrQuery,
-        LogSearchConstants.FILTER_NAME, solrUtil.makeSearcableString(filterName));
-    queryGenerator.setSingleIncludeFilter(solrQuery,
-        LogSearchConstants.USER_NAME, loggedInUserName);
+    queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.FILTER_NAME, solrUtil.makeSearcableString(filterName));
+    queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.USER_NAME, loggedInUserName);
     try {
       QueryResponse queryResponse = userConfigSolrDao.process(solrQuery);
       if (queryResponse != null) {
         SolrDocumentList documentList = queryResponse.getResults();
-        if (documentList != null && !documentList.isEmpty()
-            && !vHistory.isOverwrite()) {
+        if (documentList != null && !documentList.isEmpty() && !vHistory.isOverwrite()) {
           logger.error("Filtername is already present");
-          throw restErrorUtil.createRESTException(
-              "Filtername is already present", MessageEnums.INVALID_INPUT_DATA);
+          throw restErrorUtil.createRESTException("Filtername is already present", MessageEnums.INVALID_INPUT_DATA);
         }
       }
     } catch (SolrException | SolrServerException | IOException e) {
       logger.error("Error in checking same filtername config", e);
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
 
     try {
@@ -121,8 +107,7 @@ public class UserConfigMgr extends MgrBase {
       return convertObjToString(solrInputDoc);
     } catch (SolrException | SolrServerException | IOException e) {
       logger.error("Error saving user config. solrDoc=" + solrInputDoc, e);
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
   }
 
@@ -133,12 +118,10 @@ public class UserConfigMgr extends MgrBase {
     if (filterName != null && rowType != null) {
       SolrQuery solrQuery = new SolrQuery();
       filterName = solrUtil.makeSearcableString(filterName);
-      solrQuery.setQuery(LogSearchConstants.COMPOSITE_KEY + ":" + filterName
-          + "-" + rowType);
+      solrQuery.setQuery(LogSearchConstants.COMPOSITE_KEY + ":" + filterName + "-" + rowType);
       queryGenerator.setRowCount(solrQuery, 0);
       try {
-        Long numFound = userConfigSolrDao.process(solrQuery).getResults()
-            .getNumFound();
+        Long numFound = userConfigSolrDao.process(solrQuery).getResults().getNumFound();
         if (numFound > 0) {
           return true;
         }
@@ -150,18 +133,17 @@ public class UserConfigMgr extends MgrBase {
   }
 
   private boolean isValid(VUserConfig vHistory) {
-    return !stringUtil.isEmpty(vHistory.getFiltername())
-        && !stringUtil.isEmpty(vHistory.getRowType())
-        && !stringUtil.isEmpty(vHistory.getUserName())
-        && !stringUtil.isEmpty(vHistory.getValues());
+    return !StringUtils.isBlank(vHistory.getFiltername())
+        && !StringUtils.isBlank(vHistory.getRowType())
+        && !StringUtils.isBlank(vHistory.getUserName())
+        && !StringUtils.isBlank(vHistory.getValues());
   }
 
   public void deleteUserConfig(String id) {
     try {
       userConfigSolrDao.deleteUserConfig(id);
     } catch (SolrException | SolrServerException | IOException e) {
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
   }
 
@@ -171,40 +153,31 @@ public class UserConfigMgr extends MgrBase {
     SolrDocumentList solrList = new SolrDocumentList();
     VUserConfigList userConfigList = new VUserConfigList();
 
-    String rowType = (String) searchCriteria
-        .getParamValue(LogSearchConstants.ROW_TYPE);
-    if (stringUtil.isEmpty(rowType)) {
-      throw restErrorUtil.createRESTException("row type was not specified",
-          MessageEnums.INVALID_INPUT_DATA);
+    String rowType = (String) searchCriteria.getParamValue(LogSearchConstants.ROW_TYPE);
+    if (StringUtils.isBlank(rowType)) {
+      throw restErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA);
     }
 
-    String userName = (String) searchCriteria
-        .getParamValue(LogSearchConstants.USER_NAME);
-    if (stringUtil.isEmpty(userName)) {
-      throw restErrorUtil.createRESTException("user name was not specified",
-          MessageEnums.INVALID_INPUT_DATA);
+    String userName = (String) searchCriteria.getParamValue(LogSearchConstants.USER_NAME);
+    if (StringUtils.isBlank(userName)) {
+      throw restErrorUtil.createRESTException("user name was not specified", MessageEnums.INVALID_INPUT_DATA);
     }
-    String filterName = (String) searchCriteria
-        .getParamValue(LogSearchConstants.FILTER_NAME);
-    filterName = stringUtil.isEmpty(filterName) ? "*" : "*" + filterName + "*";
+    String filterName = (String) searchCriteria.getParamValue(LogSearchConstants.FILTER_NAME);
+    filterName = StringUtils.isBlank(filterName) ? "*" : "*" + filterName + "*";
 
     try {
 
       SolrQuery userConfigQuery = new SolrQuery();
       queryGenerator.setMainQuery(userConfigQuery, null);
       queryGenerator.setPagination(userConfigQuery, searchCriteria);
-      queryGenerator.setSingleIncludeFilter(userConfigQuery,
-          LogSearchConstants.ROW_TYPE, rowType);
-      queryGenerator.setSingleORFilter(userConfigQuery,
-          LogSearchConstants.USER_NAME, userName,
-          LogSearchConstants.SHARE_NAME_LIST, userName);
-      queryGenerator.setSingleIncludeFilter(userConfigQuery,
-          LogSearchConstants.FILTER_NAME, solrUtil.makeSearcableString(filterName));
-
-      if (stringUtil.isEmpty(searchCriteria.getSortBy())) {
+      queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.ROW_TYPE, rowType);
+      queryGenerator.setSingleORFilter(userConfigQuery, LogSearchConstants.USER_NAME, userName, LogSearchConstants.SHARE_NAME_LIST, userName);
+      queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.FILTER_NAME, solrUtil.makeSearcableString(filterName));
+
+      if (StringUtils.isBlank(searchCriteria.getSortBy())) {
         searchCriteria.setSortBy(LogSearchConstants.FILTER_NAME);
       }
-      if (stringUtil.isEmpty(searchCriteria.getSortType())) {
+      if (StringUtils.isBlank(searchCriteria.getSortType())) {
         searchCriteria.setSortType("" + SolrQuery.ORDER.asc);
       }
 
@@ -215,14 +188,12 @@ public class UserConfigMgr extends MgrBase {
 
       for (SolrDocument solrDoc : solrList) {
         VUserConfig userConfig = new VUserConfig();
-        userConfig.setFiltername(""
-            + solrDoc.get(LogSearchConstants.FILTER_NAME));
+        userConfig.setFiltername("" + solrDoc.get(LogSearchConstants.FILTER_NAME));
         userConfig.setId("" + solrDoc.get(LogSearchConstants.ID));
         userConfig.setValues("" + solrDoc.get(LogSearchConstants.VALUES));
         userConfig.setRowType("" + solrDoc.get(LogSearchConstants.ROW_TYPE));
         try {
-          List<String> shareNameList = (List<String>) solrDoc
-              .get(LogSearchConstants.SHARE_NAME_LIST);
+          List<String> shareNameList = (List<String>) solrDoc.get(LogSearchConstants.SHARE_NAME_LIST);
           userConfig.setShareNameList(shareNameList);
         } catch (Exception e) {
           // do nothing
@@ -243,8 +214,7 @@ public class UserConfigMgr extends MgrBase {
     } catch (SolrException | SolrServerException | IOException e) {
       // do nothing
       logger.error(e);
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
 
     return convertObjToString(userConfigList);
@@ -255,43 +225,30 @@ public class UserConfigMgr extends MgrBase {
     return saveUserConfig(vuserConfig);
   }
 
-  // ////////////////////////////LEVEL
-  // FILTER/////////////////////////////////////
+  // ////////////////////////////LEVEL FILTER/////////////////////////////////////
 
-  /**
-   * @return
-   */
   public String getUserFilter() {
     VLogfeederFilterWrapper userFilter;
     try {
       userFilter = userConfigSolrDao.getUserFilter();
     } catch (SolrServerException | IOException e) {
       logger.error(e);
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
     return convertObjToString(userFilter);
   }
 
-  /**
-   * Creating filter for logfeeder
-   *
-   * @param String
-   * @return
-   */
   public String saveUserFiter(String json) {
-    if (!stringUtil.isEmpty(json)) {
-      VLogfeederFilterWrapper logfeederFilterWrapper = (VLogfeederFilterWrapper) jsonUtil
-          .jsonToObj(json, VLogfeederFilterWrapper.class);
+    if (!StringUtils.isBlank(json)) {
+      VLogfeederFilterWrapper logfeederFilterWrapper = (VLogfeederFilterWrapper) jsonUtil.jsonToObj(json, VLogfeederFilterWrapper.class);
       try {
         if (logfeederFilterWrapper == null) {
           logger.error(json + " is a invalid json");
         }
-        userConfigSolrDao.saveUserFiter(logfeederFilterWrapper);
+        userConfigSolrDao.saveUserFilter(logfeederFilterWrapper);
       } catch (SolrException | SolrServerException | IOException e) {
         logger.error("user config not able to save", e);
-        throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-            .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+        throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
     }
     return getUserFilter();
@@ -307,20 +264,16 @@ public class UserConfigMgr extends MgrBase {
       if (queryResponse == null) {
         return convertObjToString(userList);
       }
-      List<Count> counList = queryResponse.getFacetField(
-          LogSearchConstants.USER_NAME).getValues();
+      List<Count> counList = queryResponse.getFacetField(LogSearchConstants.USER_NAME).getValues();
       for (Count cnt : counList) {
         String userName = cnt.getName();
         userList.add(userName);
       }
     } catch (SolrException | SolrServerException | IOException e) {
       logger.warn("Error getting all users.", e);
-      // do nothing
-      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
-          .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
     return convertObjToString(userList);
-
   }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbc40ba/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
index d934e84..0c8be45 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.SearchCriteria;
 import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.manager.MgrBase.LOG_TYPE;
+import org.apache.ambari.logsearch.manager.MgrBase.LogType;
 import org.apache.ambari.logsearch.util.ConfigUtil;
 import org.apache.ambari.logsearch.util.PropertiesUtil;
 import org.apache.commons.lang.StringUtils;
@@ -48,7 +48,7 @@ public class QueryGeneration extends QueryGenerationBase {
   private static Logger logger = Logger.getLogger(QueryGeneration.class);
 
   public SolrQuery commonServiceFilterQuery(SearchCriteria searchCriteria) {
-    LOG_TYPE logType = LOG_TYPE.SERVICE;
+    LogType logType = LogType.SERVICE;
     SolrQuery solrQuery = new SolrQuery();
     String treeParams = (String) searchCriteria.getParamValue("treeParams");
     String givenQuery = (String) searchCriteria.getParamValue("q");
@@ -59,19 +59,15 @@ public class QueryGeneration extends QueryGenerationBase {
     String eMessage = (String) searchCriteria.getParamValue("eMessage");
     String gEmessage = (String) searchCriteria.getParamValue("gEMessage");
     String selectedComp = (String) searchCriteria.getParamValue("selectComp");
-    String bundleId = (String) searchCriteria
-        .getParamValue(LogSearchConstants.BUNDLE_ID);
-    String globalExcludeComp = (String) searchCriteria
-        .getParamValue("gMustNot");
-    String unselectedComp = (String) searchCriteria
-        .getParamValue("unselectComp");
+    String bundleId = (String) searchCriteria.getParamValue(LogSearchConstants.BUNDLE_ID);
+    String globalExcludeComp = (String) searchCriteria.getParamValue("gMustNot");
+    String unselectedComp = (String) searchCriteria.getParamValue("unselectComp");
     String urlHostName = (String) searchCriteria.getParamValue("host_name");
-    String urlComponentName = (String) searchCriteria
-        .getParamValue("component_name");
+    String urlComponentName = (String) searchCriteria.getParamValue("component_name");
     String file_name = (String) searchCriteria.getParamValue("file_name");
     String advQuery = (String) searchCriteria.getParamValue("advanceSearch");
     // build advance query
-    if (!stringUtil.isEmpty(advQuery)) {
+    if (!StringUtils.isBlank(advQuery)) {
       String advQueryParameters[] = advQuery.split(Pattern.quote("}{"));
       SolrQuery advSolrQuery = new SolrQuery();
       for (String queryParam : advQueryParameters) {
@@ -79,25 +75,13 @@ public class QueryGeneration extends QueryGenerationBase {
         if (params != null && params.length > 1)
           advSolrQuery.setParam(params[0], params[1]);
       }
-      // Building and adding levels to filters
-      setFilterClauseWithFieldName(advSolrQuery, level,
-          LogSearchConstants.SOLR_LEVEL, "", CONDITION.OR);
+      setFilterClauseWithFieldName(advSolrQuery, level, LogSearchConstants.SOLR_LEVEL, "", Condition.OR);
+      setSingleRangeFilter(advSolrQuery, LogSearchConstants.LOGTIME, startTime, endTime);
+      setFilterClauseWithFieldName(advSolrQuery, unselectedComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR,
+          Condition.AND);
+      setFilterClauseWithFieldName(advSolrQuery, selectedComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.NO_OPERATOR,
+          Condition.OR);
 
-      // Adding Logtime to filters
-      setSingleRangeFilter(advSolrQuery, LogSearchConstants.LOGTIME, startTime,
-          endTime);
-
-      // Building and adding exlcude components to filters
-      setFilterClauseWithFieldName(advSolrQuery, unselectedComp,
-          LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR,
-          CONDITION.AND);
-
-      // Building and adding exlcude components to filters
-      setFilterClauseWithFieldName(advSolrQuery, selectedComp,
-          LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.NO_OPERATOR,
-          CONDITION.OR);
-
-      // Set Pagination
       setPagination(advSolrQuery, searchCriteria);
 
       return advSolrQuery;
@@ -105,140 +89,71 @@ public class QueryGeneration extends QueryGenerationBase {
 
     setMainQuery(solrQuery, givenQuery);
 
-    // Adding Logtime to filters
-    setSingleRangeFilter(solrQuery, LogSearchConstants.LOGTIME, startTime,
-        endTime);
-
-    // String mainFilterQuery = buildQueryFromJSONCompHost(jsonHCNames,
-    // selectedComp);
-
-    // if (mainFilterQuery != null && !mainFilterQuery.equals(""))
-    // solrQuery.addFilterQuery(mainFilterQuery);
-
-    // add component filter
-    addFilter(solrQuery, selectedComp, LogSearchConstants.SOLR_COMPONENT,
-        CONDITION.OR);
-
-    // add treeParams filter
-    // hosts comma separated list
-    addFilterQueryFromArray(solrQuery, treeParams,
-        LogSearchConstants.SOLR_HOST, CONDITION.OR);
-
-    // Building and adding levels to filters
-    setFilterClauseWithFieldName(solrQuery, level,
-        LogSearchConstants.SOLR_LEVEL, LogSearchConstants.NO_OPERATOR,
-        CONDITION.OR);
+    setSingleRangeFilter(solrQuery, LogSearchConstants.LOGTIME, startTime, endTime);
+    addFilter(solrQuery, selectedComp, LogSearchConstants.SOLR_COMPONENT, Condition.OR);
+    addFilterQueryFromArray(solrQuery, treeParams, LogSearchConstants.SOLR_HOST, Condition.OR);
 
-    // Building and adding include string to filters
-    setFilterClauseForSolrSearchableString(solrQuery, iMessage, CONDITION.OR,
-        LogSearchConstants.NO_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
+    setFilterClauseWithFieldName(solrQuery, level, LogSearchConstants.SOLR_LEVEL, LogSearchConstants.NO_OPERATOR, Condition.OR);
 
-    // Building and adding global exclude string to filters
-    setFilterClauseForSolrSearchableString(solrQuery, gEmessage, CONDITION.AND,
-        LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
+    setFilterClauseForSolrSearchableString(solrQuery, iMessage, Condition.OR, LogSearchConstants.NO_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
+    setFilterClauseForSolrSearchableString(solrQuery, gEmessage, Condition.AND, LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
+    setFilterClauseForSolrSearchableString(solrQuery, eMessage, Condition.AND, LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
 
-    // Building and adding exclude string to filter
-    setFilterClauseForSolrSearchableString(solrQuery, eMessage, CONDITION.AND,
-        LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
-
-    // Building and adding logfile to filters
     applyLogFileFilter(solrQuery, searchCriteria);
 
-    // Building and adding exclude components to filters
-    setFilterClauseWithFieldName(solrQuery, globalExcludeComp,
-        LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR,
-        CONDITION.AND);
-
-    // Building and adding exlcude components to filters
-    setFilterClauseWithFieldName(solrQuery, unselectedComp,
-        LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR,
-        CONDITION.AND);
+    setFilterClauseWithFieldName(solrQuery, globalExcludeComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
+    setFilterClauseWithFieldName(solrQuery, unselectedComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
 
-    // Building and adding host names given url
-    // setFilterClauseWithFieldName(solrQuery, urlHostName,
-    // LogSearchConstants.SOLR_HOST,
-    // "", "OR");
     urlHostName = solrUtil.escapeQueryChars(urlHostName);
     setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_HOST, urlHostName);
-    //
-    // //Building and addding component names given url
-    // setFilterClauseWithFieldName(solrQuery, urlComponents,
-    // LogSearchConstants.SOLR_COMPONENT,
-    // "", "OR");
     urlComponentName = solrUtil.escapeQueryChars(urlComponentName);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_COMPONENT,
-        urlComponentName);
+    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_COMPONENT, urlComponentName);
 
-    // Set Pagination
     setPagination(solrQuery, searchCriteria);
-
-    // SetSort type (by default Descending)
     setSortOrderDefaultServiceLog(solrQuery, searchCriteria);
-
-    // Set Bundle Id
     setSingleIncludeFilter(solrQuery, LogSearchConstants.BUNDLE_ID, bundleId);
-
-    // Set filename
     file_name = solrUtil.escapeQueryChars(file_name);
     setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_PATH, file_name);
-    // include query
-    this.setUserSpecificFilter(searchCriteria, solrQuery,
-        LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY,
-        logType);
-    // exclude query
-    this.setUserSpecificFilter(searchCriteria, solrQuery,
-        LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY,
-        logType);
+    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY, logType);
+    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY, logType);
+    
     return solrQuery;
   }
 
-  public void applyLogFileFilter(SolrQuery solrQuery,
-      SearchCriteria searchCriteria) {
+  public void applyLogFileFilter(SolrQuery solrQuery, SearchCriteria searchCriteria) {
     String hostLogFile = (String) searchCriteria.getParamValue("hostLogFile");
     String compLogFile = (String) searchCriteria.getParamValue("compLogFile");
     String givenQuery = (String) searchCriteria.getParamValue("q");
     String logfileQuery = "";
-    if (!stringUtil.isEmpty(hostLogFile) && !stringUtil.isEmpty(compLogFile)) {
-      logfileQuery = LogSearchConstants.SOLR_HOST + ":" + hostLogFile + " "
-          + CONDITION.AND + " " + LogSearchConstants.SOLR_COMPONENT + ":"
-          + compLogFile;
-      if (!stringUtil.isEmpty(givenQuery)) {
-        logfileQuery = "(" + givenQuery + ") " + CONDITION.AND + " ("
-            + logfileQuery + ")";
+    if (!StringUtils.isBlank(hostLogFile) && !StringUtils.isBlank(compLogFile)) {
+      logfileQuery = LogSearchConstants.SOLR_HOST + ":" + hostLogFile + " " + Condition.AND + " " +
+          LogSearchConstants.SOLR_COMPONENT + ":" + compLogFile;
+      if (!StringUtils.isBlank(givenQuery)) {
+        logfileQuery = "(" + givenQuery + ") " + Condition.AND + " (" + logfileQuery + ")";
       }
-      if (!stringUtil.isEmpty(logfileQuery)) {
+      if (!StringUtils.isBlank(logfileQuery)) {
         solrQuery.addFilterQuery(logfileQuery);
       }
     }
   }
 
-  public void setUserSpecificFilter(SearchCriteria searchCriteria,
-      SolrQuery solrQuery, String paramName, String operation, LOG_TYPE logType) {
+  private void setUserSpecificFilter(SearchCriteria searchCriteria, SolrQuery solrQuery, String paramName, String operation,
+      LogType logType) {
     String queryString = (String) searchCriteria.getParamValue(paramName);
-    String columnQuery = (String) searchCriteria
-        .getParamValue(LogSearchConstants.COLUMN_QUERY);
-    if (stringUtil.isEmpty(queryString)) {
+    String columnQuery = (String) searchCriteria.getParamValue(LogSearchConstants.COLUMN_QUERY);
+    if (StringUtils.isBlank(queryString)) {
       queryString = null;
     }
-    // if (!stringUtil.isEmpty(queryString) && "[]".equals(queryString)) {
-    // queryString = null;
-    // }
-    if (!stringUtil.isEmpty(columnQuery) && stringUtil.isEmpty(queryString)
-        && !paramName.equals(LogSearchConstants.EXCLUDE_QUERY)) {
+    if (!StringUtils.isBlank(columnQuery) && StringUtils.isBlank(queryString) && !paramName.equals(LogSearchConstants.EXCLUDE_QUERY)) {
       queryString = columnQuery;
     }
     List<String> conditionQuries = new ArrayList<String>();
     List<String> referalConditionQuries = new ArrayList<String>();
     List<String> elments = new ArrayList<String>();
-    // convert json to list of hashmap
-    List<HashMap<String, Object>> queryList = jsonUtil
-        .jsonToMapObjectList(queryString);
-    // null and size check
+    List<HashMap<String, Object>> queryList = jsonUtil.jsonToMapObjectList(queryString);
     if (queryList != null && queryList.size() > 0) {
-      if (!stringUtil.isEmpty(columnQuery) && !columnQuery.equals(queryString)
-          && !paramName.equals(LogSearchConstants.EXCLUDE_QUERY)) {
-        List<HashMap<String, Object>> columnQueryList = jsonUtil
-            .jsonToMapObjectList(columnQuery);
+      if (!StringUtils.isBlank(columnQuery) && !columnQuery.equals(queryString) && !paramName.equals(LogSearchConstants.EXCLUDE_QUERY)) {
+        List<HashMap<String, Object>> columnQueryList = jsonUtil.jsonToMapObjectList(columnQuery);
         if (columnQueryList != null && columnQueryList.size() > 0) {
           queryList.addAll(columnQueryList);
         }
@@ -248,12 +163,11 @@ public class QueryGeneration extends QueryGenerationBase {
         StringBuilder field = new StringBuilder();
         if (columnListMap != null) {
           for (String key : columnListMap.keySet()) {
-            if (!stringUtil.isEmpty(key)) {
+            if (!StringUtils.isBlank(key)) {
               String originalKey = getOriginalKey(key, logType);
-              String value = getOriginalValue(originalKey,
-                  "" + columnListMap.get(key));
+              String value = getOriginalValue(originalKey, "" + columnListMap.get(key));
               orQuery = putWildCardByType(value, originalKey, logType);
-              if (stringUtil.isEmpty(orQuery)) {
+              if (StringUtils.isBlank(orQuery)) {
                 logger.debug("Removing invalid filter for key :"+originalKey +" and value :" +value );
                 continue;
               }
@@ -264,8 +178,7 @@ public class QueryGeneration extends QueryGenerationBase {
               if (isSame && !operation.equals(LogSearchConstants.EXCLUDE_QUERY)) {
                 for (String tempCondition : conditionQuries) {
                   if (tempCondition.contains(originalKey)) {
-                    String newCondtion = tempCondition + " "
-                        + CONDITION.OR.name() + " " + orQuery;
+                    String newCondtion = tempCondition + " " + Condition.OR.name() + " " + orQuery;
                     referalConditionQuries.remove(tempCondition);
                     referalConditionQuries.add(newCondtion);
                   }
@@ -283,17 +196,16 @@ public class QueryGeneration extends QueryGenerationBase {
         }
       }
     }
-    if (!referalConditionQuries.isEmpty() && !stringUtil.isEmpty(operation)) {
-      if (operation.equals(LogSearchConstants.INCLUDE_QUERY)
-          || operation.equals(LogSearchConstants.COLUMN_QUERY)) {
+    if (!referalConditionQuries.isEmpty() && !StringUtils.isBlank(operation)) {
+      if (operation.equals(LogSearchConstants.INCLUDE_QUERY) || operation.equals(LogSearchConstants.COLUMN_QUERY)) {
         for (String filter : referalConditionQuries) {
-          if (!stringUtil.isEmpty(filter)) {
+          if (!StringUtils.isBlank(filter)) {
             solrQuery.addFilterQuery(filter);
           }
         }
       } else if (operation.equals(LogSearchConstants.EXCLUDE_QUERY)) {
         for (String filter : referalConditionQuries) {
-          if (!stringUtil.isEmpty(filter)) {
+          if (!StringUtils.isBlank(filter)) {
             filter = LogSearchConstants.MINUS_OPERATOR + filter;
             solrQuery.addFilterQuery(filter);
           }
@@ -303,40 +215,23 @@ public class QueryGeneration extends QueryGenerationBase {
   }
 
   public SolrQuery commonAuditFilterQuery(SearchCriteria searchCriteria) {
-    LOG_TYPE logType = LOG_TYPE.AUDIT;
+    LogType logType = LogType.AUDIT;
     SolrQuery solrQuery = new SolrQuery();
     solrQuery.setQuery("*:*");
     String startTime = (String) searchCriteria.getParamValue("startTime");
     String endTime = (String) searchCriteria.getParamValue("endTime");
-    String selectedComp = (String) searchCriteria
-        .getParamValue("includeString");
-    this.setFilterClauseWithFieldName(solrQuery, selectedComp,
-        LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.NO_OPERATOR,
-        CONDITION.OR);
-    String globalExcludeComp = (String) searchCriteria
-        .getParamValue("gMustNot");
-    this.setUserSpecificFilter(searchCriteria, solrQuery,
-        LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY,
-        logType);
-    this.setUserSpecificFilter(searchCriteria, solrQuery,
-        LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY,
-        logType);
-    String unselectedComp = (String) searchCriteria
-        .getParamValue("unselectComp");
-    this.setFilterClauseWithFieldName(solrQuery, globalExcludeComp,
-        LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.MINUS_OPERATOR,
-        CONDITION.AND);
-    // Building and adding exlcude components to filters
-    this.setFilterClauseWithFieldName(solrQuery, unselectedComp,
-        LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.MINUS_OPERATOR,
-        CONDITION.AND);
-    // Adding Logtime to filters
-    this.setSingleRangeFilter(solrQuery, LogSearchConstants.AUDIT_EVTTIME,
-        startTime, endTime);
-    this.setPagination(solrQuery, searchCriteria);
+    String selectedComp = (String) searchCriteria.getParamValue("includeString");
+    setFilterClauseWithFieldName(solrQuery, selectedComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.NO_OPERATOR, Condition.OR);
+    String globalExcludeComp = (String) searchCriteria.getParamValue("gMustNot");
+    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY, logType);
+    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY, logType);
+    String unselectedComp = (String) searchCriteria.getParamValue("unselectComp");
+    setFilterClauseWithFieldName(solrQuery, globalExcludeComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
+    setFilterClauseWithFieldName(solrQuery, unselectedComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
+    setSingleRangeFilter(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startTime, endTime);
+    setPagination(solrQuery, searchCriteria);
     try {
-      if (searchCriteria.getSortBy() == null
-          || searchCriteria.getSortBy().isEmpty()) {
+      if (searchCriteria.getSortBy() == null || searchCriteria.getSortBy().isEmpty()) {
         searchCriteria.setSortBy(LogSearchConstants.AUDIT_EVTTIME);
         searchCriteria.setSortType(SolrQuery.ORDER.desc.toString());
       }
@@ -344,11 +239,11 @@ public class QueryGeneration extends QueryGenerationBase {
       searchCriteria.setSortBy(LogSearchConstants.AUDIT_EVTTIME);
       searchCriteria.setSortType(SolrQuery.ORDER.desc.toString());
     }
-    this.setSortOrderDefaultServiceLog(solrQuery, searchCriteria);
+    setSortOrderDefaultServiceLog(solrQuery, searchCriteria);
     return solrQuery;
   }
 
-  private String putWildCardByType(String str, String key, LOG_TYPE logType) {
+  private String putWildCardByType(String str, String key, LogType logType) {
     String fieldType;
     SolrDaoBase solrDaoBase = null;
     switch (logType) {
@@ -368,10 +263,10 @@ public class QueryGeneration extends QueryGenerationBase {
       logger.error("Invalid logtype :" + logType);
       fieldType = null;
     }
-    if (!stringUtil.isEmpty(fieldType)) {
+    if (!StringUtils.isBlank(fieldType)) {
       if (solrUtil.isSolrFieldNumber(fieldType, solrDaoBase)) {
         String value = putEscapeCharacterForNumber(str, fieldType,solrDaoBase);
-        if (!stringUtil.isEmpty(value)) {
+        if (!StringUtils.isBlank(value)) {
           return key + ":" + value;
         } else {
           return null;
@@ -388,7 +283,7 @@ public class QueryGeneration extends QueryGenerationBase {
   }
 
   private String putEscapeCharacterForNumber(String str,String fieldType,SolrDaoBase solrDaoBase) {
-    if (!stringUtil.isEmpty(str)) {
+    if (!StringUtils.isBlank(str)) {
       str = str.replace("*", "");
     }
     String escapeCharSting = parseInputValueAsPerFieldType(str,fieldType,solrDaoBase);
@@ -420,28 +315,25 @@ public class QueryGeneration extends QueryGenerationBase {
 
   private String getOriginalValue(String name, String value) {
     String solrValue = PropertiesUtil.getProperty(name);
-    if (stringUtil.isEmpty(solrValue)) {
+    if (StringUtils.isBlank(solrValue)) {
       return value;
     }
     try {
-      String propertyFieldMappings[] = solrValue
-          .split(LogSearchConstants.LIST_SEPARATOR);
+      String propertyFieldMappings[] = solrValue.split(LogSearchConstants.LIST_SEPARATOR);
       if (propertyFieldMappings != null && propertyFieldMappings.length > 0) {
         HashMap<String, String> propertyFieldValue = new HashMap<String, String>();
         for (String temp : propertyFieldMappings) {
-          if (!stringUtil.isEmpty(temp)) {
+          if (!StringUtils.isBlank(temp)) {
             String arrayValue[] = temp.split(":");
             if (arrayValue.length > 1) {
-              propertyFieldValue.put(arrayValue[0].toLowerCase(Locale.ENGLISH),
-                  arrayValue[1].toLowerCase(Locale.ENGLISH));
+              propertyFieldValue.put(arrayValue[0].toLowerCase(Locale.ENGLISH), arrayValue[1].toLowerCase(Locale.ENGLISH));
             } else {
               logger.warn("array length is less than required length 1");
             }
           }
         }
-        String originalValue = propertyFieldValue.get(value
-            .toLowerCase(Locale.ENGLISH));
-        if (!stringUtil.isEmpty(originalValue)) {
+        String originalValue = propertyFieldValue.get(value.toLowerCase(Locale.ENGLISH));
+        if (!StringUtils.isBlank(originalValue)) {
           return originalValue;
         }
       }
@@ -451,35 +343,29 @@ public class QueryGeneration extends QueryGenerationBase {
     return value;
   }
 
-  private String getOriginalKey(String key, LOG_TYPE logType) {
+  private String getOriginalKey(String key, LogType logType) {
     String originalKey;
     switch (logType) {
     case AUDIT:
-      originalKey = ConfigUtil.auditLogsColumnMapping.get(key
-          + LogSearchConstants.UI_SUFFIX);
+      originalKey = ConfigUtil.auditLogsColumnMapping.get(key + LogSearchConstants.UI_SUFFIX);
       break;
     case SERVICE:
-      originalKey = ConfigUtil.serviceLogsColumnMapping.get(key
-          + LogSearchConstants.UI_SUFFIX);
+      originalKey = ConfigUtil.serviceLogsColumnMapping.get(key + LogSearchConstants.UI_SUFFIX);
       break;
     default:
       originalKey = null;
-      // set as null
     }
-    if (stringUtil.isEmpty(originalKey)) {
-      // return default values
+    if (StringUtils.isBlank(originalKey)) {
       return key;
     }
     return originalKey;
   }
   
-  public boolean checkTokenizer(String fieldType,Class tokenizerFactoryClass,SolrDaoBase solrDaoBase) {
+  private boolean checkTokenizer(String fieldType, Class tokenizerFactoryClass, SolrDaoBase solrDaoBase) {
     HashMap<String, Object> fieldTypeMap = solrUtil.getFieldTypeInfoMap(fieldType,solrDaoBase);
-    HashMap<String, Object> analyzer = (HashMap<String, Object>) fieldTypeMap
-        .get("analyzer");
+    HashMap<String, Object> analyzer = (HashMap<String, Object>) fieldTypeMap.get("analyzer");
     if (analyzer != null) {
-      HashMap<String, Object> tokenizerMap = (HashMap<String, Object>) analyzer
-          .get("tokenizer");
+      HashMap<String, Object> tokenizerMap = (HashMap<String, Object>) analyzer.get("tokenizer");
       if (tokenizerMap != null) {
         String tokenizerClass = (String) tokenizerMap.get("class");
         if (!StringUtils.isEmpty(tokenizerClass)) {
@@ -493,4 +379,4 @@ public class QueryGeneration extends QueryGenerationBase {
     }
     return false;
   }
-}
\ No newline at end of file
+}


Mime
View raw message