From 7f439188b428a3799a1baba4218e25853b66c882 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Tue, 29 Aug 2023 10:56:22 +0200 Subject: Consistently use the history name in the history codebase - remove portal prefix Issue-ID: PORTALNG-51 Change-Id: I2a0b68bdb6e972813a8a8f048c5d05add97754d2 Signed-off-by: Fiete Ostkamp --- README.md | 6 ++-- app/build.gradle | 4 +-- .../onap/portal/history/HistoryApplication.java | 39 ++++++++++++++++++++++ .../portal/history/PortalHistoryApplication.java | 39 ---------------------- .../history/configuration/HistoryConfig.java | 35 +++++++++++++++++++ .../history/configuration/PortalHistoryConfig.java | 35 ------------------- .../history/configuration/SchedulerConfig.java | 11 +++--- .../history/controller/ActionsController.java | 14 ++++---- .../java/org/onap/portal/history/util/Logger.java | 6 ++-- app/src/main/resources/application-local.yml | 8 ++--- app/src/main/resources/application.yml | 18 +++++----- .../onap/portal/history/BaseIntegrationTest.java | 4 +-- .../actions/ActionsControllerIntegrationTest.java | 2 +- app/src/test/resources/application.yml | 3 +- openapi/src/main/resources/api/api.yml | 2 +- 15 files changed, 113 insertions(+), 113 deletions(-) create mode 100644 app/src/main/java/org/onap/portal/history/HistoryApplication.java delete mode 100644 app/src/main/java/org/onap/portal/history/PortalHistoryApplication.java create mode 100644 app/src/main/java/org/onap/portal/history/configuration/HistoryConfig.java delete mode 100644 app/src/main/java/org/onap/portal/history/configuration/PortalHistoryConfig.java diff --git a/README.md b/README.md index 769f5d0..4c00421 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Portal-history +# History This microservice manages the user actions for the `ui` frontend application. It is a Spring Boot application that is build upon MongoDB and Webflux. ## Build @@ -29,14 +29,14 @@ To start the service execute the `run.sh` in the development folder: development/run.sh ``` -Example request against the portal-prefs service can be run in your preferred IDE with the `request.http file from the development folder. +Example request against the preferences service can be run in your preferred IDE with the `request.http file from the development folder. You can access the Keycloak UI via browser. URL: http://localhost:8080 **username:** admin **password:** password -To stop the portal-prefs service, Keycloak and the databases run: +To stop the preferences service, Keycloak and the databases run: ```sh development/stop.sh ``` diff --git a/app/build.gradle b/app/build.gradle index 468d8f4..227f384 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,7 +72,7 @@ jacocoTestReport { application { // Define the main class for the application. - mainClass = 'org.onap.portal.history.PortalHistoryApplication' + mainClass = 'org.onap.portal.history.HistoryApplication' } sourceCompatibility = '17' @@ -94,7 +94,7 @@ configurations.implementation.setCanBeResolved(true) springBoot { buildInfo { properties { - artifact = "org-onap-portal-history" + artifact = "org-onap-portalng-history" version = rootProject.file('version').text.trim() group = rootProject.group name = "History service that saves user actions" diff --git a/app/src/main/java/org/onap/portal/history/HistoryApplication.java b/app/src/main/java/org/onap/portal/history/HistoryApplication.java new file mode 100644 index 0000000..21c3c4b --- /dev/null +++ b/app/src/main/java/org/onap/portal/history/HistoryApplication.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2022. Deutsche Telekom AG + * + * Licensed 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. + * + * SPDX-License-Identifier: Apache-2.0 + * + * + */ + +/* + * This Java source file was generated by the Gradle 'init' task. + */ +package org.onap.portal.history; + + +import org.onap.portal.history.configuration.HistoryConfig; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; + +@EnableConfigurationProperties(HistoryConfig.class) +@SpringBootApplication +public class HistoryApplication { + public static void main(String[] args) { + SpringApplication.run(HistoryApplication.class, args); + } +} diff --git a/app/src/main/java/org/onap/portal/history/PortalHistoryApplication.java b/app/src/main/java/org/onap/portal/history/PortalHistoryApplication.java deleted file mode 100644 index 0e712f2..0000000 --- a/app/src/main/java/org/onap/portal/history/PortalHistoryApplication.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright (c) 2022. Deutsche Telekom AG - * - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - * - * - */ - -/* - * This Java source file was generated by the Gradle 'init' task. - */ -package org.onap.portal.history; - - -import org.onap.portal.history.configuration.PortalHistoryConfig; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -@EnableConfigurationProperties(PortalHistoryConfig.class) -@SpringBootApplication -public class PortalHistoryApplication { - public static void main(String[] args) { - SpringApplication.run(PortalHistoryApplication.class, args); - } -} diff --git a/app/src/main/java/org/onap/portal/history/configuration/HistoryConfig.java b/app/src/main/java/org/onap/portal/history/configuration/HistoryConfig.java new file mode 100644 index 0000000..f70a9d4 --- /dev/null +++ b/app/src/main/java/org/onap/portal/history/configuration/HistoryConfig.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2022. Deutsche Telekom AG + * + * Licensed 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. + * + * SPDX-License-Identifier: Apache-2.0 + * + * + */ + +package org.onap.portal.history.configuration; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import jakarta.validation.constraints.NotBlank; + +@Data +@ConfigurationProperties("history") +public class HistoryConfig { + + @NotBlank + private final Integer saveInterval; +} diff --git a/app/src/main/java/org/onap/portal/history/configuration/PortalHistoryConfig.java b/app/src/main/java/org/onap/portal/history/configuration/PortalHistoryConfig.java deleted file mode 100644 index 9a42214..0000000 --- a/app/src/main/java/org/onap/portal/history/configuration/PortalHistoryConfig.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * Copyright (c) 2022. Deutsche Telekom AG - * - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - * - * - */ - -package org.onap.portal.history.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -import jakarta.validation.constraints.NotBlank; - -@Data -@ConfigurationProperties("portal-history") -public class PortalHistoryConfig { - - @NotBlank - private final Integer saveInterval; -} diff --git a/app/src/main/java/org/onap/portal/history/configuration/SchedulerConfig.java b/app/src/main/java/org/onap/portal/history/configuration/SchedulerConfig.java index 2295a5f..88531af 100644 --- a/app/src/main/java/org/onap/portal/history/configuration/SchedulerConfig.java +++ b/app/src/main/java/org/onap/portal/history/configuration/SchedulerConfig.java @@ -23,7 +23,6 @@ package org.onap.portal.history.configuration; import org.onap.portal.history.services.ActionsService; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -34,20 +33,20 @@ import org.springframework.stereotype.Component; public class SchedulerConfig { private final ActionsService actionsService; - private final PortalHistoryConfig portalHistoryConfig; + private final HistoryConfig historyConfig; - public SchedulerConfig(ActionsService actionsService, PortalHistoryConfig portalHistoryConfig){ + public SchedulerConfig(ActionsService actionsService, HistoryConfig historyConfig){ this.actionsService = actionsService; - this.portalHistoryConfig = portalHistoryConfig; + this.historyConfig = historyConfig; } /** * This method will be trigger by Spring Boot scheduler. * The cron execution time is configured in the application properties as well as the save interval. */ - @Scheduled(cron="${portal-history.delete-interval}") + @Scheduled(cron="${history.delete-interval}") public void runDeleteActions(){ - actionsService.deleteActions(portalHistoryConfig.getSaveInterval()); + actionsService.deleteActions(historyConfig.getSaveInterval()); log.info("Delete actions in scheduled job"); } } diff --git a/app/src/main/java/org/onap/portal/history/controller/ActionsController.java b/app/src/main/java/org/onap/portal/history/controller/ActionsController.java index 8339d65..ce781f5 100644 --- a/app/src/main/java/org/onap/portal/history/controller/ActionsController.java +++ b/app/src/main/java/org/onap/portal/history/controller/ActionsController.java @@ -23,7 +23,7 @@ package org.onap.portal.history.controller; import java.util.Optional; -import org.onap.portal.history.configuration.PortalHistoryConfig; +import org.onap.portal.history.configuration.HistoryConfig; import org.onap.portal.history.openapi.api.ActionsApi; import org.onap.portal.history.openapi.model.ActionResponse; import org.onap.portal.history.openapi.model.ActionsListResponse; @@ -40,11 +40,11 @@ import reactor.core.publisher.Mono; public class ActionsController implements ActionsApi { private final ActionsService actionsService; - private final PortalHistoryConfig portalHistoryConfig; + private final HistoryConfig historyConfig; - public ActionsController(ActionsService actionsService, PortalHistoryConfig portalHistoryConfig){ + public ActionsController(ActionsService actionsService, HistoryConfig historyConfig){ this.actionsService = actionsService; - this.portalHistoryConfig = portalHistoryConfig; + this.historyConfig = historyConfig; } @Override @@ -52,7 +52,7 @@ public class ActionsController implements ActionsApi { return IdTokenExchange .validateUserId(userId, exchange, xRequestId) - .then(createActionRequest.flatMap(action -> actionsService.createActions(userId, action, portalHistoryConfig.getSaveInterval(), xRequestId))) + .then(createActionRequest.flatMap(action -> actionsService.createActions(userId, action, historyConfig.getSaveInterval(), xRequestId))) .map(ResponseEntity::ok); } @@ -70,7 +70,7 @@ public class ActionsController implements ActionsApi { return IdTokenExchange .validateUserId(userId, exchange, xRequestId) - .then(actionsService.getActions(userId, page.orElse(1), pageSize.orElse(10), showLastHours.orElse(portalHistoryConfig.getSaveInterval()), portalHistoryConfig.getSaveInterval(), xRequestId)) + .then(actionsService.getActions(userId, page.orElse(1), pageSize.orElse(10), showLastHours.orElse(historyConfig.getSaveInterval()), historyConfig.getSaveInterval(), xRequestId)) .map(ResponseEntity::ok); } @@ -78,7 +78,7 @@ public class ActionsController implements ActionsApi { public Mono> listActions(String xRequestId, Optional page, Optional pageSize, Optional showLastHours, ServerWebExchange exchange) { return actionsService - .listActions(page.orElse(1), pageSize.orElse(10), showLastHours.orElse(portalHistoryConfig.getSaveInterval()), portalHistoryConfig.getSaveInterval(), xRequestId) + .listActions(page.orElse(1), pageSize.orElse(10), showLastHours.orElse(historyConfig.getSaveInterval()), historyConfig.getSaveInterval(), xRequestId) .map(ResponseEntity::ok); } } diff --git a/app/src/main/java/org/onap/portal/history/util/Logger.java b/app/src/main/java/org/onap/portal/history/util/Logger.java index 01b159c..c072c16 100644 --- a/app/src/main/java/org/onap/portal/history/util/Logger.java +++ b/app/src/main/java/org/onap/portal/history/util/Logger.java @@ -40,7 +40,7 @@ public class Logger { * @param path which is called be the request */ public static void requestLog(String xRequestId, HttpMethod methode, URI path) { - log.info("Portal-history - request - X-Request-Id {} {} {}", xRequestId, methode, path); + log.info("History - request - X-Request-Id {} {} {}", xRequestId, methode, path); } /** @@ -49,7 +49,7 @@ public class Logger { * @param code http status of the response */ public static void responseLog(String xRequestId, HttpStatusCode httpStatusCode) { - log.info("Portal-history - response - X-Request-Id {} {}", xRequestId, httpStatusCode); + log.info("History - response - X-Request-Id {} {}", xRequestId, httpStatusCode); } /** @@ -60,6 +60,6 @@ public class Logger { */ public static void errorLog(String xRequestId, String msg, String id) { log.info( - "Portal-history - error - X-Request-Id {} {} {} not found", xRequestId, msg, id); + "History - error - X-Request-Id {} {} {} not found", xRequestId, msg, id); } } diff --git a/app/src/main/resources/application-local.yml b/app/src/main/resources/application-local.yml index a908c1b..fcb5c19 100644 --- a/app/src/main/resources/application-local.yml +++ b/app/src/main/resources/application-local.yml @@ -1,6 +1,6 @@ server: - port: 9002 - address: 0.0.0.0 + port: 9002 + address: 0.0.0.0 spring: jackson: @@ -14,13 +14,13 @@ spring: jwk-set-uri: http://localhost:8080/auth/realms/ONAP/protocol/openid-connect/certs #Keycloak Endpoint data: mongodb: - database: portal_history + database: history host: localhost port: 27017 username: root password: password -portal-history: +history: save-interval: 72 delete-interval: 0 * * * * * diff --git a/app/src/main/resources/application.yml b/app/src/main/resources/application.yml index 3bfd624..2b004ce 100644 --- a/app/src/main/resources/application.yml +++ b/app/src/main/resources/application.yml @@ -1,8 +1,10 @@ server: - port: 9002 - address: 0.0.0.0 + port: 9002 + address: 0.0.0.0 spring: + application: + name: history jackson: serialization: # needed for serializing objects of type object @@ -14,13 +16,13 @@ spring: jwk-set-uri: ${KEYCLOAK_URL}/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/certs #Keycloak Endpoint data: mongodb: - database: ${PORTALHISTORY_DATABASE} - host: ${PORTALHISTORY_HOST} - port: ${PORTALHISTORY_PORT} - username: ${PORTALHISTORY_USERNAME} - password: ${PORTALHISTORY_PASSWORD} + database: ${HISTORY_DATABASE} + host: ${HISTORY_HOST} + port: ${HISTORY_PORT} + username: ${HISTORY_USERNAME} + password: ${HISTORY_PASSWORD} -portal-history: +history: save-interval: 72 delete-interval: 0 0 * * * * diff --git a/app/src/test/java/org/onap/portal/history/BaseIntegrationTest.java b/app/src/test/java/org/onap/portal/history/BaseIntegrationTest.java index 866ce33..feee00c 100644 --- a/app/src/test/java/org/onap/portal/history/BaseIntegrationTest.java +++ b/app/src/test/java/org/onap/portal/history/BaseIntegrationTest.java @@ -55,10 +55,10 @@ public abstract class BaseIntegrationTest { // } @LocalServerPort protected int port; - @Value("${portal-history.realm}") + @Value("${history.realm}") protected String realm; - @Value("${portal-history.delete-interval}") + @Value("${history.delete-interval}") protected String deleteInterval; @Autowired protected ObjectMapper objectMapper; diff --git a/app/src/test/java/org/onap/portal/history/actions/ActionsControllerIntegrationTest.java b/app/src/test/java/org/onap/portal/history/actions/ActionsControllerIntegrationTest.java index c5fa17b..feab695 100644 --- a/app/src/test/java/org/onap/portal/history/actions/ActionsControllerIntegrationTest.java +++ b/app/src/test/java/org/onap/portal/history/actions/ActionsControllerIntegrationTest.java @@ -60,7 +60,7 @@ class ActionsControllerIntegrationTest extends BaseIntegrationTest { @Autowired private ActionsRepository repository; - // @Value("${portal-history.save-interval}") + // @Value("${history.save-interval}") protected Integer saveInterval = 72; @BeforeEach diff --git a/app/src/test/resources/application.yml b/app/src/test/resources/application.yml index df38a79..db0d057 100644 --- a/app/src/test/resources/application.yml +++ b/app/src/test/resources/application.yml @@ -19,7 +19,7 @@ de: embedded: version: 5.0.15 -portal-history: +history: realm: ONAP save-interval: 72 delete-interval: '0 0 0 1 1 *' @@ -38,4 +38,3 @@ management: enabled: true java: enabled: true - diff --git a/openapi/src/main/resources/api/api.yml b/openapi/src/main/resources/api/api.yml index 968a6f1..311d32a 100644 --- a/openapi/src/main/resources/api/api.yml +++ b/openapi/src/main/resources/api/api.yml @@ -2,7 +2,7 @@ openapi: 3.0.2 info: title: History API version: '1.0' - description: API to provide actions for portal-history + description: API to provide actions for history servers: - url: 'http://localhost:9002' tags: -- cgit 1.2.3-korg