From f4616bcd1a867530015f2eaa2ec7356f41e8c1b1 Mon Sep 17 00:00:00 2001 From: Dmitriy Novikov <7nolikov@gmail.com> Date: Wed, 21 Jul 2021 18:44:00 +0400 Subject: [PATCH 1/8] Added version info util classes --- .../common/info/CloudVersionInfoBuilder.java | 89 +++++++++++++++++++ .../core/common/info/VersionInfoBuilder.java | 26 ++++++ .../common/info/VersionInfoProperties.java | 32 +++++++ .../model/info/ConnectedOuterService.java | 11 +++ .../core/common/model/info/VersionInfo.java | 36 ++++++++ 5 files changed, 194 insertions(+) create mode 100644 src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java create mode 100644 src/main/java/org/opengroup/osdu/core/common/info/VersionInfoBuilder.java create mode 100644 src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java create mode 100644 src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java create mode 100644 src/main/java/org/opengroup/osdu/core/common/model/info/VersionInfo.java diff --git a/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java b/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java new file mode 100644 index 0000000..c7a5b0e --- /dev/null +++ b/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java @@ -0,0 +1,89 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 EPAM Systems, Inc + * + * 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 + * + * https://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.opengroup.osdu.core.common.info; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.opengroup.osdu.core.common.model.info.ConnectedOuterService; +import org.opengroup.osdu.core.common.model.info.VersionInfo; +import org.springframework.stereotype.Component; + +@Slf4j +@RequiredArgsConstructor +@Component +public class CloudVersionInfoBuilder implements VersionInfoBuilder { + + private final Properties buildInfoProperties = new Properties(); + private final Properties gitProperties = new Properties(); + private VersionInfoProperties versionInfoProperties; + + public CloudVersionInfoBuilder(VersionInfoProperties versionInfoProperties) { + this.versionInfoProperties = versionInfoProperties; + } + + public VersionInfo buildVersionInfo() throws IOException { + loadBuildInfoProperties(); + loadGitProperties(); + List connectedOuterServices = loadConnectedOuterServices(); + return VersionInfo.builder() + .groupId(buildInfoProperties.getProperty("build.group")) + .artifactId(buildInfoProperties.getProperty("build.artifact")) + .version(buildInfoProperties.getProperty("build.version")) + .buildTime(buildInfoProperties.getProperty("build.time")) + .branch(gitProperties.getProperty("git.branch")) + .commitId(gitProperties.getProperty("git.commit.id")) + .commitMessage(gitProperties.getProperty("git.commit.message.short")) + .connectedOuterServices(connectedOuterServices) + .build(); + } + + private void loadBuildInfoProperties() throws IOException { + InputStream buildInfoStream = + ClassLoader.getSystemClassLoader() + .getResourceAsStream(versionInfoProperties.getBuildPropertiesPath()); + if (buildInfoStream != null) { + buildInfoProperties.load(buildInfoStream); + } else { + log.error( + "Build-info properties file not found by path: {}", + versionInfoProperties.getBuildPropertiesPath()); + } + } + + private void loadGitProperties() throws IOException { + InputStream gitStream = + ClassLoader.getSystemClassLoader() + .getResourceAsStream(versionInfoProperties.getGitPropertiesPath()); + if (gitStream != null) { + gitProperties.load(gitStream); + } else { + log.error( + "Git properties file not found by path: {}", + versionInfoProperties.getGitPropertiesPath()); + } + } + + protected List loadConnectedOuterServices() { + return Collections.emptyList(); + } +} diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoBuilder.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoBuilder.java new file mode 100644 index 0000000..af157a8 --- /dev/null +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoBuilder.java @@ -0,0 +1,26 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 EPAM Systems, Inc + * + * 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 + * + * https://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.opengroup.osdu.core.common.info; + +import java.io.IOException; +import org.opengroup.osdu.core.common.model.info.VersionInfo; + +public interface VersionInfoBuilder { + + VersionInfo buildVersionInfo() throws IOException; +} diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java new file mode 100644 index 0000000..6e5473d --- /dev/null +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java @@ -0,0 +1,32 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 EPAM Systems, Inc + * + * 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 + * + * https://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.opengroup.osdu.core.common.info; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "version.info") +@Getter +@Setter +public class VersionInfoProperties { + + private String buildPropertiesPath = "META-INF/build-info.properties"; + private String gitPropertiesPath = "BOOT-INF/classes/git.properties"; +} diff --git a/src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java b/src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java new file mode 100644 index 0000000..dff895d --- /dev/null +++ b/src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java @@ -0,0 +1,11 @@ +package org.opengroup.osdu.core.common.model.info; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class ConnectedOuterService { + private String name; + private String version; +} diff --git a/src/main/java/org/opengroup/osdu/core/common/model/info/VersionInfo.java b/src/main/java/org/opengroup/osdu/core/common/model/info/VersionInfo.java new file mode 100644 index 0000000..f0d1d76 --- /dev/null +++ b/src/main/java/org/opengroup/osdu/core/common/model/info/VersionInfo.java @@ -0,0 +1,36 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 EPAM Systems, Inc + * + * 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 + * + * https://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.opengroup.osdu.core.common.model.info; + +import java.util.Collections; +import java.util.List; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class VersionInfo { + private String groupId; + private String artifactId; + private String version; + private String buildTime; + private String branch; + private String commitId; + private String commitMessage; + private List connectedOuterServices; +} \ No newline at end of file -- GitLab From 5b61a0104747de3faf4154e52f1581c3ec7b92e1 Mon Sep 17 00:00:00 2001 From: Dmitriy Novikov <7nolikov@gmail.com> Date: Wed, 21 Jul 2021 18:44:14 +0400 Subject: [PATCH 2/8] Added version info spring autoconfiguration --- .../info/VersionInfoAutoconfiguration.java | 25 +++++++++++++++++++ src/main/resources/META-INF/spring.factories | 1 + 2 files changed, 26 insertions(+) create mode 100644 src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java create mode 100644 src/main/resources/META-INF/spring.factories diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java new file mode 100644 index 0000000..516bb6f --- /dev/null +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java @@ -0,0 +1,25 @@ +package org.opengroup.osdu.core.common.info; + +import java.io.IOException; +import lombok.extern.java.Log; +import org.opengroup.osdu.core.common.model.info.VersionInfo; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; + +@Configuration +@Log +public class VersionInfoAutoconfiguration { + + private final VersionInfoBuilder versionInfoBuilder; + + public VersionInfoAutoconfiguration(VersionInfoBuilder versionInfoBuilder) { + this.versionInfoBuilder = versionInfoBuilder; + log.info("Version info '/info' endpoint exposed."); + } + + @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) + public VersionInfo info() throws IOException { + return versionInfoBuilder.buildVersionInfo(); + } +} diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..710080d --- /dev/null +++ b/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java \ No newline at end of file -- GitLab From faac46828c8196d4ed031bb01d740f00831f312e Mon Sep 17 00:00:00 2001 From: Dmitriy Novikov <7nolikov@gmail.com> Date: Wed, 21 Jul 2021 20:21:25 +0400 Subject: [PATCH 3/8] Fixed spring autoconfiguration --- .../info/VersionInfoAutoconfiguration.java | 18 ++++----- .../core/common/info/VersionInfoEndpoint.java | 37 +++++++++++++++++++ src/main/resources/META-INF/spring.factories | 2 +- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java index 516bb6f..5715233 100644 --- a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java @@ -1,25 +1,21 @@ package org.opengroup.osdu.core.common.info; -import java.io.IOException; import lombok.extern.java.Log; -import org.opengroup.osdu.core.common.model.info.VersionInfo; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; @Configuration @Log public class VersionInfoAutoconfiguration { - private final VersionInfoBuilder versionInfoBuilder; - - public VersionInfoAutoconfiguration(VersionInfoBuilder versionInfoBuilder) { - this.versionInfoBuilder = versionInfoBuilder; + @Bean + public VersionInfoEndpoint versionInfoEndpoint(VersionInfoBuilder versionInfoBuilder) { log.info("Version info '/info' endpoint exposed."); + return new VersionInfoEndpoint(); } - @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) - public VersionInfo info() throws IOException { - return versionInfoBuilder.buildVersionInfo(); + @Bean + public VersionInfoProperties versionInfoProperties() { + return new VersionInfoProperties(); } } diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java new file mode 100644 index 0000000..b90824b --- /dev/null +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 EPAM Systems, Inc + * + * 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 + * + * https://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.opengroup.osdu.core.common.info; + +import java.io.IOException; +import org.opengroup.osdu.core.common.model.info.VersionInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@RequestMapping +public class VersionInfoEndpoint { + + @Autowired + private VersionInfoBuilder versionInfoBuilder; + + @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) + public VersionInfo info() throws IOException { + return versionInfoBuilder.buildVersionInfo(); + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories index 710080d..4cb5336 100644 --- a/src/main/resources/META-INF/spring.factories +++ b/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java \ No newline at end of file +org.springframework.boot.autoconfigure.EnableAutoConfiguration=org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration \ No newline at end of file -- GitLab From b5cf5c7b8429b4957fc7f6157d9959b84db4c69f Mon Sep 17 00:00:00 2001 From: Dmitriy Novikov <7nolikov@gmail.com> Date: Thu, 22 Jul 2021 13:00:01 +0400 Subject: [PATCH 4/8] Fixed rest controller configuration --- .../common/info/CloudVersionInfoBuilder.java | 4 +--- .../info/VersionInfoAutoconfiguration.java | 17 +++-------------- .../core/common/info/VersionInfoEndpoint.java | 2 ++ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java b/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java index c7a5b0e..ee2c76a 100644 --- a/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java +++ b/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java @@ -22,20 +22,18 @@ import java.io.InputStream; import java.util.Collections; import java.util.List; import java.util.Properties; -import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.opengroup.osdu.core.common.model.info.ConnectedOuterService; import org.opengroup.osdu.core.common.model.info.VersionInfo; import org.springframework.stereotype.Component; @Slf4j -@RequiredArgsConstructor @Component public class CloudVersionInfoBuilder implements VersionInfoBuilder { private final Properties buildInfoProperties = new Properties(); private final Properties gitProperties = new Properties(); - private VersionInfoProperties versionInfoProperties; + private final VersionInfoProperties versionInfoProperties; public CloudVersionInfoBuilder(VersionInfoProperties versionInfoProperties) { this.versionInfoProperties = versionInfoProperties; diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java index 5715233..0a32c43 100644 --- a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoAutoconfiguration.java @@ -1,21 +1,10 @@ package org.opengroup.osdu.core.common.info; import lombok.extern.java.Log; -import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration @Log -public class VersionInfoAutoconfiguration { - - @Bean - public VersionInfoEndpoint versionInfoEndpoint(VersionInfoBuilder versionInfoBuilder) { - log.info("Version info '/info' endpoint exposed."); - return new VersionInfoEndpoint(); - } - - @Bean - public VersionInfoProperties versionInfoProperties() { - return new VersionInfoProperties(); - } -} +@ComponentScan("org.opengroup.osdu.core.common.info") +public class VersionInfoAutoconfiguration {} diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java index b90824b..6bf507e 100644 --- a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java @@ -23,7 +23,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +@RestController @RequestMapping public class VersionInfoEndpoint { -- GitLab From 8a9e3109ab7b9eae2997dcca4313cd4f58b3f206 Mon Sep 17 00:00:00 2001 From: Dmitriy Novikov <7nolikov@gmail.com> Date: Thu, 22 Jul 2021 18:35:17 +0400 Subject: [PATCH 5/8] Moved info endpoint declaration to child project --- .../core/common/info/VersionInfoEndpoint.java | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java deleted file mode 100644 index 6bf507e..0000000 --- a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoEndpoint.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2021 Google LLC - * Copyright 2021 EPAM Systems, Inc - * - * 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 - * - * https://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.opengroup.osdu.core.common.info; - -import java.io.IOException; -import org.opengroup.osdu.core.common.model.info.VersionInfo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping -public class VersionInfoEndpoint { - - @Autowired - private VersionInfoBuilder versionInfoBuilder; - - @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) - public VersionInfo info() throws IOException { - return versionInfoBuilder.buildVersionInfo(); - } -} \ No newline at end of file -- GitLab From 8b5fffe01258128aaa3ffe24b9af17f33c1ddf15 Mon Sep 17 00:00:00 2001 From: "Rostislav Dublin (EPAM)" Date: Fri, 23 Jul 2021 12:40:28 +0000 Subject: [PATCH 6/8] Update NOTICE --- NOTICE | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/NOTICE b/NOTICE index 4774084..5152ca1 100644 --- a/NOTICE +++ b/NOTICE @@ -37,7 +37,7 @@ The following software have components provided under the terms of this license: - Jackson dataformat: Smile (from http://github.com/FasterXML/jackson-dataformats-binary) - Jackson datatype: JSR310 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310) - Jackson datatype: jdk8 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8) -- Jackson-annotations (from http://wiki.fasterxml.com/JacksonHome) +- Jackson-annotations (from http://github.com/FasterXML/jackson) - Jackson-core (from http://wiki.fasterxml.com/JacksonHome) - Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson-dataformats-text) - Jackson-module-parameter-names (from https://repo1.maven.org/maven2/com/fasterxml/jackson/module/jackson-module-parameter-names) @@ -70,14 +70,6 @@ The following software have components provided under the terms of this license: - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - SnakeYAML (from http://code.google.com/p/snakeyaml/) -- Spring Boot (from http://projects.spring.io/spring-boot/) -- Spring Boot AutoConfigure (from http://projects.spring.io/spring-boot/) -- Spring Boot Json Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json) -- Spring Boot Logging Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Tomcat Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Validation Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Web Starter (from http://projects.spring.io/spring-boot/) - Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) - Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework) - Spring Framework: AOP (from http://www.springframework.org) @@ -112,10 +104,18 @@ The following software have components provided under the terms of this license: - rest-high-level (from https://github.com/elastic/elasticsearch) - rxjava (from https://github.com/ReactiveX/RxJava) - server (from https://github.com/elastic/elasticsearch) +- spring-boot (from https://spring.io/projects/spring-boot) +- spring-boot-autoconfigure (from https://spring.io/projects/spring-boot) +- spring-boot-starter (from https://spring.io/projects/spring-boot) +- spring-boot-starter-json (from https://spring.io/projects/spring-boot) +- spring-boot-starter-logging (from https://spring.io/projects/spring-boot) +- spring-boot-starter-tomcat (from https://spring.io/projects/spring-boot) +- spring-boot-starter-validation (from https://spring.io/projects/spring-boot) +- spring-boot-starter-web (from https://spring.io/projects/spring-boot) - swagger-annotations (from https://repo1.maven.org/maven2/io/swagger/swagger-annotations) - swagger-jaxrs (from ) - tomcat-embed-core (from http://tomcat.apache.org/) -- tomcat-embed-websocket (from http://tomcat.apache.org/) +- tomcat-embed-websocket (from https://tomcat.apache.org/) ======================================================================== BSD-2-Clause -- GitLab From 1bb732cde4e2c0b78c2c70cc3bd92cb655230fe4 Mon Sep 17 00:00:00 2001 From: Dmitriy Novikov <7nolikov@gmail.com> Date: Tue, 27 Jul 2021 12:25:13 +0400 Subject: [PATCH 7/8] Fixed discusses --- .../osdu/core/common/info/CloudVersionInfoBuilder.java | 2 ++ .../osdu/core/common/info/VersionInfoProperties.java | 2 +- .../osdu/core/common/model/info/ConnectedOuterService.java | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java b/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java index ee2c76a..cd6368d 100644 --- a/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java +++ b/src/main/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilder.java @@ -25,10 +25,12 @@ import java.util.Properties; import lombok.extern.slf4j.Slf4j; import org.opengroup.osdu.core.common.model.info.ConnectedOuterService; import org.opengroup.osdu.core.common.model.info.VersionInfo; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.stereotype.Component; @Slf4j @Component +@ConditionalOnMissingBean(value = VersionInfoBuilder.class) public class CloudVersionInfoBuilder implements VersionInfoBuilder { private final Properties buildInfoProperties = new Properties(); diff --git a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java index 6e5473d..d201a48 100644 --- a/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java +++ b/src/main/java/org/opengroup/osdu/core/common/info/VersionInfoProperties.java @@ -22,7 +22,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @Configuration -@ConfigurationProperties(prefix = "version.info") +@ConfigurationProperties(prefix = "osdu.version.info") @Getter @Setter public class VersionInfoProperties { diff --git a/src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java b/src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java index dff895d..cf7d7c0 100644 --- a/src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java +++ b/src/main/java/org/opengroup/osdu/core/common/model/info/ConnectedOuterService.java @@ -3,6 +3,12 @@ package org.opengroup.osdu.core.common.model.info; import lombok.Builder; import lombok.Data; +/** + * The node contains service-specific values for all outer services connected to OSDU service. + * The value is optional - basic implementation contains an empty list. + * To define outer services info for OSDU service + * need to override loadConnectedOuterServices method. + */ @Data @Builder public class ConnectedOuterService { -- GitLab From 6816b145e7a1e1434c3dfe733f08896df22e4837 Mon Sep 17 00:00:00 2001 From: Dmitriy Novikov <7nolikov@gmail.com> Date: Tue, 27 Jul 2021 14:44:22 +0400 Subject: [PATCH 8/8] Added unit tests for CloudVersionInfoBuilderTest --- .../info/CloudVersionInfoBuilderTest.java | 45 +++++++++++++++++++ .../resources/testdata/build-info.properties | 5 +++ .../resources/testdata/git-info.properties | 25 +++++++++++ 3 files changed, 75 insertions(+) create mode 100644 src/test/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilderTest.java create mode 100644 src/test/resources/testdata/build-info.properties create mode 100644 src/test/resources/testdata/git-info.properties diff --git a/src/test/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilderTest.java b/src/test/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilderTest.java new file mode 100644 index 0000000..eb501cf --- /dev/null +++ b/src/test/java/org/opengroup/osdu/core/common/info/CloudVersionInfoBuilderTest.java @@ -0,0 +1,45 @@ +package org.opengroup.osdu.core.common.info; + +import static org.mockito.Mockito.when; + +import java.io.IOException; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opengroup.osdu.core.common.model.info.VersionInfo; + +@RunWith(MockitoJUnitRunner.class) +public class CloudVersionInfoBuilderTest { + + private static final String TEST_BUILD_INFO_PATH = "testdata/build-info.properties"; + private static final String TEST_GIT_INFO_PATH = "testdata/git-info.properties"; + + @InjectMocks + private CloudVersionInfoBuilder versionInfoBuilder; + + @Mock + private VersionInfoProperties versionInfoProperties; + + @Before + public void setUp() { + when(versionInfoProperties.getBuildPropertiesPath()).thenReturn(TEST_BUILD_INFO_PATH); + when(versionInfoProperties.getGitPropertiesPath()).thenReturn(TEST_GIT_INFO_PATH); + } + + @Test + public void buildVersionInfo() throws IOException { + VersionInfo versionInfo = versionInfoBuilder.buildVersionInfo(); + + Assert.assertNotNull(versionInfo.getGroupId()); + Assert.assertNotNull(versionInfo.getArtifactId()); + Assert.assertNotNull(versionInfo.getVersion()); + Assert.assertNotNull(versionInfo.getBuildTime()); + Assert.assertNotNull(versionInfo.getBranch()); + Assert.assertNotNull(versionInfo.getCommitId()); + Assert.assertNotNull(versionInfo.getCommitMessage()); + } +} diff --git a/src/test/resources/testdata/build-info.properties b/src/test/resources/testdata/build-info.properties new file mode 100644 index 0000000..ba922d4 --- /dev/null +++ b/src/test/resources/testdata/build-info.properties @@ -0,0 +1,5 @@ +build.artifact=storage-core +build.group=org.opengroup.osdu +build.name=storage-core +build.time=2021-07-22T14\:31\:10.717Z +build.version=0.10.0-SNAPSHOT diff --git a/src/test/resources/testdata/git-info.properties b/src/test/resources/testdata/git-info.properties new file mode 100644 index 0000000..96fbae6 --- /dev/null +++ b/src/test/resources/testdata/git-info.properties @@ -0,0 +1,25 @@ +#Generated by Git-Commit-Id-Plugin +git.branch=version-endpoint +git.build.host=EPRUSARW000F +git.build.time=2021-07-22T18\:31\:17+0400 +git.build.user.email=7nolikov@gmail.com +git.build.user.name=Dmitriy Novikov +git.build.version=0.10.0-SNAPSHOT +git.closest.tag.commit.count= +git.closest.tag.name= +git.commit.author.time=2021-07-22T16\:39\:53+0400 +git.commit.committer.time=2021-07-22T16\:39\:53+0400 +git.commit.id=7777 +git.commit.id.abbrev=0aff671 +git.commit.id.describe=0aff671-dirty +git.commit.id.describe-short=0aff671-dirty +git.commit.message.full=Merge remote-tracking branch 'community/master' into version-endpoint +git.commit.message.short=Merge remote-tracking branch 'community/master' into version-endpoint +git.commit.time=2021-07-22T16\:39\:53+0400 +git.commit.user.email=7nolikov@gmail.com +git.commit.user.name=Dmitriy Novikov +git.dirty=true +git.local.branch.ahead=0 +git.local.branch.behind=0 +git.tags= +git.total.commit.count=1010 -- GitLab