ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [2/5] ambari git commit: AMBARI-18227. Add unit tests for Log Search components and refactor them as needed - Vol 1. (Miklos Gergely via oleewere)
Date Tue, 23 Aug 2016 08:57:06 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
index a128098..ca6df65 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
@@ -29,56 +29,47 @@ import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.ambari.logsearch.util.QueryBase;
 import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.util.StringUtil;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrQuery.ORDER;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import com.google.gson.Gson;
-import com.sun.jersey.api.spring.Autowire;
 
 public abstract class QueryGenerationBase extends QueryBase {
 
-  static Logger logger = Logger.getLogger(QueryGenerationBase.class);
+  private static final Logger logger = Logger.getLogger(QueryGenerationBase.class);
 
   @Autowired
-  SolrUtil solrUtil;
-
-  @Autowired
-  StringUtil stringUtil;
-
-  @Autowired
-  JSONUtil jsonUtil;
+  protected SolrUtil solrUtil;
   
   @Autowired
-  AuditSolrDao auditSolrDao;
+  protected AuditSolrDao auditSolrDao;
   
   @Autowired
-  ServiceLogsSolrDao serviceLogsSolrDao;
-  
+  protected ServiceLogsSolrDao serviceLogsSolrDao;
   
+  @Autowired
+  protected JSONUtil jsonUtil;
 
-  public static enum CONDITION {
+  public static enum Condition {
     OR, AND
   }
 
   // SetMethods to apply to the query
-  public void setFilterClauseForSolrSearchableString(SolrQuery solrQuery,
-      String commaSepratedString, CONDITION condition, String operator,
-      String messageField) {
+  protected void setFilterClauseForSolrSearchableString(SolrQuery solrQuery, String commaSepratedString, Condition condition,
+      String operator, String messageField) {
     String filterQuery = "";
-    if (!stringUtil.isEmpty(commaSepratedString)) {
+    if (!StringUtils.isBlank(commaSepratedString)) {
       StringBuilder queryMsg = new StringBuilder();
       operator = (operator == null ? LogSearchConstants.NO_OPERATOR : operator);
-      String[] msgList = commaSepratedString
-          .split(LogSearchConstants.I_E_SEPRATOR);
+      String[] msgList = commaSepratedString.split(LogSearchConstants.I_E_SEPRATOR);
       int count = 0;
       for (String temp : msgList) {
         count += 1;
         if (LogSearchConstants.SOLR_LOG_MESSAGE.equalsIgnoreCase(messageField)) {
-          queryMsg.append(" " + operator
-              + solrUtil.escapeForLogMessage(messageField, temp));
+          queryMsg.append(" " + operator + solrUtil.escapeForLogMessage(messageField, temp));
         } else {
           temp = solrUtil.escapeForStandardTokenizer(temp);
           if(temp.startsWith("\"") && temp.endsWith("\"")){
@@ -86,8 +77,7 @@ public abstract class QueryGenerationBase extends QueryBase {
             temp = temp.substring(0, temp.length()-1);
           }
           temp = "*" + temp + "*";
-          queryMsg.append(" " + operator + messageField + ":"
-              + temp);
+          queryMsg.append(" " + operator + messageField + ":" + temp);
         }
         if (msgList.length > count){
           queryMsg.append(" " + condition.name() + " ");
@@ -99,21 +89,20 @@ public abstract class QueryGenerationBase extends QueryBase {
     }
   }
 
-  public void setFilterClauseWithFieldName(SolrQuery solrQuery,
-      String commaSepratedString, String field, String operator,
-      CONDITION condition) {
-    if (!stringUtil.isEmpty(commaSepratedString)) {
+  public void setFilterClauseWithFieldName(SolrQuery solrQuery, String commaSepratedString, String field, String operator,
+      Condition condition) {
+    if (!StringUtils.isBlank(commaSepratedString)) {
       String[] arrayOfSepratedString = commaSepratedString.split(LogSearchConstants.LIST_SEPARATOR);
       String filterQuery = null;
-      if (CONDITION.OR.equals(condition)) {
+      if (Condition.OR.equals(condition)) {
         filterQuery = solrUtil.orList(operator + field, arrayOfSepratedString,"");
-      } else if (CONDITION.AND.equals(condition)) {
+      } else if (Condition.AND.equals(condition)) {
         filterQuery = solrUtil.andList(operator + field, arrayOfSepratedString,"");
       }else{
         logger.warn("Not a valid condition :" + condition.name());
       }
       //add
-      if(!stringUtil.isEmpty(filterQuery)){
+      if (!StringUtils.isBlank(filterQuery)){
         solrQuery.addFilterQuery(filterQuery);
         logger.debug("Filter added :- " + filterQuery);
       }
@@ -121,58 +110,42 @@ public abstract class QueryGenerationBase extends QueryBase {
     }
   }
 
-  public void setSortOrderDefaultServiceLog(SolrQuery solrQuery,
-      SearchCriteria searchCriteria) {
+  public void setSortOrderDefaultServiceLog(SolrQuery solrQuery, SearchCriteria searchCriteria) {
     List<SolrQuery.SortClause> defaultSort = new ArrayList<SolrQuery.SortClause>();
-    if (searchCriteria.getSortBy() != null
-        && (!searchCriteria.getSortBy().isEmpty())) {
+    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
       ORDER order = SolrQuery.ORDER.asc;
-      if (searchCriteria.getSortType() != null
-          && (!searchCriteria.getSortType().isEmpty())
-          && !searchCriteria.getSortType().equalsIgnoreCase(order.toString())) {
+      if (!order.toString().equalsIgnoreCase(searchCriteria.getSortType())) {
         order = SolrQuery.ORDER.desc;
       }
-      SolrQuery.SortClause logtimeSortClause = SolrQuery.SortClause.create(
-          searchCriteria.getSortBy(), order);
+      SolrQuery.SortClause logtimeSortClause = SolrQuery.SortClause.create(searchCriteria.getSortBy(), order);
       defaultSort.add(logtimeSortClause);
     } else {
-      // by default sorting by logtime and sequence number in
-      // Descending order
-      SolrQuery.SortClause logtimeSortClause = SolrQuery.SortClause.create(
-          LogSearchConstants.LOGTIME, SolrQuery.ORDER.desc);
+      // by default sorting by logtime and sequence number in Descending order
+      SolrQuery.SortClause logtimeSortClause = SolrQuery.SortClause.create(LogSearchConstants.LOGTIME, SolrQuery.ORDER.desc);
       defaultSort.add(logtimeSortClause);
 
     }
-    SolrQuery.SortClause sequenceNumberSortClause = SolrQuery.SortClause
-        .create(LogSearchConstants.SEQUNCE_ID, SolrQuery.ORDER.desc);
+    SolrQuery.SortClause sequenceNumberSortClause = SolrQuery.SortClause.create(LogSearchConstants.SEQUNCE_ID, SolrQuery.ORDER.desc);
     defaultSort.add(sequenceNumberSortClause);
     solrQuery.setSorts(defaultSort);
     logger.debug("Sort Order :-" + defaultSort);
   }
 
-  public void setFilterFacetSort(SolrQuery solrQuery,
-                                 SearchCriteria searchCriteria) {
-    if (searchCriteria.getSortBy() != null
-      && (!searchCriteria.getSortBy().isEmpty())) {
+  public void setFilterFacetSort(SolrQuery solrQuery, SearchCriteria searchCriteria) {
+    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
       solrQuery.setFacetSort(searchCriteria.getSortBy());
       logger.info("Sorted By :- " + searchCriteria.getSortBy());
     }
   }
 
-  public void setSingleSortOrder(SolrQuery solrQuery,
-                                 SearchCriteria searchCriteria) {
+  public void setSingleSortOrder(SolrQuery solrQuery, SearchCriteria searchCriteria) {
     List<SolrQuery.SortClause> sort = new ArrayList<SolrQuery.SortClause>();
-    if (searchCriteria.getSortBy() != null
-      && (!searchCriteria.getSortBy().isEmpty())) {
+    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
       ORDER order = SolrQuery.ORDER.asc;
-      if (searchCriteria.getSortType() != null
-        && (!searchCriteria.getSortType().isEmpty())
-        && !searchCriteria.getSortType().equalsIgnoreCase(
-        order.toString())) {
+      if (!order.toString().equalsIgnoreCase(searchCriteria.getSortType())) {
         order = SolrQuery.ORDER.desc;
       }
-      SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(
-        searchCriteria.getSortBy(), order);
+      SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(searchCriteria.getSortBy(), order);
       sort.add(sortOrder);
       solrQuery.setSorts(sort);
       logger.debug("Sort Order :-" + sort);
@@ -182,23 +155,19 @@ public abstract class QueryGenerationBase extends QueryBase {
   // Search Criteria has parameter "sort" from it can get list of Sort Order
   // Example of list can be [logtime desc,seq_num desc]
   @SuppressWarnings("unchecked")
-  public void setMultipleSortOrder(SolrQuery solrQuery,
-      SearchCriteria searchCriteria) {
+  public void setMultipleSortOrder(SolrQuery solrQuery, SearchCriteria searchCriteria) {
     List<SolrQuery.SortClause> sort = new ArrayList<SolrQuery.SortClause>();
     List<String> sortList = (List<String>) searchCriteria.getParamValue("sort");
     if (sortList != null) {
       for (String sortOrder : sortList) {
-        if (!stringUtil.isEmpty(sortOrder)) {
+        if (!StringUtils.isBlank(sortOrder)) {
           String sortByAndOrder[] = sortOrder.split(" ");
           if (sortByAndOrder.length > 1) {
-            ORDER order = sortByAndOrder[1].contains("asc") ? SolrQuery.ORDER.asc
-                : SolrQuery.ORDER.desc;
-            SolrQuery.SortClause solrSortClause = SolrQuery.SortClause.create(
-                sortByAndOrder[0], order);
+            ORDER order = sortByAndOrder[1].contains("asc") ? SolrQuery.ORDER.asc : SolrQuery.ORDER.desc;
+            SolrQuery.SortClause solrSortClause = SolrQuery.SortClause.create(sortByAndOrder[0], order);
             sort.add(solrSortClause);
             logger.debug("Sort Order :-" + sort);
           } else {
-            // log warn
             logger.warn("Not a valid sort Clause " + sortOrder);
           }
         }
@@ -207,34 +176,26 @@ public abstract class QueryGenerationBase extends QueryBase {
     }
   }
 
-  public void setSingleIncludeFilter(SolrQuery solrQuery, String filterType,
-                                     String filterValue) {
-    if (filterType != null && !filterType.isEmpty() && filterValue != null
-      && !filterValue.isEmpty()) {
+  public void setSingleIncludeFilter(SolrQuery solrQuery, String filterType, String filterValue) {
+    if (!StringUtils.isBlank(filterType) && !StringUtils.isBlank(filterValue)) {
       String filterQuery = buildFilterQuery(filterType, filterValue);
       solrQuery.addFilterQuery(filterQuery);
       logger.debug("Filter added :- " + filterQuery);
     }
   }
 
-  public void setSingleExcludeFilter(SolrQuery solrQuery, String filterType,
-      String filterValue) {
-    if (!stringUtil.isEmpty(filterValue) && !stringUtil.isEmpty(filterType)) {
-      String filterQuery = LogSearchConstants.MINUS_OPERATOR
-          + buildFilterQuery(filterType, filterValue);
+  public void setSingleExcludeFilter(SolrQuery solrQuery, String filterType, String filterValue) {
+    if (!StringUtils.isBlank(filterValue) && !StringUtils.isBlank(filterType)) {
+      String filterQuery = LogSearchConstants.MINUS_OPERATOR + buildFilterQuery(filterType, filterValue);
       solrQuery.addFilterQuery(filterQuery);
       logger.debug("Filter added :- " + filterQuery);
     }
   }
 
-  public void setSingleRangeFilter(SolrQuery solrQuery, String filterType,
-      String filterFromValue, String filterToValue) {
-    if (!stringUtil.isEmpty(filterToValue)
-        && !stringUtil.isEmpty(filterType)
-        && !stringUtil.isEmpty(filterFromValue)) {
-      String filterQuery = buildInclusiveRangeFilterQuery(filterType,
-          filterFromValue, filterToValue);
-      if (!stringUtil.isEmpty(filterQuery)) {
+  public void setSingleRangeFilter(SolrQuery solrQuery, String filterType, String filterFromValue, String filterToValue) {
+    if (!StringUtils.isBlank(filterToValue) && !StringUtils.isBlank(filterType) && !StringUtils.isBlank(filterFromValue)) {
+      String filterQuery = buildInclusiveRangeFilterQuery(filterType, filterFromValue, filterToValue);
+      if (!StringUtils.isBlank(filterQuery)) {
         solrQuery.addFilterQuery(filterQuery);
         logger.debug("Filter added :- " + filterQuery);
       }
@@ -258,30 +219,17 @@ public abstract class QueryGenerationBase extends QueryBase {
     }
 
     if (startIndex != null && maxRows != null)
-      logger.info("Pagination was set from " + startIndex.intValue()
-        + " to " + maxRows.intValue());
+      logger.info("Pagination was set from " + startIndex.intValue() + " to " + maxRows.intValue());
   }
 
-  public void setSingleORFilter(SolrQuery solrQuery, String filterName1,
-      String value1, String filterName2, String value2) {
-    String filterQuery = filterName1 + ":" + value1 + " " + CONDITION.OR.name()
-        + " " + filterName2 + ":" + value2;
+  public void setSingleORFilter(SolrQuery solrQuery, String filterName1, String value1, String filterName2, String value2) {
+    String filterQuery = filterName1 + ":" + value1 + " " + Condition.OR.name() + " " + filterName2 + ":" + value2;
     solrQuery.setFilterQueries(filterQuery);
   }
 
   // BuildMethods to prepare a particular format as required for solr
-  public String buildInclusiveRangeFilterQuery(String filterType,
-                                               String filterFromValue, String filterToValue) {
-    String filterQuery = filterType + ":[" + filterFromValue + " TO "
-      + filterToValue + "]";
-    logger.info("Build Filter was :- " + filterQuery);
-    return filterQuery;
-  }
-
-  public String buildExclusiveRangeFilterQuery(String filterType,
-                                               String filterFromValue, String filterToValue) {
-    String filterQuery = filterType + ":{" + filterFromValue + " TO "
-      + filterToValue + "}";
+  public String buildInclusiveRangeFilterQuery(String filterType, String filterFromValue, String filterToValue) {
+    String filterQuery = filterType + ":[" + filterFromValue + " TO " + filterToValue + "]";
     logger.info("Build Filter was :- " + filterQuery);
     return filterQuery;
   }
@@ -292,139 +240,32 @@ public abstract class QueryGenerationBase extends QueryBase {
     return filterQuery;
   }
 
-//  public String buildQueryFromJSONCompHost(String jsonHCNames,
-//      String selectedComponent) {
-//    String queryHostComponent = "";
-//    // Building and adding exclude string to filters
-//    String selectedCompQuery = "";
-//    if (!stringUtil.isEmpty(selectedComponent)) {
-//      String[] selectedComponents = selectedComponent
-//          .split(LogSearchConstants.LIST_SEPARATOR);
-//      selectedCompQuery = solrUtil.orList(LogSearchConstants.SOLR_COMPONENT,
-//          selectedComponents);
-//    }
-//
-//    // Building Query of Host and Components from given json
-//    if (jsonHCNames != null && !jsonHCNames.equals("")
-//        && !jsonHCNames.equals("[]")) {
-//
-//      try {
-//        JSONArray jarray = new JSONArray(jsonHCNames);
-//        int flagHost = 0;
-//        int flagComp;
-//        int count;
-//        for (int i = 0; i < jarray.length(); i++) {
-//          if (flagHost == 1)
-//            queryHostComponent = queryHostComponent + " OR ";
-//          JSONObject jsonObject = jarray.getJSONObject(i);
-//          String host = jsonObject.getString("h");
-//          queryHostComponent = queryHostComponent + "( host:" + host;
-//          List<String> components = JSONUtil.JSONToList(jsonObject
-//              .getJSONArray("c"));
-//          if (!components.isEmpty())
-//            queryHostComponent = queryHostComponent + " AND ";
-//
-//          flagComp = 0;
-//          count = 0;
-//          for (String comp : components) {
-//            if (flagComp == 0)
-//              queryHostComponent = queryHostComponent + " ( ";
-//            count += 1;
-//            queryHostComponent = queryHostComponent + " " + " type:" + comp;
-//            if (components.size() <= count)
-//              queryHostComponent = queryHostComponent + " ) ";
-//            else
-//              queryHostComponent = queryHostComponent + " OR ";
-//            flagComp = 1;
-//          }
-//          queryHostComponent = queryHostComponent + " ) ";
-//          flagHost = 1;
-//        }
-//      } catch (JSONException e) {
-//        logger.error(e);
-//      }
-//    }
-//    if (selectedCompQuery != null && !selectedCompQuery.equals("")) {
-//      if (queryHostComponent == null || queryHostComponent.equals(""))
-//        queryHostComponent = selectedCompQuery;
-//      else
-//        queryHostComponent = queryHostComponent + " OR " + selectedCompQuery;
-//    }
-//    return queryHostComponent;
-//  }
-
-  // JSON BuildMethods
-
-  /**
-   * @param function , xAxisField
-   * @return jsonString
-   */
-  public String buildJSONFacetAggregatedFuncitonQuery(String function,
-                                                      String xAxisField) {
+  public String buildJSONFacetAggregatedFuncitonQuery(String function, String xAxisField) {
     return "{x:'" + function + "(" + xAxisField + ")'}";
   }
 
-  /**
-   * @param fieldName , fieldTime, from, to, unit
-   * @return jsonString
-   * @hierarchy Term, Time Range
-   */
-  public String buildJSONFacetTermTimeRangeQuery(String fieldName,
-                                                 String fieldTime, String from, String to, String unit) {
+  public String buildJSONFacetTermTimeRangeQuery(String fieldName, String fieldTime, String from, String to, String unit) {
     String query = "{";
-    query += "x" + ":{type:terms,field:" + fieldName
-      + ",facet:{y:{type:range,field:" + fieldTime + ",start:\""
-      + from + "\",end:\"" + to + "\",gap:\"" + unit + "\"}}}";
+    query += "x" + ":{type:terms,field:" + fieldName + ",facet:{y:{type:range,field:" + fieldTime + ",start:\"" + from + "\",end:\"" + to + "\",gap:\"" + unit + "\"}}}";
     query += "}";
     logger.info("Build JSONQuery is :- " + query);
     return query;
   }
 
-  /**
-   * @param stackField , xAxisField
-   * @return jsonString
-   * @hierarchy Term, Range
-   */
-  public String buildJsonFacetTermsRangeQuery(String stackField,
-                                              String xAxisField) {
-    String jsonQuery = "{ " + stackField + ": { type: terms,field:"
-      + stackField + "," + "facet: {   x: { type: terms, field:"
-      + xAxisField + ",mincount:0,sort:{index:asc}}}}}";
-    logger.info("Build JSONQuery is :- " + jsonQuery);
-    return jsonQuery;
-  }
-
-  /**
-   * @param stackField , xAxisField, function
-   * @return
-   * @hierarchy Term, Range
-   */
-  public String buidlJSONFacetRangeQueryForNumber(String stackField,
-                                                  String xAxisField, String function) {
-    String jsonQuery = "{ " + stackField + ": { type: terms,field:"
-      + stackField + "," + "facet: {   x:'" + function + "("
-      + xAxisField + ")'}}}}";
+  public String buildJsonFacetTermsRangeQuery(String stackField, String xAxisField) {
+    String jsonQuery = "{ " + stackField + ": { type: terms,field:" + stackField + "," + "facet: {   x: { type: terms, field:" + xAxisField + ",mincount:0,sort:{index:asc}}}}}";
     logger.info("Build JSONQuery is :- " + jsonQuery);
     return jsonQuery;
   }
 
-  /**
-   * @param stackField , xAxisField, function
-   * @return
-   * @hierarchy Query, T
-   */
-  public String buidlJSONFacetRangeQueryForSuggestion(
-    String originalFieldName, String valueToSuggest) {
-    String jsonQuery = "{y:{type:query,query:\"" + originalFieldName + ":"
-      + valueToSuggest + "\",facet:{x:{type:terms,field:"
-      + originalFieldName + "}}}}";
+  public String buidlJSONFacetRangeQueryForNumber(String stackField, String xAxisField, String function) {
+    String jsonQuery = "{ " + stackField + ": { type: terms,field:" + stackField + "," + "facet: {   x:'" + function + "(" + xAxisField + ")'}}}}";
     logger.info("Build JSONQuery is :- " + jsonQuery);
     return jsonQuery;
   }
 
-  public String buildListQuery(String paramValue, String solrFieldName,
-      CONDITION condition) {
-    if (!stringUtil.isEmpty(paramValue)) {
+  private String buildListQuery(String paramValue, String solrFieldName, Condition condition) {
+    if (!StringUtils.isBlank(paramValue)) {
       String[] values = paramValue.split(LogSearchConstants.LIST_SEPARATOR);
       switch (condition) {
       case OR:
@@ -438,10 +279,8 @@ public abstract class QueryGenerationBase extends QueryBase {
     return "";
   }
 
-
-  public void addFilterQueryFromArray(SolrQuery solrQuery, String jsonArrStr,
-      String solrFieldName, CONDITION condition) {
-    if (!stringUtil.isEmpty(jsonArrStr) && condition != null && solrQuery!=null) {
+  protected void addFilterQueryFromArray(SolrQuery solrQuery, String jsonArrStr, String solrFieldName, Condition condition) {
+    if (!StringUtils.isBlank(jsonArrStr) && condition != null && solrQuery != null) {
       Gson gson = new Gson();
       String[] arr = null;
       try {
@@ -462,16 +301,15 @@ public abstract class QueryGenerationBase extends QueryBase {
         query=null;
         logger.error("Invalid condition :" + condition.name());
       }
-      if (!stringUtil.isEmpty(query)) {
+      if (!StringUtils.isBlank(query)) {
         solrQuery.addFilterQuery(query);
       }
     }
   }
 
-  public void addFilter(SolrQuery solrQuery, String paramValue,
-      String solrFieldName, CONDITION condition) {
+  protected void addFilter(SolrQuery solrQuery, String paramValue, String solrFieldName, Condition condition) {
     String filterQuery = buildListQuery(paramValue, solrFieldName, condition);
-    if (!stringUtil.isEmpty(filterQuery)) {
+    if (!StringUtils.isBlank(filterQuery)) {
       if (solrQuery != null) {
         solrQuery.addFilterQuery(filterQuery);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java
index 373f7ff..a906ceb 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java
@@ -113,7 +113,7 @@ public class ServiceLogsREST {
   public String getHosts(@Context HttpServletRequest request) {
     SearchCriteria searchCriteria = new SearchCriteria(request);
     searchCriteria.addParam("q", request.getParameter("q"));
-    return logMgr.getHosts(searchCriteria);
+    return logMgr.getHosts();
   }
 
   @GET
@@ -126,7 +126,7 @@ public class ServiceLogsREST {
   public String getComponents(@Context HttpServletRequest request) {
     SearchCriteria searchCriteria = new SearchCriteria(request);
     searchCriteria.addParam("q", request.getParameter("q"));
-    return logMgr.getComponents(searchCriteria);
+    return logMgr.getComponents();
   }
 
   @GET
@@ -174,7 +174,7 @@ public class ServiceLogsREST {
     searchCriteria
       .addParam("startDate", request.getParameter("start_time"));
     searchCriteria.addParam("endDate", request.getParameter("end_time"));
-    return logMgr.getLogLevelCount(searchCriteria);
+    return logMgr.getLogLevelCount();
   }
 
   @GET
@@ -192,7 +192,7 @@ public class ServiceLogsREST {
     searchCriteria
       .addParam("startDate", request.getParameter("start_time"));
     searchCriteria.addParam("endDate", request.getParameter("end_time"));
-    return logMgr.getComponentsCount(searchCriteria);
+    return logMgr.getComponentsCount();
   }
 
   @GET
@@ -216,7 +216,7 @@ public class ServiceLogsREST {
       .unescapeXml(request.getParameter("excludeQuery")));
     searchCriteria.addParam("includeQuery", StringEscapeUtils
       .unescapeXml(request.getParameter("includeQuery")));
-    return logMgr.getHostsCount(searchCriteria);
+    return logMgr.getHostsCount();
   }
 
   @GET

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchContextHolder.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchContextHolder.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchContextHolder.java
deleted file mode 100644
index fb23cde..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchContextHolder.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.security.context;
-
-public class LogsearchContextHolder {
-
-  private static final ThreadLocal<LogsearchSecurityContext> securityContextThreadLocal = new ThreadLocal<LogsearchSecurityContext>();
-
-  private LogsearchContextHolder() {
-
-  }
-
-  public static LogsearchSecurityContext getSecurityContext() {
-    return securityContextThreadLocal.get();
-  }
-
-  public static void setSecurityContext(LogsearchSecurityContext context) {
-    securityContextThreadLocal.set(context);
-  }
-
-  public static void resetSecurityContext() {
-    securityContextThreadLocal.remove();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchSecurityContext.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchSecurityContext.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchSecurityContext.java
deleted file mode 100644
index 4a79525..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/security/context/LogsearchSecurityContext.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.security.context;
-
-import java.io.Serializable;
-
-import org.apache.ambari.logsearch.common.RequestContext;
-import org.apache.ambari.logsearch.common.UserSessionInfo;
-
-
-public class LogsearchSecurityContext implements Serializable{
-    private static final long serialVersionUID = 1L;
-    private UserSessionInfo userSession;
-    private RequestContext requestContext;
-
-    public UserSessionInfo getUserSession() {
-        return userSession;
-    }
-
-    public void setUserSession(UserSessionInfo userSession) {
-        this.userSession = userSession;
-    }
-
-    /**
-     * @return the requestContext
-     */
-    public RequestContext getRequestContext() {
-        return requestContext;
-    }
-
-    /**
-     * @param requestContext the requestContext to set
-     */
-    public void setRequestContext(RequestContext requestContext) {
-        this.requestContext = requestContext;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
index 8dd0fb9..814b8ee 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
@@ -37,27 +37,22 @@ import org.apache.ambari.logsearch.view.VBarGraphData;
 import org.apache.ambari.logsearch.view.VHost;
 import org.apache.ambari.logsearch.view.VNameValue;
 import org.apache.ambari.logsearch.view.VSummary;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
 public class BizUtil {
-  static Logger logger = Logger.getLogger(BizUtil.class);
-
-  @Autowired
-  RESTErrorUtil restErrorUtil;
-  
-  @Autowired
-  StringUtil stringUtil;
+  private static final Logger logger = Logger.getLogger(BizUtil.class);
 
   public String convertObjectToNormalText(SolrDocumentList docList) {
     String textToSave = "";
     HashMap<String, String> blankFieldsMap = new HashMap<String, String>();
-    if(docList == null){
+    if (docList == null){
       return "no data";
     }
     if (docList.isEmpty()) {
@@ -67,66 +62,50 @@ public class BizUtil {
     if(docForBlankCaculation == null){
       return "no data";
     }
-    Collection<String> fieldsForBlankCaculation = docForBlankCaculation
-      .getFieldNames();
+    Collection<String> fieldsForBlankCaculation = docForBlankCaculation.getFieldNames();
 
     int maxLengthOfField = 0;
-    if(fieldsForBlankCaculation == null){
+    if (fieldsForBlankCaculation == null) {
       return "no data";
     }
-    for (String field : fieldsForBlankCaculation) {  
-      if (!stringUtil.isEmpty(field) && field.length() > maxLengthOfField){
+    for (String field : fieldsForBlankCaculation) {
+      if (!StringUtils.isBlank(field) && field.length() > maxLengthOfField) {
         maxLengthOfField = field.length();
       }
     }
 
     for (String field : fieldsForBlankCaculation) {
-      if(!stringUtil.isEmpty(field)){
-      blankFieldsMap
-        .put(field,
-          addBlanksToString(
-            maxLengthOfField - field.length(), field));
+      if (!StringUtils.isBlank(field)) {
+      blankFieldsMap.put(field, addBlanksToString(maxLengthOfField - field.length(), field));
       }
-    }   
+    }
 
     for (SolrDocument doc : docList) {
       if (doc != null) {
         StringBuffer textTowrite = new StringBuffer();
 
         if (doc.getFieldValue(LogSearchConstants.LOGTIME) != null) {
-          textTowrite.append(doc.getFieldValue(LogSearchConstants.LOGTIME)
-              .toString() + " ");
+          textTowrite.append(doc.getFieldValue(LogSearchConstants.LOGTIME).toString() + " ");
         }
         if (doc.getFieldValue(LogSearchConstants.SOLR_LEVEL) != null) {
-          textTowrite.append(
-              doc.getFieldValue(LogSearchConstants.SOLR_LEVEL).toString())
-              .append(" ");
+          textTowrite.append(doc.getFieldValue(LogSearchConstants.SOLR_LEVEL).toString()).append(" ");
         }
         if (doc.getFieldValue(LogSearchConstants.SOLR_THREAD_NAME) != null) {
-          textTowrite.append(
-              doc.getFieldValue(LogSearchConstants.SOLR_THREAD_NAME).toString()
-                  .trim()).append(" ");
+          textTowrite.append(doc.getFieldValue(LogSearchConstants.SOLR_THREAD_NAME).toString().trim()).append(" ");
         }
         if (doc.getFieldValue(LogSearchConstants.SOLR_LOGGER_NAME) != null) {
-          textTowrite.append(
-              doc.getFieldValue(LogSearchConstants.SOLR_LOGGER_NAME).toString()
-                  .trim()).append(" ");
+          textTowrite.append(doc.getFieldValue(LogSearchConstants.SOLR_LOGGER_NAME).toString().trim()).append(" ");
         }
-        if (doc.getFieldValue(LogSearchConstants.SOLR_FILE) != null
-            && doc.getFieldValue(LogSearchConstants.SOLR_LINE_NUMBER) != null) {
+        if (doc.getFieldValue(LogSearchConstants.SOLR_FILE) != null && doc.getFieldValue(LogSearchConstants.SOLR_LINE_NUMBER) != null) {
           textTowrite
-              .append(
-                  doc.getFieldValue(LogSearchConstants.SOLR_FILE).toString())
+              .append(doc.getFieldValue(LogSearchConstants.SOLR_FILE).toString())
               .append(":")
-              .append(
-                  doc.getFieldValue(LogSearchConstants.SOLR_LINE_NUMBER)
-                      .toString()).append(" ");
+              .append(doc.getFieldValue(LogSearchConstants.SOLR_LINE_NUMBER).toString())
+              .append(" ");
         }
         if (doc.getFieldValue(LogSearchConstants.SOLR_LOG_MESSAGE) != null) {
           textTowrite.append("- ")
-              .append(
-                  doc.getFieldValue(LogSearchConstants.SOLR_LOG_MESSAGE)
-                      .toString());
+              .append(doc.getFieldValue(LogSearchConstants.SOLR_LOG_MESSAGE).toString());
         }
         textTowrite.append("\n");
         textToSave += textTowrite.toString();
@@ -137,7 +116,7 @@ public class BizUtil {
 
   public VSummary buildSummaryForLogFile(SolrDocumentList docList) {
     VSummary vsummary = new VSummary();
-    if(docList == null || docList.isEmpty()){
+    if (CollectionUtils.isEmpty(docList)) {
       return vsummary;
     }
     int numLogs = 0;
@@ -150,14 +129,14 @@ public class BizUtil {
         String hostname = (String) doc.getFieldValue("host");
         String comp = (String) doc.getFieldValue("type");
         String level = (String) doc.getFieldValue("level");
-        if (stringUtil.isEmpty(level)) {
+        if (StringUtils.isBlank(level)) {
           level = "";
         }
         boolean newHost = true;
         for (VHost host : vHosts) {
           if (host != null && host.getName().equals(hostname)) {
             newHost = false;
-            if (stringUtil.isEmpty(comp)) {
+            if (StringUtils.isBlank(comp)) {
               Set<String> compList = host.getComponents();
               if (compList != null) {
                 compList.add(comp);
@@ -168,11 +147,11 @@ public class BizUtil {
         }
         if (newHost) {
           VHost vHost = new VHost();
-          if (!stringUtil.isEmpty(hostname)) {
+          if (!StringUtils.isBlank(hostname)) {
             vHost.setName(hostname);
           }
           Set<String> component = new LinkedHashSet<String>();
-          if (stringUtil.isEmpty(comp)) {
+          if (StringUtils.isBlank(comp)) {
             component.add(comp);
           }
           vHost.setComponents(component);
@@ -191,8 +170,8 @@ public class BizUtil {
     return vsummary;
   }
 
-  public String addBlanksToString(int count, String field) {
-    if (stringUtil.isEmpty(field)) {
+  private String addBlanksToString(int count, String field) {
+    if (StringUtils.isBlank(field)) {
       return field;
     }
     if (count > 0) {
@@ -203,8 +182,7 @@ public class BizUtil {
   }
 
   @SuppressWarnings({"unchecked", "rawtypes"})
-  public VBarDataList buildSummaryForTopCounts(
-    SimpleOrderedMap<Object> jsonFacetResponse,String innerJsonKey,String outerJsonKey) {
+  public VBarDataList buildSummaryForTopCounts(SimpleOrderedMap<Object> jsonFacetResponse,String innerJsonKey,String outerJsonKey) {
 
     VBarDataList vBarDataList = new VBarDataList();
 
@@ -217,14 +195,12 @@ public class BizUtil {
     if (userList.isEmpty()) {
       return vBarDataList;
     }
-    SimpleOrderedMap<Map<String, Object>> userMap = (SimpleOrderedMap<Map<String, Object>>) userList
-      .get(0);
+    SimpleOrderedMap<Map<String, Object>> userMap = (SimpleOrderedMap<Map<String, Object>>) userList.get(0);
     if (userMap == null) {
       logger.info("No top user details found");
       return vBarDataList;
     }
-    List<SimpleOrderedMap> userUsageList = (List<SimpleOrderedMap>) userMap
-      .get("buckets");
+    List<SimpleOrderedMap> userUsageList = (List<SimpleOrderedMap>) userMap.get("buckets");
     if(userUsageList == null){
       return vBarDataList;
     }
@@ -232,13 +208,12 @@ public class BizUtil {
       if (usageMap != null) {
         VBarGraphData vBarGraphData = new VBarGraphData();
         String userName = (String) usageMap.get("val");
-        if (!stringUtil.isEmpty(userName)) {
+        if (!StringUtils.isBlank(userName)) {
           vBarGraphData.setName(userName);
         }
         SimpleOrderedMap repoMap = (SimpleOrderedMap) usageMap.get(innerJsonKey);
         List<VNameValue> componetCountList = new ArrayList<VNameValue>();
-        List<SimpleOrderedMap> repoUsageList = (List<SimpleOrderedMap>) repoMap
-            .get("buckets");
+        List<SimpleOrderedMap> repoUsageList = (List<SimpleOrderedMap>) repoMap.get("buckets");
         if (repoMap != null) {
           for (SimpleOrderedMap repoUsageMap : repoUsageList) {
             VNameValue componetCount = new VNameValue();
@@ -265,9 +240,8 @@ public class BizUtil {
     return vBarDataList;
   }
   
-  public HashMap<String, String> sortHashMapByValues(
-    HashMap<String, String> passedMap) {
-    if(passedMap == null ){
+  public HashMap<String, String> sortHashMapByValues(HashMap<String, String> passedMap) {
+    if (passedMap == null ) {
       return passedMap;
     }
     HashMap<String, String> sortedMap = new LinkedHashMap<String, String>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/CommonUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/CommonUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/CommonUtil.java
index 320e589..8ec04f8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/CommonUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/CommonUtil.java
@@ -18,49 +18,20 @@
  */
 package org.apache.ambari.logsearch.util;
 
-import java.io.Serializable;
 import java.security.SecureRandom;
 
-public class CommonUtil implements Serializable {
-  /**
-   *
-   */
-  private static final long serialVersionUID = -7284237762948427019L;
+import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
 
-  static SecureRandom secureRandom = new SecureRandom();
-  static int counter = 0;
+public class CommonUtil {
+  private static SecureRandom secureRandom = new SecureRandom();
+  private static int counter = 0;
 
-  static public String genGUI() {
-    return System.currentTimeMillis() + "_" + secureRandom.nextInt(1000)
-      + "_" + counter++;
+  public static String genGUI() {
+    return System.currentTimeMillis() + "_" + secureRandom.nextInt(1000) + "_" + counter++;
   }
-
-  static public String genGUI(int length) {
-    String str = "";
-    for (int i = 0; i < length; i++) {
-      int ascii = genInteger(65, 90);
-      str += (char) ascii;
-    }
-    return str;
-  }
-
-  static public int genInteger() {
-    return secureRandom.nextInt();
-  }
-
-  static public int genInteger(int min, int max) {
-    int value = secureRandom.nextInt(max - min);
-    return value + min;
-  }
-
-  /**
-   * @return
-   */
-  public static long genLong() {
-    return secureRandom.nextLong();
-  }
-
-  static public int genInteger(int n) {
-    return secureRandom.nextInt();
+  
+  private static final Md5PasswordEncoder md5Encoder = new Md5PasswordEncoder();
+  public static String encryptPassword(String username, String password) {
+    return md5Encoder.encodePassword(password, username);
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/ConfigUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/ConfigUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/ConfigUtil.java
index 2661150..88f92a2 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/ConfigUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/ConfigUtil.java
@@ -27,12 +27,13 @@ import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.MessageEnums;
 import org.apache.ambari.logsearch.dao.SolrDaoBase;
 import org.apache.ambari.logsearch.manager.MgrBase;
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.log4j.Logger;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 
 public class ConfigUtil {
-  static Logger logger = Logger.getLogger(MgrBase.class);
+  private static final Logger logger = Logger.getLogger(MgrBase.class);
 
   public static HashMap<String, String> serviceLogsColumnMapping = new HashMap<String, String>();
 
@@ -43,9 +44,7 @@ public class ConfigUtil {
     initializeColumnMapping();
   }
 
-  private static void intializeUISolrColumnMapping(
-    String columnMappingArray[],
-    HashMap<String, String> columnMappingMap) {
+  private static void intializeUISolrColumnMapping(String columnMappingArray[], HashMap<String, String> columnMappingMap) {
 
     if (columnMappingArray != null && columnMappingArray.length > 0) {
       for (String columnMapping : columnMappingArray) {
@@ -54,32 +53,24 @@ public class ConfigUtil {
           String solrField = mapping[0];
           String uiField = mapping[1];
           
-          columnMappingMap.put(solrField + LogSearchConstants.SOLR_SUFFIX,
-              uiField);
-          columnMappingMap.put(uiField + LogSearchConstants.UI_SUFFIX,
-              solrField);
+          columnMappingMap.put(solrField + LogSearchConstants.SOLR_SUFFIX, uiField);
+          columnMappingMap.put(uiField + LogSearchConstants.UI_SUFFIX, solrField);
         }
       }
     }
   }
   private static void initializeColumnMapping() {
-    String serviceLogsColumnMappingArray[] = PropertiesUtil
-      .getPropertyStringList("logsearch.solr.service.logs.column.mapping");
-    String auditLogsColumnMappingArray[] = PropertiesUtil
-      .getPropertyStringList("logsearch.solr.audit.logs.column.mapping");
+    String serviceLogsColumnMappingArray[] = PropertiesUtil.getPropertyStringList("logsearch.solr.service.logs.column.mapping");
+    String auditLogsColumnMappingArray[] = PropertiesUtil.getPropertyStringList("logsearch.solr.audit.logs.column.mapping");
 
     // Initializing column mapping for Service Logs
-    intializeUISolrColumnMapping(serviceLogsColumnMappingArray,
-      serviceLogsColumnMapping);
+    intializeUISolrColumnMapping(serviceLogsColumnMappingArray, serviceLogsColumnMapping);
 
     // Initializing column mapping for Audit Logs
-    intializeUISolrColumnMapping(auditLogsColumnMappingArray,
-      auditLogsColumnMapping);
+    intializeUISolrColumnMapping(auditLogsColumnMappingArray, auditLogsColumnMapping);
   }
 
-  
-  public static void extractSchemaFieldsName(String responseString,
-      HashMap<String, String> schemaFieldsNameMap,
+  public static void extractSchemaFieldsName(String responseString, HashMap<String, String> schemaFieldsNameMap,
       HashMap<String, String> schemaFieldTypeMap) {
     try {
       JSONObject jsonObject = new JSONObject(responseString);
@@ -118,17 +109,14 @@ public class ConfigUtil {
       schemaFieldsNameMap.putAll(_schemaFieldsNameMap);
       schemaFieldTypeMap.putAll(_schemaFieldTypeMap);
     } catch (Exception e) {
-      logger.error(e + "Credentials not specified in logsearch.properties "
-          + MessageEnums.ERROR_SYSTEM);
+      logger.error(e + "Credentials not specified in logsearch.properties " + MessageEnums.ERROR_SYSTEM);
     }
   }
 
   @SuppressWarnings("rawtypes")
-  public static void getSchemaFieldsName(String excludeArray[],
-      List<String> fieldNames, SolrDaoBase solrDaoBase) {
+  public static void getSchemaFieldsName(String excludeArray[], List<String> fieldNames, SolrDaoBase solrDaoBase) {
     if (!solrDaoBase.schemaFieldsNameMap.isEmpty()) {
-      Iterator iteratorSechmaFieldsName = solrDaoBase.schemaFieldsNameMap
-          .entrySet().iterator();
+      Iterator iteratorSechmaFieldsName = solrDaoBase.schemaFieldsNameMap.entrySet().iterator();
       while (iteratorSechmaFieldsName.hasNext()) {
         Map.Entry fieldName = (Map.Entry) iteratorSechmaFieldsName.next();
         String field = "" + fieldName.getKey();
@@ -140,7 +128,7 @@ public class ConfigUtil {
   }
 
   private static boolean isExclude(String name, String excludeArray[]) {
-    if (excludeArray != null && excludeArray.length > 0) {
+    if (!ArrayUtils.isEmpty(excludeArray)) {
       for (String exclude : excludeArray) {
         if (name.equals(exclude)){
           return true;

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
index 7425aaa..516d828 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/DateUtil.java
@@ -30,35 +30,30 @@ import java.util.TimeZone;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
 public class DateUtil {
 
-  static Logger logger = Logger.getLogger(DateUtil.class);
-
-  @Autowired
-  StringUtil stringUtil;
+  private static final Logger logger = Logger.getLogger(DateUtil.class);
 
   private DateUtil() {
 
   }
 
   public String addOffsetToDate(String date, Long utcOffset, String dateFormat) {
-    if (stringUtil.isEmpty(date)) {
+    if (StringUtils.isBlank(date)) {
       logger.debug("input date is empty or null.");
       return null;
     }
     if (utcOffset == null) {
-      logger
-          .debug("Utc offset is null, Return input date without adding offset.");
+      logger.debug("Utc offset is null, Return input date without adding offset.");
       return date;
     }
-    if (stringUtil.isEmpty(dateFormat)) {
-      logger
-          .debug("dateFormat is null or empty, Return input date without adding offset.");
+    if (StringUtils.isBlank(dateFormat)) {
+      logger.debug("dateFormat is null or empty, Return input date without adding offset.");
       return date;
     }
     String retDate = "";
@@ -67,10 +62,9 @@ public class DateUtil {
       if (date.contains(".")) {
         modifiedDate = date.replace(".", ",");
       }
-      SimpleDateFormat formatter = new SimpleDateFormat(dateFormat,
-          Locale.ENGLISH);
+      SimpleDateFormat formatter = new SimpleDateFormat(dateFormat, Locale.ENGLISH);
       Date startDate = formatter.parse(modifiedDate);
-      long toWithOffset = getTimeWithOffset(startDate, utcOffset, dateFormat);
+      long toWithOffset = getTimeWithOffset(startDate, utcOffset);
       Calendar calendar = Calendar.getInstance();
       calendar.setTimeInMillis(toWithOffset);
       retDate = formatter.format(calendar.getTime());
@@ -80,98 +74,28 @@ public class DateUtil {
     return retDate;
   }
 
-  public long getTimeWithOffset(Date date, Long utcOffset, String dateFormate) {
+  private long getTimeWithOffset(Date date, Long utcOffset) {
     return date.getTime() + TimeUnit.MINUTES.toMillis(utcOffset);
   }
 
-  public Date getUTCDate(long epoh) {
-    if (epoh == 0) {
-      return null;
-    }
-    try {
-      TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT+0");
-      Calendar local = Calendar.getInstance();
-      int offset = local.getTimeZone().getOffset(epoh);
-      GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
-      utc.setTimeInMillis(epoh);
-      utc.add(Calendar.MILLISECOND, -offset);
-      return utc.getTime();
-    } catch (Exception ex) {
-      return null;
-    }
-  }
-
-  public String dateToString(Date date, String dateFormat) {
-    if (date == null || dateFormat == null || dateFormat.isEmpty()) {
-      return "";
-    }
-    SimpleDateFormat formatter = new SimpleDateFormat(dateFormat, Locale.ENGLISH);
-    TimeZone timeZone = TimeZone.getTimeZone("GMT");
-    formatter.setTimeZone(timeZone);
-    return formatter.format(date);
-  }
-
   public String getCurrentDateInString() {
     DateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss", Locale.ENGLISH);
     Date today = Calendar.getInstance().getTime();
     return df.format(today);
   }
 
-  public String getTimeInSolrFormat(String timeString) {
-    String time;
-    if (stringUtil.isEmpty(timeString)) {
-      return null;
-    }
-    time = timeString.replace(" ", "T");
-    time = time.replace(",", ".");
-    time = time + "Z";
-
-    return time;
-  }
-  
   public Date getTodayFromDate() {
     Calendar c = new GregorianCalendar();
-    c.set(Calendar.HOUR_OF_DAY, 0); 
+    c.set(Calendar.HOUR_OF_DAY, 0);
     c.set(Calendar.MINUTE, 0);
     c.set(Calendar.SECOND, 0);
     return c.getTime();
   }
 
-  public Date addHoursToDate(Date date, int hours) {
-    GregorianCalendar greorianCalendar = new GregorianCalendar();
-    greorianCalendar.setTime(date);
-    greorianCalendar.add(GregorianCalendar.HOUR_OF_DAY, hours);
-    return greorianCalendar.getTime();
-  }
-
-  public Date addMinsToDate(Date date, int mins) {
-    GregorianCalendar greorianCalendar = new GregorianCalendar();
-    greorianCalendar.setTime(date);
-    greorianCalendar.add(GregorianCalendar.MINUTE, mins);
-    return greorianCalendar.getTime();
-  }
-
-  public Date addSecondsToDate(Date date, int secs) {
-    GregorianCalendar greorianCalendar = new GregorianCalendar();
-    greorianCalendar.setTime(date);
-    greorianCalendar.add(GregorianCalendar.SECOND, secs);
-    return greorianCalendar.getTime();
-  }
-
-  public Date addMilliSecondsToDate(Date date, int secs) {
-    GregorianCalendar greorianCalendar = new GregorianCalendar();
-    greorianCalendar.setTime(date);
-    greorianCalendar.add(GregorianCalendar.MILLISECOND, secs);
-    return greorianCalendar.getTime();
-  }
-
-  public String convertGivenDateFormatToSolrDateFormat(Date date)
-    throws ParseException {
+  public String convertGivenDateFormatToSolrDateFormat(Date date) throws ParseException {
     String time = date.toString();
-    SimpleDateFormat input = new SimpleDateFormat(
-      "EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
-    SimpleDateFormat output = new SimpleDateFormat(
-      LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z, Locale.ENGLISH);
+    SimpleDateFormat input = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
+    SimpleDateFormat output = new SimpleDateFormat(LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z, Locale.ENGLISH);
     Date d = input.parse(time);
     TimeZone timeZone = TimeZone.getTimeZone("UTC");
     output.setTimeZone(timeZone);
@@ -183,53 +107,36 @@ public class DateUtil {
     if (date == null) {
       return "";
     }
-    SimpleDateFormat formatter = new SimpleDateFormat(
-      LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z, Locale.ENGLISH);
+    SimpleDateFormat formatter = new SimpleDateFormat(LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z, Locale.ENGLISH);
     TimeZone timeZone = TimeZone.getTimeZone("GMT");
     formatter.setTimeZone(timeZone);
 
     return formatter.format(date);
   }
 
-  public String convertSolrDateToNormalDateFormat(long d, long utcOffset)
-    throws ParseException {
+  public String convertSolrDateToNormalDateFormat(long d, long utcOffset) throws ParseException {
     Date date = new Date(d);
-    SimpleDateFormat formatter = new SimpleDateFormat(
-      LogSearchConstants.SOLR_DATE_FORMAT, Locale.ENGLISH);
+    SimpleDateFormat formatter = new SimpleDateFormat(LogSearchConstants.SOLR_DATE_FORMAT, Locale.ENGLISH);
     TimeZone timeZone = TimeZone.getTimeZone("GMT");
     formatter.setTimeZone(timeZone);
     String stringDate = formatter.format(date);
-    return addOffsetToDate(stringDate, Long.parseLong("" + utcOffset),
-      LogSearchConstants.SOLR_DATE_FORMAT);
+    return addOffsetToDate(stringDate, Long.parseLong("" + utcOffset), LogSearchConstants.SOLR_DATE_FORMAT);
 
   }
 
-  public Date convertStringToDate(String dateString) {
-    SimpleDateFormat formatter = new SimpleDateFormat(
-      LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z, Locale.ENGLISH);
-    TimeZone timeZone = TimeZone.getTimeZone("GMT");
-    formatter.setTimeZone(timeZone);
-    try {
-      return formatter.parse(dateString);
-    } catch (ParseException e) {
-      //do nothing
-    }
-    return null;
-  }
-  
   public boolean isDateValid(String value) {
-    if(stringUtil.isEmpty(value)){
+    if (StringUtils.isBlank(value)) {
       return false;
     }
     Date date = null;
     try {
-        SimpleDateFormat sdf = new SimpleDateFormat(LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z);
-        date = sdf.parse(value);
-        if (!value.equals(sdf.format(date))) {
-            date = null;
-        }
+      SimpleDateFormat sdf = new SimpleDateFormat(LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z);
+      date = sdf.parse(value);
+      if (!value.equals(sdf.format(date))) {
+        date = null;
+      }
     } catch (Exception ex) {
-      //do nothing
+      // do nothing
     }
     return date != null;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
index 658635c..e3c2063 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/FileUtil.java
@@ -39,24 +39,19 @@ import org.springframework.stereotype.Component;
 @Component
 public class FileUtil {
 
-  static Logger logger = Logger.getLogger(FileUtil.class);
+  private static final Logger logger = Logger.getLogger(FileUtil.class);
 
   @Autowired
-  RESTErrorUtil restErrorUtil;
+  private RESTErrorUtil restErrorUtil;
 
-  @SuppressWarnings("resource")
   public Response saveToFile(String text, String fileName, VSummary vsummary) {
     String mainExportedFile = "";
     FileOutputStream fis = null;
     try {
-      mainExportedFile = mainExportedFile
-        + "**********************Summary**********************\n";
-      mainExportedFile = mainExportedFile + "Number of Logs : "
-        + vsummary.getNumberLogs() + "\n";
-      mainExportedFile = mainExportedFile + "From           : "
-        + vsummary.getFrom() + "\n";
-      mainExportedFile = mainExportedFile + "To             : "
-        + vsummary.getTo() + "\n";
+      mainExportedFile = mainExportedFile + "**********************Summary**********************\n";
+      mainExportedFile = mainExportedFile + "Number of Logs : " + vsummary.getNumberLogs() + "\n";
+      mainExportedFile = mainExportedFile + "From           : " + vsummary.getFrom() + "\n";
+      mainExportedFile = mainExportedFile + "To             : " + vsummary.getTo() + "\n";
 
       List<VHost> hosts = vsummary.getHosts();
       String blankCharacterForHost = String.format("%-8s", "");
@@ -89,42 +84,30 @@ public class FileUtil {
           blankCharacterForHost = String.format("%-3s", blankCharacterForHost);
         }
         if (numberHost == 1) {
-          mainExportedFile = mainExportedFile + "Host"
-            + blankCharacterForHost + "   : " + h + " [" + c
-            + "] " + "\n";
+          mainExportedFile = mainExportedFile + "Host" + blankCharacterForHost + "   : " + h + " [" + c + "] " + "\n";
         } else if (numberHost > 1) {
-          mainExportedFile = mainExportedFile + "Host_" + numberHost
-            + blankCharacterForHost + " : " + h + " [" + c
-            + "] " + "\n";
+          mainExportedFile = mainExportedFile + "Host_" + numberHost + blankCharacterForHost + " : " + h + " [" + c + "] " + "\n";
         }
 
       }
-      mainExportedFile = mainExportedFile + "Levels"+String.format("%-9s", blankCharacterForHost)+": "
-        + vsummary.getLevels() + "\n";
-      mainExportedFile = mainExportedFile + "Format"+String.format("%-9s", blankCharacterForHost)+": "
-        + vsummary.getFormat() + "\n";
+      mainExportedFile = mainExportedFile + "Levels"+String.format("%-9s", blankCharacterForHost)+": " + vsummary.getLevels() + "\n";
+      mainExportedFile = mainExportedFile + "Format"+String.format("%-9s", blankCharacterForHost)+": " + vsummary.getFormat() + "\n";
       mainExportedFile = mainExportedFile + "\n";
 
-      mainExportedFile = mainExportedFile + "Included String: ["
-        + vsummary.getIncludeString() + "]\n\n";
-      mainExportedFile = mainExportedFile + "Excluded String: ["
-        + vsummary.getExcludeString() + "]\n\n";
-      mainExportedFile = mainExportedFile
-        + "************************Logs***********************"
-        + "\n";
+      mainExportedFile = mainExportedFile + "Included String: [" + vsummary.getIncludeString() + "]\n\n";
+      mainExportedFile = mainExportedFile + "Excluded String: [" + vsummary.getExcludeString() + "]\n\n";
+      mainExportedFile = mainExportedFile + "************************Logs***********************" + "\n";
       mainExportedFile = mainExportedFile + text + "\n";
       File file = File.createTempFile(fileName, vsummary.getFormat());
       fis = new FileOutputStream(file);
       fis.write(mainExportedFile.getBytes());
       return Response
         .ok(file, MediaType.APPLICATION_OCTET_STREAM)
-        .header("Content-Disposition",
-          "attachment;filename=" + fileName
-            + vsummary.getFormat()).build();
+        .header("Content-Disposition", "attachment;filename=" + fileName + vsummary.getFormat())
+        .build();
     } catch (Exception e) {
       logger.error(e.getMessage());
-      throw restErrorUtil.createRESTException(e.getMessage(),
-        MessageEnums.ERROR_SYSTEM);
+      throw restErrorUtil.createRESTException(e.getMessage(), MessageEnums.ERROR_SYSTEM);
     } finally {
       if (fis != null) {
         try {
@@ -135,13 +118,8 @@ public class FileUtil {
     }
   }
 
-  /**
-   * @param filename
-   * @return
-   */
   public File getFileFromClasspath(String filename) {
-    URL fileCompleteUrl = Thread.currentThread().getContextClassLoader()
-      .getResource(filename);
+    URL fileCompleteUrl = Thread.currentThread().getContextClassLoader().getResource(filename);
     logger.debug("File Complete URI :" + fileCompleteUrl);
     File file = null;
     try {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/JSONUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/JSONUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/JSONUtil.java
index 4703c58..5332d18 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/JSONUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/JSONUtil.java
@@ -22,15 +22,14 @@ package org.apache.ambari.logsearch.util;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.codehaus.jackson.map.ObjectMapper;
@@ -47,112 +46,51 @@ import com.google.gson.GsonBuilder;
 @Component
 public class JSONUtil {
 
-  static Logger logger = Logger.getLogger(JSONUtil.class);
+  private static final Logger logger = Logger.getLogger(JSONUtil.class);
 
   @Autowired
-  RESTErrorUtil restErrorUtil;
+  private RESTErrorUtil restErrorUtil;
 
-  @Autowired
-  StringUtil stringUtil;
-
-  public final static String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
-  Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
-
-  // Conversion from JSONArray to List<String>
-  public static List<String> JSONToList(JSONArray jarray) throws JSONException {
-    ArrayList<String> list = new ArrayList<String>();
-    JSONArray jsonArray = jarray;
-    if (jsonArray != null) {
-      int len = jsonArray.length();
-      for (int i = 0; i < len; i++) {
-        list.add(jsonArray.get(i).toString());
-      }
-    }
-    return list;
-  }
-
-  @SuppressWarnings("unchecked")
-  public HashMap<String, String> jsonToMap(String jsonStr) {
-    if (stringUtil.isEmpty(jsonStr)) {
-      logger.info("jsonString is empty, cannot conver to map");
-      return null;
-    }
-    ObjectMapper mapper = new ObjectMapper();
-    try {
-      Object tempObject = mapper.readValue(jsonStr,
-          new TypeReference<HashMap<String, String>>() {
-          });
-      return (HashMap<String, String>) tempObject;
-
-    } catch (JsonParseException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
-    } catch (JsonMappingException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
-    } catch (IOException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
-    }
-
-  }
+  private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
+  private Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
 
   @SuppressWarnings("unchecked")
   public HashMap<String, Object> jsonToMapObject(String jsonStr) {
-    if (stringUtil.isEmpty(jsonStr)) {
+    if (StringUtils.isBlank(jsonStr)) {
       logger.info("jsonString is empty, cannot conver to map");
       return null;
     }
     ObjectMapper mapper = new ObjectMapper();
     try {
-      Object tempObject = mapper.readValue(jsonStr,
-          new TypeReference<HashMap<String, Object>>() {
-          });
+      Object tempObject = mapper.readValue(jsonStr, new TypeReference<HashMap<String, Object>>() {});
       return (HashMap<String, Object>) tempObject;
 
     } catch (JsonParseException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA);
     } catch (JsonMappingException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA);
     } catch (IOException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA);
     }
 
   }
 
   @SuppressWarnings("unchecked")
   public List<HashMap<String, Object>> jsonToMapObjectList(String jsonStr) {
-    if (stringUtil.isEmpty(jsonStr)) {
+    if (StringUtils.isBlank(jsonStr)) {
       return null;
     }
     ObjectMapper mapper = new ObjectMapper();
     try {
-      Object tempObject = mapper.readValue(jsonStr,
-          new TypeReference<List<HashMap<String, Object>>>() {
-          });
+      Object tempObject = mapper.readValue(jsonStr, new TypeReference<List<HashMap<String, Object>>>() {});
       return (List<HashMap<String, Object>>) tempObject;
 
     } catch (JsonParseException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA);
     } catch (JsonMappingException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA);
     } catch (IOException e) {
-      throw restErrorUtil.createRESTException(
-          "Invalid input data: " + e.getMessage(),
-          MessageEnums.INVALID_INPUT_DATA);
+      throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA);
     }
 
   }
@@ -170,21 +108,11 @@ public class JSONUtil {
     return true;
   }
 
-  /**
-   * @param fileName
-   * @return
-   */
   public HashMap<String, Object> readJsonFromFile(File jsonFile) {
     ObjectMapper mapper = new ObjectMapper();
     try {
-      HashMap<String, Object> jsonmap = mapper.readValue(jsonFile,
-          new TypeReference<HashMap<String, Object>>() {
-          });
+      HashMap<String, Object> jsonmap = mapper.readValue(jsonFile, new TypeReference<HashMap<String, Object>>() {});
       return jsonmap;
-    } catch (JsonParseException e) {
-      logger.error(e, e.getCause());
-    } catch (JsonMappingException e) {
-      logger.error(e, e.getCause());
     } catch (IOException e) {
       logger.error(e, e.getCause());
     }
@@ -197,10 +125,6 @@ public class JSONUtil {
       String json = om.writeValueAsString(map);
 
       return json;
-    } catch (JsonGenerationException e) {
-      logger.error(e, e.getCause());
-    } catch (JsonMappingException e) {
-      logger.error(e, e.getCause());
     } catch (IOException e) {
       logger.error(e, e.getCause());
     }
@@ -209,13 +133,8 @@ public class JSONUtil {
 
   /**
    * WRITE JOSN IN FILE ( Delete existing file and create new file)
-   * 
-   * @param jsonStr
-   * @param outputFile
-   * @param beautify
    */
-  public synchronized void writeJSONInFile(String jsonStr, File outputFile,
-      boolean beautify) {
+  public synchronized void writeJSONInFile(String jsonStr, File outputFile, boolean beautify) {
     FileWriter fileWriter = null;
     if (outputFile == null) {
       logger.error("user_pass json file can't be null.");
@@ -231,14 +150,11 @@ public class JSONUtil {
         if (beautify) {
           ObjectMapper mapper = new ObjectMapper();
           Object json = mapper.readValue(jsonStr, Object.class);
-          jsonStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(
-              json);
+          jsonStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json);
         }
         fileWriter.write(jsonStr);
       } else {
-        logger
-            .error("Applcation does not have permission to update file to write enc_password. file="
-                + outputFile.getAbsolutePath());
+        logger.error("Applcation does not have permission to update file to write enc_password. file="+ outputFile.getAbsolutePath());
       }
     } catch (IOException e) {
       logger.error("Error writing to password file.", e.getCause());
@@ -248,7 +164,6 @@ public class JSONUtil {
           fileWriter.flush();
           fileWriter.close();
         } catch (Exception exception) {
-          // ignore
           logger.error(exception);
         }
       }
@@ -265,14 +180,9 @@ public class JSONUtil {
 
   /**
    * GET VALUES FROM JSON BY GIVING KEY RECURSIVELY
-   * 
-   * @param jsonStr
-   * @param keyName
-   * @return
    */
   @SuppressWarnings("rawtypes")
-  public static String getValuesOfKey(String jsonStr, String keyName,
-      List<String> values) {
+  public static String getValuesOfKey(String jsonStr, String keyName, List<String> values) {
     if (values == null) {
       return null;
     }
@@ -318,13 +228,11 @@ public class JSONUtil {
           // ignore
         }
 
-      } else if ((((JSONObject) jsonObj).optJSONArray(key) != null)
-          || (((JSONObject) jsonObj).optJSONObject(key) != null)) {
+      } else if ((((JSONObject) jsonObj).optJSONArray(key) != null) || (((JSONObject) jsonObj).optJSONObject(key) != null)) {
 
         String str = null;
         try {
-          str = getValuesOfKey("" + ((JSONObject) jsonObj).getString(key),
-              keyName, values);
+          str = getValuesOfKey("" + ((JSONObject) jsonObj).getString(key), keyName, values);
         } catch (Exception e) {
           // ignore
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/LogsearchPropertiesConfiguration.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/LogsearchPropertiesConfiguration.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/LogsearchPropertiesConfiguration.java
deleted file mode 100644
index c3ef20f..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/LogsearchPropertiesConfiguration.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.util;
-
-import java.io.File;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.log4j.Logger;
-
-public class LogsearchPropertiesConfiguration extends PropertiesConfiguration {
-
-  Logger logger = Logger.getLogger(LogsearchPropertiesConfiguration.class);
-
-  public LogsearchPropertiesConfiguration() {
-    super();
-  }
-
-
-  public static LogsearchPropertiesConfiguration getInstance() {
-    return new LogsearchPropertiesConfiguration();
-  }
-
-  public void load(File file) {
-    if (!file.exists()) {
-      logger.error("File :" + file.getAbsolutePath() + " not exists");
-      return;
-    }
-    try {
-      super.load(file);
-    } catch (ConfigurationException e) {
-      logger.error(e);
-    }
-  }
-
-  public void load(String fileAbsolutePath) {
-    File file = new File(fileAbsolutePath);
-    load(file);
-  }
-
-  /**
-   * Load from classPath
-   *
-   * @param fileName
-   */
-  public void loadFromClasspath(String fileName) {
-    logger.debug("loading config properties : " + fileName);
-    // load file from classpath
-    try {
-      URL fileCompleteUrl = Thread.currentThread()
-        .getContextClassLoader().getResource(fileName);
-      logger.debug("File Complete URI :" + fileCompleteUrl);
-      File file = new File(fileCompleteUrl.toURI());
-      load(file);
-    } catch (Exception e) {
-      logger.error(e);
-    }
-  }
-
-  public HashMap<String, Object> getPropertyMap() {
-    HashMap<String, Object> propertyMap = new HashMap<String, Object>();
-    Iterator<String> keys = this.getKeys();
-    while (keys.hasNext()) {
-      String key = keys.next();
-      propertyMap.put(key, this.getProperty(key));
-    }
-    return propertyMap;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/PropertiesUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/PropertiesUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/PropertiesUtil.java
index 16ebae2..59f0296 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/PropertiesUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/PropertiesUtil.java
@@ -34,9 +34,11 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 
 public class PropertiesUtil extends PropertyPlaceholderConfigurer {
-  static Logger logger = Logger.getLogger(PropertiesUtil.class);
-  private static Map<String, String> propertiesMap;
+  private static final Logger logger = Logger.getLogger(PropertiesUtil.class);
+  
   private static final String LOGSEARCH_PROP_FILE="logsearch.properties";
+  
+  private static Map<String, String> propertiesMap;
 
   private PropertiesUtil() {
 
@@ -45,8 +47,7 @@ public class PropertiesUtil extends PropertyPlaceholderConfigurer {
  static {
     propertiesMap = new HashMap<String, String>();
     Properties properties = new Properties();
-    URL fileCompleteUrl = Thread.currentThread()
-        .getContextClassLoader().getResource(LOGSEARCH_PROP_FILE);
+    URL fileCompleteUrl = Thread.currentThread().getContextClassLoader().getResource(LOGSEARCH_PROP_FILE);
     FileInputStream fileInputStream = null;
     try {
       File file = new File(fileCompleteUrl.toURI());
@@ -69,9 +70,7 @@ public class PropertiesUtil extends PropertyPlaceholderConfigurer {
   }
 
   @Override
-  protected void processProperties(
-    ConfigurableListableBeanFactory beanFactory, Properties props)
-    throws BeansException {
+  protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException {
     super.processProperties(beanFactory, props);
 
     propertiesMap = new HashMap<String, String>();
@@ -80,8 +79,7 @@ public class PropertiesUtil extends PropertyPlaceholderConfigurer {
     Set<Object> keySet = System.getProperties().keySet();
     for (Object key : keySet) {
       String keyStr = key.toString();
-      propertiesMap.put(keyStr, System.getProperties()
-        .getProperty(keyStr).trim());
+      propertiesMap.put(keyStr, System.getProperties().getProperty(keyStr).trim());
     }
 
     // add our properties now

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/QueryBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/QueryBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/QueryBase.java
index d1e0a86..5961cff 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/QueryBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/QueryBase.java
@@ -20,13 +20,10 @@
 package org.apache.ambari.logsearch.util;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.commons.lang.StringUtils;
 import org.apache.solr.client.solrj.SolrQuery;
-import org.springframework.beans.factory.annotation.Autowired;
 
 public class QueryBase {
-  
-  @Autowired
-  StringUtil stringUtil;
 
   //Solr Facet Methods
   public void setFacetField(SolrQuery solrQuery, String facetField) {
@@ -48,8 +45,7 @@ public class QueryBase {
     solrQuery.setFacetSort(sortType);
   }
 
-  public void setFacetPivot(SolrQuery solrQuery, int mincount,
-                            String... hirarchy) {
+  public void setFacetPivot(SolrQuery solrQuery, int mincount, String... hirarchy) {
     solrQuery.setFacet(true);
     setRowCount(solrQuery, 0);
     solrQuery.set(LogSearchConstants.FACET_PIVOT, hirarchy);
@@ -57,8 +53,7 @@ public class QueryBase {
     setFacetLimit(solrQuery, -1);
   }
 
-  public void setFacetDate(SolrQuery solrQuery, String facetField,
-                           String from, String to, String unit) {
+  public void setFacetDate(SolrQuery solrQuery, String facetField, String from, String to, String unit) {
     solrQuery.setFacet(true);
     setRowCount(solrQuery, 0);
     solrQuery.set(LogSearchConstants.FACET_DATE, facetField);
@@ -69,8 +64,7 @@ public class QueryBase {
     setFacetLimit(solrQuery, -1);
   }
 
-  public void setFacetRange(SolrQuery solrQuery, String facetField,
-                            String from, String to, String unit) {
+  public void setFacetRange(SolrQuery solrQuery, String facetField, String from, String to, String unit) {
     solrQuery.setFacet(true);
     setRowCount(solrQuery, 0);
     solrQuery.set(LogSearchConstants.FACET_RANGE, facetField);
@@ -96,7 +90,7 @@ public class QueryBase {
   //Main Query
   public void setMainQuery(SolrQuery solrQuery, String query) {
     String defalultQuery = "*:*";
-    if (stringUtil.isEmpty(query)){
+    if (StringUtils.isBlank(query)){
       solrQuery.setQuery(defalultQuery);
     }else{
       solrQuery.setQuery(query);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/RESTErrorUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/RESTErrorUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/RESTErrorUtil.java
index e64f742..6df5b05 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/RESTErrorUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/RESTErrorUtil.java
@@ -54,7 +54,7 @@ public class RESTErrorUtil {
     return webAppEx;
   }
 
-  public WebApplicationException createRESTException(VResponse response, int sc) {
+  private WebApplicationException createRESTException(VResponse response, int sc) {
     Response errorResponse = Response.status(sc).entity(response).build();
     WebApplicationException restException = new WebApplicationException(errorResponse);
     restException.fillInStackTrace();

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffcf5328/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
index ee706bf..bcf9605 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/SolrUtil.java
@@ -25,23 +25,21 @@ import java.util.Locale;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.log4j.Logger;
 import org.apache.solr.schema.TrieDoubleField;
 import org.apache.solr.schema.TrieFloatField;
 import org.apache.solr.schema.TrieIntField;
 import org.apache.solr.schema.TrieLongField;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 
 @Component
 public class SolrUtil {
-  static final Logger logger = Logger.getLogger("org.apache.ambari.logsearch");
-  
-  @Autowired
-  StringUtil stringUtil;
 
   @Autowired
-  JSONUtil jsonUtil;
+  private JSONUtil jsonUtil;
 
   public String setField(String fieldName, String value) {
     if (value == null || value.trim().length() == 0) {
@@ -50,13 +48,8 @@ public class SolrUtil {
     return fieldName + ":" + value.trim().toLowerCase(Locale.ENGLISH);
   }
 
-  /**
-   * @param string
-   * @param myClassTypes
-   * @return
-   */
   public String inList(String fieldName, int[] values) {
-    if (values == null || values.length == 0) {
+    if (ArrayUtils.isEmpty(values)) {
       return "";
     }
     String expr = "";
@@ -71,12 +64,8 @@ public class SolrUtil {
     }
   }
 
-  /**
-   * @param familyUserIdSet
-   * @return
-   */
   public String inList(Collection<Long> values) {
-    if (values == null || values.isEmpty()) {
+    if (CollectionUtils.isEmpty(values)) {
       return "";
     }
     String expr = "";
@@ -92,18 +81,12 @@ public class SolrUtil {
 
   }
 
-  /**
-   * @param wildCard
-   * @param string
-   * @param searchList
-   * @return
-   */
   public String orList(String fieldName, String[] valueList, String wildCard) {
-    if (valueList == null || valueList.length == 0) {
+    if (ArrayUtils.isEmpty(valueList)) {
       return "";
     }
     
-    if(stringUtil.isEmpty(wildCard)){
+    if (StringUtils.isBlank(wildCard)) {
       wildCard = "";
     }
     
@@ -126,18 +109,12 @@ public class SolrUtil {
 
   }
 
-  /**
-   * @param wildCard
-   * @param string
-   * @param searchList
-   * @return
-   */
   public String andList(String fieldName, String[] valueList, String wildCard) {
-    if (valueList == null || valueList.length == 0) {
+    if (ArrayUtils.isEmpty(valueList)) {
       return "";
     }
     
-    if(stringUtil.isEmpty(wildCard)){
+    if (StringUtils.isBlank(wildCard)) {
       wildCard = "";
     }
     
@@ -162,9 +139,6 @@ public class SolrUtil {
 
   /**
    * Copied from Solr ClientUtils.escapeQueryChars and removed escaping *
-   * 
-   * @param s
-   * @return
    */
   public String escapeQueryChars(String s) {
     StringBuilder sb = new StringBuilder();
@@ -195,7 +169,7 @@ public class SolrUtil {
     return sb.toString();
   }
 
-  public String escapeForWhiteSpaceTokenizer(String search) {
+  private String escapeForWhiteSpaceTokenizer(String search) {
     if (search == null) {
       return null;
     }
@@ -233,30 +207,24 @@ public class SolrUtil {
     return newSearch;
   }
 
-  public String escapeForKeyTokenizer(String search) {
-    if (search.startsWith("*") && search.endsWith("*")
-        && !stringUtil.isEmpty(search)) {
+  private String escapeForKeyTokenizer(String search) {
+    if (search.startsWith("*") && search.endsWith("*") && !StringUtils.isBlank(search)) {
       // Remove the * from both the sides
       if (search.length() > 1) {
         search = search.substring(1, search.length() - 1);
-      }else{
+      } else {
         //search string have only * 
         search="";
       }
     }
-    // Escape the string
     search = escapeQueryChars(search);
 
-    // Add the *
     return "*" + search + "*";
   }
 
   /**
    * This is a special case scenario to handle log_message for wild card
    * scenarios
-   * 
-   * @param search
-   * @return
    */
   public String escapeForLogMessage(String field, String search) {
     if (search.startsWith("*") && search.endsWith("*")) {
@@ -272,8 +240,7 @@ public class SolrUtil {
 
   public String makeSolrSearchString(String search) {
     String newString = search.trim();
-    String newSearch = newString.replaceAll(
-        "(?=[]\\[+&|!(){},:\"^~/=$@%?:.\\\\])", "\\\\");
+    String newSearch = newString.replaceAll("(?=[]\\[+&|!(){},:\"^~/=$@%?:.\\\\])", "\\\\");
     newSearch = newSearch.replace("\n", "*");
     newSearch = newSearch.replace("\t", "*");
     newSearch = newSearch.replace("\r", "*");
@@ -284,8 +251,7 @@ public class SolrUtil {
 
   public String makeSolrSearchStringWithoutAsterisk(String search) {
     String newString = search.trim();
-    String newSearch = newString.replaceAll(
-        "(?=[]\\[+&|!(){}^\"~=/$@%?:.\\\\])", "\\\\");
+    String newSearch = newString.replaceAll("(?=[]\\[+&|!(){}^\"~=/$@%?:.\\\\])", "\\\\");
     newSearch = newSearch.replace("\n", "*");
     newSearch = newSearch.replace("\t", "*");
     newSearch = newSearch.replace("\r", "*");
@@ -296,19 +262,18 @@ public class SolrUtil {
   }
 
   public String makeSearcableString(String search) {
-    if (search == null || search.isEmpty()){
+    if (StringUtils.isBlank(search)) {
       return "";
     }
     String newSearch = search.replaceAll("[\\t\\n\\r]", " ");
-    newSearch = newSearch.replaceAll("(?=[]\\[+&|!(){}^~=$/@%?:.\\\\-])",
-        "\\\\");
+    newSearch = newSearch.replaceAll("(?=[]\\[+&|!(){}^~=$/@%?:.\\\\-])", "\\\\");
 
     return newSearch.replace(" ", "\\ ");
   }
   
 
   public boolean isSolrFieldNumber(String fieldType,SolrDaoBase solrDaoBase) {
-    if (stringUtil.isEmpty(fieldType)) {
+    if (StringUtils.isBlank(fieldType)) {
       return false;
     } else {
       HashMap<String, Object> typeInfoMap = getFieldTypeInfoMap(fieldType,solrDaoBase);
@@ -344,7 +309,7 @@ public class SolrUtil {
       return new HashMap<String, Object>();
     }
     String classname = (String) fieldTypeMap.get("class");
-    if (!stringUtil.isEmpty(classname)) {
+    if (!StringUtils.isBlank(classname)) {
       classname = classname.replace("solr.", "");
       fieldTypeMap.put("class", classname);
     }


Mime
View raw message