http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java index 8cc6b94..3499bce 100644 --- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java @@ -34,7 +34,7 @@ import java.util.Map; import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.AUDIT_LOGS_STATUS_OD; import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.SERVICE_LOGS_STATUS_OD; import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.STATUS_OD; -import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.USER_CONFIG_STATUS_OD; +import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.EVENT_HISTORY_STATUS_OD; @Api(value = "status", description = "Status Operations") @Path("status") @@ -51,8 +51,8 @@ public class StatusResource { private SolrCollectionState solrAuditLogsState; @Inject - @Named("solrUserConfigState") - private SolrCollectionState solrUserConfigState; + @Named("solrEventHistoryState") + private SolrCollectionState solrEventHistoryState; @GET @Produces({"application/json"}) @@ -61,7 +61,7 @@ public class StatusResource { Map<String, SolrCollectionState> response = new HashMap<>(); response.put("serviceLogs", solrServiceLogsState); response.put("auditLogs", solrAuditLogsState); - response.put("userConfig", solrUserConfigState); + response.put("eventHistory", solrEventHistoryState); return response; } @@ -82,10 +82,10 @@ public class StatusResource { } @GET - @Path("/userconfig") + @Path("/history") @Produces({"application/json"}) - @ApiOperation(USER_CONFIG_STATUS_OD) - public SolrCollectionState getSolrUserConfigStatus() { - return solrUserConfigState; + @ApiOperation(EVENT_HISTORY_STATUS_OD) + public SolrCollectionState getSolrEventHistoryStatus() { + return solrEventHistoryState; } }
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java deleted file mode 100644 index 00b971a..0000000 --- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java +++ /dev/null @@ -1,82 +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.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.BeanParam; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.ambari.logsearch.manager.UserConfigManager; -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.springframework.context.annotation.Scope; - -import java.util.List; - -import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigOperationDescriptions.*; - -@Api(value = "userconfig", description = "User config operations") -@Path("userconfig") -@Named -@Scope("request") -public class UserConfigResource { - - @Inject - private UserConfigManager userConfigManager; - - @POST - @Produces({"application/json"}) - @ApiOperation(SAVE_USER_CONFIG_OD) - public String saveUserConfig(UserConfigData userConfig) { - return userConfigManager.saveUserConfig(userConfig); - } - - @DELETE - @Path("/{id}") - @ApiOperation(DELETE_USER_CONFIG_OD) - public void deleteUserConfig(@PathParam("id") String id) { - userConfigManager.deleteUserConfig(id); - } - - @GET - @Produces({"application/json"}) - @ApiOperation(GET_USER_CONFIG_OD) - public UserConfigDataListResponse getUserConfig(@BeanParam UserConfigRequest request) { - return userConfigManager.getUserConfig(request); - } - - @GET - @Path("/names") - @Produces({"application/json"}) - @ApiOperation(GET_ALL_USER_NAMES_OD) - public List<String> getAllUserName() { - return userConfigManager.getAllUserName(); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java index 39e134a..60fc1a3 100644 --- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java @@ -98,8 +98,8 @@ public class SolrConstants { public static final String AUDIT_TAGS_STR = "tags_str"; } - public class UserConfigConstants { - private UserConfigConstants() { + public class EventHistoryConstants { + private EventHistoryConstants() { } public static final String ID = "id"; http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchEventHistoryStateFilter.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchEventHistoryStateFilter.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchEventHistoryStateFilter.java new file mode 100644 index 0000000..356886b --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchEventHistoryStateFilter.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.web.filters; + +import org.apache.ambari.logsearch.common.MessageEnums; +import org.apache.ambari.logsearch.common.VResponse; +import org.apache.ambari.logsearch.conf.SolrPropsConfig; +import org.apache.ambari.logsearch.conf.global.SolrCollectionState; +import org.apache.ambari.logsearch.util.RESTErrorUtil; +import org.springframework.security.web.util.matcher.RequestMatcher; + +import javax.servlet.http.HttpServletRequest; + +public class LogsearchEventHistoryStateFilter extends AbstractLogsearchGlobalStateFilter { + + + public LogsearchEventHistoryStateFilter(RequestMatcher requestMatcher, SolrCollectionState state, SolrPropsConfig solrPropsConfig) { + super(requestMatcher, state, solrPropsConfig); + } + + @Override + public VResponse getErrorResponse(SolrCollectionState solrCollectionState, SolrPropsConfig solrPropsConfig, HttpServletRequest request) { + String requestUri = request.getRequestURI(); + if (!solrCollectionState.isZnodeReady()) { + return RESTErrorUtil.createMessageResponse(String.format(ZNODE_NOT_READY_MSG, + "history", solrPropsConfig.getZkConnectString(), requestUri), MessageEnums.ZNODE_NOT_READY); + } else if (!solrCollectionState.isConfigurationUploaded()) { + return RESTErrorUtil.createMessageResponse(String.format(ZK_CONFIG_NOT_READY_MSG, "history", + solrPropsConfig.getConfigName(), solrPropsConfig.getCollection(), requestUri), MessageEnums.ZK_CONFIG_NOT_READY); + } else if (!solrCollectionState.isSolrCollectionReady()) { + return RESTErrorUtil.createMessageResponse(String.format(SOLR_COLLECTION_NOT_READY_MSG, + solrPropsConfig.getCollection(), requestUri), MessageEnums.SOLR_COLLECTION_NOT_READY); + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUserConfigStateFilter.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUserConfigStateFilter.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUserConfigStateFilter.java deleted file mode 100644 index 037bed0..0000000 --- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUserConfigStateFilter.java +++ /dev/null @@ -1,52 +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.web.filters; - -import org.apache.ambari.logsearch.common.MessageEnums; -import org.apache.ambari.logsearch.common.VResponse; -import org.apache.ambari.logsearch.conf.SolrPropsConfig; -import org.apache.ambari.logsearch.conf.global.SolrCollectionState; -import org.apache.ambari.logsearch.util.RESTErrorUtil; -import org.springframework.security.web.util.matcher.RequestMatcher; - -import javax.servlet.http.HttpServletRequest; - -public class LogsearchUserConfigStateFilter extends AbstractLogsearchGlobalStateFilter { - - - public LogsearchUserConfigStateFilter(RequestMatcher requestMatcher, SolrCollectionState state, SolrPropsConfig solrPropsConfig) { - super(requestMatcher, state, solrPropsConfig); - } - - @Override - public VResponse getErrorResponse(SolrCollectionState solrCollectionState, SolrPropsConfig solrPropsConfig, HttpServletRequest request) { - String requestUri = request.getRequestURI(); - if (!solrCollectionState.isZnodeReady()) { - return RESTErrorUtil.createMessageResponse(String.format(ZNODE_NOT_READY_MSG, - "userconfig", solrPropsConfig.getZkConnectString(), requestUri), MessageEnums.ZNODE_NOT_READY); - } else if (!solrCollectionState.isConfigurationUploaded()) { - return RESTErrorUtil.createMessageResponse(String.format(ZK_CONFIG_NOT_READY_MSG, "userconfig", - solrPropsConfig.getConfigName(), solrPropsConfig.getCollection(), requestUri), MessageEnums.ZK_CONFIG_NOT_READY); - } else if (!solrCollectionState.isSolrCollectionReady()) { - return RESTErrorUtil.createMessageResponse(String.format(SOLR_COLLECTION_NOT_READY_MSG, - solrPropsConfig.getCollection(), requestUri), MessageEnums.SOLR_COLLECTION_NOT_READY); - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverterTest.java new file mode 100644 index 0000000..2940a7f --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverterTest.java @@ -0,0 +1,50 @@ +/* + * 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.EventHistoryRequest; +import org.apache.solr.client.solrj.SolrQuery; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class EventHistoryRequestQueryConverterTest extends AbstractRequestConverterTest { + + private EventHistoryRequestQueryConverter underTest; + + @Before + public void setUp() { + underTest = new EventHistoryRequestQueryConverter(); + } + + @Test + public void testConvert() { + // GIVEN + EventHistoryRequest request = new EventHistoryRequest(); + request.setRowType("myRowType"); // TODO: validate these 3 fields @Valid on EventHistoryRequest object -> not null + request.setFilterName("myFilterName"); + request.setClusters("cl1,cl2"); + // WHEN + SolrQuery queryResult = underTest.convert(request); + // THEN + assertEquals("?q=*%3A*&fq=rowtype%3AmyRowType&fq=filtername%3A*myFilterName*&fq=cluster%3A%28cl1+OR+cl2%29&start=0&rows=10&sort=filtername+asc", + queryResult.toQueryString()); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java deleted file mode 100644 index 66560c5..0000000 --- a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java +++ /dev/null @@ -1,50 +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.converter; - -import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class UserConfigRequestQueryConverterTest extends AbstractRequestConverterTest { - - private UserConfigRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new UserConfigRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - UserConfigRequest request = new UserConfigRequest(); - request.setRowType("myRowType"); // TODO: validate these 3 fields @Valid on UserConfigRequest object -> not null - request.setFilterName("myFilterName"); - request.setClusters("cl1,cl2"); - // WHEN - SolrQuery queryResult = underTest.convert(request); - // THEN - assertEquals("?q=*%3A*&fq=rowtype%3AmyRowType&fq=filtername%3A*myFilterName*&fq=cluster%3A%28cl1+OR+cl2%29&start=0&rows=10&sort=filtername+asc", - queryResult.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/collection_bases/VEventHistoryListBase.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/collection_bases/VEventHistoryListBase.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/collection_bases/VEventHistoryListBase.js index 06b2619..596695b 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/collection_bases/VEventHistoryListBase.js +++ b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/collection_bases/VEventHistoryListBase.js @@ -28,7 +28,7 @@ define(['require', var VEventHistoryListBase = BaseCollection.extend( /** @lends VEventHistoryListBase.prototype */ { - url: Globals.baseURL + 'userconfig', + url: Globals.baseURL + 'history', model: VEventHistory, @@ -48,7 +48,7 @@ define(['require', *************************/ saveEventHistory: function(postData, options) { - var url = Globals.baseURL + 'userconfig'; + var url = Globals.baseURL + 'history'; options = _.extend({ data: JSON.stringify(postData), @@ -59,7 +59,7 @@ define(['require', return this.constructor.nonCrudOperation.call(this, url, 'POST', options); }, saveDashboard: function(postData, options) { - var url = Globals.baseURL + 'userconfig'; + var url = Globals.baseURL + 'history'; options = _.extend({ data: JSON.stringify(postData), @@ -70,7 +70,7 @@ define(['require', return this.constructor.nonCrudOperation.call(this, url, 'POST', options); }, deleteEventHistory: function(postData, options) { - var url = Globals.baseURL + 'userconfig/' + postData.id; + var url = Globals.baseURL + 'history/' + postData.id; options = _.extend({ contentType: 'application/json', http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/model_bases/VUserFilterBase.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/model_bases/VUserFilterBase.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/model_bases/VUserFilterBase.js index cd469de..a672a94 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/model_bases/VUserFilterBase.js +++ b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/model_bases/VUserFilterBase.js @@ -27,7 +27,7 @@ define(['require', var VUserFilterBase = BaseModel.extend( /** @lends VUserFilterBase.prototype */ { - urlRoot: Globals.baseURL + 'userconfig/filters', + urlRoot: Globals.baseURL + 'history/filters', defaults: {}, http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js index bbd57465..3cdca56 100644 --- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js +++ b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js @@ -236,7 +236,7 @@ define(['require', content.model.set(content.setValues()); content.model.save(content.model.attributes, { - url: Globals.baseURL + 'userconfig/filters', + url: Globals.baseURL + 'history/filters', success : function(model,response){ Utils.notifySuccess({ content: "Filter has been saved."
