فهرست منبع

AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)

Change-Id: I0e99217fea1de03135b86e007fcb2a3ff6c2e257
oleewere 9 سال پیش
والد
کامیت
d7164202cc
100فایلهای تغییر یافته به همراه2665 افزوده شده و 4606 حذف شده
  1. 10 0
      ambari-logsearch/ambari-logsearch-portal/pom.xml
  2. 2 2
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java
  3. 4 62
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java
  4. 9 7
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java
  5. 3 3
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageData.java
  6. 4 6
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageEnums.java
  7. 5 5
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/VResponse.java
  8. 13 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java
  9. 11 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
  10. 59 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java
  11. 3 3
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java
  12. 55 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java
  13. 85 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java
  14. 39 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java
  15. 160 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java
  16. 53 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java
  17. 44 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java
  18. 21 9
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java
  19. 62 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java
  20. 19 9
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java
  21. 52 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java
  22. 86 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverter.java
  23. 54 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
  24. 27 14
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestQueryConverter.java
  25. 66 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverter.java
  26. 68 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverter.java
  27. 52 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverter.java
  28. 61 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverter.java
  29. 69 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverter.java
  30. 95 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverter.java
  31. 44 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverter.java
  32. 71 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
  33. 55 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverter.java
  34. 13 10
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
  35. 12 9
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
  36. 4 4
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
  37. 2 2
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
  38. 51 48
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
  39. 15 9
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
  40. 38 29
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
  41. 5 13
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
  42. 353 272
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
  43. 0 169
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
  44. 70 411
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
  45. 39 130
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
  46. 2 2
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
  47. 204 1101
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
  48. 3 2
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
  49. 87 112
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
  50. 20 14
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/common/LogFeederDataMap.java
  51. 18 22
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/common/LogfeederFilterData.java
  52. 1 1
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java
  53. 7 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
  54. 2 2
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java
  55. 0 13
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
  56. 5 6
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java
  57. 0 109
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java
  58. 1 1
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
  59. 4 11
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditComponentRequest.java
  60. 1 1
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
  61. 4 11
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditServiceLoadRequest.java
  62. 43 4
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
  63. 1 53
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
  64. 16 2
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
  65. 1 27
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceAnyGraphRequest.java
  66. 0 41
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java
  67. 25 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogAggregatedInfoRequest.java
  68. 25 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentHostRequest.java
  69. 25 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentLevelRequest.java
  70. 9 10
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogHostComponentRequest.java
  71. 25 0
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogLevelCountRequest.java
  72. 3 3
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
  73. 0 42
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java
  74. 10 7
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java
  75. 38 34
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
  76. 22 20
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigDataListResponse.java
  77. 0 340
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
  78. 0 282
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
  79. 0 70
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/SearchCriteriaConstants.java
  80. 0 44
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
  81. 0 55
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java
  82. 0 51
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
  83. 0 39
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java
  84. 0 33
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java
  85. 0 33
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java
  86. 0 34
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java
  87. 0 35
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java
  88. 0 34
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java
  89. 0 34
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
  90. 0 35
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
  91. 0 39
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
  92. 0 36
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
  93. 0 35
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java
  94. 0 36
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserConfigRequestConverter.java
  95. 0 36
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java
  96. 0 77
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java
  97. 0 33
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java
  98. 0 95
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonSearchCriteria.java
  99. 0 88
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java
  100. 0 135
      ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java

+ 10 - 0
ambari-logsearch/ambari-logsearch-portal/pom.xml

