aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml88
-rw-r--r--prh-app-server/pom.xml52
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java5
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java72
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/AppInfoController.java63
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java65
-rw-r--r--prh-app-server/src/main/resources/application.yaml8
-rw-r--r--prh-app-server/src/main/resources/logback-spring.xml2
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java32
-rw-r--r--prh-commons/pom.xml32
-rw-r--r--swagger.yaml76
11 files changed, 237 insertions, 258 deletions
diff --git a/pom.xml b/pom.xml
index 59cb87b8..61a64cff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ PNF-REGISTRATION-HANDLER
+ ~ ================================================================================
+ ~ Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
+ ~ ================================================================================
+ ~ 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.
+ ~ ============LICENSE_END=========================================================
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -7,7 +26,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.2.1</version>
+ <version>1.2.2</version>
<relativePath/>
</parent>
@@ -28,13 +47,9 @@
<properties>
<java.version>8</java.version>
- <immutables.version>2.5.6</immutables.version>
- <spring.version>5.1.2.RELEASE</spring.version>
- <spring-boot.version>2.1.0.RELEASE</spring-boot.version>
- <tomcat.version>8.5.32</tomcat.version>
- <slf4j.version>1.7.25</slf4j.version>
- <junit-platform.version>1.1.0</junit-platform.version>
- <jacoco.version>0.8.2</jacoco.version>
+ <spring-boot.version>2.1.2.RELEASE</spring-boot.version>
+ <springfox.version>2.9.2</springfox.version>
+ <immutables.version>2.7.5</immutables.version>
<sdk.version>1.1.0-SNAPSHOT</sdk.version>
</properties>
@@ -57,7 +72,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.7.0</version>
+ <version>3.8.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
@@ -74,26 +89,24 @@
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
- <version>${junit-platform.version}</version>
+ <version>1.1.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
- <groupId>com.spotify</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>1.1.1</version>
+ <groupId>pl.project13.maven</groupId>
+ <artifactId>git-commit-id-plugin</artifactId>
+ <version>2.2.6</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.1</version>
</plugin>
<plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
+ <groupId>com.spotify</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>1.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -135,30 +148,41 @@
<artifactId>common-dependency</artifactId>
<version>${sdk.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${spring-boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
- <version>2.8.0</version>
+ <version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
- <version>2.8.0</version>
+ <version>${springfox.version}</version>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${spring-boot.version}</version>
- <type>pom</type>
- <scope>import</scope>
+ <groupId>org.immutables</groupId>
+ <artifactId>value</artifactId>
+ <version>${immutables.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>gson</artifactId>
+ <version>${immutables.version}</version>
</dependency>
+
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.14.2</version>
+ <version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
-
</project>
diff --git a/prh-app-server/pom.xml b/prh-app-server/pom.xml
index f6ee2f79..5e4befbc 100644
--- a/prh-app-server/pom.xml
+++ b/prh-app-server/pom.xml
@@ -3,7 +3,7 @@
~ ============LICENSE_START=======================================================
~ PNF-REGISTRATION-HANDLER
~ ================================================================================
- ~ Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ ~ Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
~ ================================================================================
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -17,10 +17,10 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
~ ============LICENSE_END=========================================================
- -->
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -52,13 +52,36 @@
<plugins>
<plugin>
+ <groupId>pl.project13.maven</groupId>
+ <artifactId>git-commit-id-plugin</artifactId>
+ <configuration>
+ <dateFormat>${maven.build.timestamp.format}</dateFormat>
+ <generateGitPropertiesFile>true</generateGitPropertiesFile>
+ <format>json</format>
+ <generateGitPropertiesFilename>${project.build.outputDirectory}/git_info.json</generateGitPropertiesFilename>
+ </configuration>
+ <executions>
+ <execution>
+ <id>get-git-info</id>
+ <goals>
+ <goal>revision</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>3.0.2</version>
<configuration>
<archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>./${dependency.dir.name}/</classpathPrefix>
+ <useUniqueVersions>false</useUniqueVersions>
+ <mainClass>${prh.main.class}</mainClass>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
<manifestEntries>
- <Main-Class>${prh.main.class}</Main-Class>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
</archive>
@@ -91,23 +114,23 @@
<imageTags>
<tag>latest</tag>
</imageTags>
- <baseImage>openjdk:8-jre-alpine</baseImage>
- <exposes>
- <expose>8100</expose>
- <expose>8433</expose>
- </exposes>
- <entryPoint>["java", "-cp", "${docker.artifact.dir}/${dependency.dir.name}/*:${docker.artifact.dir}/${project.build.finalName}.jar", "${prh.main.class}"]</entryPoint>
+ <baseImage>openjdk:${java.version}-jre-alpine</baseImage>
+ <workdir>${docker.artifact.dir}</workdir>
<resources>
<resource>
<directory>${dependency.dir.location}</directory>
- <targetPath>${docker.artifact.dir}/${dependency.dir.name}</targetPath>
+ <targetPath>${dependency.dir.name}</targetPath>
</resource>
<resource>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
- <targetPath>${docker.artifact.dir}</targetPath>
</resource>
</resources>
+ <exposes>
+ <expose>8100</expose>
+ <expose>8433</expose>
+ </exposes>
+ <entryPoint>["java", "-jar", "${project.build.finalName}.jar"]</entryPoint>
</configuration>
<executions>
<execution>
@@ -157,6 +180,7 @@
</plugin>
</plugins>
</build>
+
<dependencies>
<dependency>
<groupId>org.onap.dcaegen2.services.prh</groupId>
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
index 613e9a83..d26fbd81 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PNF-REGISTRATION-HANDLER
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,12 +23,15 @@ package org.onap.dcaegen2.services.prh.configuration;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
+import org.springframework.core.io.Resource;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/25/18
*/
public interface Config {
+ Resource getGitInfo();
+
DmaapConsumerConfiguration getDmaapConsumerConfiguration();
AaiClientConfiguration getAaiClientConfiguration();
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
index 612fab48..85f7e983 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PNF-REGISTRATION-HANDLER
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,18 +20,8 @@
package org.onap.dcaegen2.services.prh.configuration;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.TypeAdapterFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.ServiceLoader;
-import javax.validation.constraints.NotNull;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.gson.*;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
@@ -42,6 +32,14 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
+import org.springframework.util.StreamUtils;
+
+import javax.annotation.PostConstruct;
+import javax.validation.constraints.NotNull;
+import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.ServiceLoader;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
@@ -50,6 +48,7 @@ import org.springframework.core.io.Resource;
@EnableConfigurationProperties
@ConfigurationProperties("app")
public abstract class PrhAppConfig implements Config {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PrhAppConfig.class);
private static final String CONFIG = "configs";
private static final String AAI = "aai";
@@ -59,8 +58,6 @@ public abstract class PrhAppConfig implements Config {
private static final String DMAAP_CONSUMER = "dmaapConsumerConfiguration";
private static final String SECURITY = "security";
- private static final Logger LOGGER = LoggerFactory.getLogger(PrhAppConfig.class);
-
AaiClientConfiguration aaiClientConfiguration;
DmaapConsumerConfiguration dmaapConsumerConfiguration;
@@ -68,7 +65,20 @@ public abstract class PrhAppConfig implements Config {
DmaapPublisherConfiguration dmaapPublisherConfiguration;
@Value("classpath:prh_endpoints.json")
- private Resource resourceFile;
+ private Resource prhEndpoints;
+
+ @Value("classpath:git_info.json")
+ private Resource gitInfo;
+
+ @PostConstruct
+ private void printGitInfo() throws IOException {
+ LOGGER.debug("Git info={}", StreamUtils.copyToString(gitInfo.getInputStream(), Charset.defaultCharset()));
+ }
+
+ @Override
+ public Resource getGitInfo() {
+ return gitInfo;
+ }
@Override
public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
@@ -87,21 +97,19 @@ public abstract class PrhAppConfig implements Config {
@Override
public void initFileStreamReader() {
-
GsonBuilder gsonBuilder = new GsonBuilder();
ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
JsonParser parser = new JsonParser();
- try (InputStream inputStream = resourceFile.getInputStream()) {
+ try (InputStream inputStream = prhEndpoints.getInputStream()) {
JsonElement rootElement = getJsonElement(parser, inputStream);
if (rootElement.isJsonObject()) {
deserializeAaiConfiguration(gsonBuilder, rootElement);
deserializeDmaapConsumerConfiguration(gsonBuilder, rootElement);
deserializeDmaapPublisherConfiguration(gsonBuilder, rootElement);
}
- }
- catch (IOException e) {
- LOGGER.warn("Problem with file loading, file ", e);
+ } catch (IOException e) {
+ LOGGER.warn("Failed to load/parse file", e);
}
}
@@ -109,8 +117,8 @@ public abstract class PrhAppConfig implements Config {
dmaapPublisherConfiguration = deserializeType(gsonBuilder, concatenateJsonObjects(
rootElement.getAsJsonObject().getAsJsonObject(CONFIG).getAsJsonObject(DMAAP)
.getAsJsonObject(DMAAP_PRODUCER),
- rootElement.getAsJsonObject().getAsJsonObject(CONFIG).getAsJsonObject(SECURITY)),
- DmaapPublisherConfiguration.class);
+ rootElement.getAsJsonObject().getAsJsonObject(CONFIG).getAsJsonObject(SECURITY)),
+ DmaapPublisherConfiguration.class);
}
private void deserializeDmaapConsumerConfiguration(GsonBuilder gsonBuilder, JsonElement rootElement) {
@@ -118,7 +126,7 @@ public abstract class PrhAppConfig implements Config {
rootElement.getAsJsonObject().getAsJsonObject(CONFIG).getAsJsonObject(DMAAP)
.getAsJsonObject(DMAAP_CONSUMER),
rootElement.getAsJsonObject().getAsJsonObject(CONFIG).getAsJsonObject(SECURITY)),
- DmaapConsumerConfiguration.class);
+ DmaapConsumerConfiguration.class);
}
private void deserializeAaiConfiguration(GsonBuilder gsonBuilder, JsonElement rootElement) {
@@ -134,22 +142,22 @@ public abstract class PrhAppConfig implements Config {
private JsonObject concatenateJsonObjects(JsonObject target, JsonObject source) {
source.entrySet()
- .forEach(entry -> target.add(entry.getKey(), entry.getValue()));
+ .forEach(entry -> target.add(entry.getKey(), entry.getValue()));
return target;
}
private <T> T deserializeType(@NotNull GsonBuilder gsonBuilder, @NotNull JsonObject jsonObject,
- @NotNull Class<T> type) {
+ @NotNull Class<T> type) {
try {
return gsonBuilder.create().fromJson(jsonObject, type);
- } catch (JsonSyntaxException e) {
- LOGGER.warn("Problem with Json deserialization", e);
+ } catch (JsonSyntaxException e) {
+ LOGGER.warn("Failed to parse JSON={}", jsonObject, e);
return null;
}
}
- void setResourceFile(Resource resourceFile) {
- this.resourceFile = resourceFile;
+ @VisibleForTesting
+ void setPrhEndpoints(Resource prhEndpoints) {
+ this.prhEndpoints = prhEndpoints;
}
-
-} \ No newline at end of file
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/AppInfoController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/AppInfoController.java
new file mode 100644
index 00000000..9a49dee5
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/AppInfoController.java
@@ -0,0 +1,63 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PNF-REGISTRATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.services.prh.controllers;
+
+import io.swagger.annotations.*;
+import org.onap.dcaegen2.services.prh.configuration.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.http.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/19/18
+ */
+@RestController
+@Api(value = "AppInfoController", description = "Provides basic information about application")
+public class AppInfoController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AppInfoController.class);
+ private final Resource gitInfo;
+
+ @Autowired
+ public AppInfoController(Config config) {
+ gitInfo = config.getGitInfo();
+ }
+
+ @GetMapping(value = "heartbeat", produces = MediaType.TEXT_PLAIN_VALUE)
+ @ApiOperation("Returns liveness of PRH service")
+ @ApiResponses(@ApiResponse(code = 200, message = "Service is alive"))
+ public Mono<ResponseEntity<String>> heartbeat() {
+ LOGGER.trace("Heartbeat request received");
+ return Mono.defer(() -> Mono.just(new ResponseEntity<>("alive", HttpStatus.OK))
+ );
+ }
+
+ @GetMapping(value = "version", produces = MediaType.APPLICATION_JSON_VALUE)
+ @ApiOperation("Returns version information")
+ public Mono<Resource> version() {
+ return Mono.defer(() -> Mono.just(gitInfo));
+ }
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
deleted file mode 100644
index c09cc945..00000000
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcaegen2.services.prh.controllers;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-import reactor.core.publisher.Mono;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/19/18
- */
-@RestController
-@Api(value = "HeartbeatController", description = "Check liveness of PRH service")
-public class HeartbeatController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HeartbeatController.class);
-
- /**
- * Endpoint for checking that PRH is alive.
- *
- * @return HTTP Status Code
- */
- @RequestMapping(value = "heartbeat", method = RequestMethod.GET)
- @ApiOperation(value = "Returns liveness of PRH service")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "PRH sevice is living"),
- @ApiResponse(code = 401, message = "You are not authorized to view the resource"),
- @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"),
- @ApiResponse(code = 404, message = "The resource you were trying to reach is not found")
- }
- )
- public Mono<ResponseEntity<String>> heartbeat() {
- LOGGER.trace("Receiving heartbeat request");
- return Mono.defer(() ->
- Mono.just(new ResponseEntity<>("alive", HttpStatus.OK))
- );
- }
-} \ No newline at end of file
diff --git a/prh-app-server/src/main/resources/application.yaml b/prh-app-server/src/main/resources/application.yaml
index 88d1e401..a9a89421 100644
--- a/prh-app-server/src/main/resources/application.yaml
+++ b/prh-app-server/src/main/resources/application.yaml
@@ -9,11 +9,3 @@ server:
key-store: classpath:keystore-local
key-password: nokiapnf
keyAlias: tomcat-localhost
-logging:
- level:
- ROOT: ERROR
- org.onap.dcaegen2.services.prh: INFO
- reactor.ipc.netty.http.client: WARN
- org.springframework: ERROR
- org.springframework.data: ERROR
- org.springframework.web.reactive: WARN
diff --git a/prh-app-server/src/main/resources/logback-spring.xml b/prh-app-server/src/main/resources/logback-spring.xml
index 8f9bfd1c..70908b07 100644
--- a/prh-app-server/src/main/resources/logback-spring.xml
+++ b/prh-app-server/src/main/resources/logback-spring.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
+<configuration debug="false" scan="false">
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<property name="outputFilename" value="prh-app-server_output"/>
<property name="logPath" value="/var/log/ONAP/prh/prh-app-server"/>
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java
index 42acc592..249fccc3 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PNF-REGISTRATION-HANDLER
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +20,6 @@
package org.onap.dcaegen2.services.prh.configuration;
-import static java.lang.ClassLoader.getSystemResource;
-import static java.nio.file.Files.readAllBytes;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Paths;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -38,11 +27,18 @@ import org.onap.dcaegen2.services.prh.integration.junit5.mockito.MockitoExtensio
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
+import java.io.*;
+import java.nio.file.Paths;
+
+import static java.lang.ClassLoader.getSystemResource;
+import static java.nio.file.Files.readAllBytes;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
*/
-@ExtendWith({MockitoExtension.class})
+@ExtendWith({ MockitoExtension.class })
class PrhAppConfigTest {
private static final String CORRECT_CONFIG_FILE = "correct_config.json";
@@ -58,7 +54,7 @@ class PrhAppConfigTest {
@Test
void whenTheConfigurationFits() throws Exception {
InputStream inputStream = createInputStream(CORRECT_CONFIG_FILE);
- appConfig.setResourceFile(new InputStreamResource(inputStream));
+ appConfig.setPrhEndpoints(new InputStreamResource(inputStream));
appConfig.initFileStreamReader();
assertNotNull(appConfig.getDmaapConsumerConfiguration());
@@ -71,7 +67,7 @@ class PrhAppConfigTest {
InputStream inputStream = createInputStream(CORRECT_CONFIG_FILE);
Resource resource = spy(new InputStreamResource(inputStream));
when(resource.getInputStream()).thenThrow(new IOException());
- appConfig.setResourceFile(resource);
+ appConfig.setPrhEndpoints(resource);
appConfig.initFileStreamReader();
assertNull(appConfig.getAaiClientConfiguration());
@@ -82,7 +78,7 @@ class PrhAppConfigTest {
@Test
void whenFileExistsButDmaapPublisherJsonConfigurationIsIncorrect() throws Exception {
InputStream inputStream = createInputStream(INCORRECT_CONFIG_FILE);
- appConfig.setResourceFile(new InputStreamResource(inputStream));
+ appConfig.setPrhEndpoints(new InputStreamResource(inputStream));
appConfig.initFileStreamReader();
assertNotNull(appConfig.getAaiClientConfiguration());
@@ -93,7 +89,7 @@ class PrhAppConfigTest {
@Test
void whenRootElementIsNotAJsonObject() throws Exception {
InputStream inputStream = createInputStream(NOT_JSON_OBJECT_FILE);
- appConfig.setResourceFile(new InputStreamResource(inputStream));
+ appConfig.setPrhEndpoints(new InputStreamResource(inputStream));
appConfig.initFileStreamReader();
@@ -105,4 +101,4 @@ class PrhAppConfigTest {
private InputStream createInputStream(String jsonFile) throws Exception {
return new ByteArrayInputStream(readAllBytes(Paths.get(getSystemResource(jsonFile).toURI())));
}
-} \ No newline at end of file
+}
diff --git a/prh-commons/pom.xml b/prh-commons/pom.xml
index 65f3a3a3..9043d914 100644
--- a/prh-commons/pom.xml
+++ b/prh-commons/pom.xml
@@ -1,4 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ PNF-REGISTRATION-HANDLER
+ ~ ================================================================================
+ ~ Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
+ ~ ================================================================================
+ ~ 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.
+ ~ ============LICENSE_END=========================================================
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -14,20 +33,12 @@
<artifactId>prh-commons</artifactId>
<packaging>jar</packaging>
-
<dependencies>
<dependency>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
<artifactId>common-dependency</artifactId>
</dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
@@ -43,13 +54,12 @@
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
- <version>${immutables.version}</version>
</dependency>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>gson</artifactId>
- <version>${immutables.version}</version>
</dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
diff --git a/swagger.yaml b/swagger.yaml
deleted file mode 100644
index 37040bc8..00000000
--- a/swagger.yaml
+++ /dev/null
@@ -1,76 +0,0 @@
----
-swagger: '2.0'
-info:
- description: This page lists all the rest apis for PRH app server.
- version: '1.0'
- title: PRH app server
-host: localhost:8100
-basePath: "/"
-tags:
-- name: heartbeat-controller
- description: Check liveness of PRH service
-- name: schedule-controller
- description: Schedule Controller
-paths:
- "/heartbeat":
- get:
- tags:
- - heartbeat-controller
- summary: Returns liveness of PRH service
- operationId: heartbeatUsingGET
- produces:
- - "*/*"
- responses:
- '200':
- description: PRH sevice is living
- schema:
- "$ref": "#/definitions/Mono«ResponseEntity«string»»"
- '401':
- description: You are not authorized to view the resource
- '403':
- description: Accessing the resource you were trying to reach is forbidden
- '404':
- description: The resource you were trying to reach is not found
- "/start":
- get:
- tags:
- - schedule-controller
- summary: Start scheduling worker request
- operationId: startTasksUsingGET
- produces:
- - "*/*"
- responses:
- '200':
- description: OK
- schema:
- "$ref": "#/definitions/Mono«ResponseEntity«string»»"
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- "/stopPrh":
- get:
- tags:
- - schedule-controller
- summary: Stop scheduling worker request
- operationId: stopTaskUsingGET
- produces:
- - "*/*"
- responses:
- '200':
- description: OK
- schema:
- "$ref": "#/definitions/Mono«ResponseEntity«string»»"
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
-definitions:
- Mono«ResponseEntity«string»»:
- type: object
- title: Mono«ResponseEntity«string»»
-