summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorTony Hansen <tony@att.com>2021-08-25 16:57:23 +0000
committerGerrit Code Review <gerrit@onap.org>2021-08-25 16:57:23 +0000
commit11a5507a9754d3259b8daf1b37e1fb763ad53318 (patch)
tree91f730151346953221433d9b06d0525b2b0c2fea /src/main
parentc5d694f1c7b34188bb257ca5db87378716cd2e5b (diff)
parent27866180d7fa5444878209c93b95ae8b2c1fcdf1 (diff)
Merge "Fix sonar issues in PM Mapper"
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/App.java3
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/config/FilesProcessingConfig.java12
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerResource.java7
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java2
-rw-r--r--src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasFilterConfigAdapter.java3
5 files changed, 17 insertions, 10 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java
index b020837..9cfddf0 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
* Copyright (C) 2021 Nokia.
+ * Copyright (C) 2021 Samsung Electronics.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -211,7 +212,7 @@ public class App {
private boolean isCached(String id) {
boolean isPresent = eventsCache.contains(id);
if(isPresent) {
- logger.unwrap().info("Skipping. This event is already waiting in cache to be processed: " + id);
+ logger.unwrap().info("Skipping. This event is already waiting in cache to be processed: {}", id);
}
return isPresent;
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/FilesProcessingConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/FilesProcessingConfig.java
index c79f059..e4fd0b2 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/FilesProcessingConfig.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/FilesProcessingConfig.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nokia.
+ * Copyright (C) 2021 Samsung Electronics.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +36,7 @@ public class FilesProcessingConfig {
private static final int DEFAULT_LIMIT_RATE = 1;
private static final String ENV_THREADS_MULTIPLIER = "THREADS_MULTIPLIER";
private static final String ENV_PROCESSING_THREADS_COUNT = "PROCESSING_THREADS_COUNT";
+ private static final String ENV_VARIABLE_INCORRECT_MSG = " environment variable has incorrect value.\n";
private static final int DEFAULT_MULTIPLIER = 1;
private static final ONAPLogAdapter logger = new ONAPLogAdapter(
@@ -61,7 +63,7 @@ public class FilesProcessingConfig {
.orElseGet(this::getDefaultLimitRate);
} catch (NumberFormatException exception) {
throw new EnvironmentConfigException(
- ENV_LIMIT_RATE + " environment variable has incorrect value.\n"
+ ENV_LIMIT_RATE + ENV_VARIABLE_INCORRECT_MSG
, exception);
}
}
@@ -88,7 +90,7 @@ public class FilesProcessingConfig {
private Integer parseIntegerValue(String val) throws NumberFormatException {
Integer value = Integer.valueOf(val);
- logger.unwrap().info(ENV_LIMIT_RATE + " value is: " + value);
+ logger.unwrap().info(ENV_LIMIT_RATE + " value is: {}", value);
return value;
}
@@ -104,7 +106,7 @@ public class FilesProcessingConfig {
.orElseGet(this::getDefaultMultiplier);
} catch (NumberFormatException exception) {
throw new EnvironmentConfigException(
- ENV_THREADS_MULTIPLIER + " environment variable has incorrect value.\n", exception);
+ ENV_THREADS_MULTIPLIER + ENV_VARIABLE_INCORRECT_MSG, exception);
}
}
@@ -121,14 +123,14 @@ public class FilesProcessingConfig {
.orElseGet(this::getDefaultThreadsCount);
} catch (NumberFormatException exception) {
throw new EnvironmentConfigException(
- ENV_PROCESSING_THREADS_COUNT + " environment variable has incorrect value.\n", exception);
+ ENV_PROCESSING_THREADS_COUNT + ENV_VARIABLE_INCORRECT_MSG, exception);
}
}
private int getDefaultThreadsCount() {
int defaultThreadsCount = Runtime.getRuntime().availableProcessors();
logger.unwrap().info(ENV_PROCESSING_THREADS_COUNT +
- " env not present. Setting threads count to available cores: " + defaultThreadsCount);
+ " env not present. Setting threads count to available cores: {}", defaultThreadsCount);
return defaultThreadsCount;
}
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerResource.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerResource.java
index 5c15280..ec71bdc 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerResource.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerResource.java
@@ -2,6 +2,7 @@
* -
* * ============LICENSE_START=======================================================
* * Copyright (C) 2019 Nordix Foundation.
+ * * Copyright (C) 2021 Samsung Electronics.
* * ================================================================================
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
@@ -32,19 +33,21 @@ public abstract class ServerResource implements HttpHandler {
/**
* Creates a new server resource with a custom method and endpoint.
+ *
* @param httpMethod Method that the resource should be accessible by.
* @param endpointTemplate Endpoint that the resource should be accessible by.
*/
- public ServerResource(String httpMethod, String endpointTemplate) {
+ protected ServerResource(String httpMethod, String endpointTemplate) {
this.httpMethod = httpMethod;
this.endpointTemplate = endpointTemplate;
}
/**
* Creates a new server resource with a custom endpoint and method 'get'.
+ *
* @param endpointTemplate Endpoint that the resource should be accessible by.
*/
- public ServerResource(String endpointTemplate) {
+ protected ServerResource(String endpointTemplate) {
this.httpMethod = GET_STRING;
this.endpointTemplate = endpointTemplate;
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java
index 2b81c0a..e7c317d 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/ssl/SSLContextFactory.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2021 Samsung Electronics.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +43,6 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
-import java.util.Base64;
import static java.nio.file.Files.readAllBytes;
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasFilterConfigAdapter.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasFilterConfigAdapter.java
index 1826707..a7dfab1 100644
--- a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasFilterConfigAdapter.java
+++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasFilterConfigAdapter.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2021 Samsung Electronics.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +43,7 @@ public class MeasFilterConfigAdapter extends TypeAdapter<MeasFilterConfig> {
@Override
public MeasFilterConfig read(JsonReader jsonReader) throws IOException {
- JsonElement rootElement = new JsonParser().parse(jsonReader);
+ JsonElement rootElement = JsonParser.parseReader(jsonReader);
if (rootElement.isJsonObject()) {
logger.unwrap().debug("Reading filter as an object.");
return new Gson().fromJson(rootElement, MeasFilterConfig.class);