@@ -757,5 +757,15 @@
       <artifactId>spring-data-solr</artifactId>
       <version>${spring-data-solr.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.freemarker</groupId>
+      <artifactId>freemarker</artifactId>
+      <version>2.3.20</version>
+    </dependency>
   </dependencies>
 </project>

+ 2 - 2
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java

@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
@@ -33,12 +34,11 @@ import org.apache.log4j.Logger;
 import org.glassfish.jersey.client.JerseyClient;
 import org.glassfish.jersey.client.JerseyClientBuilder;
 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.springframework.stereotype.Component;
 
 /**
  * Layer to send REST request to External server using jersey client
  */
-@Component
+@Named
 public class ExternalServerClient {
 
   private static Logger LOG = Logger.getLogger(ExternalServerClient.class);

+ 4 - 62
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java

@@ -29,7 +29,7 @@ public class LogSearchConstants {
   public static final String FATAL = "FATAL";
   public static final String UNKNOWN = "UNKNOWN";
   
-  public static final String[] SUPPORTED_LOG_LEVEL ={FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN};
+  public static final String[] SUPPORTED_LOG_LEVELS = {FATAL, ERROR, WARN, INFO, DEBUG, TRACE, UNKNOWN};
 
   // Application Constants
   public static final String HOST = "H";
@@ -37,49 +37,10 @@ public class LogSearchConstants {
   public static final String SCROLL_TYPE_AFTER = "after";
   public static final String SCROLL_TYPE_BEFORE = "before";
 
-  // UserConfig Constants
-  public static final String ID = "id";
-  public static final String USER_NAME = "username";
-  public static final String VALUES = "jsons";
-  public static final String FILTER_NAME = "filtername";
-  public static final String ROW_TYPE = "rowtype";
-  public static final String COMPOSITE_KEY = "composite_filtername-username";
-  public static final String SHARE_NAME_LIST = "share_username_list";
-
-  // SOLR Document Constants for ServiceLogs
-  public static final String BUNDLE_ID = "bundle_id";
-  public static final String LOGTIME = "logtime";
-  public static final String SEQUNCE_ID = "seq_num";
-  public static final String SOLR_COMPONENT = "type";
-  public static final String SOLR_LOG_MESSAGE = "log_message";
-  public static final String SOLR_KEY_LOG_MESSAGE = "key_log_message";
-  public static final String SOLR_HOST = "host";
-  public static final String SOLR_LEVEL = "level";
-  public static final String SOLR_THREAD_NAME = "thread_name";
-  public static final String SOLR_LOGGER_NAME = "logger_name";
-  public static final String SOLR_FILE = "file";
-  public static final String SOLR_LINE_NUMBER = "line_number";
-  public static final String SOLR_PATH = "path";
-
-  //SOLR Document Constant for audit log
-  public static final String AUDIT_COMPONENT = "repo";
-  public static final String AUDIT_EVTTIME = "evtTime";
-  public static final String AUDIT_REQUEST_USER = "reqUser";
-
-  // Operator's
-  public static final String MINUS_OPERATOR = "-";
-  public static final String NO_OPERATOR = "";
-
-  //operation
-  public static final String EXCLUDE_QUERY = "excludeQuery";
-  public static final String INCLUDE_QUERY = "includeQuery";
-
   // Seprator's
   public static final String I_E_SEPRATOR = "\\|i\\:\\:e\\|";
 
   //SUFFIX
-  public static final String UI_SUFFIX = "@UI@";
-  public static final String SOLR_SUFFIX = "@Solr@";
   public static final String NGRAM_SUFFIX = "ngram_";
 
   //Date Format for SOLR
@@ -90,41 +51,23 @@ public class LogSearchConstants {
   public static final String ASCENDING_ORDER = "asc";
   public static final String DESCENDING_ORDER = "desc";
 
-  //Solr Facet Sort By
-  public static final String FACET_INDEX = "index";
-  public static final String FACET_COUNT = "count";
-
   // logfeeder 
   public static final String LOGFEEDER_FILTER_NAME = "log_feeder_config";
-  public static final String LIST_SEPARATOR = ",";
-  
+
   public static final String SORT = "sort";
-  public static final String FL = "fl";
   
   //Facet Constant
   public static final String FACET_FIELD = "facet.field";
-  public static final String FACET_MINCOUNT = "facet.mincount";
-  public static final String FACET_JSON_FIELD = "json.facet";
   public static final String FACET_PIVOT = "facet.pivot";
   public static final String FACET_PIVOT_MINCOUNT = "facet.pivot.mincount";
-  public static final String FACET_DATE = "facet.date";
-  public static final String FACET_DATE_START = "facet.date.start";
-  public static final String FACET_DATE_END = "facet.date.end";
-  public static final String FACET_DATE_GAP = "facet.date.gap";
-  public static final String FACET_RANGE = "facet.range";
-  public static final String FACET_RANGE_START = "facet.range.start";
-  public static final String FACET_RANGE_END = "facet.range.end";
-  public static final String FACET_RANGE_GAP = "facet.range.gap";
-  public static final String FACET_GROUP = "group";
-  public static final String FACET_GROUP_MAIN = "group.main";
-  public static final String FACET_GROUP_FIELD = "group.field";
+  public static final String FACET_INDEX = "index";
 
   // Request params
-  public static final String REQUEST_PARAM_QUERY = "q";
   public static final String REQUEST_PARAM_XAXIS = "xAxis";
   public static final String REQUEST_PARAM_YAXIS = "yAxis";
   public static final String REQUEST_PARAM_STACK_BY = "stackBy";
   public static final String REQUEST_PARAM_UNIT = "unit";
+  public static final String REQUEST_PARAM_TOP = "top";
   public static final String REQUEST_PARAM_BUNDLE_ID = "bundle_id";
   public static final String REQUEST_PARAM_START_INDEX = "startIndex";
   public static final String REQUEST_PARAM_PAGE = "page";
@@ -151,7 +94,6 @@ public class LogSearchConstants {
   public static final String REQUEST_PARAM_HOST_NAME = "host_name";
   public static final String REQUEST_PARAM_COMPONENT_NAME = "component_name";
   public static final String REQUEST_PARAM_FILE_NAME = "file_name";
-  public static final String REQUEST_PARAM_DATE_RANGE_LABEL = "dateRangeLabel";
   public static final String REQUEST_PARAM_KEYWORD = "find";
   public static final String REQUEST_PARAM_SOURCE_LOG_ID = "sourceLogId";
   public static final String REQUEST_PARAM_KEYWORD_TYPE = "keywordType";

+ 9 - 7
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java

@@ -16,17 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.model;
+package org.apache.ambari.logsearch.common;
 
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_FIELD;
+public enum LogType {
+  SERVICE("Service"),
+  AUDIT("Audit");
 
-public class FieldAuditLogSearchCriteria extends CommonSearchCriteria {
+  private String label;
 
-  public String getField() {
-    return getParam(PARAM_FIELD, String.class);
+  private LogType(String label) {
+    this.label = label;
   }
 
-  public void setField(String field) {
-    addParam(PARAM_FIELD, field);
+  public String getLabel() {
+    return label;
   }
 }

+ 3 - 3
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VMessage.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageData.java

@@ -17,12 +17,12 @@
 * under the License.
 */
 
-package org.apache.ambari.logsearch.view;
+package org.apache.ambari.logsearch.common;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
-public class VMessage implements java.io.Serializable {
+public class MessageData implements java.io.Serializable {
   private static final long serialVersionUID = 1L;
 
   /**
@@ -152,7 +152,7 @@ public class VMessage implements java.io.Serializable {
    * @return formatedStr
    */
   public String toString() {
-    String str = "VMessage={";
+    String str = "MessageData={";
     str += super.toString();
     str += "name={" + name + "} ";
     str += "rbKey={" + rbKey + "} ";

+ 4 - 6
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageEnums.java

@@ -18,8 +18,6 @@
  */
 package org.apache.ambari.logsearch.common;
 
-import org.apache.ambari.logsearch.view.VMessage;
-
 public enum MessageEnums {
 
   // Common Errors
@@ -51,16 +49,16 @@ public enum MessageEnums {
     this.messageDesc = messageDesc;
   }
 
-  public VMessage getMessage() {
-    VMessage msg = new VMessage();
+  public MessageData getMessage() {
+    MessageData msg = new MessageData();
     msg.setName(this.toString());
     msg.setRbKey(rbKey);
     msg.setMessage(messageDesc);
     return msg;
   }
 
-  public VMessage getMessage(Long objectId, String fieldName) {
-    VMessage msg = new VMessage();
+  public MessageData getMessage(Long objectId, String fieldName) {
+    MessageData msg = new MessageData();
     msg.setName(this.toString());
     msg.setRbKey(rbKey);
     msg.setMessage(messageDesc);

+ 5 - 5
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VResponse.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/VResponse.java

@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.ambari.logsearch.view;
+package org.apache.ambari.logsearch.common;
 
 import java.util.List;
 
@@ -78,7 +78,7 @@ public class VResponse implements
   /**
    * List of messages
    */
-  protected List<VMessage> messageList;
+  protected List<MessageData> messageList;
 
   /**
    * Default constructor. This will set all the attributes to default value.
@@ -134,16 +134,16 @@ public class VResponse implements
    * @param messageList
    *            Value to set member attribute <b>messageList</b>
    */
-  public void setMessageList(List<VMessage> messageList) {
+  public void setMessageList(List<MessageData> messageList) {
     this.messageList = messageList;
   }
 
   /**
    * Returns the value for the member attribute <b>messageList</b>
    * 
-   * @return List<VMessage> - value of member attribute <b>messageList</b>.
+   * @return List<MessageData> - value of member attribute <b>messageList</b>.
    */
-  public List<VMessage> getMessageList() {
+  public List<MessageData> getMessageList() {
     return this.messageList;
   }
 

+ 13 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java

@@ -18,12 +18,16 @@
  */
 package org.apache.ambari.logsearch.conf;
 
+import freemarker.template.TemplateException;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 import org.springframework.context.support.ConversionServiceFactoryBean;
 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean;
+
+import java.io.IOException;
 
 @Configuration
 @ComponentScan("org.apache.ambari.logsearch")
@@ -42,4 +46,13 @@ public class ApplicationConfig {
     return conversionServiceFactoryBean;
   }
 
+  @Bean
+  public freemarker.template.Configuration freemarkerConfiguration() throws IOException, TemplateException {
+    FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
+    factoryBean.setPreferFileSystemAccess(false);
+    factoryBean.setTemplateLoaderPath("classpath:/templates");
+    factoryBean.afterPropertiesSet();
+    return factoryBean.getObject();
+  }
+
 }

+ 11 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java

@@ -18,6 +18,7 @@
  */
 package org.apache.ambari.logsearch.conf;
 
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
 import org.apache.ambari.logsearch.solr.AmbariSolrCloudClient;
 import org.apache.ambari.logsearch.solr.AmbariSolrCloudClientBuilder;
 import org.apache.commons.lang.StringUtils;
@@ -79,6 +80,16 @@ public class SolrConfig {
       solrUserConfigPropsConfig.getCollection()));
   }
 
+  @Bean(name = "serviceSolrFieldDao")
+  public SolrSchemaFieldDao serviceSolrFieldDao() {
+    return new SolrSchemaFieldDao();
+  }
+
+  @Bean(name = "auditSolrFieldDao")
+  public SolrSchemaFieldDao auditSolrFieldDao() {
+    return new SolrSchemaFieldDao();
+  }
+
   private CloudSolrClient createClient(String solrUrl, String zookeeperConnectString, String defaultCollection) {
     if (StringUtils.isNotEmpty(zookeeperConnectString)) {
       CloudSolrClient cloudSolrClient = new CloudSolrClient(zookeeperConnectString);

+ 59 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java

@@ -0,0 +1,59 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.Query;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+
+public abstract class AbstractAuditLogRequestQueryConverter<SOURCE extends BaseLogRequest, RESULT extends Query>
+  extends AbstractLogRequestQueryConverter<SOURCE, RESULT>{
+
+  @Override
+  public Sort sort(SOURCE request) {
+    String sortBy = request.getSortBy();
+    String sortType = request.getSortType();
+    Sort.Order defaultSortOrder;
+    if (StringUtils.isNotBlank(sortBy)) {
+      Sort.Direction direction = StringUtils.equals(sortType , LogSearchConstants.ASCENDING_ORDER) ? Sort.Direction.ASC : Sort.Direction.DESC;
+      defaultSortOrder = new Sort.Order(direction, sortBy);
+    } else {
+      defaultSortOrder = new Sort.Order(Sort.Direction.DESC, AUDIT_EVTTIME);
+    }
+    Sort.Order secuqnceIdOrder = new Sort.Order(Sort.Direction.DESC, SEQUENCE_ID);
+    return new Sort(defaultSortOrder, secuqnceIdOrder);
+  }
+
+  @Override
+  public void addComponentFilters(SOURCE request, RESULT query) {
+    List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
+    List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
+    addInFilterQuery(query, AUDIT_COMPONENT, includeTypes);
+    addInFilterQuery(query, AUDIT_COMPONENT, excludeTypes, true);
+  }
+
+}

+ 3 - 3
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractConverterAware.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java

@@ -16,20 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.converter;
+package org.apache.ambari.logsearch.converter;
 
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.core.convert.ConversionService;
 import org.springframework.core.convert.converter.Converter;
 import org.springframework.core.convert.converter.ConverterRegistry;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
 public abstract class AbstractConverterAware<SOURCE, RESULT> implements Converter<SOURCE, RESULT> {
 
   @Inject
-  @Qualifier("conversionService")
+  @Named("conversionService")
   private ConversionService conversionService;
 
   public ConversionService getConversionService() {

+ 55 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java

@@ -0,0 +1,55 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import java.util.Locale;
+
+public abstract class AbstractDateRangeFacetQueryConverter<SOURCE extends DateRangeParamDefinition & UnitParamDefinition>
+  extends AbstractOperationHolderConverter<SOURCE , SolrQuery> {
+
+  @Override
+  public SolrQuery convert(SOURCE request) {
+    SolrQuery solrQuery = new SolrQuery();
+    String unit = StringUtils.defaultIfEmpty(request.getUnit(), "+1HOUR");
+    solrQuery.setQuery("*:*");
+    solrQuery.setFacet(true);
+    solrQuery.addFacetPivotField("{!range=r1}" + getTypeFieldName());
+    solrQuery.setFacetMinCount(1);
+    solrQuery.setFacetLimit(-1);
+    solrQuery.setFacetSort(LogSearchConstants.FACET_INDEX);
+    solrQuery.add("facet.range", "{!tag=r1}" + getDateFieldName());
+    solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.start"}), request.getFrom());
+    solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.end"}), request.getTo());
+    solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.gap"}), unit);
+    solrQuery.remove("sort");
+    solrQuery.setRows(0);
+    solrQuery.setStart(0);
+    return solrQuery;
+  }
+
+  public abstract String getDateFieldName();
+
+  public abstract String getTypeFieldName();
+}

+ 85 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java

@@ -0,0 +1,85 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+public abstract class AbstractLogRequestFacetQueryConverter<SOURCE extends BaseLogRequest> extends AbstractOperationHolderConverter<SOURCE, SimpleFacetQuery>{
+
+  @Override
+  public SimpleFacetQuery convert(SOURCE request) {
+    String fromValue = StringUtils.isNotEmpty(request.getFrom()) ? request.getFrom() : "*";
+    String toValue = StringUtils.isNotEmpty(request.getTo()) ? request.getTo() : "*";
+    Criteria criteria = new SimpleStringCriteria("*:*");
+    SimpleFacetQuery facetQuery = new SimpleFacetQuery();
+    facetQuery.addCriteria(criteria);
+    SimpleFilterQuery simpleFilterQuery = new SimpleFilterQuery();
+    simpleFilterQuery.addCriteria(new SimpleStringCriteria(getDateTimeField() + ":[" + fromValue +" TO "+ toValue+ "]" ));
+    facetQuery.addFilterQuery(simpleFilterQuery);
+    FacetOptions facetOptions = new FacetOptions();
+    facetOptions.setFacetMinCount(1);
+    facetOptions.setFacetSort(getFacetSort());
+    appendFacetOptions(facetOptions, request);
+    addIncludeFieldValues(facetQuery, StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
+    addExcludeFieldValues(facetQuery, StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
+    facetQuery.setFacetOptions(facetOptions);
+    facetQuery.setRows(0);
+    addComponentFilters(facetQuery, request);
+    appendFacetQuery(facetQuery, request);
+    return facetQuery;
+  }
+
+  public abstract FacetOptions.FacetSort getFacetSort();
+
+  public abstract String getDateTimeField();
+
+  public abstract LogType getLogType();
+
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, SOURCE request) {
+  }
+
+  public void appendFacetOptions(FacetOptions facetOptions, SOURCE request) {
+    facetOptions.setFacetLimit(-1);
+  }
+
+  private void addComponentFilters(SimpleFacetQuery query, SOURCE request) {
+    List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
+    List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
+    if (LogType.AUDIT.equals(getLogType())) {
+      addInFilterQuery(query, AUDIT_COMPONENT, includeTypes);
+      addInFilterQuery(query, AUDIT_COMPONENT, excludeTypes, true);
+    } else if (LogType.SERVICE.equals(getLogType())) {
+      addInFilterQuery(query, COMPONENT, includeTypes);
+      addInFilterQuery(query, COMPONENT, excludeTypes, true);
+    }
+  }
+}

+ 39 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java

@@ -0,0 +1,39 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.springframework.data.solr.core.query.Query;
+
+public abstract class AbstractLogRequestQueryConverter<REQUEST_TYPE extends BaseLogRequest, QUERY_TYPE extends Query>
+  extends AbstractSearchRequestQueryConverter<REQUEST_TYPE, QUERY_TYPE> {
+
+  @Override
+  public QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query) {
+    addComponentFilters(request, query);
+    addIncludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
+    addExcludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
+    return extendLogQuery(request, query);
+  }
+
+  public abstract QUERY_TYPE extendLogQuery(REQUEST_TYPE request, QUERY_TYPE query);
+
+  public abstract void addComponentFilters(REQUEST_TYPE request, QUERY_TYPE query);
+}

+ 160 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java

@@ -0,0 +1,160 @@
+/*
+ * 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.converter;
+
+import com.google.common.base.Splitter;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.Query;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOG_MESSAGE;
+
+public abstract class AbstractOperationHolderConverter <REQUEST_TYPE, QUERY_TYPE>
+  extends AbstractConverterAware<REQUEST_TYPE, QUERY_TYPE> {
+
+  @Inject
+  @Named("serviceSolrFieldDao")
+  private SolrSchemaFieldDao serviceSolrSchemaFieldDao;
+
+  @Inject
+  @Named("auditSolrFieldDao")
+  private SolrSchemaFieldDao auditSolrSchemaFieldDao;
+
+  public List<String> splitValueAsList(String value, String separator) {
+    return StringUtils.isNotEmpty(value) ? Splitter.on(separator).omitEmptyStrings().splitToList(value) : null;
+  }
+
+  public Query addEqualsFilterQuery(Query query, String field, String value) {
+    return this.addEqualsFilterQuery(query, field, value, false);
+  }
+
+  public Query addEqualsFilterQuery(Query query, String field, String value, boolean negate) {
+    if (StringUtils.isNotEmpty(value)) {
+      addFilterQuery(query, new Criteria(field).is(value), negate);
+    }
+    return query;
+  }
+
+  public Query addContainsFilterQuery(Query query, String field, String value) {
+    return this.addContainsFilterQuery(query, field, value, false);
+  }
+
+  public Query addContainsFilterQuery(Query query, String field, String value, boolean negate) {
+    if (StringUtils.isNotEmpty(value)) {
+      addFilterQuery(query, new Criteria(field).contains(value), negate);
+    }
+    return query;
+  }
+
+  public Query addInFilterQuery(Query query, String field, List<String> values) {
+    return this.addInFilterQuery(query, field, values, false);
+  }
+
+  public Query addInFilterQuery(Query query, String field, List<String> values, boolean negate) {
+    if (CollectionUtils.isNotEmpty(values)) {
+      addFilterQuery(query, new Criteria(field).is(values), negate);
+    }
+    return query;
+  }
+
+  public Query addRangeFilter(Query query, String field, String from, String to) {
+    return this.addRangeFilter(query, field, from, to, false);
+  }
+
+  public Query addRangeFilter(Query query, String field, String from, String to, boolean negate) { // TODO use criteria.between without escaping
+    String fromValue = StringUtils.defaultIfEmpty(from, "*");
+    String toValue = StringUtils.defaultIfEmpty(to, "*");
+    addFilterQuery(query, new SimpleStringCriteria(field + ":[" + fromValue +" TO "+ toValue + "]" ), negate);
+    return query;
+  }
+
+  public void addFilterQuery(Query query, Criteria criteria, boolean negate) {
+    if (negate) {
+      criteria.not();
+    }
+    query.addFilterQuery(new SimpleFilterQuery(criteria));
+  }
+
+  public Query addIncludeFieldValues(Query query, String fieldValuesMapStr) {
+    if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
+      List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
+        new TypeToken<List<HashMap<String, String>>>(){}.getType());
+      for (Map<String, String> criteriaMap : criterias) {
+        for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
+          escapeFieldValueByType(fieldEntry);
+          if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
+            addFilterQuery(query, new Criteria(fieldEntry.getKey()).contains(escapeFieldValueByType(fieldEntry)), false);
+          } else {
+            addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeFieldValueByType(fieldEntry)), false);
+          }
+        }
+      }
+    }
+    return query;
+  }
+
+  public Query addExcludeFieldValues(Query query, String fieldValuesMapStr) {
+    if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
+      List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
+        new TypeToken<List<HashMap<String, String>>>(){}.getType());
+      for (Map<String, String> criteriaMap : criterias) {
+        for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
+          escapeFieldValueByType(fieldEntry);
+          if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
+            addFilterQuery(query, new Criteria(fieldEntry.getKey()).contains(escapeFieldValueByType(fieldEntry)), true);
+          } else {
+            addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeFieldValueByType(fieldEntry)), true);
+          }
+        }
+      }
+    }
+    return query;
+  }
+
+  public abstract LogType getLogType();
+
+  private String escapeFieldValueByType(Map.Entry<String, String> fieldEntry) {
+    String escapedFieldValue;
+    if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
+      escapedFieldValue = SolrUtil.escapeForLogMessage(fieldEntry.getValue());
+    } else {
+      escapedFieldValue = SolrUtil.putWildCardByType(fieldEntry.getValue(), fieldEntry.getKey(), getSchemaFieldsTypeMapByLogType(getLogType()));
+    }
+    return escapedFieldValue;
+  }
+
+  private Map<String, String> getSchemaFieldsTypeMapByLogType(LogType logType) {
+    return LogType.AUDIT.equals(logType) ? auditSolrSchemaFieldDao.getSchemaFieldTypeMap() : serviceSolrSchemaFieldDao.getSchemaFieldTypeMap();
+  }
+
+}

+ 53 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java

@@ -0,0 +1,53 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
+import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.Query;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public abstract class AbstractSearchRequestQueryConverter<REQUEST_TYPE extends CommonSearchRequest, QUERY_TYPE extends Query>
+  extends AbstractOperationHolderConverter<REQUEST_TYPE, QUERY_TYPE> {
+
+  @Override
+  public QUERY_TYPE convert(REQUEST_TYPE request) {
+    QUERY_TYPE query = createQuery();
+    int page = StringUtils.isNumeric(request.getPage()) ? new Integer(request.getPage()) : 0;
+    int pageSize = StringUtils.isNumeric(request.getPageSize()) ? new Integer(request.getPageSize()) : 99999;
+    PageRequest pageRequest = new PageRequest(page, pageSize, sort(request));
+    query.setPageRequest(pageRequest);
+    Criteria criteria = new SimpleStringCriteria("*:*");
+    query.addCriteria(criteria);
+    return extendSolrQuery(request, query);
+  }
+
+  public abstract QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query);
+
+  public abstract Sort sort(REQUEST_TYPE request);
+
+  public abstract QUERY_TYPE createQuery();
+}

+ 44 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java

@@ -0,0 +1,44 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.springframework.data.solr.core.query.Query;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+
+public abstract class AbstractServiceLogRequestQueryConverter<REQUEST_TYPE extends BaseLogRequest, QUERY_TYPE extends Query>
+  extends AbstractLogRequestQueryConverter<REQUEST_TYPE, QUERY_TYPE>  {
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  @Override
+  public void addComponentFilters(REQUEST_TYPE request, QUERY_TYPE query) {
+    List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
+    List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
+    addInFilterQuery(query, COMPONENT, includeTypes);
+    addInFilterQuery(query, COMPONENT, excludeTypes, true);
+  }
+}

+ 21 - 9
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java

@@ -16,19 +16,31 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.converter;
+package org.apache.ambari.logsearch.converter;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
-import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
-import org.springframework.stereotype.Component;
 
-@Component
-public class AuditBarGraphRequestConverter extends AbstractCommonAuditLogRequestConverter<AuditBarGraphRequest, AuditBarGraphSearchCriteria>{
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+
+@Named
+public class AuditBarGraphRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<AuditBarGraphRequest> {
+
+  @Override
+  public String getDateFieldName() {
+    return AUDIT_EVTTIME;
+  }
+
+  @Override
+  public String getTypeFieldName() {
+    return AUDIT_COMPONENT;
+  }
 
   @Override
-  public AuditBarGraphSearchCriteria createCriteria(AuditBarGraphRequest request) {
-    AuditBarGraphSearchCriteria criteria = new AuditBarGraphSearchCriteria();
-    criteria.setUnit(request.getUnit());
-    return criteria;
+  public LogType getLogType() {
+    return LogType.AUDIT;
   }
 }

+ 62 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java

@@ -0,0 +1,62 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class AuditComponentsRequestQueryConverter extends AbstractSearchRequestQueryConverter<AuditComponentRequest, SimpleFacetQuery> {
+
+  @Override
+  public SimpleFacetQuery extendSolrQuery(AuditComponentRequest request, SimpleFacetQuery query) {
+    FacetOptions facetOptions = new FacetOptions(); // TODO: check that date filtering is needed or not
+    facetOptions.addFacetOnField(AUDIT_COMPONENT);
+    facetOptions.setFacetSort(FacetOptions.FacetSort.INDEX);
+    facetOptions.setFacetLimit(-1);
+    query.setFacetOptions(facetOptions);
+    return query;
+  }
+
+  @Override
+  public Sort sort(AuditComponentRequest request) {
+    Sort.Direction direction = StringUtils.equals(request.getSortType(), LogSearchConstants.DESCENDING_ORDER)
+      ? Sort.Direction.DESC : Sort.Direction.ASC;
+    return new Sort(new Sort.Order(direction, AUDIT_COMPONENT));
+  }
+
+  @Override
+  public SimpleFacetQuery createQuery() {
+    return new SimpleFacetQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.AUDIT;
+  }
+}

+ 19 - 9
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java

@@ -16,19 +16,29 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.converter;
+package org.apache.ambari.logsearch.converter;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
-import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
-import org.springframework.stereotype.Component;
+import org.springframework.data.solr.core.query.SimpleQuery;
 
-@Component
-public class AuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<AuditLogRequest, AuditLogSearchCriteria> {
+import javax.inject.Named;
+
+@Named
+public class AuditLogRequestQueryConverter extends AbstractAuditLogRequestQueryConverter<AuditLogRequest, SimpleQuery> {
+
+  @Override
+  public SimpleQuery extendLogQuery(AuditLogRequest request, SimpleQuery query) {
+    return query;
+  }
+
+  @Override
+  public SimpleQuery createQuery() {
+    return new SimpleQuery();
+  }
 
   @Override
-  public AuditLogSearchCriteria createCriteria(AuditLogRequest request) {
-    AuditLogSearchCriteria criteria = new AuditLogSearchCriteria();
-    criteria.setLastPage(request.isLastPage());
-    return criteria;
+  public LogType getLogType() {
+    return LogType.AUDIT;
   }
 }

+ 52 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java

@@ -0,0 +1,52 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class AuditServiceLoadRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<AuditServiceLoadRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return AUDIT_EVTTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.AUDIT;
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, AuditServiceLoadRequest request) {
+    facetOptions.addFacetOnField(AUDIT_COMPONENT);
+  }
+}

+ 86 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverter.java

@@ -0,0 +1,86 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.SimpleQuery;
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.KEY_LOG_MESSAGE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.PATH;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.BUNDLE_ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+
+@Named
+public class BaseServiceLogRequestQueryConverter extends AbstractServiceLogRequestQueryConverter<BaseServiceLogRequest, SimpleQuery> {
+
+  @Override
+  public SimpleQuery extendLogQuery(BaseServiceLogRequest request, SimpleQuery query) {
+    List<String> levels = splitValueAsList(request.getLevel(), ",");
+    addContainsFilterQuery(query, KEY_LOG_MESSAGE, SolrUtil.escapeForStandardTokenizer(request.getiMessage()));
+    addContainsFilterQuery(query, KEY_LOG_MESSAGE, SolrUtil.escapeForStandardTokenizer(request.geteMessage()), true);
+    addEqualsFilterQuery(query, HOST, SolrUtil.escapeQueryChars(request.getHostName()));
+    addEqualsFilterQuery(query, PATH, SolrUtil.escapeQueryChars(request.getFileName()));
+    addEqualsFilterQuery(query, COMPONENT, SolrUtil.escapeQueryChars(request.getComponentName()));
+    addEqualsFilterQuery(query, BUNDLE_ID, request.getBundleId());
+    addInFilterQuery(query, LEVEL, levels);
+    addRangeFilter(query, LOGTIME, request.getFrom(), request.getTo());
+    return query;
+  }
+
+  @Override
+  public Sort sort(BaseServiceLogRequest request) {
+    String sortBy = request.getSortBy();
+    String sortType = request.getSortType();
+    Sort.Order defaultSortOrder;
+    if (StringUtils.isNotBlank(sortBy)) {
+      Sort.Direction direction = StringUtils.equals(sortType, LogSearchConstants.ASCENDING_ORDER) ? Sort.Direction.ASC : Sort.Direction.DESC;
+      defaultSortOrder = new Sort.Order(direction, sortBy);
+    } else {
+      defaultSortOrder = new Sort.Order(Sort.Direction.DESC, LOGTIME);
+    }
+    Sort.Order secuqnceIdOrder = new Sort.Order(Sort.Direction.DESC, SEQUENCE_ID);
+    return new Sort(defaultSortOrder, secuqnceIdOrder);
+  }
+
+  @Override
+  public SimpleQuery createQuery() {
+    return new SimpleQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  @Override
+  public void addComponentFilters(BaseServiceLogRequest request, SimpleQuery query) {
+
+  }
+}

+ 54 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java

@@ -0,0 +1,54 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class FieldAuditLogRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<FieldAuditLogRequest> {
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, FieldAuditLogRequest request) {
+    facetOptions.addFacetOnPivot(request.getField(), AUDIT_COMPONENT);
+    facetOptions.setFacetLimit(request.getTop());
+  }
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return AUDIT_EVTTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.AUDIT;
+  }
+
+}

+ 27 - 14
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestQueryConverter.java

@@ -16,24 +16,37 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.converter;
+package org.apache.ambari.logsearch.converter;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
-import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
-import org.springframework.stereotype.Component;
+import org.springframework.data.solr.core.query.FacetOptions;
 
-@Component
-public class ServiceAnyGraphRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceAnyGraphRequest, ServiceAnyGraphSearchCriteria> {
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+
+import javax.inject.Named;
+
+@Named
+public class ServiceLogAnyGraphRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceAnyGraphRequest>{
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceAnyGraphRequest request) {
+    facetOptions.addFacetOnField(LEVEL);
+  }
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
 
   @Override
-  public ServiceAnyGraphSearchCriteria createCriteria(ServiceAnyGraphRequest anyGraphRequest) {
-    ServiceAnyGraphSearchCriteria criteria = new ServiceAnyGraphSearchCriteria();
-    criteria.setxAxis(anyGraphRequest.getxAxis());
-    criteria.setyAxis(anyGraphRequest.getyAxis());
-    criteria.setStackBy(anyGraphRequest.getStackBy());
-    criteria.setUnit(anyGraphRequest.getUnit());
-    criteria.setFrom(anyGraphRequest.getFrom());
-    criteria.setTo(anyGraphRequest.getTo());
-    return criteria;
+  public LogType getLogType() {
+    return LogType.SERVICE;
   }
 }

+ 66 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverter.java

@@ -0,0 +1,66 @@
+/*
+ * 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.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogComponentLevelRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogComponentLevelRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogComponentLevelRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel()); // TODO: add @Valid on request object to make sure not throw exception if levels are missing
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogComponentLevelRequest request) {
+    facetOptions.addFacetOnPivot(COMPONENT, LEVEL);
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+}

+ 68 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverter.java

@@ -0,0 +1,68 @@
+/*
+ * 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.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogComponentRequestFacetQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogComponentHostRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogComponentHostRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogComponentHostRequest request) {
+    facetOptions.addFacetOnPivot(COMPONENT, HOST, LEVEL);
+    facetOptions.addFacetOnPivot(COMPONENT, LEVEL);
+  }
+}

+ 52 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverter.java

@@ -0,0 +1,52 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogLevelCountRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+
+@Named
+public class ServiceLogLevelCountRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogLevelCountRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogLevelCountRequest request) {
+    facetOptions.addFacetOnField(LEVEL);
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+}

+ 61 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverter.java

@@ -0,0 +1,61 @@
+/*
+ * 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.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import javax.inject.Named;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogLevelDateRangeRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<ServiceGraphRequest>{
+
+  @Override
+  public String getDateFieldName() {
+    return LOGTIME;
+  }
+
+  @Override
+  public String getTypeFieldName() {
+    return LEVEL;
+  }
+
+  @Override
+  public SolrQuery convert(ServiceGraphRequest request) {
+    SolrQuery solrQuery = super.convert(request);
+    if (StringUtils.isNotEmpty(request.getLevel())) {
+      List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+      solrQuery.addFilterQuery(String.format("%s:(%s)", LEVEL, StringUtils.join(levels, " OR ")));
+    }
+    return solrQuery;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+}

+ 69 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverter.java

@@ -0,0 +1,69 @@
+/*
+ * 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.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogTreeRequestFacetQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogHostComponentRequest>{
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogHostComponentRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogHostComponentRequest request) {
+    facetOptions.addFacetOnPivot(HOST, COMPONENT, LEVEL);
+    facetOptions.addFacetOnPivot(HOST, LEVEL);
+  }
+}

+ 95 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverter.java

@@ -0,0 +1,95 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.SimpleQuery;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+public class ServiceLogTruncatedRequestQueryConverter extends AbstractServiceLogRequestQueryConverter<ServiceLogTruncatedRequest, SimpleQuery>{
+
+  private String sequenceId;
+
+  private String logTime;
+
+  @Override
+  public SimpleQuery extendLogQuery(ServiceLogTruncatedRequest request, SimpleQuery query) {
+    addEqualsFilterQuery(query, COMPONENT, request.getComponentName());
+    addEqualsFilterQuery(query, HOST, request.getHostName());
+    String scrollType = request.getScrollType();
+    if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType)) {
+      Integer secuenceIdNum = Integer.parseInt(getSequenceId()) - 1;
+      addRangeFilter(query, LOGTIME, null, getLogTime());
+      addRangeFilter(query, SEQUENCE_ID, null, secuenceIdNum.toString());
+    } else if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
+      Integer secuenceIdNum = Integer.parseInt(getSequenceId()) + 1;
+      addRangeFilter(query, LOGTIME, getLogTime(), null);
+      addRangeFilter(query, SEQUENCE_ID, secuenceIdNum.toString(), null);
+    }
+    query.setRows(request.getNumberRows());
+    return query;
+  }
+
+  @Override
+  public Sort sort(ServiceLogTruncatedRequest request) {
+    String scrollType = request.getScrollType();
+    Sort.Direction direction;
+    if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
+      direction = Sort.Direction.ASC;
+    } else {
+      direction = Sort.Direction.DESC;
+    }
+    Sort.Order logtimeSortOrder = new Sort.Order(direction, LOGTIME);
+    Sort.Order secuqnceIdSortOrder = new Sort.Order(direction, SEQUENCE_ID);
+    return new Sort(logtimeSortOrder, secuqnceIdSortOrder);
+  }
+
+  @Override
+  public SimpleQuery createQuery() {
+    return new SimpleQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  public String getSequenceId() {
+    return sequenceId;
+  }
+
+  public void setSequenceId(String sequenceId) {
+    this.sequenceId = sequenceId;
+  }
+
+  public String getLogTime() {
+    return logTime;
+  }
+
+  public void setLogTime(String logTime) {
+    this.logTime = logTime;
+  }
+}

+ 44 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverter.java

@@ -0,0 +1,44 @@
+/*
+ * 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.converter;
+
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Named;
+
+@Named
+public class StringFieldFacetQueryConverter extends AbstractConverterAware<String, SimpleFacetQuery> {
+
+  @Override
+  public SimpleFacetQuery convert(String fieldName) {
+    Criteria criteria = new SimpleStringCriteria("*:*");
+    SimpleFacetQuery facetQuery = new SimpleFacetQuery();
+    facetQuery.addCriteria(criteria);
+    facetQuery.setRows(0);
+    FacetOptions facetOptions = new FacetOptions();
+    facetOptions.setFacetMinCount(1);
+    facetOptions.addFacetOnField(fieldName);
+    facetOptions.setFacetLimit(-1);
+    facetQuery.setFacetOptions(facetOptions);
+    return facetQuery;
+  }
+}

+ 71 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java

@@ -0,0 +1,71 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import javax.inject.Named;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.FILTER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ROW_TYPE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.SHARE_NAME_LIST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.USER_NAME;
+
+@Named
+public class UserConfigRequestQueryConverter extends AbstractConverterAware<UserConfigRequest, SolrQuery> {
+
+  @Override
+  public SolrQuery convert(UserConfigRequest userConfigRequest) {
+    SolrQuery userConfigQuery = new SolrQuery();
+    userConfigQuery.setQuery("*:*");
+
+    int startIndex = StringUtils.isNotEmpty(userConfigRequest.getStartIndex()) && StringUtils.isNumeric(userConfigRequest.getStartIndex())
+      ? Integer.parseInt(userConfigRequest.getStartIndex()) : 0;
+    int maxRows = StringUtils.isNotEmpty(userConfigRequest.getPageSize()) && StringUtils.isNumeric(userConfigRequest.getStartIndex())
+      ? Integer.parseInt(userConfigRequest.getStartIndex()) : 10;
+
+    SolrQuery.ORDER order = userConfigRequest.getSortType() != null && SolrQuery.ORDER.desc.equals(SolrQuery.ORDER.valueOf(userConfigRequest.getSortType()))
+      ? SolrQuery.ORDER.desc : SolrQuery.ORDER.asc;
+    String sortBy = StringUtils.isNotEmpty(userConfigRequest.getSortBy()) ? userConfigRequest.getSortBy(): FILTER_NAME;
+    String filterName = StringUtils.isBlank(userConfigRequest.getFilterName()) ? "*" : "*" + userConfigRequest.getFilterName() + "*";
+
+    userConfigQuery.addFilterQuery(String.format("%s:%s",
+      ROW_TYPE, userConfigRequest.getRowType()));
+    userConfigQuery.addFilterQuery(String.format("%s:%s OR %s:%s",
+      USER_NAME, userConfigRequest.getUserId(),
+      SHARE_NAME_LIST, userConfigRequest.getUserId()));
+    userConfigQuery.addFilterQuery(String.format("%s:%s",
+      FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
+    userConfigQuery.setStart(startIndex);
+    userConfigQuery.setRows(maxRows);
+
+    SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(sortBy, order);
+    List<SolrQuery.SortClause> sort = new ArrayList<>();
+    sort.add(sortOrder);
+    userConfigQuery.setSorts(sort);
+
+    return userConfigQuery;
+  }
+}

+ 55 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverter.java

@@ -0,0 +1,55 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_REQUEST_USER;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_RESOURCE;
+
+@Named
+public class UserExportRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<UserExportRequest> {
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, UserExportRequest request) {
+    facetOptions.addFacetOnPivot(AUDIT_REQUEST_USER, AUDIT_COMPONENT);
+    facetOptions.addFacetOnPivot(AUDIT_RESOURCE, AUDIT_COMPONENT);
+  }
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return AUDIT_EVTTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.AUDIT;
+  }
+}

+ 13 - 10
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java

@@ -21,17 +21,15 @@ package org.apache.ambari.logsearch.dao;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 
-@Component
+@Named
 public class AuditSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(AuditSolrDao.class);
@@ -40,7 +38,7 @@ public class AuditSolrDao extends SolrDaoBase {
   private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
 
   @Inject
-  @Qualifier("auditSolrTemplate")
+  @Named("auditSolrTemplate")
   private SolrTemplate auditSolrTemplate;
 
   @Inject
@@ -50,6 +48,7 @@ public class AuditSolrDao extends SolrDaoBase {
   private SolrCollectionDao solrCollectionDao;
 
   @Inject
+  @Named("auditSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   public AuditSolrDao() {
@@ -57,8 +56,8 @@ public class AuditSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) auditSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return auditSolrTemplate;
   }
 
   @PostConstruct
@@ -71,13 +70,17 @@ public class AuditSolrDao extends SolrDaoBase {
       boolean createAlias = (aliasNameIn != null && !StringUtils.isBlank(rangerAuditCollection));
       solrCollectionDao.setupCollections(getSolrClient(), solrAuditLogPropsConfig);
       if (createAlias) {
-        solrAliasDao.setupAlias(solrSchemaFieldDao, getSolrClient(), solrAuditLogPropsConfig, this);
+        solrAliasDao.setupAlias(solrSchemaFieldDao, getSolrClient(), solrAuditLogPropsConfig);
       } else {
-        solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrAuditLogPropsConfig, this);
+        solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrAuditLogPropsConfig);
       }
     } catch (Exception e) {
       LOG.error("Error while connecting to Solr for audit logs : solrUrl=" + solrAuditLogPropsConfig.getSolrUrl() + ", zkConnectString=" +
           solrAuditLogPropsConfig.getZkConnectString() + ", collection=" + solrAuditLogPropsConfig.getCollection(), e);
     }
   }
+
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
+  }
 }

+ 12 - 9
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java

@@ -21,16 +21,14 @@ package org.apache.ambari.logsearch.dao;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 
-@Component
+@Named
 public class ServiceLogsSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(ServiceLogsSolrDao.class);
@@ -42,10 +40,11 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
   private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
 
   @Inject
-  @Qualifier("serviceSolrTemplate")
+  @Named("serviceSolrTemplate")
   private SolrTemplate serviceSolrTemplate;
 
   @Inject
+  @Named("serviceSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   public ServiceLogsSolrDao() {
@@ -53,8 +52,8 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) serviceSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return serviceSolrTemplate;
   }
 
   @PostConstruct
@@ -63,11 +62,15 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
     try {
       solrCollectionDao.checkSolrStatus(getSolrClient());
       solrCollectionDao.setupCollections(getSolrClient(), solrServiceLogPropsConfig);
-      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrServiceLogPropsConfig, this);
+      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrServiceLogPropsConfig);
     } catch (Exception e) {
       LOG.error("error while connecting to Solr for service logs : solrUrl=" + solrServiceLogPropsConfig.getSolrUrl()
         + ", zkConnectString=" + solrServiceLogPropsConfig.getZkConnectString()
         + ", collection=" + solrServiceLogPropsConfig.getCollection(), e);
     }
   }
+
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
+  }
 }

+ 4 - 4
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java

@@ -26,16 +26,16 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 
-@Component
+@Named
 public class SolrAliasDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrAliasDao.class);
@@ -46,7 +46,7 @@ public class SolrAliasDao {
   private SolrCollectionDao solrCollectionDao;
 
   protected void setupAlias(final SolrSchemaFieldDao solrSchemaFieldDao, final CloudSolrClient solrClient,
-                            final SolrAuditLogPropsConfig solrPropsConfig, final SolrDaoBase solrDaoBase) throws Exception {
+                            final SolrAuditLogPropsConfig solrPropsConfig) throws Exception {
     final Collection<String> collectionListIn = Arrays.asList(solrPropsConfig.getCollection(), solrPropsConfig.getRangerCollection().trim());
 
     if (solrPropsConfig.getAliasNameIn() == null || collectionListIn.size() == 0 || solrClient == null) {
@@ -71,7 +71,7 @@ public class SolrAliasDao {
               if (count == collectionListIn.size()) {
                 LOG.info("Setup for alias " + solrPropsConfig.getAliasNameIn() + " is successful. Exiting setup retry thread. " +
                   "Collections=" + collectionListIn);
-                solrSchemaFieldDao.populateSchemaFields(solrClient, solrPropsConfig, solrDaoBase);
+                solrSchemaFieldDao.populateSchemaFields(solrClient, solrPropsConfig);
                 break;
               }
             } else {

+ 2 - 2
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java

@@ -30,15 +30,15 @@ import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
+import javax.inject.Named;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 
-@Component
+@Named
 public class SolrCollectionDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrCollectionDao.class);

+ 51 - 48
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java

@@ -19,88 +19,91 @@
 
 package org.apache.ambari.logsearch.dao;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
-import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.util.DateUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrRequest.METHOD;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
+import org.springframework.data.solr.core.DefaultQueryParser;
+import org.springframework.data.solr.core.SolrCallback;
+import org.springframework.data.solr.core.SolrTemplate;
+import org.springframework.data.solr.core.query.SolrDataQuery;
+
+import java.io.IOException;
 
 public abstract class SolrDaoBase {
 
+  private static final Logger LOG = Logger.getLogger(SolrDaoBase.class);
   private static final Logger LOG_PERFORMANCE = Logger.getLogger("org.apache.ambari.logsearch.performance");
 
-  public Map<String, String> schemaFieldNameMap = new HashMap<>();
-  public Map<String, String> schemaFieldTypeMap = new HashMap<>();
-
   private LogType logType;
   
   protected SolrDaoBase(LogType logType) {
     this.logType = logType;
   }
 
-  public QueryResponse process(SolrQuery solrQuery) throws SolrServerException, IOException {
+  public QueryResponse process(SolrQuery solrQuery, String event) {
     if (getSolrClient() != null) {
-      String event = solrQuery.get("event");
+      event = event == null ? solrQuery.get("event") : event;
       solrQuery.remove("event");
-      QueryResponse queryResponse = getSolrClient().query(solrQuery, METHOD.POST);
-      if (event != null && !"/audit/logs/live/count".equalsIgnoreCase(event)) {
-        LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
+      try {
+        QueryResponse queryResponse = getSolrClient().query(solrQuery, METHOD.POST);
+        if (event != null) {
+          LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
             solrQuery + "\nQuery Time Execution :- " + queryResponse.getQTime() + " Total Time Elapsed is :- " +
             queryResponse.getElapsedTime());
+        }
+        return queryResponse;
+      } catch (Exception e){
+        LOG.error("Error during solrQuery=" + e);
+        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
-      return queryResponse;
     } else {
       throw RESTErrorUtil.createRESTException("Solr configuration improper for " + logType.getLabel() +" logs",
           MessageEnums.ERROR_SYSTEM);
     }
   }
 
-  @SuppressWarnings("unchecked")
-  public void extractValuesFromBuckets(SimpleOrderedMap<Object> jsonFacetResponse, String outerField, String innerField,
-                                        List<BarGraphData> histogramData) {
-    NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
-    ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get("buckets");
-    for (Object temp : stackBuckets) {
-      BarGraphData vBarGraphData = new BarGraphData();
-
-      SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
-      String name = ((String) level.getVal(0)).toUpperCase();
-      vBarGraphData.setName(name);
+  public QueryResponse process(SolrQuery solrQuery) {
+    return process(solrQuery, null);
+  }
 
-      Collection<NameValueData> vNameValues = new ArrayList<>();
-      vBarGraphData.setDataCount(vNameValues);
-      ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level.get(innerField)).get("buckets");
-      for (Object temp1 : levelBuckets) {
-        SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
-        String value = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
+  public QueryResponse process(SolrDataQuery solrDataQuery) {
+    return process(new DefaultQueryParser().doConstructSolrQuery(solrDataQuery));
+  }
 
-        String count = "" + countValue.getVal(1);
-        NameValueData vNameValue = new NameValueData();
-        vNameValue.setName(value);
-        vNameValue.setValue(count);
-        vNameValues.add(vNameValue);
+  public long count(final SolrDataQuery solrDataQuery) {
+    return getSolrTemplate().execute(new SolrCallback<Long>() {
+      @Override
+      public Long doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
+        SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(solrDataQuery);
+        solrQuery.setStart(0);
+        solrQuery.setRows(0);
+        QueryResponse queryResponse = solrClient.query(solrQuery);
+        long count = solrClient.query(solrQuery).getResults().getNumFound();
+        LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Count SolrQuery :- " +
+          solrQuery + "\nQuery Time Execution :- " + queryResponse.getQTime() + " Total Time Elapsed is :- " +
+          queryResponse.getElapsedTime() + " Count result :- " + count);
+        return count;
       }
-      histogramData.add(vBarGraphData);
-    }
+    });
+  }
+
+  public QueryResponse process(SolrDataQuery solrDataQuery, String event) {
+    return process(new DefaultQueryParser().doConstructSolrQuery(solrDataQuery), event);
   }
 
-  public abstract CloudSolrClient getSolrClient();
+  public CloudSolrClient getSolrClient() {
+    return (CloudSolrClient) getSolrTemplate().getSolrClient();
+  }
+
+  public abstract SolrTemplate getSolrTemplate();
+
+  public abstract SolrSchemaFieldDao getSolrSchemaFieldDao();
 }

+ 15 - 9
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java

@@ -33,16 +33,12 @@ import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-@Component
-@Scope(value = "prototype")
 public class SolrSchemaFieldDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrSchemaFieldDao.class);
@@ -52,11 +48,13 @@ public class SolrSchemaFieldDao {
 
   private boolean populateFieldsThreadActive = false;
 
+  private Map<String, String> schemaFieldNameMap = new HashMap<>();
+  private Map<String, String> schemaFieldTypeMap = new HashMap<>();
+
   @Inject
   private SolrUserPropsConfig solrUserPropsConfig;
 
-  public void populateSchemaFields(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig,
-                                   final SolrDaoBase solrDao) {
+  public void populateSchemaFields(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig) {
     if (!populateFieldsThreadActive) {
       populateFieldsThreadActive = true;
       LOG.info("Creating thread to populated fields for collection=" + solrPropsConfig.getCollection());
@@ -69,7 +67,7 @@ public class SolrSchemaFieldDao {
             try {
               Thread.sleep(SETUP_RETRY_SECOND * 1000);
               retryCount++;
-              boolean _result = _populateSchemaFields(solrClient, solrPropsConfig, solrDao);
+              boolean _result = _populateSchemaFields(solrClient, solrPropsConfig);
               if (_result) {
                 LOG.info("Populate fields for collection " + solrPropsConfig.getCollection() + " is success, Update it after " +
                   SETUP_UPDATE_SECOND + " sec");
@@ -94,7 +92,7 @@ public class SolrSchemaFieldDao {
   /**
    * Called from the thread. Don't call this directly
    */
-  private boolean _populateSchemaFields(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig, SolrDaoBase solrDao) {
+  private boolean _populateSchemaFields(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig) {
     SolrRequest<SchemaResponse> request = new SchemaRequest();
     request.setMethod(SolrRequest.METHOD.GET);
     request.setPath("/schema");
@@ -109,7 +107,7 @@ public class SolrSchemaFieldDao {
       }
 
       if (namedList != null) {
-        extractSchemaFieldsName(namedList.toString(), solrDao.schemaFieldNameMap, solrDao.schemaFieldTypeMap);
+        extractSchemaFieldsName(namedList.toString(), schemaFieldNameMap, schemaFieldTypeMap);
         return true;
       }
     }
@@ -156,4 +154,12 @@ public class SolrSchemaFieldDao {
       LOG.error(e + "Credentials not specified in logsearch.properties " + MessageEnums.ERROR_SYSTEM);
     }
   }
+
+  public Map<String, String> getSchemaFieldTypeMap() {
+    return schemaFieldTypeMap;
+  }
+
+  public Map<String, String> getSchemaFieldNameMap() {
+    return schemaFieldNameMap;
+  }
 }

+ 38 - 29
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java

@@ -28,14 +28,15 @@ import java.util.List;
 import java.util.Scanner;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrUserPropsConfig;
-import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.common.LogFeederDataMap;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.UpdateResponse;
 import org.apache.solr.common.SolrDocument;
@@ -47,15 +48,18 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import com.google.gson.JsonParseException;
 
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
-@Component
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.USER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.VALUES;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.FILTER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ROW_TYPE;
+
+@Named
 public class UserConfigSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(UserConfigSolrDao.class);
@@ -69,10 +73,11 @@ public class UserConfigSolrDao extends SolrDaoBase {
   private SolrCollectionDao solrCollectionDao;
 
   @Inject
+  @Named("serviceSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   @Inject
-  @Qualifier("userConfigSolrTemplate")
+  @Named("userConfigSolrTemplate")
   private SolrTemplate userConfigSolrTemplate;
 
   public UserConfigSolrDao() {
@@ -80,11 +85,10 @@ public class UserConfigSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) userConfigSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return userConfigSolrTemplate;
   }
 
-
   @PostConstruct
   public void postConstructor() {
     String solrUrl = solrUserConfig.getSolrUrl();
@@ -94,7 +98,7 @@ public class UserConfigSolrDao extends SolrDaoBase {
     try {
       solrCollectionDao.checkSolrStatus(getSolrClient());
       solrCollectionDao.setupCollections(getSolrClient(), solrUserConfig);
-      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrUserConfig, this);
+      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrUserConfig);
       intializeLogFeederFilter();
 
     } catch (Exception e) {
@@ -111,15 +115,15 @@ public class UserConfigSolrDao extends SolrDaoBase {
     }
   }
 
-  public void saveUserFilter(VLogfeederFilterWrapper logfeederFilterWrapper) throws SolrException, SolrServerException, IOException {
+  public void saveUserFilter(LogFeederDataMap logfeederFilterWrapper) throws SolrException, SolrServerException, IOException {
     String filterName = LogSearchConstants.LOGFEEDER_FILTER_NAME;
     String json = JSONUtil.objToJson(logfeederFilterWrapper);
     SolrInputDocument configDocument = new SolrInputDocument();
-    configDocument.addField(LogSearchConstants.ID, logfeederFilterWrapper.getId());
-    configDocument.addField(LogSearchConstants.ROW_TYPE, filterName);
-    configDocument.addField(LogSearchConstants.VALUES, json);
-    configDocument.addField(LogSearchConstants.USER_NAME, filterName);
-    configDocument.addField(LogSearchConstants.FILTER_NAME, filterName);
+    configDocument.addField(ID, logfeederFilterWrapper.getId());
+    configDocument.addField(ROW_TYPE, filterName);
+    configDocument.addField(VALUES, json);
+    configDocument.addField(USER_NAME, filterName);
+    configDocument.addField(FILTER_NAME, filterName);
     addDocs(configDocument);
   }
 
@@ -144,23 +148,23 @@ public class UserConfigSolrDao extends SolrDaoBase {
   }
 
 	@SuppressWarnings("unchecked")
-  public VLogfeederFilterWrapper getUserFilter() throws SolrServerException, IOException {
+  public LogFeederDataMap getUserFilter() throws SolrServerException, IOException {
 
     SolrQuery solrQuery = new SolrQuery();
     solrQuery.setQuery("*:*");
-    String fq = LogSearchConstants.ROW_TYPE + ":" + LogSearchConstants.LOGFEEDER_FILTER_NAME;
+    String fq = ROW_TYPE + ":" + LogSearchConstants.LOGFEEDER_FILTER_NAME;
     solrQuery.setFilterQueries(fq);
 
     QueryResponse response = process(solrQuery);
     SolrDocumentList documentList = response.getResults();
-    VLogfeederFilterWrapper logfeederFilterWrapper = null;
+    LogFeederDataMap logfeederDataMap = null;
     if (!CollectionUtils.isEmpty(documentList)) {
       SolrDocument configDoc = documentList.get(0);
       String configJson = JSONUtil.objToJson(configDoc);
       HashMap<String, Object> configMap = JSONUtil.jsonToMapObject(configJson);
-      String json = (String) configMap.get(LogSearchConstants.VALUES);
-      logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(json, VLogfeederFilterWrapper.class);
-      logfeederFilterWrapper.setId("" + configDoc.get(LogSearchConstants.ID));
+      String json = (String) configMap.get(VALUES);
+      logfeederDataMap = (LogFeederDataMap) JSONUtil.jsonToObj(json, LogFeederDataMap.class);
+      logfeederDataMap.setId("" + configDoc.get(ID));
 
     } else {
       List<String> logfeederDefaultLevels = solrUserConfig.getLogLevels();
@@ -189,16 +193,21 @@ public class UserConfigSolrDao extends SolrDaoBase {
           }
         }
         jsonValue.put("filter", componentList);
-        logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(jsonValue.toString(), VLogfeederFilterWrapper.class);
-        logfeederFilterWrapper.setId(""+new Date().getTime());
-        saveUserFilter(logfeederFilterWrapper);
+        logfeederDataMap = (LogFeederDataMap) JSONUtil.jsonToObj(jsonValue.toString(), LogFeederDataMap.class);
+        logfeederDataMap.setId(""+new Date().getTime());
+        saveUserFilter(logfeederDataMap);
 
       } catch (JsonParseException | JSONException je) {
         LOG.error("Error parsing JSON. key=" + key + ", componentArray=" + componentArray, je);
-        logfeederFilterWrapper = new VLogfeederFilterWrapper();
+        logfeederDataMap = new LogFeederDataMap();
       }
     }
-    return logfeederFilterWrapper;
+    return logfeederDataMap;
+  }
+
+  @Override
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
   }
 
   private String getHadoopServiceConfigJSON() {

+ 5 - 13
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java

@@ -44,6 +44,7 @@ public class DocConstants {
     public static final String IS_LAST_PAGE_D = "Show last page (true/false)";
     public static final String FIELD_D = "Get values for particular field";
     public static final String FORMAT_D = "File Export format, can be 'txt' or 'json'";
+    public static final String TOP = "Number that defines how many top element you would like to see.";
   }
 
   public class AuditOperationDescriptions {
@@ -51,11 +52,7 @@ public class DocConstants {
     public static final String GET_AUDIT_LOGS_OD = "Get the list of logs details";
     public static final String GET_AUDIT_COMPONENTS_OD = "Get the list of audit components currently active or having data in Solr";
     public static final String GET_AUDIT_LINE_GRAPH_DATA_OD = "Get the data required for line graph";
-    public static final String GET_TOP_AUDIT_USERS_OD = "Get the top audit users having maximum access";
-    public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resources having maximum access";
-    public static final String GET_LIVE_LOGS_COUNT_OD = "not required";
-    public static final String GET_REQUEST_USER_LINE_GRAPH_OD = "not required";
-    public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
+    public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resource count (grouped by type)";
     public static final String EXPORT_USER_TALBE_TO_TEXT_FILE_OD = "Export the tables shown on Audit tab";
     public static final String GET_SERVICE_LOAD_OD = "The graph for showing the top users accessing the services";
   }
@@ -64,7 +61,6 @@ public class DocConstants {
     public static final String LEVEL_D = "filter for log level";
     public static final String BUNDLE_ID = "filter for host";
     public static final String FILE_NAME_D = "File name filter which is supported from browser url";
-    public static final String DATE_RANGE_LABEL_D = "Date range label (e.g.: Today)";
     public static final String HOST_NAME_D = "Host name filter which is supported from browser url";
     public static final String COMPONENT_NAME_D = "Component name filter which is supported from browser url";
     public static final String FIND_D = "Finding particular text on subsequent pages in case of table view with pagination";
@@ -72,7 +68,6 @@ public class DocConstants {
     public static final String KEYWORD_TYPE_D = "Serching the find param value in previous or next in paginated table";
     public static final String TOKEN_D = "unique number used along with FIND_D. The request can be canceled using this token";
     public static final String SOURCE_LOG_ID_D = "fetch the record set having that log Id";
-    public static final String G_MUST_NOT_D = "not required";
     public static final String NUMBER_ROWS_D = "Getting rows after particular log entry - used in 'Preview' option";
     public static final String SCROLL_TYPE_D = "Used in 'Preview' feature for getting records 'after' or 'before'";
     public static final String UTC_OFFSET_D = "timezone offset";
@@ -86,18 +81,15 @@ public class DocConstants {
     public static final String GET_LOG_LEVELS_COUNT_OD = "Get Log levels with their counts";
     public static final String GET_COMPONENTS_COUNT_OD = "Get components with their counts";
     public static final String GET_HOSTS_COUNT_OD = "Get hosts with their counts";
-    public static final String GET_TREE_EXTENSION_OD = "Get host and compoenets hierarchy";
+    public static final String GET_TREE_EXTENSION_OD = "Get host and compoenets hierarchy with log counts";
     public static final String GET_HISTOGRAM_DATA_OD = "Get data for histogram";
-    public static final String CANCEL_FIND_REQUEST_OD = "Cancel the FIND_D param request using TOKEN_D";
     public static final String EXPORT_TO_TEXT_FILE_OD = "Export the table data in file";
     public static final String GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD = "Get components with log level distribution count";
-    public static final String GET_EXTREME_DATES_FOR_BUNDLE_ID_OD = "Get the start and end time of particular bundle_id";
-    public static final String GET_SERVICE_LOGS_FIELD_NAME_OD = "Get service logs schema fields name (Human readable)";
-    public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
-    public static final String GET_AFTER_BEFORE_LOGS_OD = "Preview feature data";
+    public static final String GET_ANY_GRAPH_COUNT_DATA_OD = "Get the data generic enough to use for graph plots (yAzis is always count)";
     public static final String GET_HOST_LIST_BY_COMPONENT_OD = "Get host list of components";
     public static final String GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD = "Get service logs schema fields";
     public static final String GET_HADOOP_SERVICE_CONFIG_JSON_OD = "Get the json having meta data of services supported by logsearch";
+    public static final String GET_AFTER_BEFORE_LOGS_OD = "Preview feature data";
   }
 
   public class PublicOperationDescriptions {

+ 353 - 272
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java

@@ -19,324 +19,405 @@
 
 package org.apache.ambari.logsearch.graph;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.MessageEnums;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import org.apache.ambari.logsearch.model.response.BarGraphData;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.CountData;
+import org.apache.ambari.logsearch.model.response.CountDataListResponse;
+import org.apache.ambari.logsearch.model.response.GraphData;
+import org.apache.ambari.logsearch.model.response.GraphDataListResponse;
 import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.query.QueryGeneration;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
+import org.apache.ambari.logsearch.model.response.NodeData;
+import org.apache.ambari.logsearch.model.response.NodeListResponse;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.FacetField;
 import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.PivotField;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.RangeFacet;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.stereotype.Component;
+import org.apache.solr.common.util.NamedList;
 
-import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
-public class GraphDataGenerator extends GraphDataGeneratorBase {
+@Named
+public class GraphDataGenerator {
 
-  private static final Logger logger = Logger.getLogger(GraphDataGenerator.class);
+  public BarGraphDataListResponse generateBarGraphDataResponseWithRanges(QueryResponse response, String typeField, boolean typeUppercase) {
+    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+    if (response == null) {
+      return dataList;
+    }
+    NamedList<List<PivotField>> facetPivotResponse = response.getFacetPivot();
+    if (response.getFacetPivot() == null) {
+      return dataList;
+    }
+    List<PivotField> pivotFields = facetPivotResponse.get(typeField);
+    for (int pivotIndex = 0; pivotIndex < pivotFields.size(); pivotIndex++) {
+      PivotField pivotField = facetPivotResponse.get(typeField).get(pivotIndex);
+      List<NameValueData> nameValues = generateNameValueDataList(pivotField.getFacetRanges());
+      BarGraphData barGraphData = new BarGraphData();
+      barGraphData.setDataCount(nameValues);
+      String typeValue = typeUppercase ? StringUtils.upperCase(pivotField.getValue().toString()) : pivotField.getValue().toString();
+      barGraphData.setName(typeValue);
+      dataList.getGraphData().add(barGraphData);
+    }
+    return dataList;
+  }
 
-  @Inject
-  private QueryGeneration queryGenerator;
+  public BarGraphDataListResponse generateSecondLevelBarGraphDataResponse(QueryResponse response, int val) {
+    BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
+    NamedList<List<PivotField>> pivotFieldNameList = response.getFacetPivot();
+    if (pivotFieldNameList == null) {
+      return barGraphDataListResponse;
+    }
+    List<PivotField> pivotFields = pivotFieldNameList.getVal(val);
+    List<BarGraphData> barGraphDataList = new ArrayList<>();
+    for (PivotField pivotField : pivotFields) {
+      BarGraphData barGraphData = new BarGraphData();
+      barGraphData.setName(String.valueOf(pivotField.getValue()));
+      List<PivotField> secondLevelPivotFields = pivotField.getPivot();
+      List<NameValueData> nameValueDataList = new ArrayList<>();
+      for (PivotField sPivotField : secondLevelPivotFields) {
+        NameValueData nvD = new NameValueData();
+        nvD.setName(String.valueOf(sPivotField.getValue()));
+        nvD.setValue(String.valueOf(sPivotField.getCount()));
+        nameValueDataList.add(nvD);
+      }
+      barGraphData.setDataCount(nameValueDataList);
+      barGraphDataList.add(barGraphData);
+    }
+    barGraphDataListResponse.setGraphData(barGraphDataList);
+    return barGraphDataListResponse;
+  }
 
-  public BarGraphDataListResponse getAnyGraphData(SearchCriteria searchCriteria, SolrDaoBase solrDaoBase, SolrQuery solrQuery) {
-    // X axis credentials
-    String xAxisField = (String) searchCriteria.getParamValue("xAxis");
-    String stackField = (String) searchCriteria.getParamValue("stackBy");
-    String from = (String) searchCriteria.getParamValue("from");
-    String to = (String) searchCriteria.getParamValue("to");
-    String unit = (String) searchCriteria.getParamValue("unit");
-    String typeXAxis = solrDaoBase.schemaFieldNameMap.get(xAxisField);
-    typeXAxis = (StringUtils.isBlank(typeXAxis)) ? "string" : typeXAxis;
+  public BarGraphDataListResponse generateBarGraphFromFieldFacet(QueryResponse response, String facetField) {
+    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+    Collection<BarGraphData> vaDatas = new ArrayList<>();
+    dataList.setGraphData(vaDatas);
+    if (response == null) {
+      return dataList;
+    }
+    FacetField facetFieldObj = response.getFacetField(facetField);
+    if (facetFieldObj == null) {
+      return dataList;
+    }
+
+    List<Count> counts = facetFieldObj.getValues();
+    if (counts == null) {
+      return dataList;
+    }
+    for (Count cnt : counts) {
+      List<NameValueData> valueList = new ArrayList<>();
+      BarGraphData vBarGraphData = new BarGraphData();
+      vaDatas.add(vBarGraphData);
+      NameValueData vNameValue = new NameValueData();
+      vNameValue.setName(cnt.getName());
+      vBarGraphData.setName(cnt.getName().toUpperCase());
+      vNameValue.setValue("" + cnt.getCount());
+      valueList.add(vNameValue);
+      vBarGraphData.setDataCount(valueList);
+    }
+    return dataList;
+  }
+
+  public List<NameValueData> generateNameValueDataList(List<RangeFacet> rangeFacet) {
+    List<NameValueData> nameValues = new ArrayList<>();
+    if (rangeFacet == null) {
+      return nameValues;
+    }
+    RangeFacet range = rangeFacet.get(0);
 
-    // Y axis credentials
-    String yAxisField = (String) searchCriteria.getParamValue("yAxis");
-    // add updated typeXAxis as a type parameter
-    searchCriteria.addParam("type", typeXAxis);
-    String fieldTime = (String) searchCriteria.getParamValue("fieldTime");
-    // decide graph type based on user request parameter
-    GraphType garphType = getGraphType(searchCriteria);
-    switch (garphType) {
-    case NORMAL_GRAPH:
-      return normalGraph(xAxisField, yAxisField, from, to, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    case RANGE_NON_STACK_GRAPH:
-      return rangeNonStackGraph(xAxisField, yAxisField, from, to, unit, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    case NON_RANGE_STACK_GRAPH:
-      return nonRangeStackGraph(xAxisField, yAxisField, stackField, from, to, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    case RANGE_STACK_GRAPH:
-      return rangeStackGraph(xAxisField, stackField, from, to, unit, solrDaoBase, solrQuery);
-    default:
-      logger.warn("Invalid graph type :" + garphType.name());
-      return null;
+    if (range == null) {
+      return nameValues;
+    }
+    List<RangeFacet.Count> listCount = range.getCounts();
+    for (RangeFacet.Count cnt : listCount) {
+      NameValueData nameValue = new NameValueData();
+      nameValue.setName(String.valueOf(cnt.getValue()));
+      nameValue.setValue(String.valueOf(cnt.getCount()));
+      nameValues.add(nameValue);
     }
+    return nameValues;
   }
 
-  private GraphType getGraphType(SearchCriteria searchCriteria) {
-    // default graph type is unknown
-    GraphType graphType = GraphType.UNKNOWN;
-    // X axis credentials
-    String xAxisField = (String) searchCriteria.getParamValue("xAxis");
-    String stackField = (String) searchCriteria.getParamValue("stackBy");
-    String from = (String) searchCriteria.getParamValue("from");
-    String to = (String) searchCriteria.getParamValue("to");
-    String xType = (String) searchCriteria.getParamValue("type");
-    if (xType != null) {
-      // Y axis credentials
-      String yAxisField = (String) searchCriteria.getParamValue("yAxis");
-      if (StringUtils.isBlank(xAxisField) || StringUtils.isBlank(yAxisField)) {
-        graphType = GraphType.UNKNOWN;
-      } else if (StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && !(xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.NORMAL_GRAPH;
-      } else if (StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && (xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.RANGE_NON_STACK_GRAPH;
-      } else if (!StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && !(xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.NON_RANGE_STACK_GRAPH;
-      } else if (!StringUtils.isBlank(stackField) && !StringUtils.isBlank(to) && !StringUtils.isBlank(from)
-          && (xType.contains("date") || xType.contains("time"))) {
-        graphType = GraphType.RANGE_STACK_GRAPH;
+  public List<Count> generateCount(QueryResponse response) {
+    List<Count> counts = new ArrayList<>();
+    List<FacetField> facetFields = null;
+    FacetField facetField = null;
+    if (response == null) {
+      return counts;
+    }
+
+    facetFields = response.getFacetFields();
+    if (facetFields == null) {
+      return counts;
+    }
+    if (!facetFields.isEmpty()) {
+      facetField = facetFields.get(0);
+    }
+    if (facetField != null) {
+      counts = facetField.getValues();
+    }
+    return counts;
+  }
+
+  public BarGraphDataListResponse getGraphDataWithDefaults(QueryResponse queryResponse, String field, String[] defaults) {
+    BarGraphDataListResponse response = new BarGraphDataListResponse();
+    BarGraphData barGraphData = new BarGraphData();
+    List<NameValueData> nameValues = generateLevelCountData(queryResponse, defaults);
+    barGraphData.setName(field);
+    barGraphData.setDataCount(nameValues);
+    response.setGraphData(Lists.newArrayList(barGraphData));
+    return response;
+  }
+
+  public NameValueDataListResponse getNameValueDataListResponseWithDefaults(QueryResponse response, String[] defaults) {
+    NameValueDataListResponse result = new NameValueDataListResponse();
+    result.setvNameValues(generateLevelCountData(response, defaults));
+    return result;
+  }
+
+  public NodeListResponse generateServiceNodeTreeFromFacetResponse(QueryResponse queryResponse,
+                                                                   String firstHierarchy, String secondHierarchy,
+                                                                   String firstType, String secondType) {
+    NodeListResponse response = new NodeListResponse();
+    if (queryResponse == null) {
+      return response;
+    }
+    NamedList<List<PivotField>> namedPivotFieldList = queryResponse.getFacetPivot();
+    List<PivotField> firstLevelPivots = namedPivotFieldList.get(firstHierarchy);
+    List<PivotField> secondLevelPivots = namedPivotFieldList.get(secondHierarchy);
+    if (!CollectionUtils.isNotEmpty(firstLevelPivots) || !CollectionUtils.isNotEmpty(secondLevelPivots)) {
+      return response;
+    }
+    List<NodeData> nodeDataList = buidTreeData(firstLevelPivots, secondLevelPivots, firstType, secondType);
+    response.setvNodeList(nodeDataList);
+    return response;
+  }
+
+  public NodeListResponse generateOneLevelServiceNodeTree(QueryResponse queryResponse, String componentLevelHirachy) {
+    NodeListResponse response = new NodeListResponse();
+    List<NodeData> datatList = new ArrayList<>();
+    List<List<PivotField>> listPivotField = new ArrayList<>();
+    NamedList<List<PivotField>> namedList = queryResponse.getFacetPivot();
+    if (namedList != null) {
+      listPivotField = namedList.getAll(componentLevelHirachy);
+    }
+    List<PivotField> secondHirarchicalPivotFields = null;
+    if (listPivotField == null || listPivotField.isEmpty()) {
+      return response;
+    } else {
+      secondHirarchicalPivotFields = listPivotField.get(0);
+    }
+    for (PivotField singlePivotField : secondHirarchicalPivotFields) {
+      if (singlePivotField != null) {
+        NodeData comp = new NodeData();
+        comp.setName("" + singlePivotField.getValue());
+        List<PivotField> levelList = singlePivotField.getPivot();
+        List<NameValueData> levelCountList = new ArrayList<>();
+        comp.setLogLevelCount(levelCountList);
+        if (levelList != null) {
+          for (PivotField levelPivot : levelList) {
+            NameValueData level = new NameValueData();
+            level.setName(("" + levelPivot.getValue()).toUpperCase());
+            level.setValue("" + levelPivot.getCount());
+            levelCountList.add(level);
+          }
+        }
+        datatList.add(comp);
       }
     }
-    return graphType;
+    response.setvNodeList(datatList);
+    return response;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse normalGraph(String xAxisField, String yAxisField, String from, String to, SolrDaoBase solrDaoBase,
-      String typeXAxis, String fieldTime, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vBarGraphDatas = new ArrayList<BarGraphData>();
-    BarGraphData vBarGraphData = new BarGraphData();
-    Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
-    SolrUtil.setMainQuery(solrQuery, null);
-    queryGenerator.setSingleIncludeFilter(solrQuery, fieldTime, "[" + from + " TO " + to + "]");
-    if (typeXAxis.contains("string") || typeXAxis.contains("key_lower_case") || typeXAxis.contains("text")) {
-      SolrUtil.setFacetField(solrQuery, xAxisField);
-      try {
-        QueryResponse response = solrDaoBase.process(solrQuery);
-        if (response != null && response.getResults() != null) {
-          long count = response.getResults().getNumFound();
-          if (count > 0) {
-            FacetField facetField = response.getFacetField(xAxisField);
-            if (facetField != null) {
-              List<Count> countValues = facetField.getValues();
-              if (countValues != null) {
-                for (Count countValue : countValues) {
-                  if (countValue != null) {
-                    NameValueData vNameValue = new NameValueData();
-                    vNameValue.setName(countValue.getName());
-                    vNameValue.setValue("" + countValue.getCount());
-                    vNameValues.add(vNameValue);
-                  }
-                }
+  private List<NodeData> buidTreeData(List<PivotField> firstHirarchicalPivotFields,
+                                      List<PivotField> secondHirarchicalPivotFields,
+                                      String firstPriority, String secondPriority) {
+    List<NodeData> extensionTree = new ArrayList<>();
+    if (firstHirarchicalPivotFields != null) {
+      for (PivotField pivotHost : firstHirarchicalPivotFields) {
+        if (pivotHost != null) {
+          NodeData hostNode = new NodeData();
+          String name = (pivotHost.getValue() == null ? "" : "" + pivotHost.getValue());
+          String value = "" + pivotHost.getCount();
+          if (!StringUtils.isBlank(name)) {
+            hostNode.setName(name);
+          }
+          if (!StringUtils.isBlank(value)) {
+            hostNode.setValue(value);
+          }
+          if (!StringUtils.isBlank(firstPriority)) {
+            hostNode.setType(firstPriority);
+          }
+
+          hostNode.setParent(true);
+          hostNode.setRoot(true);
+          PivotField hostPivot = null;
+          for (PivotField searchHost : secondHirarchicalPivotFields) {
+            if (!StringUtils.isBlank(hostNode.getName())
+              && hostNode.getName().equals(searchHost.getValue())) {
+              hostPivot = searchHost;
+              break;
+            }
+          }
+          List<PivotField> pivotLevelHost = hostPivot == null? null : hostPivot.getPivot();
+          if (pivotLevelHost != null) {
+            Collection<NameValueData> logLevelCount = new ArrayList<>();
+            for (PivotField pivotLevel : pivotLevelHost) {
+              if (pivotLevel != null) {
+                NameValueData vnameValue = new NameValueData();
+                String levelName = (pivotLevel.getValue() == null ? "" : "" + pivotLevel.getValue());
+                vnameValue.setName(levelName.toUpperCase());
+                vnameValue.setValue("" + pivotLevel.getCount());
+                logLevelCount.add(vnameValue);
               }
-              vBarGraphData.setName(xAxisField);
-              vBarGraphDatas.add(vBarGraphData);
-              dataList.setGraphData(vBarGraphDatas);
             }
+            hostNode.setLogLevelCount(logLevelCount);
           }
-        }
-        if (xAxisField.equalsIgnoreCase(LogSearchConstants.SOLR_LEVEL)) {
-          Collection<NameValueData> sortedVNameValues = new ArrayList<NameValueData>();
-          for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
-            NameValueData value = new NameValueData();
-            value.setName(level);
-            String val = "0";
-            for (NameValueData valueLevel : vNameValues) {
-              if (valueLevel.getName().equalsIgnoreCase(level)) {
-                val = valueLevel.getValue();
-                break;
+          List<PivotField> pivotComponents = pivotHost.getPivot();
+          if (pivotComponents != null) {
+            Collection<NodeData> componentNodes = new ArrayList<>();
+            for (PivotField pivotComp : pivotComponents) {
+              if (pivotComp != null) {
+                NodeData compNode = new NodeData();
+                String compName = (pivotComp.getValue() == null ? "" : "" + pivotComp.getValue());
+                compNode.setName(compName);
+                if (!StringUtils.isBlank(secondPriority)) {
+                  compNode.setType(secondPriority);
+                }
+                compNode.setValue("" + pivotComp.getCount());
+                compNode.setParent(false);
+                compNode.setRoot(false);
+                List<PivotField> pivotLevels = pivotComp.getPivot();
+                if (pivotLevels != null) {
+                  Collection<NameValueData> logLevelCount = new ArrayList<>();
+                  for (PivotField pivotLevel : pivotLevels) {
+                    if (pivotLevel != null) {
+                      NameValueData vnameValue = new NameValueData();
+                      String compLevel = pivotLevel.getValue() == null ? "" : "" + pivotLevel.getValue();
+                      vnameValue.setName((compLevel).toUpperCase());
+
+                      vnameValue.setValue("" + pivotLevel.getCount());
+                      logLevelCount.add(vnameValue);
+                    }
+                  }
+                  compNode.setLogLevelCount(logLevelCount);
+                }
+                componentNodes.add(compNode);
               }
             }
-            value.setValue(val);
-            sortedVNameValues.add(value);
+            hostNode.setChilds(componentNodes);
           }
-          vBarGraphData.setDataCount(sortedVNameValues);
-        } else {
-          vBarGraphData.setDataCount(vNameValues);
-        }
-        return dataList;
-      } catch (SolrException | SolrServerException | IOException e) {
-        String query = solrQuery != null ? solrQuery.toQueryString() : "";
-        logger.error("Got exception for solr query :" + query, e.getCause());
-      }
-    } else {
-      SolrUtil.setRowCount(solrQuery, 0);
-      String yAxis = yAxisField.contains("count") ? "sum" : yAxisField;
-      String jsonQuery = queryGenerator.buildJSONFacetAggregatedFuncitonQuery(yAxis, xAxisField);
-      SolrUtil.setJSONFacet(solrQuery, jsonQuery);
-      try {
-        QueryResponse response = solrDaoBase.process(solrQuery);
-        SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-        if (jsonFacetResponse.toString().equals("{count=0}")) {
-          return dataList;
+          extensionTree.add(hostNode);
         }
-        NameValueData value = new NameValueData();
-        String sum = (String) jsonFacetResponse.getVal(1);
-        value.setName(xAxisField);
-        value.setValue(sum != null ? sum.substring(0, sum.indexOf(".")) : "");
-        vNameValues.add(value);
-        vBarGraphData.setDataCount(vNameValues);
-        vBarGraphData.setName(xAxisField);
-        vBarGraphDatas.add(vBarGraphData);
-        dataList.setGraphData(vBarGraphDatas);
-        return dataList;
-      } catch (SolrException | SolrServerException | IOException e) {
-        String query = solrQuery != null ? solrQuery.toQueryString() : "";
-        logger.error("Got exception for solr query :" + query, e.getCause());
       }
     }
-    return null;
+
+    return extensionTree;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse nonRangeStackGraph(String xAxisField, String yAxisField, String stackField, String from, String to,
-      SolrDaoBase solrDaoBase, String typeXAxis, String fieldTime, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vGraphData = new ArrayList<BarGraphData>();
-    String mainQuery = queryGenerator.buildInclusiveRangeFilterQuery(fieldTime, from, to);
-    SolrUtil.setMainQuery(solrQuery, mainQuery);
-    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-    String jsonQuery = "";
-    if (SolrUtil.isSolrFieldNumber(typeXAxis,solrDaoBase)) {
-      String function = (yAxisField.contains("count")) ? "sum" : yAxisField;
-      jsonQuery = queryGenerator.buidlJSONFacetRangeQueryForNumber(stackField, xAxisField, function);
-    } else {
-      jsonQuery = queryGenerator.buildJsonFacetTermsRangeQuery(stackField, xAxisField);
-    }
-    try {
-      SolrUtil.setJSONFacet(solrQuery, jsonQuery);
-      dataList.setGraphData(vGraphData);
-      QueryResponse response = solrDaoBase.process(solrQuery);
-      if (response == null) {
-        response = new QueryResponse();
-      }
-      Long count = response.getResults().getNumFound();
-      if (count <= 0) {
-        return dataList;
-      }
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-      if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
-        return dataList;
-      }
-      extractNonRangeStackValuesFromBucket(jsonFacetResponse, stackField, vGraphData, typeXAxis);
-      if (LogSearchConstants.SOLR_LEVEL.equalsIgnoreCase(stackField) && LogSearchConstants.SOLR_LEVEL.equalsIgnoreCase(xAxisField)) {
-        Collection<BarGraphData> levelVGraphData = dataList.getGraphData();
-        for (BarGraphData graphData : levelVGraphData) {
-          Collection<NameValueData> valueList = graphData.getDataCount();
-          Collection<NameValueData> valueListSorted = new ArrayList<NameValueData>();
-          for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
-            String val = "0";
-            for (NameValueData value : valueList) {
-              if (value.getName().equalsIgnoreCase(level)) {
-                val = value.getValue();
-                break;
-              }
-            }
-            NameValueData v1 = new NameValueData();
-            v1.setName(level.toUpperCase());
-            v1.setValue(val);
-            valueListSorted.add(v1);
-          }
-          graphData.setDataCount(valueListSorted);
-        }
+  private List<NameValueData> generateLevelCountData(QueryResponse queryResponse, String[] defaults) {
+    List<NameValueData> nameValues = Lists.newLinkedList();
+    Map<String, NameValueData> linkedMap = Maps.newLinkedHashMap();
+    List<Count> counts = generateCount(queryResponse);
+    if (!CollectionUtils.isNotEmpty(counts)) {
+      return nameValues;
+    }
+    for (String defaultValue : defaults) {
+      NameValueData nameValue = new NameValueData();
+      nameValue.setName(defaultValue);
+      nameValue.setValue("0");
+      linkedMap.put(defaultValue, nameValue);
+    }
+    for (Count count : counts) {
+      if (!linkedMap.containsKey(count.getName())) {
+        NameValueData nameValue = new NameValueData();
+        String name = count.getName().toUpperCase();
+        nameValue.setName(name);
+        nameValue.setValue(String.valueOf(count.getCount()));
+        linkedMap.put(name, nameValue);
       }
-      return dataList;
-    } catch (SolrException | IOException | SolrServerException e) {
-      String query = solrQuery != null ? solrQuery.toQueryString() : "";
-      logger.error("Got exception for solr query :" + query, e.getCause());
-      throw RESTErrorUtil.createRESTException(MessageEnums.DATA_NOT_FOUND.getMessage().getMessage(), MessageEnums.DATA_NOT_FOUND);
     }
+
+    for (Map.Entry<String, NameValueData> nameValueDataEntry : linkedMap.entrySet()) {
+      nameValues.add(nameValueDataEntry.getValue());
+    }
+    return nameValues;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse rangeNonStackGraph(String xAxisField, String yAxisField, String from, String to, String unit,
-      SolrDaoBase solrDaoBase, String typeXAxis, String fieldTime, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vBarGraphDatas = new ArrayList<BarGraphData>();
-    BarGraphData vBarGraphData = new BarGraphData();
-    Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
-    SolrUtil.setMainQuery(solrQuery, null);
-    if (SolrUtil.isSolrFieldNumber(typeXAxis,solrDaoBase)) {
-      queryGenerator.setSingleRangeFilter(solrQuery, fieldTime, from, to);
-      return normalGraph(xAxisField, yAxisField, from, to, solrDaoBase, typeXAxis, fieldTime, solrQuery);
-    } else {
-      try {
-        SolrUtil.setFacetRange(solrQuery, xAxisField, from, to, unit);
-        QueryResponse response = solrDaoBase.process(solrQuery);
-        if (response != null) {
-          Long count = response.getResults().getNumFound();
-          if (count > 0) {
-            @SuppressWarnings("rawtypes")
-            List<RangeFacet> rangeFacet = response.getFacetRanges();
-            if (rangeFacet != null && rangeFacet.size() > 0) {
-              List<RangeFacet.Count> listCount = rangeFacet.get(0).getCounts();
-              if (listCount != null) {
-                for (RangeFacet.Count cnt : listCount) {
-                  NameValueData vNameValue = new NameValueData();
-                  vNameValue.setName(cnt.getValue());
-                  vNameValue.setValue("" + cnt.getCount());
-                  vNameValues.add(vNameValue);
-                }
-                vBarGraphData.setDataCount(vNameValues);
-                vBarGraphDatas.add(vBarGraphData);
-                vBarGraphData.setName(xAxisField);
-                dataList.setGraphData(vBarGraphDatas);
-              }
-            }
-          }
-        }
-        return dataList;
-      } catch (SolrException | SolrServerException | IOException e) {
-        logger.error("Got exception for solr query :" + solrQuery, e.getCause());
+  public CountDataListResponse generateCountResponseByField(QueryResponse response, String field) {
+    CountDataListResponse collection = new CountDataListResponse();
+    List<CountData> vCounts = new ArrayList<>();
+    if (response == null) {
+      return collection;
+    }
+    FacetField facetFields = response.getFacetField(field);
+    if (facetFields == null) {
+      return collection;
+    }
+    List<Count> fieldList = facetFields.getValues();
+
+    if (fieldList == null) {
+      return collection;
+    }
+
+    for (Count cnt : fieldList) {
+      if (cnt != null) {
+        CountData vCount = new CountData();
+        vCount.setName(cnt.getName());
+        vCount.setCount(cnt.getCount());
+        vCounts.add(vCount);
       }
     }
-    return null;
+    collection.setvCounts(vCounts);
+    return collection;
   }
 
-  @SuppressWarnings("unchecked")
-  private BarGraphDataListResponse rangeStackGraph(String xAxisField, String stackField, String from, String to, String unit,
-      SolrDaoBase solrDaoBase, SolrQuery solrQuery) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
-    SolrUtil.setMainQuery(solrQuery, null);
-    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-    String jsonHistogramQuery =
-        queryGenerator.buildJSONFacetTermTimeRangeQuery(stackField, xAxisField, from, to, unit).replace("\\", "");
-    try {
-      solrQuery.set("json.facet", jsonHistogramQuery);
-      SolrUtil.setRowCount(solrQuery, 0);
-      QueryResponse response = solrDaoBase.process(solrQuery);
-      if (response != null) {
-        SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-        if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
-          return dataList;
+  public GraphDataListResponse generateSimpleGraphResponse(QueryResponse response, String hierarchy) {
+    GraphDataListResponse graphInfo = new GraphDataListResponse();
+    if (response == null) {
+      return graphInfo;
+    }
+    List<List<PivotField>> hirarchicalPivotField = new ArrayList<List<PivotField>>();
+    List<GraphData> dataList = new ArrayList<>();
+    NamedList<List<PivotField>> namedList = response.getFacetPivot();
+    if (namedList != null) {
+      hirarchicalPivotField = namedList.getAll(hierarchy);
+    }
+    if (!hirarchicalPivotField.isEmpty()) {
+      dataList = buidGraphData(hirarchicalPivotField.get(0));
+    }
+    if (!dataList.isEmpty()) {
+      graphInfo.setGraphData(dataList);
+    }
+
+    return graphInfo;
+  }
+
+  private List<GraphData> buidGraphData(List<PivotField> pivotFields) {
+    List<GraphData> logList = new ArrayList<>();
+    if (pivotFields != null) {
+      for (PivotField pivotField : pivotFields) {
+        if (pivotField != null) {
+          GraphData logLevel = new GraphData();
+          logLevel.setName("" + pivotField.getValue());
+          logLevel.setCount(Long.valueOf(pivotField.getCount()));
+          if (pivotField.getPivot() != null) {
+            logLevel.setDataList(buidGraphData(pivotField.getPivot()));
+          }
+          logList.add(logLevel);
         }
-        extractRangeStackValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
-        dataList.setGraphData(histogramData);
       }
-      return dataList;
-    } catch (SolrException | IOException | SolrServerException e) {
-      logger.error("Got exception for solr query :" + solrQuery, e.getCause());
     }
-    return null;
+    return logList;
   }
 }

+ 0 - 169
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java

@@ -1,169 +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.graph;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.ambari.logsearch.manager.ManagerBase;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
-import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.util.DateUtil;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-
-class GraphDataGeneratorBase {
-
-  private static final String BUCKETS = "buckets";
-  
-  private static enum DataType {
-    LONG("long"),
-    DOUBLE("double"),
-    FLOAT("long"),
-    INT("long");
-    
-    private String type;
-    
-    DataType(String type) {
-      this.type = type;
-    }
-    
-    String getType() {
-      return type;
-    }
-  }
-
-  protected static enum GraphType {
-    UNKNOWN,
-    NORMAL_GRAPH,
-    RANGE_NON_STACK_GRAPH,
-    NON_RANGE_STACK_GRAPH,
-    RANGE_STACK_GRAPH;
-  }
-
-  @SuppressWarnings("unchecked")
-  protected void extractRangeStackValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String outerField,
-      String innerField, List<BarGraphData> histogramData) {
-    if (jsonFacetResponse != null) {
-      NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
-      if (stack != null) {
-        ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get(BUCKETS);
-        if (stackBuckets != null) {
-          for (Object stackBucket : stackBuckets) {
-            BarGraphData vBarGraphData = new BarGraphData();
-            SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) stackBucket;
-            if (level != null) {
-              String name = level.getVal(0) != null ? level.getVal(0).toString().toUpperCase() : "";
-              vBarGraphData.setName(name);
-              Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
-              NamedList<Object> innerFiledValue = (NamedList<Object>) level.get(innerField);
-              if (innerFiledValue != null) {
-                ArrayList<Object> levelBuckets = (ArrayList<Object>) innerFiledValue.get(BUCKETS);
-                if (levelBuckets != null) {
-                  for (Object levelBucket : levelBuckets) {
-                    SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) levelBucket;
-                    if (countValue != null) {
-                      String innerName = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
-                      String innerValue = countValue.getVal(1) != null ? countValue.getVal(1).toString() : "";
-                      NameValueData vNameValue = new NameValueData();
-                      vNameValue.setName(innerName);
-                      vNameValue.setValue(innerValue);
-                      vNameValues.add(vNameValue);
-                    }
-                  }
-                }
-              }
-              vBarGraphData.setDataCount(vNameValues);
-            }
-            histogramData.add(vBarGraphData);
-          }
-        }
-      }
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  protected boolean extractNonRangeStackValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String level,
-      Collection<BarGraphData> vGraphDatas, String typeXAxis) {
-    boolean zeroFlag = true;
-    if (jsonFacetResponse == null || jsonFacetResponse.get(level) == null
-        || jsonFacetResponse.get(level).toString().equals("{count=0}")) {
-      return false;
-    }
-    NamedList<Object> levelList = (NamedList<Object>) jsonFacetResponse.get(level);
-    if (levelList != null) {
-      ArrayList<Object> bucketList = (ArrayList<Object>) levelList.get(BUCKETS);
-      if (bucketList != null) {
-        for (int index = 0; index < bucketList.size(); index++) {
-          SimpleOrderedMap<Object> valueCount = (SimpleOrderedMap<Object>) bucketList.get(index);
-          if (valueCount != null && valueCount.size() > 2) {
-            BarGraphData vGraphData = new BarGraphData();
-            Collection<NameValueData> levelCounts = new ArrayList<NameValueData>();
-            String name = valueCount.getVal(0) != null ? valueCount.getVal(0).toString().trim() : "";
-            if (isTypeNumber(typeXAxis)) {
-              NameValueData nameValue = new NameValueData();
-              Double sumValue = (Double) valueCount.getVal(2);
-              String value = "0";// default is zero
-              if (sumValue != null) {
-                value = "" + sumValue.longValue();
-              }
-              nameValue.setName(name);
-              nameValue.setValue(value);
-              levelCounts.add(nameValue);
-            } else {
-              SimpleOrderedMap<Object> valueCountMap = (SimpleOrderedMap<Object>) valueCount.getVal(2);
-              if (valueCountMap != null) {
-                ArrayList<Object> buckets = (ArrayList<Object>) valueCountMap.get(BUCKETS);
-                if (buckets != null) {
-                  for (int innerIndex = 0; innerIndex < buckets.size(); innerIndex++) {
-                    SimpleOrderedMap<Object> innerValueCount = (SimpleOrderedMap<Object>) buckets.get(innerIndex);
-                    if (innerValueCount != null) {
-                      String innerName = innerValueCount.getVal(0) != null ? innerValueCount.getVal(0).toString().trim() : "";
-                      String innerValue = innerValueCount.getVal(1) != null ? innerValueCount.getVal(1).toString().trim() : "";
-                      NameValueData nameValue = new NameValueData();
-                      nameValue.setValue(innerValue);
-                      nameValue.setName(innerName);
-                      levelCounts.add(nameValue);
-                    }
-                  }
-                }
-              }
-            }
-            vGraphData.setName(name);
-            vGraphData.setDataCount(levelCounts);
-            vGraphDatas.add(vGraphData);
-          }
-        }
-      }
-    }
-    return zeroFlag;
-  }
-
-  protected boolean isTypeNumber(String typeXAxis) {
-    if (StringUtils.isBlank(typeXAxis)) {
-      return false;
-    } else {
-      return typeXAxis.contains(DataType.LONG.getType()) || typeXAxis.contains(DataType.INT.getType())
-          || typeXAxis.contains(DataType.FLOAT.getType()) || typeXAxis.contains(DataType.DOUBLE.getType());
-    }
-  }
-}

+ 70 - 411
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java

@@ -20,398 +20,148 @@
 package org.apache.ambari.logsearch.manager;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.text.ParseException;
+import java.io.StringWriter;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.ManageStartEndTime;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
 import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
 import org.apache.ambari.logsearch.dao.AuditSolrDao;
 import org.apache.ambari.logsearch.graph.GraphDataGenerator;
+import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
 import org.apache.ambari.logsearch.model.response.AuditLogResponse;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
 import org.apache.ambari.logsearch.model.response.GroupListResponse;
 import org.apache.ambari.logsearch.model.response.LogData;
-import org.apache.ambari.logsearch.model.response.LogSearchResponse;
-import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
-import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
-import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
+import org.apache.ambari.logsearch.solr.SolrConstants;
 import org.apache.ambari.logsearch.solr.model.SolrAuditLogData;
 import org.apache.ambari.logsearch.solr.model.SolrComponentTypeLogData;
-import org.apache.ambari.logsearch.util.BizUtil;
-import org.apache.ambari.logsearch.util.DateUtil;
+import org.apache.ambari.logsearch.util.DownloadUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VResponse;
-import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
+import org.apache.ambari.logsearch.common.VResponse;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField;
 import org.apache.solr.client.solrj.response.FacetField.Count;
 import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.RangeFacet;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.stereotype.Component;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleQuery;
 
-@Component
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
 public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResponse> {
   private static final Logger logger = Logger.getLogger(AuditLogsManager.class);
 
+  private static final String AUDIT_LOG_TEMPLATE = "audit_log_txt.ftl";
+
   @Inject
   private AuditSolrDao auditSolrDao;
   @Inject
   private GraphDataGenerator graphDataGenerator;
   @Inject
-  private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
+  private ConversionService conversionService;
+  @Inject
+  private Configuration freemarkerConfiguration;
 
-  public AuditLogResponse getLogs(AuditLogSearchCriteria searchCriteria) {
-    Boolean isLastPage = searchCriteria.isLastPage();
-    if (isLastPage) {
-      SolrQuery lastPageQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-      LogSearchResponse logResponse = getLastPage(searchCriteria, LogSearchConstants.AUDIT_EVTTIME, auditSolrDao, lastPageQuery);
-      if (logResponse == null) {
-        logResponse = new AuditLogResponse();
-      }
-      return (AuditLogResponse) logResponse;
-    }
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    return getLogAsPaginationProvided(solrQuery, auditSolrDao);
+  public AuditLogResponse getLogs(AuditLogRequest auditLogRequest) {
+    return getLogAsPaginationProvided(conversionService.convert(auditLogRequest, SimpleQuery.class), auditSolrDao, "/audit/logs");
   }
 
-  private List<LogData> getComponents(CommonSearchCriteria searchCriteria) {
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+  private List<LogData> getComponents(AuditComponentRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
     List<LogData> docList = new ArrayList<>();
-    try {
-      SolrUtil.setFacetField(solrQuery, LogSearchConstants.AUDIT_COMPONENT);
-      SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-      List<FacetField> facetFields = null;
-      List<Count> componentsCount = new ArrayList<Count>();
-      FacetField facetField = null;
+    QueryResponse queryResponse = auditSolrDao.process(facetQuery);
+    List<Count> componentsCount = graphDataGenerator.generateCount(queryResponse);
 
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
-      if (queryResponse == null) {
-        return docList;
-      }
-
-      facetFields = queryResponse.getFacetFields();
-      if (facetFields == null) {
-        return docList;
-      }
-      if (!facetFields.isEmpty()) {
-        facetField = facetFields.get(0);
-      }
-      if (facetField != null) {
-        componentsCount = facetField.getValues();
-      }
-
-      for (Count component : componentsCount) {
-        SolrComponentTypeLogData logData = new SolrComponentTypeLogData();
-        logData.setType(component.getName());
-        docList.add(logData);
-      }
-      return docList;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+    for (Count component : componentsCount) {
+      SolrComponentTypeLogData logData = new SolrComponentTypeLogData();
+      logData.setType(component.getName());
+      docList.add(logData);
     }
+    return docList;
   }
 
-  public GroupListResponse getAuditComponents(CommonSearchCriteria searchCriteria) {
+  public GroupListResponse getAuditComponents(AuditComponentRequest request) {
     GroupListResponse componentResponse = new GroupListResponse();
-    List<LogData> docList = getComponents(searchCriteria);
+    List<LogData> docList = getComponents(request);
     componentResponse.setGroupList(docList);
     return componentResponse;
   }
 
-  @SuppressWarnings("unchecked")
-  public BarGraphDataListResponse getAuditBarGraphData(AuditBarGraphSearchCriteria searchCriteria) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
-    String from = getFrom(searchCriteria.getStartTime());
-    String to = getTo(searchCriteria.getEndTime());
-    String unit = getUnit(searchCriteria.getUnit());
-
-    List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
-    String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_COMPONENT,
-      LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
-
-    return getGraphResponse(dataList, solrQuery, histogramData, jsonHistogramQuery);
-  }
-
-  @SuppressWarnings({"unchecked", "rawtypes"})
-  public NameValueDataListResponse getLiveLogCounts() {
-    NameValueDataListResponse nameValueList = new NameValueDataListResponse();
-    SolrQuery solrQuery = new SolrQuery();
-    solrQuery.setParam("event", "/audit/logs/live/count");
-    try {
-      Date[] timeRange = ManageStartEndTime.getStartEndTime();
-      String startDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[0]);
-      String endDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[1]);
-
-      SolrUtil.setMainQuery(solrQuery, null);
-      SolrUtil.setFacetRange(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startDate, endDate, "+2MINUTE");
-      List<RangeFacet.Count> listCount;
-
-      QueryResponse response = auditSolrDao.process(solrQuery);
-
-      List<RangeFacet> rangeFacet = response.getFacetRanges();
-      if (rangeFacet == null) {
-        return nameValueList;
-      }
-      RangeFacet range = rangeFacet.get(0);
-
-      if (range == null) {
-        return nameValueList;
-      }
-
-      listCount = range.getCounts();
-
-      List<NameValueData> nameValues = new ArrayList<>();
-      int count = 0;
-      for (RangeFacet.Count cnt : listCount) {
-        NameValueData nameValue = new NameValueData();
-        nameValue.setName("" + count);
-        nameValue.setValue("" + cnt.getCount());
-        nameValues.add(nameValue);
-        count++;
-      }
-      nameValueList.setvNameValues(nameValues);
-      return nameValueList;
-
-    } catch (SolrException | SolrServerException | ParseException
-      | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-
-  public BarGraphDataListResponse topTenUsers(FieldAuditBarGraphSearchCriteria searchCriteria) {
-
-    String jsonUserQuery =
-      "{Users:{type:terms, field:reqUser, facet:{ Repo:{ type:terms, field:repo, facet:{eventCount:\"sum(event_count)\"}}}}}";
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
-    SolrUtil.setRowCount(solrQuery, 0);
-    try {
-      BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
-      if (queryResponse == null) {
-        return barGraphDataListResponse;
-      }
-
-      NamedList<Object> namedList = queryResponse.getResponse();
-
-      if (namedList == null) {
-        return barGraphDataListResponse;
-      }
-
-      @SuppressWarnings("unchecked")
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
-      if (jsonFacetResponse == null) {
-        return barGraphDataListResponse;
-      }
-      if (jsonFacetResponse.toString().equals("{count=0}")) {
-        return barGraphDataListResponse;
-      }
-      barGraphDataListResponse = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
-      return barGraphDataListResponse;
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error("Error during solrQuery=" + e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-
-  public BarGraphDataListResponse topTenResources(FieldAuditLogSearchCriteria searchCriteria) {
-
-    String jsonUserQuery =
-      "{Users:{type:terms,field:resource,facet:{Repo:{type:terms,field:repo,facet:{eventCount:\"sum(event_count)\"}}}}}";
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
-    SolrUtil.setRowCount(solrQuery, 0);
-    try {
-      BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
-      if (queryResponse == null) {
-        return barGraphDataListResponse;
-      }
-
-      NamedList<Object> namedList = queryResponse.getResponse();
-      if (namedList == null) {
-        return barGraphDataListResponse;
-      }
-
-      @SuppressWarnings("unchecked")
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
-
-      barGraphDataListResponse = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
-      return barGraphDataListResponse;
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
+  public BarGraphDataListResponse getAuditBarGraphData(AuditBarGraphRequest request) {
+    SolrQuery solrQuery = conversionService.convert(request, SolrQuery.class);
+    QueryResponse response = auditSolrDao.process(solrQuery);
+    return graphDataGenerator.generateBarGraphDataResponseWithRanges(response, SolrConstants.AuditLogConstants.AUDIT_COMPONENT, true);
   }
 
-  @SuppressWarnings("unchecked")
-  public BarGraphDataListResponse getRequestUserLineGraph(FieldAuditBarGraphSearchCriteria searchCriteria) {
-
-    String from = getFrom(searchCriteria.getStartTime());
-    String to = getTo(searchCriteria.getEndTime());
-    String unit = getUnit(searchCriteria.getUnit());
-
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
-
-    SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-
-    String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_REQUEST_USER,
-      LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
-
-    return getGraphResponse(dataList, solrQuery, histogramData, jsonHistogramQuery);
+  public BarGraphDataListResponse topResources(FieldAuditLogRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    QueryResponse queryResponse = auditSolrDao.process(facetQuery);
+    return graphDataGenerator.generateSecondLevelBarGraphDataResponse(queryResponse, 0);
   }
 
   public String getAuditLogsSchemaFieldsName() {
-    return convertObjToString(auditSolrDao.schemaFieldNameMap);
+    return convertObjToString(auditSolrDao.getSolrSchemaFieldDao().getSchemaFieldNameMap());
   }
 
-  public BarGraphDataListResponse getAnyGraphData(AnyGraphSearchCriteria searchCriteria) {
-    searchCriteria.addParam("fieldTime", LogSearchConstants.AUDIT_EVTTIME);
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    BarGraphDataListResponse result = graphDataGenerator.getAnyGraphData(searchCriteria, auditSolrDao, solrQuery);
-    if (result == null) {
-      result = new BarGraphDataListResponse();
-    }
-    return result;
-
+  public BarGraphDataListResponse getServiceLoad(AuditServiceLoadRequest request) {
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
+    QueryResponse response = auditSolrDao.process(facetQuery);
+    return graphDataGenerator.generateBarGraphFromFieldFacet(response, AUDIT_COMPONENT);
   }
 
-  @SuppressWarnings({"unchecked"})
-  public Response exportUserTableToTextFile(UserExportSearchCriteria searchCriteria) {
-    String jsonUserQuery =
-      "{ Users: { type: terms, field: reqUser, facet:  {Repo: {  type: terms, field: repo, facet: {  eventCount: \"sum(event_count)\"}}}},x:{ type: terms,field: resource, facet: {y: {  type: terms, field: repo,facet: {  eventCount: \"sum(event_count)\"}}}}}";
-
-    SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-    String startTime = searchCriteria.getStartTime();
-    String endTime = searchCriteria.getEndTime();
+  public Response export(UserExportRequest request) throws TemplateException {
+    String startTime = request.getFrom();
+    String endTime = request.getTo();
+    SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
 
     startTime = startTime == null ? "" : startTime;
     endTime = endTime == null ? "" : "_" + endTime;
 
-    SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
-    SolrUtil.setRowCount(solrQuery, 0);
-
-    String dataFormat = searchCriteria.getFormat();
+    String dataFormat = request.getFormat();
 
     FileOutputStream fis = null;
     try {
-      QueryResponse queryResponse = auditSolrDao.process(solrQuery);
+      QueryResponse queryResponse = auditSolrDao.process(facetQuery);
       if (queryResponse == null) {
         VResponse response = new VResponse();
-        response.setMsgDesc("Query was not able to execute " + solrQuery);
+        response.setMsgDesc("Query was not able to execute " + facetQuery);
         throw RESTErrorUtil.createRESTException(response);
       }
-
-      NamedList<Object> namedList = queryResponse.getResponse();
-      if (namedList == null) {
-        VResponse response = new VResponse();
-        response.setMsgDesc("Query was not able to execute " + solrQuery);
-        throw RESTErrorUtil.createRESTException(response);
-      }
-      BarGraphDataListResponse vBarUserDataList = new BarGraphDataListResponse();
-      BarGraphDataListResponse vBarResourceDataList = new BarGraphDataListResponse();
-
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
-      vBarUserDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
-      vBarResourceDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "y", "x");
+      BarGraphDataListResponse vBarUserDataList = graphDataGenerator.generateSecondLevelBarGraphDataResponse(queryResponse, 0);
+      BarGraphDataListResponse vBarResourceDataList = graphDataGenerator.generateSecondLevelBarGraphDataResponse(queryResponse, 1);
       String data = "";
-      String summary = "";
       if ("text".equals(dataFormat)) {
-        int users = 0;
-        int resources = 0;
-        summary += "\n\n\n\n";
-        data += addBlank("Users") + "Components/Access" + "\n";
-        data += "--------------------------------------------------------------------------\n";
-        Collection<BarGraphData> tableUserData = vBarUserDataList.getGraphData();
-        for (BarGraphData graphData : tableUserData) {
-          String userName = graphData.getName();
-          String largeUserName = "";
-
-          if (userName.length() > 45) {
-            largeUserName = userName.substring(0, 45);
-            data += addBlank(largeUserName);
-          } else
-            data += addBlank(userName);
-
-          Collection<NameValueData> vnameValueList = graphData.getDataCount();
-          data = appendNameValueData(data, vnameValueList);
-          while (largeUserName.length() > 0) {
-            data += largeUserName.substring(0, 45) + "\n";
-          }
-
-          users += 1;
-        }
-        data += "\n\n\n\n\n\n";
-        data += addBlank("Resources") + "Components/Access" + "\n";
-        data += "--------------------------------------------------------------------------\n";
-        Collection<BarGraphData> tableResourceData = vBarResourceDataList.getGraphData();
-        for (BarGraphData graphData : tableResourceData) {
-          String resourceName = graphData.getName();
-          String largeResourceName = resourceName;
-          if (largeResourceName.length() > 45) {
-            resourceName = largeResourceName.substring(0, 45);
-            largeResourceName = largeResourceName.substring(45, largeResourceName.length());
-          } else {
-            largeResourceName = "";
-          }
+        StringWriter stringWriter = new StringWriter();
+        Template template = freemarkerConfiguration.getTemplate(AUDIT_LOG_TEMPLATE);
+        Map<String, Object> models = new HashMap<>();
+        DownloadUtil.fillUserResourcesModel(models, vBarUserDataList, vBarResourceDataList);
+        template.process(models, stringWriter);
+        data = stringWriter.toString();
 
-          //resourceName = resourceName.replaceAll("(.{45})", resourceName.substring(0, 45)+"\n");
-          data += addBlank(resourceName);
-          Collection<NameValueData> vnameValueList = graphData.getDataCount();
-          data = appendNameValueData(data, vnameValueList);
-          String tempLargeResourceName = largeResourceName;
-          while (largeResourceName.length() > 45) {
-            largeResourceName = tempLargeResourceName.substring(0, 45);
-            tempLargeResourceName = tempLargeResourceName.substring(45, tempLargeResourceName.length());
-            data += largeResourceName + "\n";
-          }
-          if (largeResourceName.length() < 45 && !largeResourceName.isEmpty()) {
-            data += largeResourceName + "\n";
-          }
-          resources += 1;
-        }
-        String header = "--------------------------------SUMMARY-----------------------------------\n";
-        summary = header + "Users  = " + users + "\nResources  = " + resources + "\n" + summary;
-        data = summary + data;
       } else {
         data = "{" + convertObjToString(vBarUserDataList) + "," + convertObjToString(vBarResourceDataList) + "}";
         dataFormat = "json";
       }
       String fileName = "Users_Resource" + startTime + endTime + ".";
       File file = File.createTempFile(fileName, dataFormat);
-
       fis = new FileOutputStream(file);
       fis.write(data.getBytes());
       return Response
@@ -419,8 +169,8 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
         .header("Content-Disposition", "attachment;filename=" + fileName + dataFormat)
         .build();
 
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error("Error during solrQuery=" + e);
+    } catch (IOException e) {
+      logger.error("Error during download file (audit log) " + e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     } finally {
       if (fis != null) {
@@ -432,97 +182,6 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResp
     }
   }
 
-  private BarGraphDataListResponse getGraphResponse(BarGraphDataListResponse dataList, SolrQuery solrQuery,
-                                                    List<BarGraphData> histogramData, String jsonHistogramQuery) {
-    try {
-      SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
-      SolrUtil.setRowCount(solrQuery, 0);
-      QueryResponse response = auditSolrDao.process(solrQuery);
-      if (response == null) {
-        return dataList;
-      }
-      SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-
-      if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
-        return dataList;
-      }
-
-      auditSolrDao.extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
-
-      dataList.setGraphData(histogramData);
-      return dataList;
-
-    } catch (SolrServerException | SolrException | IOException e) {
-      logger.error(e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-
-    }
-  }
-
-  private String appendNameValueData(String data, Collection<NameValueData> vnameValueList) {
-    int count = 0;
-    String blank = "";
-    for (NameValueData vNameValue : vnameValueList) {
-      data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
-      if (count == 0)
-        blank = addBlank(blank);
-      count++;
-    }
-    return data;
-  }
-
-  private String addBlank(String field) {
-    int blanks = 50;
-    int strSize = field.length();
-    String fieldWithBlank = field;
-    for (int i = 0; i < blanks - strSize; i++) {
-      fieldWithBlank += " ";
-    }
-    return fieldWithBlank;
-  }
-
-  public BarGraphDataListResponse getServiceLoad(CommonSearchCriteria searchCriteria) {
-    BarGraphDataListResponse dataList = new BarGraphDataListResponse();
-    Collection<BarGraphData> vaDatas = new ArrayList<BarGraphData>();
-    dataList.setGraphData(vaDatas);
-
-    SolrQuery serivceLoadQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
-    try {
-      SolrUtil.setFacetField(serivceLoadQuery, LogSearchConstants.AUDIT_COMPONENT);
-      QueryResponse serviceLoadResponse = auditSolrDao.process(serivceLoadQuery);
-      if (serviceLoadResponse == null) {
-        return dataList;
-      }
-      FacetField serviceFacetField = serviceLoadResponse.getFacetField(LogSearchConstants.AUDIT_COMPONENT);
-      if (serviceFacetField == null) {
-        return dataList;
-      }
-
-      List<Count> serviceLoadFacets = serviceFacetField.getValues();
-      if (serviceLoadFacets == null) {
-        return dataList;
-      }
-      for (Count cnt : serviceLoadFacets) {
-        List<NameValueData> valueList = new ArrayList<NameValueData>();
-        BarGraphData vBarGraphData = new BarGraphData();
-        vaDatas.add(vBarGraphData);
-        NameValueData vNameValue = new NameValueData();
-        vNameValue.setName(cnt.getName());
-        vBarGraphData.setName(cnt.getName().toUpperCase());
-        vNameValue.setValue("" + cnt.getCount());
-        valueList.add(vNameValue);
-        vBarGraphData.setDataCount(valueList);
-      }
-
-      return dataList;
-
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-
   @Override
   protected List<SolrAuditLogData> convertToSolrBeans(QueryResponse response) {
     return response.getBeans(SolrAuditLogData.class);

+ 39 - 130
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java

@@ -21,55 +21,28 @@ package org.apache.ambari.logsearch.manager;
 
 import java.io.File;
 import java.io.IOException;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Scanner;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.MessageEnums;
 import org.apache.ambari.logsearch.model.response.LogData;
 import org.apache.ambari.logsearch.model.response.LogSearchResponse;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
 import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.query.QueryGeneration;
-import org.apache.ambari.logsearch.util.DateUtil;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-
-import javax.inject.Inject;
+import org.springframework.data.solr.core.DefaultQueryParser;
+import org.springframework.data.solr.core.query.SimpleQuery;
+import org.springframework.data.solr.core.query.SolrDataQuery;
 
 public abstract class ManagerBase<LOG_DATA_TYPE extends LogData, SEARCH_RESPONSE extends LogSearchResponse> extends JsonManagerBase {
   private static final Logger logger = Logger.getLogger(ManagerBase.class);
 
-  @Inject
-  protected QueryGeneration queryGenerator;
-
-  public enum LogType {
-    SERVICE("Service"),
-    AUDIT("Audit");
-    
-    private String label;
-    
-    private LogType(String label) {
-      this.label = label;
-    }
-    
-    public String getLabel() {
-      return label;
-    }
-  }
-
   public ManagerBase() {
     super();
   }
@@ -103,116 +76,52 @@ public abstract class ManagerBase<LOG_DATA_TYPE extends LogData, SEARCH_RESPONSE
 
   }
   
-  protected SEARCH_RESPONSE getLastPage(SearchCriteria searchCriteria, String logTimeField, SolrDaoBase solrDoaBase,
-                                    SolrQuery lastPageQuery) {
-    
-    Integer maxRows = searchCriteria.getMaxRows();
-    String givenSortType = searchCriteria.getSortType();
-    searchCriteria = new SearchCriteria();
-    searchCriteria.setSortBy(logTimeField);
-    if (givenSortType == null || givenSortType.equals(LogSearchConstants.DESCENDING_ORDER)) {
-      lastPageQuery.removeSort(LogSearchConstants.LOGTIME);
-      searchCriteria.setSortType(LogSearchConstants.ASCENDING_ORDER);
-    } else {
-      searchCriteria.setSortType(LogSearchConstants.DESCENDING_ORDER);
-    }
-    queryGenerator.setSingleSortOrder(lastPageQuery, searchCriteria);
-
-
-    Long totalLogs = 0l;
-    int startIndex = 0;
-    int numberOfLogsOnLastPage = 0;
-    SEARCH_RESPONSE logResponse = null;
-    try {
-      SolrUtil.setStart(lastPageQuery, 0);
-      SolrUtil.setRowCount(lastPageQuery, maxRows);
-      logResponse = getLogAsPaginationProvided(lastPageQuery, solrDoaBase);
-      totalLogs = countQuery(lastPageQuery,solrDoaBase);
-      startIndex = Integer.parseInt("" + ((totalLogs / maxRows) * maxRows));
-      numberOfLogsOnLastPage = Integer.parseInt("" + (totalLogs - startIndex));
-      logResponse.setStartIndex(startIndex);
-      logResponse.setTotalCount(totalLogs);
-      logResponse.setPageSize(maxRows);
-      List<LOG_DATA_TYPE> docList = logResponse.getLogList();
-      List<LOG_DATA_TYPE> lastPageDocList = new ArrayList<>();
-      logResponse.setLogList(lastPageDocList);
-      int cnt = 0;
-      for(LOG_DATA_TYPE doc:docList){
-        if(cnt<numberOfLogsOnLastPage){
-          lastPageDocList.add(doc);
-        }
-        cnt++;
+  protected SEARCH_RESPONSE getLastPage(SolrDaoBase solrDoaBase, SimpleQuery lastPageQuery, String event) {
+    int maxRows = lastPageQuery.getRows();
+    SEARCH_RESPONSE logResponse = getLogAsPaginationProvided(lastPageQuery, solrDoaBase, event);
+    Long totalLogs = solrDoaBase.count(lastPageQuery);
+    int startIndex = Integer.parseInt("" + ((totalLogs / maxRows) * maxRows));
+    int numberOfLogsOnLastPage = Integer.parseInt("" + (totalLogs - startIndex));
+    logResponse.setStartIndex(startIndex);
+    logResponse.setTotalCount(totalLogs);
+    logResponse.setPageSize(maxRows);
+    List<LOG_DATA_TYPE> docList = logResponse.getLogList();
+    List<LOG_DATA_TYPE> lastPageDocList = new ArrayList<>();
+    logResponse.setLogList(lastPageDocList);
+    int cnt = 0;
+    for (LOG_DATA_TYPE doc : docList) {
+      if (cnt < numberOfLogsOnLastPage) {
+        lastPageDocList.add(doc);
       }
-      Collections.reverse(lastPageDocList);
-
-    } catch (SolrException | SolrServerException | IOException | NumberFormatException e) {
-      logger.error("Count Query was not executed successfully",e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+      cnt++;
     }
+    Collections.reverse(lastPageDocList);
     return logResponse;
   }
 
-  protected SEARCH_RESPONSE getLogAsPaginationProvided(SolrQuery solrQuery, SolrDaoBase solrDaoBase) {
-    try {
-      QueryResponse response = solrDaoBase.process(solrQuery);
-      SEARCH_RESPONSE logResponse = createLogSearchResponse();
-      SolrDocumentList docList = response.getResults();
-      List<LOG_DATA_TYPE> serviceLogDataList = convertToSolrBeans(response);
-      if (docList != null && !docList.isEmpty()) {
-        logResponse.setLogList(serviceLogDataList);
-        logResponse.setStartIndex((int) docList.getStart());
-        logResponse.setTotalCount(docList.getNumFound());
-        Integer rowNumber = solrQuery.getRows();
-        if (rowNumber == null) {
-          logger.error("No RowNumber was set in solrQuery");
-          return createLogSearchResponse();
-        }
-        logResponse.setPageSize(rowNumber);
-      }
-      return logResponse;
-    } catch (SolrException | SolrServerException | IOException e) {
-      logger.error("Error during solrQuery=" + solrQuery, e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-  }
-  
-  protected Long countQuery(SolrQuery query,SolrDaoBase solrDaoBase) throws SolrException, SolrServerException, IOException {
-    query.setRows(0);
-    QueryResponse response = solrDaoBase.process(query);
-    if (response == null) {
-      return 0l;
-    }
-    SolrDocumentList docList = response.getResults();
-    if (docList == null) {
-      return 0l;
-    }
-    return docList.getNumFound();
+  protected SEARCH_RESPONSE getLogAsPaginationProvided(SolrDataQuery solrQuery, SolrDaoBase solrDaoBase, String event) {
+    SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(solrQuery);
+    return getLogAsPaginationProvided(query, solrDaoBase, event);
   }
 
-  protected String getUnit(String unit) {
-    if (StringUtils.isBlank(unit)) {
-      unit = "+1HOUR";
-    }
-    return unit;
-  }
 
-  protected String getFrom(String from) {
-    if (StringUtils.isBlank(from)) {
-      Date date = DateUtil.getTodayFromDate();
-      try {
-        from = DateUtil.convertGivenDateFormatToSolrDateFormat(date);
-      } catch (ParseException e) {
-        from = "NOW";
+  protected SEARCH_RESPONSE getLogAsPaginationProvided(SolrQuery solrQuery, SolrDaoBase solrDaoBase, String event) {
+    QueryResponse response = solrDaoBase.process(solrQuery, event);
+    SEARCH_RESPONSE logResponse = createLogSearchResponse();
+    SolrDocumentList docList = response.getResults();
+    List<LOG_DATA_TYPE> serviceLogDataList = convertToSolrBeans(response);
+    if (docList != null && !docList.isEmpty()) {
+      logResponse.setLogList(serviceLogDataList);
+      logResponse.setStartIndex((int) docList.getStart());
+      logResponse.setTotalCount(docList.getNumFound());
+      Integer rowNumber = solrQuery.getRows();
+      if (rowNumber == null) {
+        logger.error("No RowNumber was set in solrQuery");
+        return createLogSearchResponse();
       }
+      logResponse.setPageSize(rowNumber);
     }
-    return from;
-  }
-
-  protected String getTo(String to) {
-    if (StringUtils.isBlank(to)) {
-      to = "NOW";
-    }
-    return to;
+    return logResponse;
   }
 
   protected abstract List<LOG_DATA_TYPE> convertToSolrBeans(QueryResponse response);

+ 2 - 2
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java

@@ -25,11 +25,11 @@ import java.util.List;
 import org.apache.ambari.logsearch.conf.AuthPropsConfig;
 import org.apache.ambari.logsearch.model.response.NameValueData;
 import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+@Named
 public class PublicManager extends JsonManagerBase {
 
   @Inject

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 204 - 1101
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java


+ 3 - 2
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java

@@ -24,9 +24,10 @@ import org.apache.log4j.Logger;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.web.authentication.WebAuthenticationDetails;
-import org.springframework.stereotype.Component;
 
-@Component
+import javax.inject.Named;
+
+@Named
 public class SessionManager {
 
   private static final Logger logger = Logger.getLogger(SessionManager.class);

+ 87 - 112
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java

@@ -24,17 +24,14 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.MessageEnums;
 import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
-import org.apache.ambari.logsearch.query.QueryGeneration;
-import org.apache.ambari.logsearch.util.JSONUtil;
+import org.apache.ambari.logsearch.model.common.LogFeederDataMap;
+import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest;
+import org.apache.ambari.logsearch.model.response.UserConfigData;
+import org.apache.ambari.logsearch.model.response.UserConfigDataListResponse;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
-import org.apache.ambari.logsearch.view.VUserConfig;
-import org.apache.ambari.logsearch.view.VUserConfigList;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.solr.client.solrj.SolrQuery;
@@ -45,56 +42,66 @@ import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
-import org.springframework.stereotype.Component;
+import org.springframework.core.convert.ConversionService;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
-@Component
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.USER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.VALUES;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.FILTER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ROW_TYPE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.SHARE_NAME_LIST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.COMPOSITE_KEY;
+
+@Named
 public class UserConfigManager extends JsonManagerBase {
 
   private static final Logger logger = Logger.getLogger(UserConfigManager.class);
+
   @Inject
   private UserConfigSolrDao userConfigSolrDao;
   @Inject
-  private QueryGeneration queryGenerator;
+  private ConversionService conversionService;
 
-  public String saveUserConfig(VUserConfig vHistory) {
+  public String saveUserConfig(UserConfigData userConfig) {
 
     SolrInputDocument solrInputDoc = new SolrInputDocument();
-    if (!isValid(vHistory)) {
+    if (!isValid(userConfig)) {
       throw RESTErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA);
     }
 
-    if (isNotUnique(vHistory) && !vHistory.isOverwrite()) {
-      throw RESTErrorUtil.createRESTException( "Name '" + vHistory.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
+    if (isNotUnique(userConfig) && !userConfig.isOverwrite()) {
+      throw RESTErrorUtil.createRESTException( "Name '" + userConfig.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
     }
-    String loggedInUserName = vHistory.getUserName();
-    String filterName = vHistory.getFiltername();
-
-    solrInputDoc.addField(LogSearchConstants.ID, vHistory.getId());
-    solrInputDoc.addField(LogSearchConstants.USER_NAME, loggedInUserName);
-    solrInputDoc.addField(LogSearchConstants.VALUES, vHistory.getValues());
-    solrInputDoc.addField(LogSearchConstants.FILTER_NAME, filterName);
-    solrInputDoc.addField(LogSearchConstants.ROW_TYPE, vHistory.getRowType());
-    List<String> shareNameList = vHistory.getShareNameList();
+    String loggedInUserName = userConfig.getUserName();
+    String filterName = userConfig.getFiltername();
+
+    solrInputDoc.addField(ID, userConfig.getId());
+    solrInputDoc.addField(USER_NAME, loggedInUserName);
+    solrInputDoc.addField(VALUES, userConfig.getValues());
+    solrInputDoc.addField(FILTER_NAME, filterName);
+    solrInputDoc.addField(ROW_TYPE, userConfig.getRowType());
+    List<String> shareNameList = userConfig.getShareNameList();
     if (shareNameList != null && !shareNameList.isEmpty()) {
-      solrInputDoc.addField(LogSearchConstants.SHARE_NAME_LIST, shareNameList);
+      solrInputDoc.addField(SHARE_NAME_LIST, shareNameList);
     }
     // Check whether the Filter Name exists in solr
     SolrQuery solrQuery = new SolrQuery();
-    SolrUtil.setMainQuery(solrQuery, null);
-    queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
-    queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.USER_NAME, loggedInUserName);
+    solrQuery.setQuery("*:*");
+    solrQuery.addFilterQuery(String.format("%s:%s", FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
+    solrQuery.addFilterQuery(String.format("%s:%s", USER_NAME, loggedInUserName));
     try {
       QueryResponse queryResponse = userConfigSolrDao.process(solrQuery);
       if (queryResponse != null) {
         SolrDocumentList documentList = queryResponse.getResults();
-        if (documentList != null && !documentList.isEmpty() && !vHistory.isOverwrite()) {
+        if (documentList != null && !documentList.isEmpty() && !userConfig.isOverwrite()) {
           logger.error("Filtername is already present");
           throw RESTErrorUtil.createRESTException("Filtername is already present", MessageEnums.INVALID_INPUT_DATA);
         }
       }
-    } catch (SolrException | SolrServerException | IOException e) {
+    } catch (SolrException e) {
       logger.error("Error in checking same filtername config", e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
@@ -108,28 +115,28 @@ public class UserConfigManager extends JsonManagerBase {
     }
   }
 
-  private boolean isNotUnique(VUserConfig vHistory) {
-    String filterName = vHistory.getFiltername();
-    String rowType = vHistory.getRowType();
+  private boolean isNotUnique(UserConfigData userConfig) {
+    String filterName = userConfig.getFiltername();
+    String rowType = userConfig.getRowType();
 
     if (filterName != null && rowType != null) {
       SolrQuery solrQuery = new SolrQuery();
       filterName = SolrUtil.makeSearcableString(filterName);
-      solrQuery.setQuery(LogSearchConstants.COMPOSITE_KEY + ":" + filterName + "-" + rowType);
+      solrQuery.setQuery(COMPOSITE_KEY + ":" + filterName + "-" + rowType);
       SolrUtil.setRowCount(solrQuery, 0);
       try {
         Long numFound = userConfigSolrDao.process(solrQuery).getResults().getNumFound();
         if (numFound > 0) {
           return true;
         }
-      } catch (SolrException | SolrServerException | IOException e) {
+      } catch (SolrException e) {
         logger.error("Error while checking if userConfig is unique.", e);
       }
     }
     return false;
   }
 
-  private boolean isValid(VUserConfig vHistory) {
+  private boolean isValid(UserConfigData vHistory) {
     return !StringUtils.isBlank(vHistory.getFiltername())
         && !StringUtils.isBlank(vHistory.getRowType())
         && !StringUtils.isBlank(vHistory.getUserName())
@@ -145,131 +152,99 @@ public class UserConfigManager extends JsonManagerBase {
   }
 
   @SuppressWarnings("unchecked")
-  public String getUserConfig(SearchCriteria searchCriteria) {
-
-    SolrDocumentList solrList = new SolrDocumentList();
-    VUserConfigList userConfigList = new VUserConfigList();
-
-    String rowType = (String) searchCriteria.getParamValue(LogSearchConstants.ROW_TYPE);
+  public UserConfigDataListResponse getUserConfig(UserConfigRequest request) {
+    UserConfigDataListResponse response = new UserConfigDataListResponse();
+    String rowType = request.getRowType();
     if (StringUtils.isBlank(rowType)) {
       throw RESTErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA);
     }
 
-    String userName = (String) searchCriteria.getParamValue(LogSearchConstants.USER_NAME);
+    String userName = request.getUserId();
     if (StringUtils.isBlank(userName)) {
       throw RESTErrorUtil.createRESTException("user name was not specified", MessageEnums.INVALID_INPUT_DATA);
     }
-    String filterName = (String) searchCriteria.getParamValue(LogSearchConstants.FILTER_NAME);
-    filterName = StringUtils.isBlank(filterName) ? "*" : "*" + filterName + "*";
 
-    try {
+    SolrQuery userConfigQuery = conversionService.convert(request, SolrQuery.class);
+    SolrDocumentList solrList = userConfigSolrDao.process(userConfigQuery).getResults();
 
-      SolrQuery userConfigQuery = new SolrQuery();
-      SolrUtil.setMainQuery(userConfigQuery, null);
-      queryGenerator.setPagination(userConfigQuery, searchCriteria);
-      queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.ROW_TYPE, rowType);
-      queryGenerator.setSingleORFilter(userConfigQuery, LogSearchConstants.USER_NAME, userName, LogSearchConstants.SHARE_NAME_LIST, userName);
-      queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
+    Collection<UserConfigData> configList = new ArrayList<>();
 
-      if (StringUtils.isBlank(searchCriteria.getSortBy())) {
-        searchCriteria.setSortBy(LogSearchConstants.FILTER_NAME);
-      }
-      if (StringUtils.isBlank(searchCriteria.getSortType())) {
-        searchCriteria.setSortType("" + SolrQuery.ORDER.asc);
+    for (SolrDocument solrDoc : solrList) {
+      UserConfigData userConfig = new UserConfigData();
+      userConfig.setFiltername("" + solrDoc.get(FILTER_NAME));
+      userConfig.setId("" + solrDoc.get(ID));
+      userConfig.setValues("" + solrDoc.get(VALUES));
+      userConfig.setRowType("" + solrDoc.get(ROW_TYPE));
+      try {
+        List<String> shareNameList = (List<String>) solrDoc.get(SHARE_NAME_LIST);
+        userConfig.setShareNameList(shareNameList);
+      } catch (Exception e) {
+        // do nothing
       }
 
-      queryGenerator.setSingleSortOrder(userConfigQuery, searchCriteria);
-      solrList = userConfigSolrDao.process(userConfigQuery).getResults();
-
-      Collection<VUserConfig> configList = new ArrayList<VUserConfig>();
-
-      for (SolrDocument solrDoc : solrList) {
-        VUserConfig userConfig = new VUserConfig();
-        userConfig.setFiltername("" + solrDoc.get(LogSearchConstants.FILTER_NAME));
-        userConfig.setId("" + solrDoc.get(LogSearchConstants.ID));
-        userConfig.setValues("" + solrDoc.get(LogSearchConstants.VALUES));
-        userConfig.setRowType("" + solrDoc.get(LogSearchConstants.ROW_TYPE));
-        try {
-          List<String> shareNameList = (List<String>) solrDoc.get(LogSearchConstants.SHARE_NAME_LIST);
-          userConfig.setShareNameList(shareNameList);
-        } catch (Exception e) {
-          // do nothing
-        }
+      userConfig.setUserName("" + solrDoc.get(USER_NAME));
 
-        userConfig.setUserName("" + solrDoc.get(LogSearchConstants.USER_NAME));
+      configList.add(userConfig);
+    }
 
-        configList.add(userConfig);
-      }
+    response.setName("historyList");
+    response.setUserConfigList(configList);
 
-      userConfigList.setName("historyList");
-      userConfigList.setUserConfigList(configList);
+    response.setStartIndex(Integer.parseInt(request.getStartIndex()));
+    response.setPageSize(Integer.parseInt(request.getPageSize()));
 
-      userConfigList.setStartIndex(searchCriteria.getStartIndex());
-      userConfigList.setPageSize((int) searchCriteria.getMaxRows());
+    response.setTotalCount((long) solrList.getNumFound());
 
-      userConfigList.setTotalCount((long) solrList.getNumFound());
-    } catch (SolrException | SolrServerException | IOException e) {
-      // do nothing
-      logger.error(e);
-      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-    }
-
-    return convertObjToString(userConfigList);
+    return response;
 
   }
 
-  public String updateUserConfig(VUserConfig vuserConfig) {
-    return saveUserConfig(vuserConfig);
+  public String updateUserConfig(UserConfigData userConfig) {
+    return saveUserConfig(userConfig);
   }
 
   // ////////////////////////////LEVEL FILTER/////////////////////////////////////
 
-  public String getUserFilter() {
-    VLogfeederFilterWrapper userFilter;
+  public LogFeederDataMap getUserFilter() {
+    LogFeederDataMap userFilter;
     try {
       userFilter = userConfigSolrDao.getUserFilter();
     } catch (SolrServerException | IOException e) {
       logger.error(e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
-    return convertObjToString(userFilter);
+    return userFilter;
   }
 
-  public String saveUserFiter(String json) {
-    if (!StringUtils.isBlank(json)) {
-      VLogfeederFilterWrapper logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(json, VLogfeederFilterWrapper.class);
-      try {
-        if (logfeederFilterWrapper == null) {
-          logger.error(json + " is a invalid json");
-        }
-        userConfigSolrDao.saveUserFilter(logfeederFilterWrapper);
-      } catch (SolrException | SolrServerException | IOException e) {
-        logger.error("user config not able to save", e);
-        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-      }
+  public LogFeederDataMap saveUserFiter(LogFeederDataMap logfeederFilters) {
+    try {
+      userConfigSolrDao.saveUserFilter(logfeederFilters);
+    } catch (SolrException | SolrServerException | IOException e) {
+      logger.error("user config not able to save", e);
+      throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
     return getUserFilter();
   }
 
-  public String getAllUserName() {
+  public List<String> getAllUserName() {
     List<String> userList = new ArrayList<String>();
     try {
       SolrQuery userListQuery = new SolrQuery();
-      SolrUtil.setMainQuery(userListQuery, null);
-      SolrUtil.setFacetField(userListQuery, LogSearchConstants.USER_NAME);
+      userListQuery.setQuery("*:*");
+      SolrUtil.setFacetField(userListQuery, USER_NAME);
       QueryResponse queryResponse = userConfigSolrDao.process(userListQuery);
       if (queryResponse == null) {
-        return convertObjToString(userList);
+        return userList;
       }
-      List<Count> counList = queryResponse.getFacetField(LogSearchConstants.USER_NAME).getValues();
+      List<Count> counList = queryResponse.getFacetField(USER_NAME).getValues();
       for (Count cnt : counList) {
         String userName = cnt.getName();
         userList.add(userName);
       }
-    } catch (SolrException | SolrServerException | IOException e) {
+    } catch (SolrException e) {
       logger.warn("Error getting all users.", e);
       throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
     }
-    return convertObjToString(userList);
+    return userList;
   }
 }

+ 20 - 14
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VHost.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/common/LogFeederDataMap.java

@@ -16,29 +16,35 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.ambari.logsearch.model.common;
 
-package org.apache.ambari.logsearch.view;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 
-import java.util.Set;
+import java.util.HashMap;
 
-public class VHost {
-  protected String name;
-  protected Set<String> components;
+@ApiModel
+public class LogFeederDataMap {
 
-  public String getName() {
-    return name;
-  }
+  @ApiModelProperty
+  private String id;
+
+  @ApiModelProperty
+  private HashMap<String, LogfeederFilterData> filter;
 
-  public void setName(String name) {
-    this.name = name;
+  public HashMap<String, LogfeederFilterData> getFilter() {
+    return filter;
   }
 
-  public Set<String> getComponents() {
-    return components;
+  public void setFilter(HashMap<String, LogfeederFilterData> filter) {
+    this.filter = filter;
   }
 
-  public void setComponents(Set<String> components) {
-    this.components = components;
+  public String getId() {
+    return id;
   }
 
+  public void setId(String id) {
+    this.id = id;
+  }
 }

+ 18 - 22
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogfeederFilter.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/common/LogfeederFilterData.java

@@ -16,35 +16,33 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.view;
+package org.apache.ambari.logsearch.model.common;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
+@ApiModel
+public class LogfeederFilterData {
+
+  @ApiModelProperty
+  private String label;
 
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
+  @ApiModelProperty
+  private List<String> hosts = new ArrayList<>();
 
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VLogfeederFilter {
+  @ApiModelProperty
+  private List<String> defaultLevels = new ArrayList<>();
 
-  private String label;
-  private List<String> hosts;
-  private List<String> defaultLevels;
-  private List<String> overrideLevels;
+  @ApiModelProperty
+  private List<String> overrideLevels = new ArrayList<>();
+
+  @ApiModelProperty
   private String expiryTime;
 
-  public VLogfeederFilter() {
-    hosts = new ArrayList<String>();
-    defaultLevels = new ArrayList<String>();
-    overrideLevels = new ArrayList<String>();
+  public LogfeederFilterData() {
   }
 
   public String getLabel() {
@@ -86,6 +84,4 @@ public class VLogfeederFilter {
   public void setExpiryTime(String expiryTime) {
     this.expiryTime = expiryTime;
   }
-
-
 }

+ 1 - 1
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java

@@ -27,6 +27,6 @@ public interface FieldParamDefinition {
 
   String getField();
 
-  @ApiParam(value = FIELD_D, name = LogSearchConstants.REQUEST_PARAM_FIELD)
+  @ApiParam(value = FIELD_D, name = LogSearchConstants.REQUEST_PARAM_FIELD, required = true)
   void setField(String field);
 }

+ 7 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java

@@ -20,6 +20,8 @@ package org.apache.ambari.logsearch.model.request;
 
 import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.E_MESSAGE_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.I_MESSAGE_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_BE_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_NOT_D;
@@ -33,6 +35,11 @@ public interface LogParamDefinition {
   @ApiParam(value = I_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
   void setiMessage(String iMessage);
 
+  String geteMessage();
+
+  @ApiParam(value = E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
+  void seteMessage(String eMessage);
+
   String getMustBe();
 
   @ApiParam(value = MUST_BE_D, name = LogSearchConstants.REQUEST_PARAM_MUST_BE)

+ 2 - 2
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java

@@ -37,8 +37,8 @@ public interface LogTruncatedParamDefinition {
   @ApiParam(value = SCROLL_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_SCROLL_TYPE)
   void setScrollType(String scrollType);
 
-  String getNumberRows();
+  Integer getNumberRows();
 
   @ApiParam(value = NUMBER_ROWS_D, name = LogSearchConstants.REQUEST_PARAM_NUMBER_ROWS)
-  void setNumberRows(String numberRows);
+  void setNumberRows(Integer numberRows);
 }

+ 0 - 13
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java

@@ -22,12 +22,9 @@ import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.LEVEL_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.E_MESSAGE_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.G_MUST_NOT_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.HOST_NAME_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.COMPONENT_NAME_D;
 import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.FILE_NAME_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.DATE_RANGE_LABEL_D;
 
 public interface ServiceLogParamDefinition {
 
@@ -36,11 +33,6 @@ public interface ServiceLogParamDefinition {
   @ApiParam(value = LEVEL_D, name = LogSearchConstants.REQUEST_PARAM_LEVEL)
   void setLevel(String level);
 
-  String geteMessage();
-
-  @ApiParam(value = E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
-  void seteMessage(String eMessage);
-
   String getHostName();
 
   @ApiParam(value = HOST_NAME_D, name = LogSearchConstants.REQUEST_PARAM_HOST_NAME)
@@ -55,9 +47,4 @@ public interface ServiceLogParamDefinition {
 
   @ApiParam(value = FILE_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILE_NAME)
   void setFileName(String fileName);
-
-  String getDateRangeLabel();
-
-  @ApiParam(value = DATE_RANGE_LABEL_D, name = LogSearchConstants.REQUEST_PARAM_DATE_RANGE_LABEL)
-  void setDateRangeLabel(String dateRangeLabel);
 }

+ 5 - 6
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java

@@ -21,12 +21,11 @@ package org.apache.ambari.logsearch.model.request;
 import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.QUERY_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.TOP;
 
-public interface QueryParamDefinition {
+public interface TopParamDefinition {
+  Integer getTop();
 
-  String getQuery();
-
-  @ApiParam(value = QUERY_D, name = LogSearchConstants.REQUEST_PARAM_QUERY)
-  void setQuery(String query);
+  @ApiParam(value = TOP, name = LogSearchConstants.REQUEST_PARAM_TOP, required = true)
+  void setTop(Integer top);
 }

+ 0 - 109
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java

@@ -1,109 +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.model.request.impl;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.AnyGraphParamDefinition;
-import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
-import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class AnyGraphRequest extends CommonSearchRequest
-  implements AnyGraphParamDefinition, DateRangeParamDefinition, UnitParamDefinition{
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_XAXIS)
-  private String xAxis;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_YAXIS)
-  private String yAxis;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_STACK_BY)
-  private String stackBy;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
-  private String from;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
-  private String to;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
-  private String unit;
-
-  @Override
-  public String getxAxis() {
-    return xAxis;
-  }
-
-  @Override
-  public void setxAxis(String xAxis) {
-    this.xAxis = xAxis;
-  }
-
-  @Override
-  public String getyAxis() {
-    return yAxis;
-  }
-
-  @Override
-  public void setyAxis(String yAxis) {
-    this.yAxis = yAxis;
-  }
-
-  @Override
-  public String getStackBy() {
-    return stackBy;
-  }
-
-  @Override
-  public void setStackBy(String stackBy) {
-    this.stackBy = stackBy;
-  }
-
-  @Override
-  public String getFrom() {
-    return from;
-  }
-
-  @Override
-  public void setFrom(String from) {
-    this.from = from;
-  }
-
-  @Override
-  public String getTo() {
-    return to;
-  }
-
-  @Override
-  public void setTo(String to) {
-    this.to = to;
-  }
-
-  @Override
-  public String getUnit() {
-    return unit;
-  }
-
-  @Override
-  public void setUnit(String unit) {
-    this.unit = unit;
-  }
-}

+ 1 - 1
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java

@@ -23,7 +23,7 @@ import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
 
 import javax.ws.rs.QueryParam;
 
-public class AuditBarGraphRequest extends BaseAuditLogRequest implements UnitParamDefinition {
+public class AuditBarGraphRequest extends BaseLogRequest implements UnitParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
   private String unit;

+ 4 - 11
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditComponentRequest.java

@@ -16,17 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.model;
+package org.apache.ambari.logsearch.model.request.impl;
 
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_FIELD;
+import org.apache.ambari.logsearch.common.Marker;
 
-public class FieldAuditBarGraphSearchCriteria extends AuditBarGraphSearchCriteria {
-
-  public String getField() {
-    return getParam(PARAM_FIELD, String.class);
-  }
-
-  public void setField(String field) {
-    addParam(PARAM_FIELD, field);
-  }
+@Marker
+public class AuditComponentRequest extends CommonSearchRequest {
 }

+ 1 - 1
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java

@@ -23,7 +23,7 @@ import org.apache.ambari.logsearch.model.request.LastPageParamDefinition;
 
 import javax.ws.rs.QueryParam;
 
-public class AuditLogRequest extends BaseAuditLogRequest implements LastPageParamDefinition {
+public class AuditLogRequest extends BaseLogRequest implements LastPageParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_LAST_PAGE)
   private boolean isLastPage;

+ 4 - 11
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditServiceLoadRequest.java

@@ -16,17 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.model;
+package org.apache.ambari.logsearch.model.request.impl;
 
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
+import org.apache.ambari.logsearch.common.Marker;
 
-public class ServiceGraphSearchCriteria extends ServiceLogSearchCriteria {
-
-  public String getUnit() {
-    return getParam(SearchCriteriaConstants.PARAM_UNIT, String.class);
-  }
-
-  public void setUnit(String unit) {
-    addParam(SearchCriteriaConstants.PARAM_UNIT, unit);
-  }
+@Marker
+public class AuditServiceLoadRequest extends BaseLogRequest {
 }

+ 43 - 4
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java

@@ -18,28 +18,37 @@
  */
 package org.apache.ambari.logsearch.model.request.impl;
 
-import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
 import org.apache.ambari.logsearch.model.request.LogParamDefinition;
 
 import javax.ws.rs.QueryParam;
 
-public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
+public class BaseLogRequest extends CommonSearchRequest implements LogParamDefinition, DateRangeParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
   private String iMessage;
 
+  @QueryParam(LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
+  private String eMessage;
+
   @QueryParam(LogSearchConstants.REQUEST_PARAM_MUST_BE)
   private String mustBe;
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_MUST_NOT)
   private String mustNot;
 
+  @QueryParam(LogSearchConstants.REQUEST_PARAM_INCLUDE_QUERY)
+  private String includeQuery;
+
   @QueryParam(LogSearchConstants.REQUEST_PARAM_EXCLUDE_QUERY)
   private String excludeQuery;
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_INCLUDE_QUERY)
-  private String includeQuery;
+  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
+  private String from;
+
+  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
+  private String to;
 
   @Override
   public String getiMessage() {
@@ -51,6 +60,16 @@ public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
     this.iMessage = iMessage;
   }
 
+  @Override
+  public String geteMessage() {
+    return eMessage;
+  }
+
+  @Override
+  public void seteMessage(String eMessage) {
+    this.eMessage = eMessage;
+  }
+
   @Override
   public String getMustBe() {
     return mustBe;
@@ -90,4 +109,24 @@ public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
   public void setExcludeQuery(String excludeQuery) {
     this.excludeQuery = excludeQuery;
   }
+
+  @Override
+  public String getFrom() {
+    return from;
+  }
+
+  @Override
+  public void setFrom(String from) {
+    this.from = from;
+  }
+
+  @Override
+  public String getTo() {
+    return to;
+  }
+
+  @Override
+  public void setTo(String to) {
+    this.to = to;
+  }
 }

+ 1 - 53
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java

@@ -26,14 +26,11 @@ import org.apache.ambari.logsearch.model.request.ServiceLogParamDefinition;
 import javax.ws.rs.QueryParam;
 
 public class BaseServiceLogRequest extends BaseLogRequest
-  implements ServiceLogParamDefinition, BundleIdParamDefinition, DateRangeParamDefinition {
+  implements ServiceLogParamDefinition, BundleIdParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_LEVEL)
   private String level;
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
-  private String eMessage;
-
   @QueryParam(LogSearchConstants.REQUEST_PARAM_HOST_NAME)
   private String hostName;
 
@@ -46,15 +43,6 @@ public class BaseServiceLogRequest extends BaseLogRequest
   @QueryParam(LogSearchConstants.REQUEST_PARAM_BUNDLE_ID)
   private String bundleId;
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
-  private String from;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
-  private String to;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_DATE_RANGE_LABEL)
-  private String dateRangeLabel;
-
   @Override
   public String getLevel() {
     return level;
@@ -65,16 +53,6 @@ public class BaseServiceLogRequest extends BaseLogRequest
     this.level = level;
   }
 
-  @Override
-  public String geteMessage() {
-    return eMessage;
-  }
-
-  @Override
-  public void seteMessage(String eMessage) {
-    this.eMessage = eMessage;
-  }
-
   @Override
   public String getHostName() {
     return hostName;
@@ -114,34 +92,4 @@ public class BaseServiceLogRequest extends BaseLogRequest
   public void setBundleId(String bundleId) {
     this.bundleId = bundleId;
   }
-
-  @Override
-  public String getFrom() {
-    return from;
-  }
-
-  @Override
-  public void setFrom(String from) {
-    this.from = from;
-  }
-
-  @Override
-  public String getTo() {
-    return to;
-  }
-
-  @Override
-  public void setTo(String to) {
-    this.to = to;
-  }
-
-  @Override
-  public String getDateRangeLabel() {
-    return dateRangeLabel;
-  }
-
-  @Override
-  public void setDateRangeLabel(String dateRangeLabel) {
-    this.dateRangeLabel = dateRangeLabel;
-  }
 }

+ 16 - 2
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java

@@ -18,17 +18,21 @@
  */
 package org.apache.ambari.logsearch.model.request.impl;
 
-import io.swagger.annotations.ApiParam;
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.model.request.FieldParamDefinition;
+import org.apache.ambari.logsearch.model.request.TopParamDefinition;
 
+import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 
-public class FieldAuditLogRequest extends BaseAuditLogRequest implements FieldParamDefinition {
+public class FieldAuditLogRequest extends BaseLogRequest implements FieldParamDefinition, TopParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_FIELD)
   private String field;
 
+  @PathParam(LogSearchConstants.REQUEST_PARAM_TOP)
+  private Integer top;
+
   @Override
   public String getField() {
     return field;
@@ -38,4 +42,14 @@ public class FieldAuditLogRequest extends BaseAuditLogRequest implements FieldPa
   public void setField(String field) {
     this.field = field;
   }
+
+  @Override
+  public Integer getTop() {
+    return top;
+  }
+
+  @Override
+  public void setTop(Integer top) {
+    this.top = top;
+  }
 }

+ 1 - 27
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceAnyGraphRequest.java

@@ -27,7 +27,7 @@ import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
 import javax.ws.rs.QueryParam;
 
 public class ServiceAnyGraphRequest extends ServiceLogRequest
-  implements AnyGraphParamDefinition, DateRangeParamDefinition, UnitParamDefinition {
+  implements AnyGraphParamDefinition, UnitParamDefinition {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_XAXIS)
   private String xAxis;
@@ -41,12 +41,6 @@ public class ServiceAnyGraphRequest extends ServiceLogRequest
   @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
   private String unit;
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
-  private String from;
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
-  private String to;
-
   @Override
   public String getxAxis() {
     return xAxis;
@@ -86,24 +80,4 @@ public class ServiceAnyGraphRequest extends ServiceLogRequest
   public void setUnit(String unit) {
     this.unit = unit;
   }
-
-  @Override
-  public String getFrom() {
-    return from;
-  }
-
-  @Override
-  public void setFrom(String from) {
-    this.from = from;
-  }
-
-  @Override
-  public String getTo() {
-    return to;
-  }
-
-  @Override
-  public void setTo(String to) {
-    this.to = to;
-  }
 }

+ 0 - 41
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java

@@ -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.model.request.impl;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.BundleIdParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class ServiceExtremeDatesRequest extends CommonSearchRequest implements BundleIdParamDefinition {
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_BUNDLE_ID)
-  private String bundleId;
-
-  @Override
-  public String getBundleId() {
-    return bundleId;
-  }
-
-  @Override
-  public void setBundleId(String bundleId) {
-    this.bundleId = bundleId;
-  }
-}

+ 25 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogAggregatedInfoRequest.java

@@ -0,0 +1,25 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogAggregatedInfoRequest extends BaseServiceLogRequest {
+}

+ 25 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentHostRequest.java

@@ -0,0 +1,25 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogComponentHostRequest extends ServiceLogRequest {
+}

+ 25 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogComponentLevelRequest.java

@@ -0,0 +1,25 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogComponentLevelRequest extends ServiceLogRequest {
+}

+ 9 - 10
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogHostComponentRequest.java

@@ -18,23 +18,22 @@
  */
 package org.apache.ambari.logsearch.model.request.impl;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.QueryParamDefinition;
+import io.swagger.annotations.ApiParam;
 
 import javax.ws.rs.QueryParam;
 
-public class QueryRequest extends CommonSearchRequest implements QueryParamDefinition {
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_QUERY)
-  private String query;
+public class ServiceLogHostComponentRequest extends ServiceLogRequest {
+  @QueryParam("hostName")
+  @ApiParam
+  String hostName;
 
   @Override
-  public String getQuery() {
-    return query;
+  public String getHostName() {
+    return hostName;
   }
 
   @Override
-  public void setQuery(String query) {
-    this.query = query;
+  public void setHostName(String hostName) {
+    this.hostName = hostName;
   }
 }

+ 25 - 0
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogLevelCountRequest.java

@@ -0,0 +1,25 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogLevelCountRequest extends BaseServiceLogRequest {
+}

+ 3 - 3
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java

@@ -32,7 +32,7 @@ public class ServiceLogTruncatedRequest extends ServiceLogRequest implements Log
   private String scrollType;
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_NUMBER_ROWS)
-  private String numberRows;
+  private Integer numberRows;
 
   @Override
   public String getId() {
@@ -55,12 +55,12 @@ public class ServiceLogTruncatedRequest extends ServiceLogRequest implements Log
   }
 
   @Override
-  public String getNumberRows() {
+  public Integer getNumberRows() {
     return numberRows;
   }
 
   @Override
-  public void setNumberRows(String numberRows) {
+  public void setNumberRows(Integer numberRows) {
     this.numberRows = numberRows;
   }
 }

+ 0 - 42
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java

@@ -1,42 +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.model.request.impl;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.QueryParamDefinition;
-import org.apache.ambari.logsearch.model.request.SearchRequest;
-
-import javax.ws.rs.QueryParam;
-
-
-public class SimpleQueryRequest implements SearchRequest, QueryParamDefinition {
-
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_QUERY)
-  private String query;
-
-  @Override
-  public String getQuery() {
-    return query;
-  }
-
-  @Override
-  public void setQuery(String query) {
-    this.query = query;
-  }
-}

+ 10 - 7
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java

@@ -16,18 +16,21 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.query.model;
+package org.apache.ambari.logsearch.model.response;
 
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_UNIT;
+public class TemplateData {
 
-public class AuditBarGraphSearchCriteria extends CommonSearchCriteria {
+  private String data;
 
-  public void setUnit(String unit) {
-    addParam(PARAM_UNIT, unit);
+  public TemplateData(String data) {
+    this.data = data;
   }
 
-  public String getUnit() {
-    return getParam(PARAM_UNIT, String.class);
+  public String getData() {
+    return data;
   }
 
+  public void setData(String data) {
+    this.data = data;
+  }
 }

+ 38 - 34
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VUserConfig.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java

@@ -16,33 +16,38 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.ambari.logsearch.model.response;
 
-package org.apache.ambari.logsearch.view;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.util.Date;
 import java.util.List;
 
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VUserConfig {
-
-  protected String id;
-  protected String userName;
-  protected String filtername;
-  protected String values;
-  
-  List<String> shareNameList;
-  String rowType;
-  
-  boolean isOverwrite;
-  
-  public VUserConfig(){
-    setId(""+new Date().getTime());
-    isOverwrite=false;
+public class UserConfigData {
+
+  @ApiModelProperty
+  private String id;
+
+  @ApiModelProperty
+  private String userName;
+
+  @ApiModelProperty
+  private String filtername;
+
+  @ApiModelProperty
+  private String values;
+
+  @ApiModelProperty
+  private List<String> shareNameList;
+
+  @ApiModelProperty
+  private String rowType;
+
+  @ApiModelProperty
+  private boolean isOverwrite = false;
+
+  public UserConfigData() {
+    id = String.valueOf(new Date().getTime());
   }
 
   public String getId() {
@@ -69,15 +74,6 @@ public class VUserConfig {
     this.filtername = filtername;
   }
 
-  public String getValues() {
-    return values;
-  }
-
-  public void setValues(String values) {
-    this.values = values;
-  }
-
-
   public List<String> getShareNameList() {
     return shareNameList;
   }
@@ -86,6 +82,14 @@ public class VUserConfig {
     this.shareNameList = shareNameList;
   }
 
+  public String getValues() {
+    return values;
+  }
+
+  public void setValues(String values) {
+    this.values = values;
+  }
+
   public String getRowType() {
     return rowType;
   }
@@ -98,7 +102,7 @@ public class VUserConfig {
     return isOverwrite;
   }
 
-  public void setOverwrite(boolean isOverwrite) {
-    this.isOverwrite = isOverwrite;
+  public void setOverwrite(boolean overwrite) {
+    isOverwrite = overwrite;
   }
-}
+}

+ 22 - 20
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java → ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigDataListResponse.java

@@ -16,38 +16,40 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.ambari.logsearch.model.request.impl;
+package org.apache.ambari.logsearch.model.response;
 
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 
-import javax.ws.rs.QueryParam;
+import java.util.Collection;
 
-public class BaseAuditLogRequest extends BaseLogRequest implements DateRangeParamDefinition {
+@ApiModel
+public class UserConfigDataListResponse extends SearchResponse{
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
-  private String from;
+  @ApiModelProperty
+  private String name;
 
-  @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
-  private String to;
+  @ApiModelProperty
+  private Collection<UserConfigData> userConfigList;
 
-  @Override
-  public String getFrom() {
-    return from;
+  public String getName() {
+    return name;
   }
 
-  @Override
-  public void setFrom(String from) {
-    this.from = from;
+  public void setName(String name) {
+    this.name = name;
   }
 
-  @Override
-  public String getTo() {
-    return to;
+  public Collection<UserConfigData> getUserConfigList() {
+    return userConfigList;
+  }
+
+  public void setUserConfigList(Collection<UserConfigData> userConfigList) {
+    this.userConfigList = userConfigList;
   }
 
   @Override
-  public void setTo(String to) {
-    this.to = to;
+  public int getListSize() {
+    return userConfigList != null ? userConfigList.size() : 0;
   }
 }

+ 0 - 340
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java

@@ -1,340 +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.query;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
-import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
-import org.apache.ambari.logsearch.util.JSONUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
-import org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory;
-import org.apache.lucene.analysis.standard.StandardTokenizerFactory;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.schema.TrieDoubleField;
-import org.apache.solr.schema.TrieFloatField;
-import org.apache.solr.schema.TrieLongField;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-
-@Component
-public class QueryGeneration extends QueryGenerationBase {
-
-  private static Logger logger = Logger.getLogger(QueryGeneration.class);
-
-  @Inject
-  private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
-
-  @Inject
-  private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
-
-  public SolrQuery commonServiceFilterQuery(CommonServiceLogSearchCriteria searchCriteria) {
-    LogType logType = LogType.SERVICE;
-    SolrQuery solrQuery = new SolrQuery();
-    // TODO: check these are used from the UI or not
-    String globalExcludeComp = (String) searchCriteria.getParamValue("gMustNot");
-    String unselectedComp = (String) searchCriteria.getParamValue("unselectComp");
-
-    String givenQuery = (String) searchCriteria.getParamValue("q");
-    String level = searchCriteria.getLevel();
-    String startTime = searchCriteria.getFrom();
-    String endTime = searchCriteria.getTo();
-    String iMessage = searchCriteria.getIncludeMessage();
-    String eMessage = searchCriteria.getExcludeMessage();
-    String selectedComp = searchCriteria.getSelectComp();
-    String bundleId = searchCriteria.getBundleId();
-    String urlHostName = searchCriteria.getHostName();
-    String urlComponentName = searchCriteria.getComponentName();
-    String file_name = searchCriteria.getFileName();
-
-    SolrUtil.setMainQuery(solrQuery, givenQuery);
-
-    setSingleRangeFilter(solrQuery, LogSearchConstants.LOGTIME, startTime, endTime);
-    addFilter(solrQuery, selectedComp, LogSearchConstants.SOLR_COMPONENT, Condition.OR);
-
-    setFilterClauseWithFieldName(solrQuery, level, LogSearchConstants.SOLR_LEVEL, LogSearchConstants.NO_OPERATOR, Condition.OR);
-
-    setFilterClauseForSolrSearchableString(solrQuery, iMessage, Condition.OR, LogSearchConstants.NO_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
-    setFilterClauseForSolrSearchableString(solrQuery, eMessage, Condition.AND, LogSearchConstants.MINUS_OPERATOR, LogSearchConstants.SOLR_KEY_LOG_MESSAGE);
-
-    applyLogFileFilter(solrQuery, searchCriteria);
-
-    setFilterClauseWithFieldName(solrQuery, globalExcludeComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
-    setFilterClauseWithFieldName(solrQuery, unselectedComp, LogSearchConstants.SOLR_COMPONENT, LogSearchConstants.MINUS_OPERATOR, Condition.AND);
-
-    urlHostName = SolrUtil.escapeQueryChars(urlHostName);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_HOST, urlHostName);
-    urlComponentName = SolrUtil.escapeQueryChars(urlComponentName);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_COMPONENT, urlComponentName);
-
-    setPagination(solrQuery, searchCriteria);
-    setSortOrderDefaultServiceLog(solrQuery, searchCriteria);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.BUNDLE_ID, bundleId);
-    file_name = SolrUtil.escapeQueryChars(file_name);
-    setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_PATH, file_name);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY, logType);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY, logType);
-    
-    return solrQuery;
-  }
-
-  public void applyLogFileFilter(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    String hostLogFile = (String) searchCriteria.getParamValue("hostLogFile");
-    String compLogFile = (String) searchCriteria.getParamValue("compLogFile");
-    String givenQuery = (String) searchCriteria.getParamValue("q");
-    String logfileQuery = "";
-    if (!StringUtils.isBlank(hostLogFile) && !StringUtils.isBlank(compLogFile)) {
-      logfileQuery = LogSearchConstants.SOLR_HOST + ":" + hostLogFile + " " + Condition.AND + " " +
-          LogSearchConstants.SOLR_COMPONENT + ":" + compLogFile;
-      if (!StringUtils.isBlank(givenQuery)) {
-        logfileQuery = "(" + givenQuery + ") " + Condition.AND + " (" + logfileQuery + ")";
-      }
-      if (!StringUtils.isBlank(logfileQuery)) {
-        solrQuery.addFilterQuery(logfileQuery);
-      }
-    }
-  }
-
-  private void setUserSpecificFilter(SearchCriteria searchCriteria, SolrQuery solrQuery, String paramName, String operation,
-      LogType logType) {
-    String queryString = (String) searchCriteria.getParamValue(paramName);
-    if (StringUtils.isBlank(queryString)) {
-      queryString = null;
-    }
-    List<String> conditionQuries = new ArrayList<String>();
-    List<String> referalConditionQuries = new ArrayList<String>();
-    List<String> elments = new ArrayList<String>();
-    List<HashMap<String, Object>> queryList = JSONUtil.jsonToMapObjectList(queryString);
-    if (queryList != null && queryList.size() > 0) {
-      for (HashMap<String, Object> columnListMap : queryList) {
-        String orQuery = "";
-        StringBuilder field = new StringBuilder();
-        if (columnListMap != null) {
-          for (String key : columnListMap.keySet()) {
-            if (!StringUtils.isBlank(key)) {;
-              String value = getOriginalValue(key, "" + columnListMap.get(key));
-              orQuery = putWildCardByType(value, key, logType);
-              if (StringUtils.isBlank(orQuery)) {
-                logger.debug("Removing invalid filter for key :"+key +" and value :" +value );
-                continue;
-              }
-              boolean isSame = false;
-              if (elments.contains(key)) {
-                isSame = true;
-              }
-              if (isSame && !operation.equals(LogSearchConstants.EXCLUDE_QUERY)) {
-                for (String tempCondition : conditionQuries) {
-                  if (tempCondition.contains(key)) {
-                    String newCondtion = tempCondition + " " + Condition.OR.name() + " " + orQuery;
-                    referalConditionQuries.remove(tempCondition);
-                    referalConditionQuries.add(newCondtion);
-                  }
-                }
-                conditionQuries.clear();
-                conditionQuries.addAll(referalConditionQuries);
-              } else {
-                conditionQuries.add(orQuery);
-                referalConditionQuries.add(orQuery);
-              }
-              field.append(key);
-              elments.add(field.toString());
-            }
-          }
-        }
-      }
-    }
-    if (!referalConditionQuries.isEmpty() && !StringUtils.isBlank(operation)) {
-      if (operation.equals(LogSearchConstants.INCLUDE_QUERY)) {
-        for (String filter : referalConditionQuries) {
-          if (!StringUtils.isBlank(filter)) {
-            solrQuery.addFilterQuery(filter);
-          }
-        }
-      } else if (operation.equals(LogSearchConstants.EXCLUDE_QUERY)) {
-        for (String filter : referalConditionQuries) {
-          if (!StringUtils.isBlank(filter)) {
-            filter = LogSearchConstants.MINUS_OPERATOR + filter;
-            solrQuery.addFilterQuery(filter);
-          }
-        }
-      }
-    }
-  }
-
-  public SolrQuery commonAuditFilterQuery(CommonSearchCriteria searchCriteria) {
-    LogType logType = LogType.AUDIT;
-    SolrQuery solrQuery = new SolrQuery();
-    solrQuery.setQuery("*:*");
-
-    String startTime = searchCriteria.getStartTime();
-    String endTime = searchCriteria.getEndTime();
-    String selectedComp = searchCriteria.getMustBe();
-    setFilterClauseWithFieldName(solrQuery, selectedComp, LogSearchConstants.AUDIT_COMPONENT, LogSearchConstants.NO_OPERATOR, Condition.OR);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.INCLUDE_QUERY, LogSearchConstants.INCLUDE_QUERY, logType);
-    setUserSpecificFilter(searchCriteria, solrQuery, LogSearchConstants.EXCLUDE_QUERY, LogSearchConstants.EXCLUDE_QUERY, logType);
-    setSingleRangeFilter(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startTime, endTime);
-    setPagination(solrQuery, searchCriteria);
-    try {
-      if (searchCriteria.getSortBy() == null || searchCriteria.getSortBy().isEmpty()) {
-        searchCriteria.setSortBy(LogSearchConstants.AUDIT_EVTTIME);
-        searchCriteria.setSortType(SolrQuery.ORDER.desc.toString());
-      }
-    } catch (Exception e) {
-      searchCriteria.setSortBy(LogSearchConstants.AUDIT_EVTTIME);
-      searchCriteria.setSortType(SolrQuery.ORDER.desc.toString());
-    }
-    setSortOrderDefaultServiceLog(solrQuery, searchCriteria);
-    return solrQuery;
-  }
-
-  private String putWildCardByType(String str, String key, LogType logType) {
-    String fieldType;
-    SolrDaoBase solrDaoBase = null;
-    switch (logType) {
-    case AUDIT:
-      fieldType = auditSolrDao.schemaFieldNameMap.get(key);
-      solrDaoBase = auditSolrDao;
-      break;
-    case SERVICE:
-      fieldType = serviceLogsSolrDao.schemaFieldNameMap.get(key);
-      solrDaoBase = serviceLogsSolrDao;
-      if (key.equalsIgnoreCase(LogSearchConstants.SOLR_LOG_MESSAGE)) {
-        return SolrUtil.escapeForLogMessage(key, str);
-      }
-      break;
-    default:
-      // set as null
-      logger.error("Invalid logtype :" + logType);
-      fieldType = null;
-    }
-    if (!StringUtils.isBlank(fieldType)) {
-      if (SolrUtil.isSolrFieldNumber(fieldType, solrDaoBase)) {
-        String value = putEscapeCharacterForNumber(str, fieldType,solrDaoBase);
-        if (!StringUtils.isBlank(value)) {
-          return key + ":" + value;
-        } else {
-          return null;
-        }
-      } else if (checkTokenizer(fieldType, StandardTokenizerFactory.class,solrDaoBase)) {
-        return key + ":" + SolrUtil.escapeForStandardTokenizer(str);
-      } else if (checkTokenizer(fieldType, KeywordTokenizerFactory.class,solrDaoBase)|| "string".equalsIgnoreCase(fieldType)) {
-        return key + ":" + SolrUtil.makeSolrSearchStringWithoutAsterisk(str);
-      } else if (checkTokenizer(fieldType, PathHierarchyTokenizerFactory.class,solrDaoBase)) {
-        return key + ":" + str;
-      }
-    }
-   return key + ":" + "*" + str + "*";
-  }
-
-  private String putEscapeCharacterForNumber(String str,String fieldType,SolrDaoBase solrDaoBase) {
-    if (!StringUtils.isBlank(str)) {
-      str = str.replace("*", "");
-    }
-    String escapeCharSting = parseInputValueAsPerFieldType(str,fieldType,solrDaoBase);
-    if (escapeCharSting == null || escapeCharSting.isEmpty()) {
-      return null;
-    }
-    escapeCharSting = escapeCharSting.replace("-", "\\-");
-    return escapeCharSting;
-  }
-
-  private String parseInputValueAsPerFieldType(String str,String fieldType,SolrDaoBase solrDaoBase ) {
-    try {
-      HashMap<String, Object> fieldTypeInfoMap= SolrUtil.getFieldTypeInfoMap(fieldType,solrDaoBase);
-      String className = (String) fieldTypeInfoMap.get("class");
-      if( className.equalsIgnoreCase(TrieDoubleField.class.getSimpleName())){
-        return ""+ Double.parseDouble(str);
-      }else if(className.equalsIgnoreCase(TrieFloatField.class.getSimpleName())){
-        return ""+ Float.parseFloat(str);
-      }else if(className.equalsIgnoreCase(TrieLongField.class.getSimpleName())){
-        return ""+ Long.parseLong(str);
-      }else {
-        return "" + Integer.parseInt(str);
-      }
-    } catch (Exception e) {
-      logger.debug("Invaid input str: " + str + " For fieldType :" + fieldType);
-      return null;
-    }
-  }
-
-  private String getOriginalValue(String name, String value) {
-    String solrValue = PropertiesHelper.getProperty(name);
-    if (StringUtils.isBlank(solrValue)) {
-      return value;
-    }
-    try {
-      String propertyFieldMappings[] = solrValue.split(LogSearchConstants.LIST_SEPARATOR);
-      if (propertyFieldMappings.length > 0) {
-        HashMap<String, String> propertyFieldValue = new HashMap<String, String>();
-        for (String temp : propertyFieldMappings) {
-          if (!StringUtils.isBlank(temp)) {
-            String arrayValue[] = temp.split(":");
-            if (arrayValue.length > 1) {
-              propertyFieldValue.put(arrayValue[0].toLowerCase(Locale.ENGLISH), arrayValue[1].toLowerCase(Locale.ENGLISH));
-            } else {
-              logger.warn("array length is less than required length 1");
-            }
-          }
-        }
-        String originalValue = propertyFieldValue.get(value.toLowerCase(Locale.ENGLISH));
-        if (!StringUtils.isBlank(originalValue)) {
-          return originalValue;
-        }
-      }
-    } catch (Exception e) {
-      // do nothing
-    }
-    return value;
-  }
-
-
-  private boolean checkTokenizer(String fieldType, Class tokenizerFactoryClass, SolrDaoBase solrDaoBase) {
-    HashMap<String, Object> fieldTypeMap = SolrUtil.getFieldTypeInfoMap(fieldType,solrDaoBase);
-    HashMap<String, Object> analyzer = (HashMap<String, Object>) fieldTypeMap.get("analyzer");
-    if (analyzer != null) {
-      HashMap<String, Object> tokenizerMap = (HashMap<String, Object>) analyzer.get("tokenizer");
-      if (tokenizerMap != null) {
-        String tokenizerClass = (String) tokenizerMap.get("class");
-        if (!StringUtils.isEmpty(tokenizerClass)) {
-          tokenizerClass =tokenizerClass.replace("solr.", "");
-          if (tokenizerClass.equalsIgnoreCase(tokenizerFactoryClass
-              .getSimpleName())) {
-            return true;
-          }
-        }
-      }
-    }
-    return false;
-  }
-}

+ 0 - 282
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java

@@ -1,282 +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.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.query.model.SearchCriteria;
-import org.apache.ambari.logsearch.dao.AuditSolrDao;
-import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
-import org.apache.ambari.logsearch.util.SolrUtil;
-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 com.google.gson.Gson;
-
-import javax.inject.Inject;
-
-public abstract class QueryGenerationBase {
-
-  private static final Logger logger = Logger.getLogger(QueryGenerationBase.class);
-  
-  @Inject
-  protected AuditSolrDao auditSolrDao;
-  
-  @Inject
-  protected ServiceLogsSolrDao serviceLogsSolrDao;
-
-  public enum Condition {
-    OR, AND
-  }
-
-  // SetMethods to apply to the query
-  protected void setFilterClauseForSolrSearchableString(SolrQuery solrQuery, String commaSepratedString, Condition condition,
-      String operator, String messageField) {
-    String filterQuery = "";
-    if (!StringUtils.isBlank(commaSepratedString)) {
-      StringBuilder queryMsg = new StringBuilder();
-      operator = (operator == null ? LogSearchConstants.NO_OPERATOR : operator);
-      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));
-        } else {
-          temp = SolrUtil.escapeForStandardTokenizer(temp);
-          if(temp.startsWith("\"") && temp.endsWith("\"")){
-            temp = temp.substring(1);
-            temp = temp.substring(0, temp.length()-1);
-          }
-          temp = "*" + temp + "*";
-          queryMsg.append(" " + operator + messageField + ":" + temp);
-        }
-        if (msgList.length > count){
-          queryMsg.append(" " + condition.name() + " ");
-        }
-      }
-      filterQuery = queryMsg.toString();
-      solrQuery.addFilterQuery(filterQuery);
-      logger.debug("Filter added :- " + filterQuery);
-    }
-  }
-
-  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)) {
-        filterQuery = SolrUtil.orList(operator + field, arrayOfSepratedString,"");
-      } else if (Condition.AND.equals(condition)) {
-        filterQuery = SolrUtil.andList(operator + field, arrayOfSepratedString,"");
-      }else{
-        logger.warn("Not a valid condition :" + condition.name());
-      }
-      //add
-      if (!StringUtils.isBlank(filterQuery)){
-        solrQuery.addFilterQuery(filterQuery);
-        logger.debug("Filter added :- " + filterQuery);
-      }
-    }
-  }
-
-  public void setSortOrderDefaultServiceLog(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    List<SolrQuery.SortClause> defaultSort = new ArrayList<SolrQuery.SortClause>();
-    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
-      ORDER order = SolrQuery.ORDER.asc;
-      if (!order.toString().equalsIgnoreCase(searchCriteria.getSortType())) {
-        order = SolrQuery.ORDER.desc;
-      }
-      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);
-      defaultSort.add(logtimeSortClause);
-
-    }
-    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 (!StringUtils.isBlank(searchCriteria.getSortBy())) {
-      solrQuery.setFacetSort(searchCriteria.getSortBy());
-      logger.info("Sorted By :- " + searchCriteria.getSortBy());
-    }
-  }
-
-  public void setSingleSortOrder(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    List<SolrQuery.SortClause> sort = new ArrayList<SolrQuery.SortClause>();
-    if (!StringUtils.isBlank(searchCriteria.getSortBy())) {
-      ORDER order = SolrQuery.ORDER.asc;
-      if (!order.toString().equalsIgnoreCase(searchCriteria.getSortType())) {
-        order = SolrQuery.ORDER.desc;
-      }
-      SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(searchCriteria.getSortBy(), order);
-      sort.add(sortOrder);
-      solrQuery.setSorts(sort);
-      logger.debug("Sort Order :-" + sort);
-    }
-  }
-
-  // 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) {
-    List<SolrQuery.SortClause> sort = new ArrayList<SolrQuery.SortClause>();
-    List<String> sortList = (List<String>) searchCriteria.getParamValue("sort");
-    if (sortList != null) {
-      for (String sortOrder : sortList) {
-        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);
-            sort.add(solrSortClause);
-            logger.debug("Sort Order :-" + sort);
-          } else {
-            logger.warn("Not a valid sort Clause " + sortOrder);
-          }
-        }
-      }
-      solrQuery.setSorts(sort);
-    }
-  }
-
-  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 (!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 (!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);
-      }
-    }
-  }
-
-  public void setPagination(SolrQuery solrQuery, SearchCriteria searchCriteria) {
-    Integer startIndex = null;
-    Integer maxRows = null;
-    try {
-      startIndex = (Integer) searchCriteria.getStartIndex();
-      SolrUtil.setStart(solrQuery, startIndex);
-    } catch (ClassCastException e) {
-      SolrUtil.setStart(solrQuery, 0);
-    }
-    try {
-      maxRows = (Integer) searchCriteria.getMaxRows();
-      SolrUtil.setRowCount(solrQuery, maxRows);
-    } catch (ClassCastException e) {
-      SolrUtil.setRowCount(solrQuery, 10);
-    }
-
-    if (startIndex != null && maxRows != null)
-      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;
-    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 buildFilterQuery(String filterType, String filterValue) {
-    String filterQuery = filterType + ":" + filterValue;
-    logger.info("Build Filter Query was :- " + filterQuery);
-    return filterQuery;
-  }
-
-  public String buildJSONFacetAggregatedFuncitonQuery(String function, String xAxisField) {
-    return "{x:'" + function + "(" + xAxisField + ")'}";
-  }
-
-  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 += "}";
-    logger.info("Build JSONQuery is :- " + query);
-    return query;
-  }
-
-  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;
-  }
-
-  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;
-  }
-
-  private String buildListQuery(String paramValue, String solrFieldName, Condition condition) {
-    if (!StringUtils.isBlank(paramValue)) {
-      String[] values = paramValue.split(LogSearchConstants.LIST_SEPARATOR);
-      switch (condition) {
-      case OR:
-        return SolrUtil.orList(solrFieldName, values,"");
-      case AND:
-        return SolrUtil.andList(solrFieldName, values, "");
-      default:
-        logger.error("Invalid condition " + condition.name());
-      }
-    }
-    return "";
-  }
-
-  protected void addFilter(SolrQuery solrQuery, String paramValue, String solrFieldName, Condition condition) {
-    String filterQuery = buildListQuery(paramValue, solrFieldName, condition);
-    if (!StringUtils.isBlank(filterQuery)) {
-      if (solrQuery != null) {
-        solrQuery.addFilterQuery(filterQuery);
-      }
-    }
-  }
-}

+ 0 - 70
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/SearchCriteriaConstants.java

@@ -1,70 +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.query;
-
-public class SearchCriteriaConstants {
-
-  private SearchCriteriaConstants() {
-  }
-
-  public static final String PARAM_FIELD = "field";
-  public static final String PARAM_UNIT = "unit";
-  public static final String PARAM_INCLUDE_MESSAGE = "iMessage";
-  public static final String PARAM_EXCLUDE_MESSAGE = "eMessage";
-  public static final String PARAM_MUST_BE_STRING = "includeString";
-  public static final String PARAM_MUST_NOT_STRING = "unselectComp";
-  public static final String PARAM_EXCLUDE_QUERY = "excludeQuery";
-  public static final String PARAM_INCLUDE_QUERY = "includeQuery";
-  public static final String PARAM_START_TIME = "startTime";
-  public static final String PARAM_END_TIME = "endTime";
-
-  public static final String PARAM_IS_LAST_PAGE = "isLastPage";
-
-  public static final String PARAM_GLOBAL_START_TIME = "globalStartTime";
-  public static final String PARAM_GLOBAL_END_TIME = "globalEndTime";
-
-  public static final String PARAM_X_AXIS = "xAxis";
-  public static final String PARAM_Y_AXIS = "yAxis";
-  public static final String PARAM_STACK_BY = "stackBy";
-  public static final String PARAM_FROM = "from";
-  public static final String PARAM_TO = "to";
-
-  public static final String PARAM_COMPONENT_NAME = "component_name";
-  public static final String PARAM_HOST_NAME = "host_name";
-  public static final String PARAM_FILE_NAME = "file_name";
-  public static final String PARAM_BUNDLE_ID = "bundle_id";
-  public static final String PARAM_SELECT_COMP = "selectComp";
-  public static final String PARAM_LEVEL = "level";
-
-  public static final String PARAM_ID = "id";
-  public static final String PARAM_SCROLL_TYPE = "scrollType";
-  public static final String PARAM_NUMBER_ROWS = "numberRows";
-
-  public static final String PARAM_FORMAT = "format";
-  public static final String PARAM_UTC_OFFSET = "utcOffset";
-  public static final String PARAM_KEYWORD = "keyword";
-  public static final String PARAM_SOURCE_LOG_ID = "sourceLogId";
-  public static final String PARAM_KEYWORD_TYPE = "keywordType";
-  public static final String PARAM_TOKEN = "token";
-
-  public static final String PARAM_USER_NAME = "username";
-  public static final String PARAM_FILTER_NAME = "filtername";
-  public static final String PARAM_ROW_TYPE = "rowtype";
-
-}

+ 0 - 44
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java

@@ -1,44 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.stereotype.Component;
-
-@Component
-public abstract class AbstractCommonAuditLogRequestConverter<SOURCE extends BaseAuditLogRequest, RESULT extends CommonSearchCriteria>
-  extends AbstractCommonSearchRequestConverter<SOURCE, RESULT> {
-
-  @Override
-  public RESULT convertToSearchCriteria(SOURCE request) {
-    RESULT criteria = createCriteria(request);
-    criteria.addParam("q", request.getQuery());
-    criteria.setMustBe(request.getMustBe());
-    criteria.setMustNot(request.getMustNot());
-    criteria.setExcludeQuery(StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
-    criteria.setIncludeQuery(StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
-    criteria.setStartTime(request.getFrom());
-    criteria.setEndTime(request.getTo());
-    return criteria;
-  }
-
-  public abstract RESULT createCriteria(SOURCE request);
-}

+ 0 - 55
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java

@@ -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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.commons.lang.StringUtils;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_GLOBAL_END_TIME;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_GLOBAL_START_TIME;
-
-public abstract class AbstractCommonSearchRequestConverter<SOURCE extends CommonSearchRequest, RESULT extends CommonSearchCriteria>
-  extends AbstractConverterAware<SOURCE, RESULT> {
-
-  @Override
-  public RESULT convert(SOURCE source) {
-    RESULT criteria = convertToSearchCriteria(source);
-    addDefaultParams(source, criteria);
-    return criteria;
-  }
-
-  public abstract RESULT convertToSearchCriteria(SOURCE source);
-
-  private void addDefaultParams(SOURCE request, RESULT criteria) {
-    criteria.setStartIndex(StringUtils.isNumeric(request.getStartIndex()) ? new Integer(request.getStartIndex()) : 0);
-    criteria.setPage(StringUtils.isNumeric(request.getPage()) ? new Integer(request.getPage()) : 0);
-    criteria.setMaxRows(StringUtils.isNumeric(request.getPageSize()) ? new Integer(request.getPageSize()) : 50);
-    criteria.setSortBy(request.getSortBy());
-    criteria.setSortType(request.getSortType());
-    if (StringUtils.isNotEmpty(request.getStartTime())){
-      criteria.setGlobalStartTime(request.getStartTime());
-      criteria.getUrlParamMap().put(PARAM_GLOBAL_START_TIME, request.getStartTime());
-    }
-    if (StringUtils.isNotEmpty(request.getEndTime())){
-      criteria.setGlobalEndTime(request.getEndTime());
-      criteria.getUrlParamMap().put(PARAM_GLOBAL_END_TIME, request.getEndTime());
-    }
-  }
-}

+ 0 - 51
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java

@@ -1,51 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.apache.commons.lang.StringEscapeUtils;
-
-public abstract class AbstractCommonServiceLogRequestConverter<SOURCE extends BaseServiceLogRequest, RESULT extends CommonServiceLogSearchCriteria>
-  extends AbstractCommonSearchRequestConverter<SOURCE, RESULT> {
-
-  @Override
-  public RESULT convertToSearchCriteria(SOURCE request) {
-    RESULT criteria = createCriteria(request);
-    // TODO: check are these used from the UI or not?
-    criteria.addParam("q", request.getQuery());
-    criteria.addParam("unselectComp", request.getMustNot());
-
-    criteria.setLevel(request.getLevel());
-    criteria.setFrom(request.getFrom());
-    criteria.setTo(request.getTo());
-    criteria.setSelectComp(request.getMustBe());
-    criteria.setBundleId(request.getBundleId());
-    criteria.setHostName(request.getHostName());
-    criteria.setComponentName(request.getComponentName());
-    criteria.setFileName(request.getFileName());
-    criteria.setStartTime(request.getStartTime());
-    criteria.setEndTime(request.getEndTime());
-    criteria.setExcludeQuery(StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
-    criteria.setIncludeQuery(StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
-    return criteria;
-  }
-
-  public abstract RESULT createCriteria(SOURCE request);
-}

+ 0 - 39
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java

@@ -1,39 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.AnyGraphRequest;
-import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AnyGraphRequestConverter extends AbstractCommonSearchRequestConverter<AnyGraphRequest, AnyGraphSearchCriteria> {
-
-  @Override
-  public AnyGraphSearchCriteria convertToSearchCriteria(AnyGraphRequest anyGraphRequest) {
-    AnyGraphSearchCriteria criteria = new AnyGraphSearchCriteria();
-    criteria.setxAxis(anyGraphRequest.getxAxis());
-    criteria.setyAxis(anyGraphRequest.getyAxis());
-    criteria.setStackBy(anyGraphRequest.getStackBy());
-    criteria.setUnit(anyGraphRequest.getUnit());
-    criteria.setFrom(anyGraphRequest.getFrom());
-    criteria.setTo(anyGraphRequest.getTo());
-    return criteria;
-  }
-}

+ 0 - 33
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java

@@ -1,33 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class BaseAuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<BaseAuditLogRequest, CommonSearchCriteria> {
-
-  @Override
-  public CommonSearchCriteria createCriteria(BaseAuditLogRequest request) {
-    return new CommonSearchCriteria();
-  }
-
-}

+ 0 - 33
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java

@@ -1,33 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.apache.ambari.logsearch.query.model.CommonServiceLogSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class BaseServiceLogRequestConverter extends AbstractCommonServiceLogRequestConverter<BaseServiceLogRequest, CommonServiceLogSearchCriteria> {
-
-  @Override
-  public CommonServiceLogSearchCriteria createCriteria(BaseServiceLogRequest request) {
-    return new CommonServiceLogSearchCriteria();
-  }
-}

+ 0 - 34
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java

@@ -1,34 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
-import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class FieldAuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<FieldAuditLogRequest, FieldAuditLogSearchCriteria> {
-
-  @Override
-  public FieldAuditLogSearchCriteria createCriteria(FieldAuditLogRequest request) {
-    FieldAuditLogSearchCriteria criteria = new FieldAuditLogSearchCriteria();
-    criteria.setField(request.getField());
-    return criteria;
-  }
-}

+ 0 - 35
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java

@@ -1,35 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.FieldAuditBarGraphRequest;
-import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class FieldBarGraphRequestConverter extends AbstractCommonAuditLogRequestConverter<FieldAuditBarGraphRequest, FieldAuditBarGraphSearchCriteria> {
-
-  @Override
-  public FieldAuditBarGraphSearchCriteria createCriteria(FieldAuditBarGraphRequest request) {
-    FieldAuditBarGraphSearchCriteria criteria = new FieldAuditBarGraphSearchCriteria();
-    criteria.setUnit(request.getUnit());
-    criteria.setField(request.getField());
-    return criteria;
-  }
-}

+ 0 - 34
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java

@@ -1,34 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceExtremeDatesRequest;
-import org.apache.ambari.logsearch.query.model.ServiceExtremeDatesCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceExtremeDatesRequestConverter extends AbstractCommonSearchRequestConverter<ServiceExtremeDatesRequest, ServiceExtremeDatesCriteria> {
-
-  @Override
-  public ServiceExtremeDatesCriteria convertToSearchCriteria(ServiceExtremeDatesRequest request) {
-    ServiceExtremeDatesCriteria criteria = new ServiceExtremeDatesCriteria();
-    criteria.setBundleId(request.getBundleId());
-    return criteria;
-  }
-}

+ 0 - 34
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java

@@ -1,34 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
-import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceGraphRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceGraphRequest, ServiceGraphSearchCriteria> {
-
-  @Override
-  public ServiceGraphSearchCriteria createCriteria(ServiceGraphRequest request) {
-    ServiceGraphSearchCriteria criteria = new ServiceGraphSearchCriteria();
-    criteria.setUnit(request.getUnit());
-    return criteria;
-  }
-}

+ 0 - 35
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java

@@ -1,35 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
-import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceLogExportRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogExportRequest, ServiceLogExportSearchCriteria> {
-
-  @Override
-  public ServiceLogExportSearchCriteria createCriteria(ServiceLogExportRequest request) {
-    ServiceLogExportSearchCriteria criteria = new ServiceLogExportSearchCriteria();
-    criteria.setFormat(request.getFormat());
-    criteria.setUtcOffset(request.getUtcOffset());
-    return criteria;
-  }
-}

+ 0 - 39
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java

@@ -1,39 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
-import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceLogRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogRequest, ServiceLogSearchCriteria> {
-
-  @Override
-  public ServiceLogSearchCriteria createCriteria(ServiceLogRequest request) {
-    ServiceLogSearchCriteria criteria = new ServiceLogSearchCriteria();
-    criteria.setKeyword(StringEscapeUtils.unescapeXml(request.getKeyWord()));
-    criteria.setKeywordType(request.getKeywordType());
-    criteria.setSourceLogId(request.getSourceLogId());
-    criteria.setToken(request.getToken());
-    criteria.setLastPage(request.isLastPage());
-    return criteria;
-  }
-}

+ 0 - 36
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java

@@ -1,36 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
-import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceLogTruncatedRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogTruncatedRequest, ServiceLogTruncatedSearchCriteria> {
-
-  @Override
-  public ServiceLogTruncatedSearchCriteria createCriteria(ServiceLogTruncatedRequest request) {
-    ServiceLogTruncatedSearchCriteria criteria = new ServiceLogTruncatedSearchCriteria();
-    criteria.setId(request.getId());
-    criteria.setScrollType(request.getScrollType());
-    criteria.setNumberRows(request.getNumberRows());
-    return criteria;
-  }
-}

+ 0 - 35
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java

@@ -1,35 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.SimpleQueryRequest;
-import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SimpleQueryRequestConverter extends AbstractConverterAware<SimpleQueryRequest, CommonSearchCriteria> {
-
-  @Override
-  public CommonSearchCriteria convert(SimpleQueryRequest simpleQueryRequest) {
-    CommonSearchCriteria searchCriteria = new CommonSearchCriteria();
-    searchCriteria.addParam("q", simpleQueryRequest.getQuery());
-    return searchCriteria;
-  }
-
-}

+ 0 - 36
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserConfigRequestConverter.java

@@ -1,36 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest;
-import org.apache.ambari.logsearch.query.model.UserConfigSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class UserConfigRequestConverter extends AbstractConverterAware<UserConfigRequest, UserConfigSearchCriteria> {
-
-  @Override
-  public UserConfigSearchCriteria convert(UserConfigRequest request) {
-    UserConfigSearchCriteria criteria = new UserConfigSearchCriteria();
-    criteria.setUserName(request.getUserId());
-    criteria.setFilterName(request.getFilterName());
-    criteria.setRowType(request.getRowType());
-    return criteria;
-  }
-}

+ 0 - 36
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java

@@ -1,36 +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.query.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
-import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
-import org.springframework.stereotype.Component;
-
-@Component
-public class UserExportRequestConverter extends AbstractCommonAuditLogRequestConverter<UserExportRequest, UserExportSearchCriteria> {
-
-  @Override
-  public UserExportSearchCriteria createCriteria(UserExportRequest request) {
-    UserExportSearchCriteria criteria = new UserExportSearchCriteria();
-    criteria.setField(request.getField());
-    criteria.setFormat(request.getFormat());
-    return criteria;
-  }
-
-}

+ 0 - 77
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java

@@ -1,77 +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.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_FROM;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_STACK_BY;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_TO;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_UNIT;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_X_AXIS;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_Y_AXIS;
-
-public class AnyGraphSearchCriteria extends CommonSearchCriteria {
-
-  public String getxAxis() {
-    return getParam(PARAM_X_AXIS, String.class);
-  }
-
-  public void setxAxis(String xAxis) {
-    addParam(PARAM_X_AXIS, xAxis);
-  }
-
-  public String getyAxis() {
-    return getParam(PARAM_Y_AXIS, String.class);
-  }
-
-  public void setyAxis(String yAxis) {
-    addParam(PARAM_Y_AXIS, yAxis);
-  }
-
-  public String getStackBy() {
-    return getParam(PARAM_STACK_BY, String.class);
-  }
-
-  public void setStackBy(String stackBy) {
-    addParam(PARAM_STACK_BY, stackBy);
-  }
-
-  public String getUnit() {
-    return getParam(PARAM_UNIT, String.class);
-  }
-
-  public void setUnit(String unit) {
-    addParam(PARAM_UNIT, unit);
-  }
-
-  public String getFrom() {
-    return getParam(PARAM_FROM, String.class);
-  }
-
-  public void setFrom(String from) {
-    addParam(PARAM_FROM, from);
-  }
-
-  public String getTo() {
-    return getParam(PARAM_TO, String.class);
-  }
-
-  public void setTo(String to) {
-    addParam(PARAM_TO, to);
-  }
-}

+ 0 - 33
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java

@@ -1,33 +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.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_IS_LAST_PAGE;
-
-public class AuditLogSearchCriteria extends CommonSearchCriteria {
-
-  public void setLastPage(boolean lastPage) {
-    addParam(PARAM_IS_LAST_PAGE, lastPage);
-  }
-
-  public boolean isLastPage() {
-    return getParam(PARAM_IS_LAST_PAGE, Boolean.class);
-  }
-
-}

+ 0 - 95
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonSearchCriteria.java

@@ -1,95 +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.query.model;
-
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_END_TIME;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_EXCLUDE_MESSAGE;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_EXCLUDE_QUERY;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_INCLUDE_MESSAGE;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_INCLUDE_QUERY;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_MUST_BE_STRING;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_MUST_NOT_STRING;
-import static org.apache.ambari.logsearch.query.SearchCriteriaConstants.PARAM_START_TIME;
-
-public class CommonSearchCriteria extends SearchCriteria {
-
-  public String getIncludeMessage() {
-    return getParam(PARAM_INCLUDE_MESSAGE, String.class);
-  }
-
-  public void setIncludeMessage(String includeMessage) {
-    addParam(PARAM_INCLUDE_MESSAGE, includeMessage);
-  }
-
-  public String getExcludeMessage() {
-    return getParam(PARAM_EXCLUDE_MESSAGE, String.class);
-  }
-
-  public void setExcludeMessage(String excludeMessage) {
-    addParam(PARAM_EXCLUDE_MESSAGE, excludeMessage);
-  }
-
-  public String getMustBe() {
-    return getParam(PARAM_MUST_BE_STRING, String.class);
-  }
-
-  public void setMustBe(String mustHave) {
-    addParam(PARAM_MUST_BE_STRING, mustHave);
-  }
-
-  public String getMustNot() {
-    return getParam(PARAM_MUST_NOT_STRING, String.class);
-  }
-
-  public void setMustNot(String mustNot) {
-    addParam(PARAM_MUST_NOT_STRING, mustNot);
-  }
-
-  public String getIncludeQuery() {
-    return getParam(PARAM_INCLUDE_QUERY, String.class);
-  }
-
-  public void setIncludeQuery(String includeQuery) {
-    addParam(PARAM_INCLUDE_QUERY, includeQuery);
-  }
-
-  public String getExcludeQuery() {
-    return getParam(PARAM_EXCLUDE_QUERY, String.class);
-  }
-
-  public void setExcludeQuery(String excludeQuery) {
-    addParam(PARAM_EXCLUDE_QUERY, excludeQuery);
-  }
-
-  public String getStartTime() {
-    return getParam(PARAM_START_TIME, String.class);
-  }
-
-  public void setStartTime(String startTime) {
-    addParam(PARAM_START_TIME, startTime);
-  }
-
-  public String getEndTime() {
-    return getParam(PARAM_END_TIME, String.class);
-  }
-
-  public void setEndTime(String endTime) {
-    addParam(PARAM_END_TIME, endTime);
-  }
-}

+ 0 - 88
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonServiceLogSearchCriteria.java

@@ -1,88 +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.query.model;
-
-import org.apache.ambari.logsearch.query.SearchCriteriaConstants;
-
-public class CommonServiceLogSearchCriteria extends CommonSearchCriteria {
-
-  public String getLevel() {
-    return getParam(SearchCriteriaConstants.PARAM_LEVEL, String.class);
-  }
-
-  public void setLevel(String level) {
-    addParam(SearchCriteriaConstants.PARAM_LEVEL, level);
-  }
-
-  public String getSelectComp() {
-    return getParam(SearchCriteriaConstants.PARAM_SELECT_COMP, String.class);
-  }
-
-  public void setSelectComp(String selectComp) {
-    addParam(SearchCriteriaConstants.PARAM_SELECT_COMP, selectComp);
-  }
-
-  public String getBundleId() {
-    return getParam(SearchCriteriaConstants.PARAM_BUNDLE_ID, String.class);
-  }
-
-  public void setBundleId(String bunldeId) {
-    addParam(SearchCriteriaConstants.PARAM_BUNDLE_ID, bunldeId);
-  }
-
-  public String getFrom() {
-    return getParam(SearchCriteriaConstants.PARAM_FROM ,String.class);
-  }
-
-  public void setFrom(String from) {
-    addParam(SearchCriteriaConstants.PARAM_FROM, from);
-  }
-
-  public String getTo() {
-    return getParam(SearchCriteriaConstants.PARAM_TO ,String.class);
-  }
-
-  public void setTo(String to) {
-    addParam(SearchCriteriaConstants.PARAM_TO, to);
-  }
-
-  public String getHostName() {
-    return getParam(SearchCriteriaConstants.PARAM_HOST_NAME ,String.class);
-  }
-
-  public void setHostName(String hostName) {
-    addParam(SearchCriteriaConstants.PARAM_HOST_NAME, hostName);
-  }
-
-  public String getComponentName() {
-    return getParam(SearchCriteriaConstants.PARAM_COMPONENT_NAME ,String.class);
-  }
-
-  public void setComponentName(String componentName) {
-    addParam(SearchCriteriaConstants.PARAM_COMPONENT_NAME, componentName);
-  }
-
-  public String getFileName() {
-    return getParam(SearchCriteriaConstants.PARAM_FILE_NAME ,String.class);
-  }
-
-  public void setFileName(String fileName) {
-    addParam(SearchCriteriaConstants.PARAM_FILE_NAME, fileName);
-  }
-}

+ 0 - 135
ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java

@@ -1,135 +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.query.model;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.ambari.logsearch.common.PropertiesHelper;
-
-public class SearchCriteria {
-
-  private int startIndex = 0;
-  private int maxRows = Integer.MAX_VALUE;
-  private String sortBy = null;
-  private String sortType = null;
-  private int page = 0;
-
-  private String globalStartTime = null;
-  private String globalEndTime = null;
-
-  private HashMap<String, Object> paramList = new HashMap<String, Object>();
-
-  private Map<String, Object> urlParamMap = new HashMap<String, Object>();
-
-  public SearchCriteria() {
-    // Auto-generated constructor stub
-  }
-
-
-  public void addParam(String name, Object value) {
-    paramList.put(name, value);
-  }
-
-  public Object getParamValue(String name) {
-    return paramList.get(name);
-  }
-
-  public <T> T getParam(String key, Class<T> type) {
-    if (getParamValue(key) != null) {
-      return (T) getParamValue(key);
-    }
-    return null;
-  }
-
-  public Map<String, Object> getUrlParamMap() {
-    return urlParamMap;
-  }
-
-  public void setUrlParamMap(Map<String, Object> urlParamMap) {
-    this.urlParamMap = urlParamMap;
-  }
-
-  public int getStartIndex() {
-    return startIndex;
-  }
-
-  public void setStartIndex(int startIndex) {
-    this.startIndex = startIndex;
-  }
-
-  public int getMaxRows() {
-    return maxRows;
-  }
-
-  public void setMaxRows(int maxRows) {
-    this.maxRows = maxRows;
-  }
-
-  public String getSortType() {
-    return sortType;
-  }
-
-  public String getSortBy() {
-    return sortBy;
-  }
-
-  public void setSortBy(String sortBy) {
-    this.sortBy = sortBy;
-  }
-
-  public void setSortType(String sortType) {
-    this.sortType = sortType;
-  }
-
-  public int getPage() {
-    return page;
-  }
-
-  public void setPage(int page) {
-    this.page = page;
-  }
-
-  public String getGlobalStartTime() {
-    return globalStartTime;
-  }
-
-  public void setGlobalStartTime(String globalStartTime) {
-    this.globalStartTime = globalStartTime;
-  }
-
-  public String getGlobalEndTime() {
-    return globalEndTime;
-  }
-
-  public void setGlobalEndTime(String globalEndTime) {
-    this.globalEndTime = globalEndTime;
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder();
-    for (Map.Entry<String, Object> entry : paramList.entrySet()) {
-      sb.append(entry.getKey() + " : " + entry.getValue() + ";");
-    }
-    return sb.toString();
-  }
-
-}

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است