summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-09-04 09:38:35 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-09-04 09:38:35 +0200
commit3737046ff3c8e032257b257912778403fc058ee0 (patch)
tree0a0b5ea8c88f822ba8e94b6904b0ef9e77e6614e /prh-app-server/src/main
parent83df6e1df5ec20627c85af9ba2f49036dd58f328 (diff)
Clear warnings in sysout Fix:
*Checkstyle violations *Sonar Issues *FindBugs Issues Change-Id: Ie634fa6644cdbdb1f952826a75c6a4ffeabe0cbf Issue-ID: DCAEGEN2-606 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java5
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java12
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java16
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java29
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java12
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java11
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java14
10 files changed, 53 insertions, 52 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java
index fdf6847b..114e9839 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java
@@ -20,6 +20,8 @@
package org.onap.dcaegen2.services.prh.configuration;
+import java.util.Optional;
+import java.util.Properties;
import org.onap.dcaegen2.services.prh.exceptions.EnvironmentLoaderException;
import org.onap.dcaegen2.services.prh.model.EnvProperties;
import org.onap.dcaegen2.services.prh.model.ImmutableEnvProperties;
@@ -27,9 +29,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;
-import java.util.Optional;
-import java.util.Properties;
-
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
*/
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 92574417..03d24382 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
@@ -20,8 +20,8 @@
package org.onap.dcaegen2.services.prh.configuration;
-import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.INVOCATION_ID;
-import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.REQUEST_ID;
+import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.INVOCATION_ID;
+import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.REQUEST_ID;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
@@ -141,11 +141,11 @@ public abstract class PrhAppConfig implements Config {
this.filepath = filepath;
}
- public void setXOnapRequestId(String xOnapRequestId) {
- MDC.put(REQUEST_ID, xOnapRequestId);
+ public void setXOnapRequestId(String xonaprequestid) {
+ MDC.put(REQUEST_ID, xonaprequestid);
}
- public void setXInvocationId(String xInvocationId) {
- MDC.put(INVOCATION_ID, xInvocationId);
+ public void setXInvocationId(String xinvocationid) {
+ MDC.put(INVOCATION_ID, xinvocationid);
}
} \ No newline at end of file
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
index 214d6db6..76ba5ec6 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
@@ -21,6 +21,12 @@
package org.onap.dcaegen2.services.prh.configuration;
import io.swagger.annotations.ApiOperation;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ScheduledFuture;
+import javax.annotation.PostConstruct;
import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,12 +40,6 @@ import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import reactor.core.publisher.Mono;
-import javax.annotation.PostConstruct;
-import java.time.Duration;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ScheduledFuture;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 6/13/18
@@ -60,8 +60,8 @@ public class SchedulerConfig {
@Autowired
public SchedulerConfig(TaskScheduler taskScheduler,
- ScheduledTasks scheduledTask,
- CloudConfiguration cloudConfiguration) {
+ ScheduledTasks scheduledTask,
+ CloudConfiguration cloudConfiguration) {
this.taskScheduler = taskScheduler;
this.scheduledTask = scheduledTask;
this.cloudConfiguration = cloudConfiguration;
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
index 1b2f4a11..c09cc945 100644
--- 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
@@ -54,7 +54,7 @@ public class HeartbeatController {
@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");
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
index a5ecc1dd..4e34f6e6 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
@@ -23,6 +23,8 @@ package org.onap.dcaegen2.services.prh.service;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import java.util.Optional;
+import java.util.stream.StreamSupport;
import org.onap.dcaegen2.services.prh.exceptions.DmaapEmptyResponseException;
import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
@@ -30,9 +32,6 @@ import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Mono;
-import java.util.Optional;
-import java.util.stream.StreamSupport;
-
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18
*/
@@ -88,21 +87,21 @@ public class DmaapConsumerJsonParser {
private Mono<ConsumerDmaapModel> transform(JsonObject responseFromDmaap) {
JsonObject commonEventHeader = responseFromDmaap.getAsJsonObject(EVENT)
- .getAsJsonObject(COMMON_EVENT_HEADER);
+ .getAsJsonObject(COMMON_EVENT_HEADER);
JsonObject pnfRegistrationFields = responseFromDmaap.getAsJsonObject(EVENT)
- .getAsJsonObject(PNF_REGISTRATION_FIELDS);
+ .getAsJsonObject(PNF_REGISTRATION_FIELDS);
String pnfSourceName = getValueFromJson(commonEventHeader, SOURCE_NAME);
String pnfOamIpv4Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_4_ADDRESS);
String pnfOamIpv6Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_6_ADDRESS);
- return ( StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address) )
- ? Mono.error(new DmaapNotFoundException("Incorrect json, consumerDmaapModel can not be created: "
- + printMessage(pnfSourceName, pnfOamIpv4Address, pnfOamIpv6Address))) :
- Mono.just(ImmutableConsumerDmaapModel.builder()
- .sourceName(pnfSourceName)
- .ipv4(pnfOamIpv4Address)
- .ipv6(pnfOamIpv6Address).build());
+ return (StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address))
+ ? Mono.error(new DmaapNotFoundException("Incorrect json, consumerDmaapModel can not be created: "
+ + printMessage(pnfSourceName, pnfOamIpv4Address, pnfOamIpv6Address))) :
+ Mono.just(ImmutableConsumerDmaapModel.builder()
+ .sourceName(pnfSourceName)
+ .ipv4(pnfOamIpv4Address)
+ .ipv6(pnfOamIpv6Address).build());
}
private String getValueFromJson(JsonObject jsonObject, String jsonKey) {
@@ -119,9 +118,9 @@ public class DmaapConsumerJsonParser {
private String printMessage(String sourceName, String oamIpv4Address, String oamIpv6Address) {
return String.format("%n{"
- + "\"" + SOURCE_NAME + "\": \"%s\","
- + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\","
- + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\""
+ + "\"" + SOURCE_NAME + "\": \"%s\","
+ + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\","
+ + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\""
+ "%n}", sourceName, oamIpv4Address, oamIpv6Address);
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java
index 4f66e25c..e3a8dcf6 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java
@@ -46,7 +46,7 @@ class HttpGetClient {
this.gson = new Gson();
}
- <T> Mono<T> callHttpGet(String url, Class<T> tClass) {
+ <T> Mono<T> callHttpGet(String url, Class<T> genericClassDeclaration) {
return webClient
.get()
.uri(url)
@@ -54,7 +54,7 @@ class HttpGetClient {
.onStatus(HttpStatus::is4xxClientError, response -> Mono.error(getException(response)))
.onStatus(HttpStatus::is5xxServerError, response -> Mono.error(getException(response)))
.bodyToMono(String.class)
- .flatMap(body -> getJsonFromRequest(body, tClass));
+ .flatMap(body -> getJsonFromRequest(body, genericClassDeclaration));
}
private RuntimeException getException(ClientResponse response) {
@@ -62,16 +62,16 @@ class HttpGetClient {
response.statusCode().value()));
}
- private <T> Mono<T> getJsonFromRequest(String body, Class<T> tClass) {
+ private <T> Mono<T> getJsonFromRequest(String body, Class<T> genericClassDeclaration) {
try {
- return Mono.just(parseJson(body, tClass));
+ return Mono.just(parseJson(body, genericClassDeclaration));
} catch (JsonSyntaxException | IllegalStateException e) {
return Mono.error(e);
}
}
- private <T> T parseJson(String body, Class<T> tClass) {
- return gson.fromJson(body, tClass);
+ private <T> T parseJson(String body, Class<T> genericClassDeclaration) {
+ return gson.fromJson(body, genericClassDeclaration);
}
private static ExchangeFilterFunction logResponse() {
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java
index b346bf5e..414c5a34 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java
@@ -22,6 +22,7 @@ package org.onap.dcaegen2.services.prh.service;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+import java.net.URISyntaxException;
import org.apache.http.client.utils.URIBuilder;
import org.onap.dcaegen2.services.prh.model.EnvProperties;
import org.slf4j.Logger;
@@ -29,7 +30,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
-import java.net.URISyntaxException;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
@@ -59,7 +59,7 @@ public class PrhConfigurationProvider {
LOGGER.info("Retrieving Config Binding Service endpoint from Consul");
try {
return httpGetClient.callHttpGet(getConsulUrl(envProperties), JsonArray.class)
- .flatMap(jsonArray -> this.createConfigBindingServiceURL(jsonArray, envProperties.appName()));
+ .flatMap(jsonArray -> this.createConfigBindingserviceurl(jsonArray, envProperties.appName()));
} catch (URISyntaxException e) {
LOGGER.warn("Malformed Consul uri", e);
return Mono.error(e);
@@ -77,11 +77,12 @@ public class PrhConfigurationProvider {
}
- private Mono<String> createConfigBindingServiceURL(JsonArray jsonArray, String appName) {
- return getConfigBindingObject(jsonArray).flatMap(jsonObject -> buildConfigBindingServiceURL(jsonObject, appName));
+ private Mono<String> createConfigBindingserviceurl(JsonArray jsonArray, String appName) {
+ return getConfigBindingObject(jsonArray)
+ .flatMap(jsonObject -> buildConfigBindingserviceurl(jsonObject, appName));
}
- private Mono<String> buildConfigBindingServiceURL(JsonObject jsonObject, String appName) {
+ private Mono<String> buildConfigBindingserviceurl(JsonObject jsonObject, String appName) {
try {
return Mono.just(getUri(jsonObject.get("ServiceAddress").getAsString(),
jsonObject.get("ServicePort").getAsInt(), "/service_component", appName));
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
index 5a05d374..efa4f66f 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
@@ -20,6 +20,7 @@
package org.onap.dcaegen2.services.prh.tasks;
+import javax.net.ssl.SSLException;
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
@@ -29,7 +30,6 @@ import org.onap.dcaegen2.services.prh.service.producer.AaiProducerReactiveHttpCl
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
-import javax.net.ssl.SSLException;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
index 7ccf75a6..5bf3e408 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
@@ -20,6 +20,7 @@
package org.onap.dcaegen2.services.prh.tasks;
+import javax.net.ssl.SSLException;
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException;
@@ -36,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
-import javax.net.ssl.SSLException;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
index f74bc56a..728c0dae 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
@@ -20,8 +20,9 @@
package org.onap.dcaegen2.services.prh.tasks;
-import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.INSTANCE_UUID;
-import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.RESPONSE_CODE;
+
+import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.INSTANCE_UUID;
+import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.RESPONSE_CODE;
import java.util.Map;
import java.util.UUID;
@@ -30,7 +31,7 @@ import javax.net.ssl.SSLException;
import org.onap.dcaegen2.services.prh.exceptions.DmaapEmptyResponseException;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.services.prh.model.logging.MDCVariables;
+import org.onap.dcaegen2.services.prh.model.logging.MdcVariables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -71,7 +72,7 @@ public class ScheduledTasks {
* Main function for scheduling prhWorkflow.
*/
public void scheduleMainPrhEventTask() {
- MDCVariables.setMdcContextMap(contextMap);
+ MdcVariables.setMdcContextMap(contextMap);
try {
logger.trace("Execution of tasks was registered");
CountDownLatch mainCountDownLatch = new CountDownLatch(1);
@@ -86,7 +87,8 @@ public class ScheduledTasks {
mainCountDownLatch.await();
} catch (InterruptedException e) {
- throw new RuntimeException(e);
+ logger.warn("Interruption problem on countDownLatch ", e);
+ Thread.currentThread().interrupt();
}
}
@@ -110,7 +112,7 @@ public class ScheduledTasks {
private Mono<ConsumerDmaapModel> consumeFromDMaaPMessage() {
return Mono.defer(() -> {
- MDCVariables.setMdcContextMap(contextMap);
+ MdcVariables.setMdcContextMap(contextMap);
MDC.put(INSTANCE_UUID, UUID.randomUUID().toString());
logger.info("Init configs");
dmaapConsumerTask.initConfigs();