ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [23/52] [abbrv] ambari git commit: AMBARI-18253. Fix LogSearch utility classes (Miklos Gergely via oleewere)
Date Wed, 28 Sep 2016 09:41:50 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/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 e3c2063..505b74d 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
@@ -33,18 +33,15 @@ import org.apache.ambari.logsearch.common.MessageEnums;
 import org.apache.ambari.logsearch.view.VHost;
 import org.apache.ambari.logsearch.view.VSummary;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 
-@Component
 public class FileUtil {
-
   private static final Logger logger = Logger.getLogger(FileUtil.class);
 
-  @Autowired
-  private RESTErrorUtil restErrorUtil;
-
-  public Response saveToFile(String text, String fileName, VSummary vsummary) {
+  private FileUtil() {
+    throw new UnsupportedOperationException();
+  }
+  
+  public static Response saveToFile(String text, String fileName, VSummary vsummary) {
     String mainExportedFile = "";
     FileOutputStream fis = null;
     try {
@@ -107,7 +104,7 @@ public class FileUtil {
         .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 {
@@ -118,7 +115,7 @@ public class FileUtil {
     }
   }
 
-  public File getFileFromClasspath(String filename) {
+  public static File getFileFromClasspath(String filename) {
     URL fileCompleteUrl = Thread.currentThread().getContextClassLoader().getResource(filename);
     logger.debug("File Complete URI :" + fileCompleteUrl);
     File file = null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/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 5332d18..d08c0f4 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
@@ -37,25 +37,22 @@ import org.codehaus.jackson.type.TypeReference;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
-@Component
 public class JSONUtil {
-
   private static final Logger logger = Logger.getLogger(JSONUtil.class);
 
-  @Autowired
-  private RESTErrorUtil restErrorUtil;
-
   private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
-  private Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
+  private static final Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
 
+  private JSONUtil() {
+    throw new UnsupportedOperationException();
+  }
+  
   @SuppressWarnings("unchecked")
-  public HashMap<String, Object> jsonToMapObject(String jsonStr) {
+  public static HashMap<String, Object> jsonToMapObject(String jsonStr) {
     if (StringUtils.isBlank(jsonStr)) {
       logger.info("jsonString is empty, cannot conver to map");
       return null;
@@ -66,17 +63,17 @@ public class JSONUtil {
       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) {
+  public static List<HashMap<String, Object>> jsonToMapObjectList(String jsonStr) {
     if (StringUtils.isBlank(jsonStr)) {
       return null;
     }
@@ -86,16 +83,16 @@ public class JSONUtil {
       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);
     }
 
   }
 
-  public boolean isJSONValid(String jsonString) {
+  public static boolean isJSONValid(String jsonString) {
     try {
       new JSONObject(jsonString);
     } catch (JSONException ex) {
@@ -108,7 +105,7 @@ public class JSONUtil {
     return true;
   }
 
-  public HashMap<String, Object> readJsonFromFile(File jsonFile) {
+  public static HashMap<String, Object> readJsonFromFile(File jsonFile) {
     ObjectMapper mapper = new ObjectMapper();
     try {
       HashMap<String, Object> jsonmap = mapper.readValue(jsonFile, new TypeReference<HashMap<String, Object>>() {});
@@ -119,7 +116,7 @@ public class JSONUtil {
     return new HashMap<String, Object>();
   }
 
-  public String mapToJSON(Map<String, Object> map) {
+  public static String mapToJSON(Map<String, Object> map) {
     ObjectMapper om = new ObjectMapper();
     try {
       String json = om.writeValueAsString(map);
@@ -134,7 +131,7 @@ public class JSONUtil {
   /**
    * WRITE JOSN IN FILE ( Delete existing file and create new file)
    */
-  public synchronized void writeJSONInFile(String jsonStr, File outputFile, boolean beautify) {
+  public static 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.");
@@ -170,11 +167,11 @@ public class JSONUtil {
     }
   }
 
-  public String objToJson(Object obj) {
+  public static String objToJson(Object obj) {
     return gson.toJson(obj);
   }
 
-  public Object jsonToObj(String json, Class<?> klass) {
+  public static Object jsonToObj(String json, Class<?> klass) {
     return gson.fromJson(json, klass);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/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
deleted file mode 100644
index 59f0296..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/PropertiesUtil.java
+++ /dev/null
@@ -1,182 +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.io.FileInputStream;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
-
-public class PropertiesUtil extends PropertyPlaceholderConfigurer {
-  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() {
-
-  }
-  
- static {
-    propertiesMap = new HashMap<String, String>();
-    Properties properties = new Properties();
-    URL fileCompleteUrl = Thread.currentThread().getContextClassLoader().getResource(LOGSEARCH_PROP_FILE);
-    FileInputStream fileInputStream = null;
-    try {
-      File file = new File(fileCompleteUrl.toURI());
-      fileInputStream = new FileInputStream(file.getAbsoluteFile());
-      properties.load(fileInputStream);
-    } catch (IOException | URISyntaxException e) {
-      logger.error("error loading prop for protocol config",e);
-    } finally {
-      if (fileInputStream != null) {
-        try {
-          fileInputStream.close();
-        } catch (IOException e) {
-        }
-      }
-    }
-    for (String key : properties.stringPropertyNames()) {
-      String value = properties.getProperty(key);
-      propertiesMap.put(key, value);
-    }
-  }
-
-  @Override
-  protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException {
-    super.processProperties(beanFactory, props);
-
-    propertiesMap = new HashMap<String, String>();
-
-    // First add the system properties
-    Set<Object> keySet = System.getProperties().keySet();
-    for (Object key : keySet) {
-      String keyStr = key.toString();
-      propertiesMap.put(keyStr, System.getProperties().getProperty(keyStr).trim());
-    }
-
-    // add our properties now
-    keySet = props.keySet();
-    for (Object key : keySet) {
-      String keyStr = key.toString();
-      propertiesMap.put(keyStr, props.getProperty(keyStr).trim());
-    }
-  }
-
-  public static String getProperty(String key, String defaultValue) {
-    if (key == null) {
-      return null;
-    }
-    String rtrnVal = propertiesMap.get(key);
-    if (rtrnVal == null) {
-      rtrnVal = defaultValue;
-    }
-    return rtrnVal;
-  }
-
-  public static String getProperty(String key) {
-    if (key == null) {
-      return null;
-    }
-    return propertiesMap.get(key);
-  }
-
-  public static String[] getPropertyStringList(String key) {
-    if (key == null) {
-      return null;
-    }
-    String value = propertiesMap.get(key);
-    if (value == null || value.trim().equals("")) {
-      return new String[0];
-    } else {
-      String[] splitValues = value.split(",");
-      String[] returnValues = new String[splitValues.length];
-      for (int i = 0; i < splitValues.length; i++) {
-        returnValues[i] = splitValues[i].trim();
-      }
-      return returnValues;
-    }
-  }
-
-  public static Integer getIntProperty(String key, int defaultValue) {
-    if (key == null) {
-      return null;
-    }
-    String rtrnVal = propertiesMap.get(key);
-    if (rtrnVal == null) {
-      return defaultValue;
-    }
-    return Integer.valueOf(rtrnVal);
-  }
-
-  public static Integer getIntProperty(String key) {
-    if (key == null) {
-      return null;
-    }
-    String rtrnVal = propertiesMap.get(key);
-    if (rtrnVal == null) {
-      return null;
-    }
-    return Integer.valueOf(rtrnVal);
-  }
-
-  public static Long getLongProperty(String key, long defaultValue) {
-    if (key == null) {
-      return null;
-    }
-    String rtrnVal = propertiesMap.get(key);
-    if (rtrnVal == null) {
-      return defaultValue;
-    }
-    return Long.valueOf(rtrnVal);
-  }
-
-  public static Long getLongProperty(String key) {
-    if (key == null) {
-      return null;
-    }
-    String rtrnVal = propertiesMap.get(key);
-    if (rtrnVal == null) {
-      return null;
-    }
-    return Long.valueOf(rtrnVal);
-  }
-
-  public static boolean getBooleanProperty(String key, boolean defaultValue) {
-    if (key == null) {
-      return defaultValue;
-    }
-    String value = getProperty(key);
-    if (value == null) {
-      return defaultValue;
-    }
-    return Boolean.parseBoolean(value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/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
deleted file mode 100644
index 5961cff..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/QueryBase.java
+++ /dev/null
@@ -1,132 +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 org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.SolrQuery;
-
-public class QueryBase {
-
-  //Solr Facet Methods
-  public void setFacetField(SolrQuery solrQuery, String facetField) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_FIELD, facetField);
-    setFacetLimit(solrQuery, -1);
-  }
-
-  public void setJSONFacet(SolrQuery solrQuery, String jsonQuery) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_JSON_FIELD, jsonQuery);
-    setFacetLimit(solrQuery, -1);
-  }
-
-  public void setFacetSort(SolrQuery solrQuery, String sortType) {
-    solrQuery.setFacet(true);
-    solrQuery.setFacetSort(sortType);
-  }
-
-  public void setFacetPivot(SolrQuery solrQuery, int mincount, String... hirarchy) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_PIVOT, hirarchy);
-    solrQuery.set(LogSearchConstants.FACET_PIVOT_MINCOUNT, mincount);
-    setFacetLimit(solrQuery, -1);
-  }
-
-  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);
-    solrQuery.set(LogSearchConstants.FACET_DATE_START, from);
-    solrQuery.set(LogSearchConstants.FACET_DATE_END, to);
-    solrQuery.set(LogSearchConstants.FACET_DATE_GAP, unit);
-    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, 0);
-    setFacetLimit(solrQuery, -1);
-  }
-
-  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);
-    solrQuery.set(LogSearchConstants.FACET_RANGE_START, from);
-    solrQuery.set(LogSearchConstants.FACET_RANGE_END, to);
-    solrQuery.set(LogSearchConstants.FACET_RANGE_GAP, unit);
-    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, 0);
-    setFacetLimit(solrQuery, -1);
-  }
-
-  public void setFacetLimit(SolrQuery solrQuery, int limit) {
-    solrQuery.set("facet.limit", limit);
-  }
-
-  //Solr Group Mehtods
-  public void setGroupField(SolrQuery solrQuery, String groupField, int rows) {
-    solrQuery.set(LogSearchConstants.FACET_GROUP, true);
-    solrQuery.set(LogSearchConstants.FACET_GROUP_FIELD, groupField);
-    solrQuery.set(LogSearchConstants.FACET_GROUP_MAIN, true);
-    setRowCount(solrQuery, rows);
-  }
-
-  //Main Query
-  public void setMainQuery(SolrQuery solrQuery, String query) {
-    String defalultQuery = "*:*";
-    if (StringUtils.isBlank(query)){
-      solrQuery.setQuery(defalultQuery);
-    }else{
-      solrQuery.setQuery(query);
-    }
-  }
-
-  public void setStart(SolrQuery solrQuery, int start) {
-    int defaultStart = 0;
-    if (start > defaultStart) {
-      solrQuery.setStart(start);
-    } else {
-      solrQuery.setStart(defaultStart);
-    }
-  }
-
-  //Set Number of Rows
-  public void setRowCount(SolrQuery solrQuery, int rows) {
-    if (rows > 0) {
-      solrQuery.setRows(rows);
-    } else {
-      solrQuery.setRows(0);
-      solrQuery.remove(LogSearchConstants.SORT);
-    }
-  }
-
-  //Solr Facet Methods
-  public void setFacetFieldWithMincount(SolrQuery solrQuery, String facetField, int minCount) {
-    solrQuery.setFacet(true);
-    setRowCount(solrQuery, 0);
-    solrQuery.set(LogSearchConstants.FACET_FIELD, facetField);
-    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, minCount);
-    setFacetLimit(solrQuery, -1);
-  }
-  
-  public void setFl(SolrQuery solrQuery,String field){
-    solrQuery.set(LogSearchConstants.FL, field);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/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 6df5b05..88fb0d5 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
@@ -29,19 +29,19 @@ import org.apache.ambari.logsearch.common.MessageEnums;
 import org.apache.ambari.logsearch.view.VMessage;
 import org.apache.ambari.logsearch.view.VResponse;
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
-@Component
 public class RESTErrorUtil {
+  private static final Logger logger = Logger.getLogger(RESTErrorUtil.class);
 
-  private static Logger logger = Logger.getLogger(RESTErrorUtil.class);
-
-  public WebApplicationException createRESTException(VResponse response) {
+  private RESTErrorUtil() {
+    throw new UnsupportedOperationException();
+  }
+  
+  public static WebApplicationException createRESTException(VResponse response) {
     return createRESTException(response, HttpServletResponse.SC_BAD_REQUEST);
   }
 
-  public WebApplicationException createRESTException(String errorMessage,
-                                                     MessageEnums messageEnum) {
+  public static WebApplicationException createRESTException(String errorMessage, MessageEnums messageEnum) {
     List<VMessage> messageList = new ArrayList<VMessage>();
     messageList.add(messageEnum.getMessage());
 
@@ -54,7 +54,7 @@ public class RESTErrorUtil {
     return webAppEx;
   }
 
-  private WebApplicationException createRESTException(VResponse response, int sc) {
+  private static 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/c69016d4/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 bcf9605..33262f3 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,30 +25,28 @@ import java.util.Locale;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.dao.SolrDaoBase;
+import org.apache.solr.client.solrj.SolrQuery;
 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 {
-
-  @Autowired
-  private JSONUtil jsonUtil;
-
-  public String setField(String fieldName, String value) {
+  private SolrUtil() {
+    throw new UnsupportedOperationException();
+  }
+  
+  public static String setField(String fieldName, String value) {
     if (value == null || value.trim().length() == 0) {
       return "";
     }
     return fieldName + ":" + value.trim().toLowerCase(Locale.ENGLISH);
   }
 
-  public String inList(String fieldName, int[] values) {
+  public static String inList(String fieldName, int[] values) {
     if (ArrayUtils.isEmpty(values)) {
       return "";
     }
@@ -64,7 +62,7 @@ public class SolrUtil {
     }
   }
 
-  public String inList(Collection<Long> values) {
+  public static String inList(Collection<Long> values) {
     if (CollectionUtils.isEmpty(values)) {
       return "";
     }
@@ -81,7 +79,7 @@ public class SolrUtil {
 
   }
 
-  public String orList(String fieldName, String[] valueList, String wildCard) {
+  public static String orList(String fieldName, String[] valueList, String wildCard) {
     if (ArrayUtils.isEmpty(valueList)) {
       return "";
     }
@@ -109,7 +107,7 @@ public class SolrUtil {
 
   }
 
-  public String andList(String fieldName, String[] valueList, String wildCard) {
+  public static String andList(String fieldName, String[] valueList, String wildCard) {
     if (ArrayUtils.isEmpty(valueList)) {
       return "";
     }
@@ -140,7 +138,7 @@ public class SolrUtil {
   /**
    * Copied from Solr ClientUtils.escapeQueryChars and removed escaping *
    */
-  public String escapeQueryChars(String s) {
+  public static String escapeQueryChars(String s) {
     StringBuilder sb = new StringBuilder();
     int prev = 0;
     if (s != null) {
@@ -169,7 +167,7 @@ public class SolrUtil {
     return sb.toString();
   }
 
-  private String escapeForWhiteSpaceTokenizer(String search) {
+  private static String escapeForWhiteSpaceTokenizer(String search) {
     if (search == null) {
       return null;
     }
@@ -188,7 +186,7 @@ public class SolrUtil {
     return newSearch;
   }
 
-  public String escapeForStandardTokenizer(String search) {
+  public static String escapeForStandardTokenizer(String search) {
     if (search == null) {
       return null;
     }
@@ -207,7 +205,7 @@ public class SolrUtil {
     return newSearch;
   }
 
-  private String escapeForKeyTokenizer(String search) {
+  private static String escapeForKeyTokenizer(String search) {
     if (search.startsWith("*") && search.endsWith("*") && !StringUtils.isBlank(search)) {
       // Remove the * from both the sides
       if (search.length() > 1) {
@@ -226,7 +224,7 @@ public class SolrUtil {
    * This is a special case scenario to handle log_message for wild card
    * scenarios
    */
-  public String escapeForLogMessage(String field, String search) {
+  public static String escapeForLogMessage(String field, String search) {
     if (search.startsWith("*") && search.endsWith("*")) {
       field = LogSearchConstants.SOLR_KEY_LOG_MESSAGE;
       search = escapeForKeyTokenizer(search);
@@ -238,7 +236,7 @@ public class SolrUtil {
     return field + ":" + search;
   }
 
-  public String makeSolrSearchString(String search) {
+  public static String makeSolrSearchString(String search) {
     String newString = search.trim();
     String newSearch = newString.replaceAll("(?=[]\\[+&|!(){},:\"^~/=$@%?:.\\\\])", "\\\\");
     newSearch = newSearch.replace("\n", "*");
@@ -249,7 +247,7 @@ public class SolrUtil {
     return "*" + newSearch + "*";
   }
 
-  public String makeSolrSearchStringWithoutAsterisk(String search) {
+  public static String makeSolrSearchStringWithoutAsterisk(String search) {
     String newString = search.trim();
     String newSearch = newString.replaceAll("(?=[]\\[+&|!(){}^\"~=/$@%?:.\\\\])", "\\\\");
     newSearch = newSearch.replace("\n", "*");
@@ -261,7 +259,7 @@ public class SolrUtil {
     return newSearch;
   }
 
-  public String makeSearcableString(String search) {
+  public static String makeSearcableString(String search) {
     if (StringUtils.isBlank(search)) {
       return "";
     }
@@ -272,7 +270,7 @@ public class SolrUtil {
   }
   
 
-  public boolean isSolrFieldNumber(String fieldType,SolrDaoBase solrDaoBase) {
+  public static boolean isSolrFieldNumber(String fieldType,SolrDaoBase solrDaoBase) {
     if (StringUtils.isBlank(fieldType)) {
       return false;
     } else {
@@ -281,30 +279,25 @@ public class SolrUtil {
         return false;
       }
       String fieldTypeClassName = (String) typeInfoMap.get("class");
-      if (fieldTypeClassName.equalsIgnoreCase(TrieIntField.class
-          .getSimpleName())) {
+      if (fieldTypeClassName.equalsIgnoreCase(TrieIntField.class.getSimpleName())) {
         return true;
       }
-      if (fieldTypeClassName.equalsIgnoreCase(TrieDoubleField.class
-          .getSimpleName())) {
+      if (fieldTypeClassName.equalsIgnoreCase(TrieDoubleField.class.getSimpleName())) {
         return true;
       }
-      if (fieldTypeClassName.equalsIgnoreCase(TrieFloatField.class
-          .getSimpleName())) {
+      if (fieldTypeClassName.equalsIgnoreCase(TrieFloatField.class.getSimpleName())) {
         return true;
       }
-      if (fieldTypeClassName.equalsIgnoreCase(TrieLongField.class
-          .getSimpleName())) {
+      if (fieldTypeClassName.equalsIgnoreCase(TrieLongField.class.getSimpleName())) {
         return true;
       }
       return false;
     }
   }
   
-  public HashMap<String, Object> getFieldTypeInfoMap(String fieldType,SolrDaoBase solrDaoBase) {
+  public static HashMap<String, Object> getFieldTypeInfoMap(String fieldType,SolrDaoBase solrDaoBase) {
     String fieldTypeMetaData = solrDaoBase.schemaFieldTypeMap.get(fieldType);
-    HashMap<String, Object> fieldTypeMap = jsonUtil
-        .jsonToMapObject(fieldTypeMetaData);
+    HashMap<String, Object> fieldTypeMap = JSONUtil.jsonToMapObject(fieldTypeMetaData);
     if (fieldTypeMap == null) {
       return new HashMap<String, Object>();
     }
@@ -315,4 +308,111 @@ public class SolrUtil {
     }
     return fieldTypeMap;
   }
+  
+  //=============================================================================================================
+  
+  //Solr Facet Methods
+  public static void setFacetField(SolrQuery solrQuery, String facetField) {
+    solrQuery.setFacet(true);
+    setRowCount(solrQuery, 0);
+    solrQuery.set(LogSearchConstants.FACET_FIELD, facetField);
+    setFacetLimit(solrQuery, -1);
+  }
+
+  public static void setJSONFacet(SolrQuery solrQuery, String jsonQuery) {
+    solrQuery.setFacet(true);
+    setRowCount(solrQuery, 0);
+    solrQuery.set(LogSearchConstants.FACET_JSON_FIELD, jsonQuery);
+    setFacetLimit(solrQuery, -1);
+  }
+
+  public static void setFacetSort(SolrQuery solrQuery, String sortType) {
+    solrQuery.setFacet(true);
+    solrQuery.setFacetSort(sortType);
+  }
+
+  public static void setFacetPivot(SolrQuery solrQuery, int mincount, String... hirarchy) {
+    solrQuery.setFacet(true);
+    setRowCount(solrQuery, 0);
+    solrQuery.set(LogSearchConstants.FACET_PIVOT, hirarchy);
+    solrQuery.set(LogSearchConstants.FACET_PIVOT_MINCOUNT, mincount);
+    setFacetLimit(solrQuery, -1);
+  }
+
+  public static void setFacetDate(SolrQuery solrQuery, String facetField, String from, String to, String unit) {
+    solrQuery.setFacet(true);
+    setRowCount(solrQuery, 0);
+    solrQuery.set(LogSearchConstants.FACET_DATE, facetField);
+    solrQuery.set(LogSearchConstants.FACET_DATE_START, from);
+    solrQuery.set(LogSearchConstants.FACET_DATE_END, to);
+    solrQuery.set(LogSearchConstants.FACET_DATE_GAP, unit);
+    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, 0);
+    setFacetLimit(solrQuery, -1);
+  }
+
+  public static void setFacetRange(SolrQuery solrQuery, String facetField, String from, String to, String unit) {
+    solrQuery.setFacet(true);
+    setRowCount(solrQuery, 0);
+    solrQuery.set(LogSearchConstants.FACET_RANGE, facetField);
+    solrQuery.set(LogSearchConstants.FACET_RANGE_START, from);
+    solrQuery.set(LogSearchConstants.FACET_RANGE_END, to);
+    solrQuery.set(LogSearchConstants.FACET_RANGE_GAP, unit);
+    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, 0);
+    setFacetLimit(solrQuery, -1);
+  }
+
+  public static void setFacetLimit(SolrQuery solrQuery, int limit) {
+    solrQuery.set("facet.limit", limit);
+  }
+
+  //Solr Group Mehtods
+  public static void setGroupField(SolrQuery solrQuery, String groupField, int rows) {
+    solrQuery.set(LogSearchConstants.FACET_GROUP, true);
+    solrQuery.set(LogSearchConstants.FACET_GROUP_FIELD, groupField);
+    solrQuery.set(LogSearchConstants.FACET_GROUP_MAIN, true);
+    setRowCount(solrQuery, rows);
+  }
+
+  //Main Query
+  public static void setMainQuery(SolrQuery solrQuery, String query) {
+    String defalultQuery = "*:*";
+    if (StringUtils.isBlank(query)){
+      solrQuery.setQuery(defalultQuery);
+    }else{
+      solrQuery.setQuery(query);
+    }
+  }
+
+  public static void setStart(SolrQuery solrQuery, int start) {
+    int defaultStart = 0;
+    if (start > defaultStart) {
+      solrQuery.setStart(start);
+    } else {
+      solrQuery.setStart(defaultStart);
+    }
+  }
+
+  //Set Number of Rows
+  public static void setRowCount(SolrQuery solrQuery, int rows) {
+    if (rows > 0) {
+      solrQuery.setRows(rows);
+    } else {
+      solrQuery.setRows(0);
+      solrQuery.remove(LogSearchConstants.SORT);
+    }
+  }
+
+  //Solr Facet Methods
+  public static void setFacetFieldWithMincount(SolrQuery solrQuery, String facetField, int minCount) {
+    solrQuery.setFacet(true);
+    setRowCount(solrQuery, 0);
+    solrQuery.set(LogSearchConstants.FACET_FIELD, facetField);
+    solrQuery.set(LogSearchConstants.FACET_MINCOUNT, minCount);
+    setFacetLimit(solrQuery, -1);
+  }
+  
+  public static void setFl(SolrQuery solrQuery,String field){
+    solrQuery.set(LogSearchConstants.FL, field);
+  }
+  
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/XMLPropertiesUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/XMLPropertiesUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/XMLPropertiesUtil.java
deleted file mode 100644
index ff80e73..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/XMLPropertiesUtil.java
+++ /dev/null
@@ -1,85 +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.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.log4j.Logger;
-import org.springframework.util.DefaultPropertiesPersister;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class XMLPropertiesUtil extends DefaultPropertiesPersister {
-  private static Logger logger = Logger.getLogger(XMLPropertiesUtil.class);
-
-  public XMLPropertiesUtil() {
-  }
-
-  @Override
-  public void loadFromXml(Properties properties, InputStream inputStream)
-      throws IOException {
-    try {
-      DocumentBuilderFactory xmlDocumentBuilderFactory = DocumentBuilderFactory
-          .newInstance();
-      xmlDocumentBuilderFactory.setIgnoringComments(true);
-      xmlDocumentBuilderFactory.setNamespaceAware(true);
-      DocumentBuilder xmlDocumentBuilder = xmlDocumentBuilderFactory
-          .newDocumentBuilder();
-      Document xmlDocument = xmlDocumentBuilder.parse(inputStream);
-      if (xmlDocument != null) {
-        xmlDocument.getDocumentElement().normalize();
-        NodeList nList = xmlDocument.getElementsByTagName("property");
-        if (nList != null) {
-          for (int temp = 0; temp < nList.getLength(); temp++) {
-            Node nNode = nList.item(temp);
-            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
-              Element eElement = (Element) nNode;
-              String propertyName = "";
-              String propertyValue = "";
-              if (eElement.getElementsByTagName("name") != null
-                  && eElement.getElementsByTagName("name").item(0) != null) {
-                propertyName = eElement.getElementsByTagName("name").item(0)
-                    .getTextContent().trim();
-              }
-              if (eElement.getElementsByTagName("value") != null
-                  && eElement.getElementsByTagName("value").item(0) != null) {
-                propertyValue = eElement.getElementsByTagName("value").item(0)
-                    .getTextContent().trim();
-              }
-              if (propertyName != null && !propertyName.isEmpty()) {
-                properties.put(propertyName, propertyValue);
-              }
-            }
-          }
-        }
-      }
-    } catch (Exception e) {
-      logger.error("Error loading xml properties ", e);
-    }
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/authenticate/LogsearchAuthFailureHandler.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/authenticate/LogsearchAuthFailureHandler.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/authenticate/LogsearchAuthFailureHandler.java
index d706beb..fdec8d3 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/authenticate/LogsearchAuthFailureHandler.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/authenticate/LogsearchAuthFailureHandler.java
@@ -24,27 +24,20 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler;
 
 public class LogsearchAuthFailureHandler extends ExceptionMappingAuthenticationFailureHandler {
-
   private static final Logger logger = Logger.getLogger(LogsearchAuthFailureHandler.class);
 
-  @Autowired
-  RESTErrorUtil restErrorUtil;
-
-  public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
-                                      AuthenticationException exception) throws IOException, ServletException {
+  public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception)
+      throws IOException, ServletException {
     logger.debug(" AuthFailureHandler + onAuthenticationFailure");
     // TODO UI side handle status and redirect to login page with proper
     response.setContentType("application/json");
     response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
     response.getOutputStream().println("{ \"error\": \"" + "login failed !!" + "\" }");
-
   }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchAuthenticationEntryPoint.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchAuthenticationEntryPoint.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchAuthenticationEntryPoint.java
index 62f762c..1b24c06 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchAuthenticationEntryPoint.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchAuthenticationEntryPoint.java
@@ -24,23 +24,17 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
 
 class LogsearchAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
-
-  @Autowired
-  RESTErrorUtil restErrorUtil;
+  private static final Logger logger = Logger.getLogger(LogsearchAuthenticationEntryPoint.class);
 
   public LogsearchAuthenticationEntryPoint(String loginFormUrl) {
     super(loginFormUrl);
   }
 
-  private static final Logger logger = Logger.getLogger(LogsearchAuthenticationEntryPoint.class);
-
   @Override
   public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
     throws IOException, ServletException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
index 6443d62..29fd5b2 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
@@ -40,7 +40,6 @@ import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.ambari.logsearch.util.PropertiesUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.security.authentication.AbstractAuthenticationToken;
@@ -54,6 +53,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.context.SecurityContextImpl;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.UserDetails;
+import org.apache.ambari.logsearch.common.PropertiesHelper;
 import org.apache.commons.collections.iterators.IteratorEnumeration;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
@@ -102,18 +102,18 @@ public class LogsearchKRBAuthenticationFilter extends LogsearchKrbFilter {
   @Override
   public void init(FilterConfig conf) throws ServletException {
     final FilterConfig globalConf = conf;
-    String hostName = PropertiesUtil.getProperty(HOST_NAME, "localhost");
+    String hostName = PropertiesHelper.getProperty(HOST_NAME, "localhost");
     final Map<String, String> params = new HashMap<String, String>();
     if (spnegoEnable) {
       authType = KerberosAuthenticationHandler.TYPE;
     }
     params.put(AUTH_TYPE,authType);
-    params.put(NAME_RULES_PARAM,PropertiesUtil.getProperty(NAME_RULES, "DEFAULT"));
-    params.put(TOKEN_VALID_PARAM, PropertiesUtil.getProperty(TOKEN_VALID, "30"));
-    params.put(COOKIE_DOMAIN_PARAM, PropertiesUtil.getProperty(COOKIE_DOMAIN, hostName));
-    params.put(COOKIE_PATH_PARAM, PropertiesUtil.getProperty(COOKIE_PATH, "/"));
-    params.put(PRINCIPAL_PARAM,PropertiesUtil.getProperty(PRINCIPAL,""));
-    params.put(KEYTAB_PARAM,PropertiesUtil.getProperty(KEYTAB,""));
+    params.put(NAME_RULES_PARAM,PropertiesHelper.getProperty(NAME_RULES, "DEFAULT"));
+    params.put(TOKEN_VALID_PARAM, PropertiesHelper.getProperty(TOKEN_VALID, "30"));
+    params.put(COOKIE_DOMAIN_PARAM, PropertiesHelper.getProperty(COOKIE_DOMAIN, hostName));
+    params.put(COOKIE_PATH_PARAM, PropertiesHelper.getProperty(COOKIE_PATH, "/"));
+    params.put(PRINCIPAL_PARAM,PropertiesHelper.getProperty(PRINCIPAL,""));
+    params.put(KEYTAB_PARAM,PropertiesHelper.getProperty(KEYTAB,""));
     FilterConfig myConf = new FilterConfig() {
       @Override
       public ServletContext getServletContext() {
@@ -196,7 +196,7 @@ public class LogsearchKRBAuthenticationFilter extends LogsearchKrbFilter {
     }
     if (!isLoginRequest(httpRequest) && spnegoEnable
         && (existingAuth == null || !existingAuth.isAuthenticated())) {
-      KerberosName.setRules(PropertiesUtil.getProperty(NAME_RULES, "DEFAULT"));
+      KerberosName.setRules(PropertiesHelper.getProperty(NAME_RULES, "DEFAULT"));
       String userName = getUsernameFromRequest(httpRequest);
       if ((existingAuth == null || !existingAuth.isAuthenticated())
           && (!StringUtils.isEmpty(userName))) {
@@ -230,12 +230,12 @@ public class LogsearchKRBAuthenticationFilter extends LogsearchKrbFilter {
   }
 
   private void isSpnegoEnable() {
-    spnegoEnable = PropertiesUtil.getBooleanProperty(KERBEROS_ENABLE, false);
+    spnegoEnable = PropertiesHelper.getBooleanProperty(KERBEROS_ENABLE, false);
     if (spnegoEnable) {
       spnegoEnable = false;
-      String keytab = PropertiesUtil.getProperty(KEYTAB);
-      String principal = PropertiesUtil.getProperty(PRINCIPAL);
-      String hostname = PropertiesUtil.getProperty(HOST_NAME);
+      String keytab = PropertiesHelper.getProperty(KEYTAB);
+      String principal = PropertiesHelper.getProperty(PRINCIPAL);
+      String hostname = PropertiesHelper.getProperty(HOST_NAME);
       if (!StringUtils.isEmpty(keytab) && !StringUtils.isEmpty(principal)
           && !StringUtils.isEmpty(hostname)) {
         spnegoEnable = true;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LdapUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LdapUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LdapUtil.java
index 99940df..6248e74 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LdapUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LdapUtil.java
@@ -21,8 +21,8 @@ package org.apache.ambari.logsearch.web.security;
 import java.io.IOException;
 import java.util.Properties;
 
-import org.apache.ambari.logsearch.util.PropertiesUtil;
-import org.apache.ambari.logsearch.util.XMLPropertiesUtil;
+import org.apache.ambari.logsearch.common.PropertiesHelper;
+import org.apache.ambari.logsearch.common.XMLPropertiesHelper;
 import org.apache.log4j.Logger;
 import org.springframework.core.io.ClassPathResource;
 
@@ -94,13 +94,13 @@ public class LdapUtil {
    */
   public static LdapProperties loadLdapProperties() {
     LdapProperties ldapServerProperties = null;
-    String ldapConfigFileName = PropertiesUtil.getProperty("logsearch.login.ldap.config", "logsearch-admin-site.xml");
+    String ldapConfigFileName = PropertiesHelper.getProperty("logsearch.login.ldap.config", "logsearch-admin-site.xml");
     Properties props = null;
     ClassPathResource resource = new ClassPathResource(ldapConfigFileName);
     if (resource != null) {
       try {
         props = new Properties();
-        new XMLPropertiesUtil().loadFromXml(props, resource.getInputStream());
+        new XMLPropertiesHelper().loadFromXml(props, resource.getInputStream());
         ldapServerProperties = getLdapServerProperties(props);
       } catch (IOException e) {
         logger.error("Ldap configudation file loading failed : " + e.getMessage());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
index d82bf8e..0c102c3 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
@@ -21,7 +21,7 @@ package org.apache.ambari.logsearch.web.security;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.ambari.logsearch.util.PropertiesUtil;
+import org.apache.ambari.logsearch.common.PropertiesHelper;
 import org.springframework.security.authentication.AuthenticationProvider;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.GrantedAuthority;
@@ -61,7 +61,7 @@ public abstract class LogsearchAbstractAuthenticationProvider implements Authent
   public boolean isEnable(AUTH_METHOD method) {
     String methodName = method.name().toLowerCase();
     String property = AUTH_METHOD_PROP_START_WITH + methodName + ".enable";
-    boolean isEnable = PropertiesUtil.getBooleanProperty(property, false);
+    boolean isEnable = PropertiesHelper.getBooleanProperty(property, false);
     return isEnable;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
index 8c69152..0f7377d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
@@ -54,12 +54,6 @@ public class LogsearchAuthenticationProvider extends
   @Autowired
   LogsearchExternalServerAuthenticationProvider externalServerAuthenticationProvider;
 
-  @Autowired
-  JSONUtil jsonUtil;
-
-  @Autowired
-  private UserDetailsService userService;
-
   @Override
   public Authentication authenticate(Authentication authentication)
     throws AuthenticationException {
@@ -117,7 +111,7 @@ public class LogsearchAuthenticationProvider extends
       }
       return authentication;
     } finally {
-      String jsonStr = jsonUtil.mapToJSON(auditRecord);
+      String jsonStr = JSONUtil.mapToJSON(auditRecord);
       if (isSuccess) {
         auditLogger.info(jsonStr);
       } else {
@@ -126,11 +120,6 @@ public class LogsearchAuthenticationProvider extends
     }
   }
 
-  /**
-   * @param authentication
-   * @param authMethod
-   * @return
-   */
   public Authentication doAuth(Authentication authentication, AUTH_METHOD authMethod) {
     if (authMethod.equals(AUTH_METHOD.LDAP)) {
       authentication = ldapAuthenticationProvider.authenticate(authentication);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
index 72ee60f..4eea3e1 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
@@ -23,9 +23,9 @@ import java.util.List;
 
 import javax.annotation.PostConstruct;
 
-import org.apache.ambari.logsearch.util.ExternalServerClient;
+import org.apache.ambari.logsearch.common.ExternalServerClient;
+import org.apache.ambari.logsearch.common.PropertiesHelper;
 import org.apache.ambari.logsearch.util.JSONUtil;
-import org.apache.ambari.logsearch.util.PropertiesUtil;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
@@ -98,14 +98,11 @@ public class LogsearchExternalServerAuthenticationProvider extends
   @Autowired
   ExternalServerClient externalServerClient;
 
-  @Autowired
-  JSONUtil jsonUtil;
-
   private String loginAPIURL = "/api/v1/users/$USERNAME/privileges?fields=*";// default
 
   @PostConstruct
   public void initialization() {
-    loginAPIURL = PropertiesUtil.getProperty(AUTH_METHOD_PROP_START_WITH
+    loginAPIURL = PropertiesHelper.getProperty(AUTH_METHOD_PROP_START_WITH
         + "external_auth.login_url", loginAPIURL);
   }
 
@@ -160,11 +157,11 @@ public class LogsearchExternalServerAuthenticationProvider extends
    */
   @SuppressWarnings("static-access")
   private boolean isAllowedRole(String responseJson) {
-    String allowedRoleList[] = PropertiesUtil
+    String allowedRoleList[] = PropertiesHelper
         .getPropertyStringList(ALLOWED_ROLE_PROP);
 
     List<String> values = new ArrayList<String>();
-    jsonUtil.getValuesOfKey(responseJson,
+    JSONUtil.getValuesOfKey(responseJson,
         PRIVILEGE_INFO.PERMISSION_NAME.toString(), values);
     if (values.isEmpty())
       return true;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
index f334e67..b457a1d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
@@ -37,9 +37,9 @@ http://www.springframework.org/schema/util/spring-util.xsd">
 
 	<context:component-scan base-package="org.apache.ambari.logsearch" />
 	<task:annotation-driven />
-	<bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.util.XMLPropertiesUtil" />
+	<bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.common.XMLPropertiesHelper" />
 	
-	<bean id="propertyConfigurer" class="org.apache.ambari.logsearch.util.PropertiesUtil">
+	<bean id="propertyConfigurer" class="org.apache.ambari.logsearch.common.PropertiesHelper">
 		<property name="locations">
 			<list>
 				<value>classpath:default.properties</value>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
index 0ded95d..ba5b074 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
@@ -232,7 +232,6 @@ public class SolrDaoBaseTest {
     expectedException.expect(WebApplicationException.class);
     
     SolrDaoBase dao = new SolrDaoBase(LogType.SERVICE) {};
-    dao.restErrorUtil = new RESTErrorUtil();
     dao.process(new SolrQuery());
   }
   

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
index 5ef286f..dddbf31 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
@@ -33,20 +33,11 @@ import org.easymock.Capture;
 import org.easymock.CaptureType;
 import org.easymock.EasyMock;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import junit.framework.Assert;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "/applicationContext.xml" })
 public class UserConfigSolrDaoTest {
   
-  @Autowired
-  private UserConfigSolrDao dao;
-  
   @Test
   public void testUserConfigDaoPostConstructor() throws Exception {
     SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
@@ -78,6 +69,8 @@ public class UserConfigSolrDaoTest {
     EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
     EasyMock.replay(mockSolrClient);
     
+    UserConfigSolrDao dao = new UserConfigSolrDao();
+    dao.postConstructor();
     dao.solrClient = mockSolrClient;
     dao.isZkConnectString = true;
     
@@ -119,6 +112,8 @@ public class UserConfigSolrDaoTest {
     EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
     EasyMock.replay(mockSolrClient);
     
+    UserConfigSolrDao dao = new UserConfigSolrDao();
+    dao.postConstructor();
     dao.solrClient = mockSolrClient;
     dao.isZkConnectString = true;
     

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
index 5e24d88..38437a4 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
@@ -37,9 +37,9 @@ http://www.springframework.org/schema/util/spring-util.xsd">
 
 	<context:component-scan base-package="org.apache.ambari.logsearch" />
 	<task:annotation-driven />
-	<bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.util.XMLPropertiesUtil" />
+	<bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.common.XMLPropertiesHelper" />
 	
-	<bean id="propertyConfigurer" class="org.apache.ambari.logsearch.util.PropertiesUtil">
+	<bean id="propertyConfigurer" class="org.apache.ambari.logsearch.common.PropertiesHelper">
 		<property name="locations">
 			<list>
 				<value>classpath:default.properties</value>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c69016d4/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml
deleted file mode 100644
index f1d1dbe..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext_testManagers.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
-xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
-xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns:util="http://www.springframework.org/schema/util"
-xsi:schemaLocation="http://www.springframework.org/schema/aop
-http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
-http://www.springframework.org/schema/beans
-http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
-http://www.springframework.org/schema/context
-http://www.springframework.org/schema/context/spring-context-4.2.xsd
-http://www.springframework.org/schema/jee
-http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
-http://www.springframework.org/schema/tx
-http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
-http://www.springframework.org/schema/task
-http://www.springframework.org/schema/task/spring-task-4.2.xsd
-http://www.springframework.org/schema/util
-http://www.springframework.org/schema/util/spring-util.xsd">
-
-	<context:component-scan base-package="org.apache.ambari.logsearch.manager.dao, org.apache.ambari.logsearch.util" />
-	<task:annotation-driven />
-	<bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.util.XMLPropertiesUtil" />
-	
-	<bean id="propertyConfigurer" class="org.apache.ambari.logsearch.util.PropertiesUtil">
-		<property name="locations">
-			<list>
-				<value>classpath:default.properties</value>
-				<value>classpath:logsearch.properties</value>
-				<value>classpath:logsearch-admin-site.xml</value>
-			</list>
-		</property>
-		<property name="propertiesPersister" ref="xmlPropertyConfigurer" />
-	</bean>
-	
-</beans>


Mime
View raw message