aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-16 15:21:15 -0500
committerMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-18 14:40:18 -0500
commit6d7e231986b84cf6646e46beba7e7e05699bffe6 (patch)
treee08ebda96bc5797d64dd66e667303cf55ad87491 /controlloop/common/model-impl
parent5ae90a9bf72d2d6dbb163c3dbea5474b657be7e7 (diff)
Code cleanup to resolve critical sonar issues
Code cleanup mostly involed directing the output of exception messages to the correct logger stream. Issue-ID: [POLICY-115] Change-Id: I2042bac3d3b0991a2ebed33421a73f1aa300c7c1 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'controlloop/common/model-impl')
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java7
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java10
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java2
-rw-r--r--controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java8
-rw-r--r--controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java9
5 files changed, 26 insertions, 10 deletions
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
index e02021a43..b079122e4 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
@@ -28,10 +28,13 @@ import org.onap.policy.aai.AAIGETResponse;
import org.onap.policy.aai.util.Serialization;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.JsonSyntaxException;
public final class AAINQF199Manager {
+ private static final Logger logger = LoggerFactory.getLogger(AAINQF199Manager.class);
public static AAINQF199Response postQuery(String url, String username, String password, AAINQF199Request request, UUID requestID) {
@@ -57,7 +60,7 @@ public final class AAINQF199Manager {
AAINQF199Response response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQF199Response.class);
return response;
} catch (JsonSyntaxException e) {
- System.err.println("Failed to deserialize into AAIResponse" + e.getLocalizedMessage());
+ logger.error("postQuery threw: ", e);
}
}
@@ -93,7 +96,7 @@ public final class AAINQF199Manager {
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETResponse.class);
return responseGet;
} catch (JsonSyntaxException e) {
- System.err.println("Failed to deserialize into AAIResponse" + e.getLocalizedMessage());
+ logger.error("getQuery threw: ", e);
}
}
try {
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
index 8a801c32b..be7a66ada 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
@@ -25,6 +25,9 @@ import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
@@ -37,16 +40,17 @@ import com.google.gson.JsonSerializer;
public final class Serialization {
- public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+ public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
-
+ private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
+
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
throws JsonParseException {
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (Exception e) {
- System.err.println(e);
+ logger.error("deserialize threw: ", e);
}
return null;
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
index a45947733..9e6d1afc0 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -73,7 +73,7 @@ public final class Serialization {
}
public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
- public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+ public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
throws JsonParseException {
diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java
index 79725901a..81d43ef76 100644
--- a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java
+++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java
@@ -26,11 +26,15 @@ import java.util.Map;
import org.onap.policy.mso.util.Serialization;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.JsonSyntaxException;
public final class MSOManager {
+ private static final Logger logger = LoggerFactory.getLogger(MSOManager.class);
+
public static MSOResponse createModuleInstance(String url, String urlBase, String username, String password, MSORequest request) {
//
@@ -87,9 +91,9 @@ public final class MSOManager {
System.out.println("***** ######## VF Module Creation timeout. Status: ("+responseGet.request.requestStatus.requestState+")");
return responseGet;
} catch (JsonSyntaxException e) {
- System.err.println("Failed to deserialize into MSOResponse" + e.getLocalizedMessage());
+ logger.error("Failed to deserialize into MSOResponse: ", e);
} catch (InterruptedException e) {
- System.err.println("Interrupted exception: " + e.getLocalizedMessage());
+ logger.error("Interrupted exception: ", e);
}
}
diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
index e42ab1693..8c79d2ad3 100644
--- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
+++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
@@ -34,9 +34,13 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class RESTManager {
+ private static final Logger logger = LoggerFactory.getLogger(RESTManager.class);
+
public static class Pair<A, B> {
public final A a;
public final B b;
@@ -81,7 +85,8 @@ public final class RESTManager {
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
- System.err.println("Failed to POST to " + url + e.getLocalizedMessage());
+ logger.error("Failed to POST to {}",url,e);
+
return null;
}
@@ -108,7 +113,7 @@ public final class RESTManager {
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
- System.err.println("Failed to GET to " + url + e.getLocalizedMessage());
+ logger.error("Failed to GET to {}",url,e);
return null;
}
}