http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java new file mode 100644 index 0000000..091194e --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java @@ -0,0 +1,136 @@ +/* + * 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 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 void addParam(String name, Object value) { + String solrValue = PropertiesHelper.getProperty(name); + if (solrValue == null || solrValue.isEmpty()) { + paramList.put(name, value); + } else { + try { + String propertyFieldMappings[] = solrValue.split(","); + HashMap<String, String> propertyFieldValue = new HashMap<String, String>(); + for (String temp : propertyFieldMappings) { + String arrayValue[] = temp.split(":"); + propertyFieldValue.put(arrayValue[0].toLowerCase(Locale.ENGLISH), arrayValue[1].toLowerCase(Locale.ENGLISH)); + } + String originalValue = propertyFieldValue.get(value.toString().toLowerCase(Locale.ENGLISH)); + if (originalValue != null && !originalValue.isEmpty()) + paramList.put(name, originalValue); + + } catch (Exception e) { + //do nothing + } + } + } + + public Object getParamValue(String name) { + return paramList.get(name); + } + + 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; + } + + public Map<String, Object> getUrlParamMap() { + return urlParamMap; + } + + public void setUrlParamMap(Map<String, Object> urlParamMap) { + this.urlParamMap = urlParamMap; + } + +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java new file mode 100644 index 0000000..0ef5bdf --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class ServiceAnyGraphSearchCriteria extends ServiceLogFileSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java new file mode 100644 index 0000000..3fc6ff8 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class ServiceExtremeDatesCriteria extends CommonSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java new file mode 100644 index 0000000..31a57a4 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class ServiceGraphSearchCriteria extends ServiceLogFileSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java new file mode 100644 index 0000000..8bab7f0 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class ServiceLogExportSearchCriteria extends ServiceLogFileSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java new file mode 100644 index 0000000..a9f5926 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class ServiceLogFileSearchCriteria extends CommonSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java new file mode 100644 index 0000000..d41c589 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class ServiceLogSearchCriteria extends ServiceLogFileSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java new file mode 100644 index 0000000..24dc9a8 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class ServiceLogTruncatedSearchCriteria extends ServiceLogFileSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.java new file mode 100644 index 0000000..8798cd6 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class UserConfigSearchCriteria extends CommonSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java new file mode 100644 index 0000000..755c673 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.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.query.model; + +import org.apache.ambari.logsearch.common.Marker; + +@Marker +public class UserExportSearchCriteria extends FieldAuditLogSearchCriteria { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java deleted file mode 100644 index 3d99dc0..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java +++ /dev/null @@ -1,283 +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.rest; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.apache.ambari.logsearch.common.SearchCriteria; -import org.apache.ambari.logsearch.manager.AuditMgr; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.*; -import static org.apache.ambari.logsearch.doc.DocConstants.AuditOperationDescriptions.*; - -@Api(value = "audit/logs", description = "Audit log operations") -@Path("audit/logs") -@Component -@Scope("request") -public class AuditLogsREST { - - @Autowired - AuditMgr auditMgr; - - @GET - @Path("/schema/fields") - @Produces({"application/json"}) - @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD) - public String getSolrFieldList(@Context HttpServletRequest request) { - return auditMgr.getAuditLogsSchemaFieldsName(); - } - - @GET - @Produces({"application/json"}) - @ApiOperation(GET_AUDIT_LOGS_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = IS_LAST_PAGE_D, name = "isLastPage", dataType = "boolean", paramType = "query") - }) - public String getAuditLogs(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addRequiredAuditLogsParams(request); - searchCriteria.addParam("isLastPage", request.getParameter("isLastPage")); - return auditMgr.getLogs(searchCriteria); - } - - @GET - @Path("/components") - @Produces({"application/json"}) - @ApiOperation(GET_AUDIT_COMPONENTS_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - }) - public String getAuditComponents(@Context HttpServletRequest request) { - - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addParam("q", request.getParameter("q")); - return auditMgr.getAuditComponents(searchCriteria); - } - - @GET - @Path("/linegraph") - @Produces({"application/json"}) - @ApiOperation(GET_AUDIT_LINE_GRAPH_DATA_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query") - }) - public String getAuditLineGraphData(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addRequiredAuditLogsParams(request); - searchCriteria.addParam("unit", request.getParameter("unit")); - return auditMgr.getAuditLineGraphData(searchCriteria); - } - - @GET - @Path("/users") - @Produces({"application/json"}) - @ApiOperation(GET_TOP_AUDIT_USERS_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query") - }) - public String getTopAuditUsers(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addRequiredAuditLogsParams(request); - searchCriteria.addParam("field", request.getParameter("field")); - return auditMgr.topTenUsers(searchCriteria); - } - - @GET - @Path("/resources") - @Produces({"application/json"}) - @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query") - }) - public String getTopAuditResources(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addRequiredAuditLogsParams(request); - searchCriteria.addParam("field", request.getParameter("field")); - //return auditMgr.getTopAuditFieldCount(searchCriteria); - return auditMgr.topTenResources(searchCriteria); - - } - - @GET - @Path("/live/count") - @Produces({"application/json"}) - @ApiOperation(GET_LIVE_LOGS_COUNT_OD) - public String getLiveLogsCount() { - return auditMgr.getLiveLogCounts(); - } - - @GET - @Path("/request/user/linegraph") - @Produces({"application/json"}) - @ApiOperation(GET_REQUEST_USER_LINE_GRAPH_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query") - }) - public String getRequestUserLineGraph(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addRequiredAuditLogsParams(request); - searchCriteria.addParam("field", request.getParameter("field")); - searchCriteria.addParam("unit", request.getParameter("unit")); - return auditMgr.getRequestUserLineGraph(searchCriteria); - } - - @GET - @Path("/anygraph") - @Produces({"application/json"}) - @ApiOperation(GET_ANY_GRAPH_DATA_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = X_AXIS_D, name = "xAxis", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = Y_AXIS_D, name = "yAxis", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = STACK_BY_D, name = "stackBy", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query") - }) - public String getAnyGraphData(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addParam("xAxis", request.getParameter("xAxis")); - searchCriteria.addParam("yAxis", request.getParameter("yAxis")); - searchCriteria.addParam("stackBy", request.getParameter("stackBy")); - searchCriteria.addParam("from", request.getParameter("from")); - searchCriteria.addParam("to", request.getParameter("to")); - searchCriteria.addParam("unit", request.getParameter("unit")); - return auditMgr.getAnyGraphData(searchCriteria); - } - - @GET - @Path("/users/export") - @Produces({"application/json"}) - @ApiOperation(EXPORT_USER_TALBE_TO_TEXT_FILE_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FORMAT_D, name = "format", dataType = "string", paramType = "query") - }) - public Response exportUserTableToTextFile(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addRequiredAuditLogsParams(request); - searchCriteria.addParam("field", request.getParameter("field")); - searchCriteria.addParam("format", request.getParameter("format")); - return auditMgr.exportUserTableToTextFile(searchCriteria); - } - - @GET - @Path("/serviceload") - @Produces({"application/json"}) - @ApiOperation(GET_SERVICE_LOAD_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), - }) - public String getServiceLoad(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addRequiredAuditLogsParams(request); - return auditMgr.getServiceLoad(searchCriteria); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java new file mode 100644 index 0000000..82e21e8 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java @@ -0,0 +1,157 @@ +/* + * 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.rest; + +import javax.inject.Inject; +import javax.ws.rs.BeanParam; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.ambari.logsearch.model.request.impl.AnyGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest; +import org.apache.ambari.logsearch.model.request.impl.FieldAuditBarGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest; +import org.apache.ambari.logsearch.model.request.impl.SimpleQueryRequest; +import org.apache.ambari.logsearch.model.request.impl.UserExportRequest; +import org.apache.ambari.logsearch.model.response.AuditLogResponse; +import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse; +import org.apache.ambari.logsearch.model.response.GroupListResponse; +import org.apache.ambari.logsearch.model.response.NameValueDataListResponse; +import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria; +import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria; +import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria; +import org.apache.ambari.logsearch.query.model.CommonSearchCriteria; +import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria; +import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria; +import org.apache.ambari.logsearch.query.model.SearchCriteria; +import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest; +import org.apache.ambari.logsearch.manager.AuditLogsManager; +import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria; +import org.springframework.context.annotation.Scope; +import org.springframework.core.convert.ConversionService; +import org.springframework.stereotype.Component; + +import static org.apache.ambari.logsearch.doc.DocConstants.AuditOperationDescriptions.*; + +@Api(value = "audit/logs", description = "Audit log operations") +@Path("audit/logs") +@Component +@Scope("request") +public class AuditLogsResource { + + @Inject + private AuditLogsManager auditLogsManager; + + @Inject + private ConversionService conversionService; + + @GET + @Path("/schema/fields") + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD) + public String getSolrFieldList() { + return auditLogsManager.getAuditLogsSchemaFieldsName(); + } + + @GET + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_LOGS_OD) + public AuditLogResponse getAuditLogs(@BeanParam AuditLogRequest auditLogRequest) { + return auditLogsManager.getLogs(conversionService.convert(auditLogRequest, AuditLogSearchCriteria.class)); + } + + @GET + @Path("/components") + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_COMPONENTS_OD) + public GroupListResponse getAuditComponents(@BeanParam SimpleQueryRequest request) { + return auditLogsManager.getAuditComponents(conversionService.convert(request, SearchCriteria.class)); + } + + @GET + @Path("/bargraph") + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_LINE_GRAPH_DATA_OD) + public BarGraphDataListResponse getAuditBarGraphData(@BeanParam AuditBarGraphRequest request) { + return auditLogsManager.getAuditBarGraphData(conversionService.convert(request, AuditBarGraphSearchCriteria.class)); + } + + @GET + @Path("/users") + @Produces({"application/json"}) + @ApiOperation(GET_TOP_AUDIT_USERS_OD) + public BarGraphDataListResponse getTopAuditUsers(@BeanParam FieldAuditBarGraphRequest request) { + return auditLogsManager.topTenUsers(conversionService.convert(request, FieldAuditBarGraphSearchCriteria.class)); + } + + @GET + @Path("/resources") + @Produces({"application/json"}) + @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD) + public BarGraphDataListResponse getTopAuditResources(@BeanParam FieldAuditLogRequest request) { + return auditLogsManager.topTenResources(conversionService.convert(request, FieldAuditLogSearchCriteria.class)); + } + + @GET + @Path("/live/count") + @Produces({"application/json"}) + @ApiOperation(GET_LIVE_LOGS_COUNT_OD) + public NameValueDataListResponse getLiveLogsCount() { + return auditLogsManager.getLiveLogCounts(); + } + + @GET + @Path("/request/user/bargraph") + @Produces({"application/json"}) + @ApiOperation(GET_REQUEST_USER_LINE_GRAPH_OD) + public BarGraphDataListResponse getRequestUserBarGraph(@BeanParam FieldAuditBarGraphRequest request) { + return auditLogsManager.getRequestUserLineGraph(conversionService.convert(request, FieldAuditBarGraphSearchCriteria.class)); + } + + @GET + @Path("/anygraph") + @Produces({"application/json"}) + @ApiOperation(GET_ANY_GRAPH_DATA_OD) + public BarGraphDataListResponse getAnyGraphData(@BeanParam AnyGraphRequest request) { + return auditLogsManager.getAnyGraphData(conversionService.convert(request, AnyGraphSearchCriteria.class)); + } + + @GET + @Path("/users/export") + @Produces({"application/json"}) + @ApiOperation(EXPORT_USER_TALBE_TO_TEXT_FILE_OD) + public Response exportUserTableToTextFile(@BeanParam UserExportRequest request) { + return auditLogsManager.exportUserTableToTextFile(conversionService.convert(request, UserExportSearchCriteria.class)); + } + + @GET + @Path("/serviceload") + @Produces({"application/json"}) + @ApiOperation(GET_SERVICE_LOAD_OD) + public BarGraphDataListResponse getServiceLoad(@BeanParam BaseAuditLogRequest request) { + return auditLogsManager.getServiceLoad(conversionService.convert(request, CommonSearchCriteria.class)); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java deleted file mode 100644 index 6099e0f..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java +++ /dev/null @@ -1,84 +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.rest; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.apache.ambari.logsearch.common.SearchCriteria; -import org.apache.ambari.logsearch.manager.LogFileMgr; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.*; -import static org.apache.ambari.logsearch.doc.DocConstants.LogFileOperationDescriptions.*; - -@Api(value = "logfile", description = "Logfile operations") -@Path("logfile") -@Component -@Scope("request") -public class LogFileREST { - - @Autowired - LogFileMgr logFileMgr; - - @GET - @Produces({"application/json"}) - @ApiOperation(SEARCH_LOG_FILES_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = LOG_TYPE_D, name = "logType", dataType = "string", paramType = "query") - }) - public String searchLogFiles(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(request); - searchCriteria.addParam("component", request.getParameter("component")); - searchCriteria.addParam("host", request.getParameter("host")); - searchCriteria.addParam("logType", request.getParameter("logType")); - return logFileMgr.searchLogFiles(searchCriteria); - } - - @GET - @Path("/tail") - @Produces({"application/json"}) - @ApiOperation(GET_LOG_FILE_TAIL_OD) - @ApiImplicitParams(value = { - @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = LOG_TYPE_D, name = "logType", dataType = "string", paramType = "query"), - @ApiImplicitParam(value = TAIL_SIZE_D, name = "tailSize", dataType = "string", paramType = "query") - }) - public String getLogFileTail(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = new SearchCriteria(); - searchCriteria.addParam("host", request.getParameter("host")); - searchCriteria.addParam("component", request.getParameter("component")); - searchCriteria.addParam("name", request.getParameter("name")); - searchCriteria.addParam("tailSize", request.getParameter("tailSize")); - return logFileMgr.getLogFileTail(searchCriteria); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java new file mode 100644 index 0000000..c23f457 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.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.rest; + +import javax.inject.Inject; +import javax.ws.rs.BeanParam; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.ambari.logsearch.model.request.impl.LogFileRequest; +import org.apache.ambari.logsearch.model.request.impl.LogFileTailRequest; +import org.apache.ambari.logsearch.model.response.LogFileDataListResponse; +import org.apache.ambari.logsearch.model.response.LogListResponse; +import org.apache.ambari.logsearch.query.model.LogFileSearchCriteria; +import org.apache.ambari.logsearch.query.model.LogFileTailSearchCriteria; +import org.apache.ambari.logsearch.manager.LogFileManager; +import org.springframework.context.annotation.Scope; +import org.springframework.core.convert.ConversionService; +import org.springframework.stereotype.Component; + +import static org.apache.ambari.logsearch.doc.DocConstants.LogFileOperationDescriptions.*; + +@Api(value = "logfile", description = "Logfile operations") +@Path("logfile") +@Component +@Scope("request") +public class LogFileResource { + + @Inject + private LogFileManager logFileManager; + + @Inject + private ConversionService conversionService; + + @GET + @Produces({"application/json"}) + @ApiOperation(SEARCH_LOG_FILES_OD) + public LogFileDataListResponse searchLogFiles(@BeanParam LogFileRequest request) { + return logFileManager.searchLogFiles(conversionService.convert(request, LogFileSearchCriteria.class)); + } + + @GET + @Path("/tail") + @Produces({"application/json"}) + @ApiOperation(GET_LOG_FILE_TAIL_OD) + public LogListResponse getLogFileTail(@BeanParam LogFileTailRequest request) { + return logFileManager.getLogFileTail(conversionService.convert(request, LogFileTailSearchCriteria.class)); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java deleted file mode 100644 index 5218f5d..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java +++ /dev/null @@ -1,48 +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.rest; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.ambari.logsearch.manager.PublicMgr; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -import static org.apache.ambari.logsearch.doc.DocConstants.PublicOperationDescriptions.OBTAIN_GENERAL_CONFIG_OD; - -@Api(value = "public", description = "Public operations") -@Path("public") -@Component -@Scope("request") -public class PublicREST { - - @Autowired - PublicMgr generalMgr; - - @GET - @Path("/config") - @ApiOperation(OBTAIN_GENERAL_CONFIG_OD) - public String getGeneralConfig() { - return generalMgr.getGeneralConfig(); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java new file mode 100644 index 0000000..94bf059 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java @@ -0,0 +1,48 @@ +/* + * 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.rest; + +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.ambari.logsearch.manager.PublicManager; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import static org.apache.ambari.logsearch.doc.DocConstants.PublicOperationDescriptions.OBTAIN_GENERAL_CONFIG_OD; + +@Api(value = "public", description = "Public operations") +@Path("public") +@Component +@Scope("request") +public class PublicResource { + + @Inject + private PublicManager publicManager; + + @GET + @Path("/config") + @ApiOperation(OBTAIN_GENERAL_CONFIG_OD) + public String getGeneralConfig() { + return publicManager.getGeneralConfig(); + } +}
