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 --- .../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 ++-- 7 files changed, 89 insertions(+), 90 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 (limited to 'app/src/main/java') 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); } } -- cgit 1.2.3-korg