summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/model-impl')
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java16
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java7
-rw-r--r--controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java12
-rw-r--r--controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java12
-rw-r--r--controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java20
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java6
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java23
7 files changed, 56 insertions, 40 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 b079122e4..fd999fb5f 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
@@ -48,13 +48,13 @@ public final class AAINQF199Manager {
Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
if (httpDetails == null) {
- System.out.println("AAI POST Null Response to " + url);
+ logger.debug("AAI POST Null Response to {}", url);
return null;
}
- System.out.println(url);
- System.out.println(httpDetails.a);
- System.out.println(httpDetails.b);
+ logger.debug(url);
+ logger.debug("{}", httpDetails.a);
+ logger.debug("{}", httpDetails.b);
if (httpDetails.a == 200) {
try {
AAINQF199Response response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQF199Response.class);
@@ -83,13 +83,13 @@ public final class AAINQF199Manager {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
if (httpDetailsGet == null) {
- System.out.println("AAI GET Null Response to " + urlGet);
+ logger.debug("AAI GET Null Response to {}", urlGet);
return null;
}
- System.out.println(urlGet);
- System.out.println(httpDetailsGet.a);
- System.out.println(httpDetailsGet.b);
+ logger.debug(urlGet);
+ logger.debug("{}", httpDetailsGet.a);
+ logger.debug("{}", httpDetailsGet.b);
if (httpDetailsGet.a == 200) {
try {
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 9e6d1afc0..9578d9ac2 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
@@ -27,6 +27,8 @@ import java.time.format.DateTimeFormatter;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -38,10 +40,12 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+
public final class Serialization {
public static class notificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
+
@Override
public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
JsonSerializationContext context) {
@@ -73,6 +77,7 @@ public final class Serialization {
}
public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
@@ -80,7 +85,7 @@ public final class Serialization {
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (Exception e) {
- System.err.println(e);
+ logger.error(e.getMessage(), e);
}
return null;
}
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 9f4fe5bbc..c23935586 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
@@ -60,8 +60,8 @@ public final class MSOManager {
MSOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, MSOResponse.class);
String body = Serialization.gsonPretty.toJson(response);
- System.out.println("***** Response to post:");
- System.out.println(body);
+ logger.debug("***** Response to post:");
+ logger.debug(body);
String requestId = response.requestReferences.requestId;
int attemptsLeft = 20;
@@ -75,24 +75,26 @@ public final class MSOManager {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, MSOResponse.class);
body = Serialization.gsonPretty.toJson(responseGet);
- System.out.println("***** Response to get:");
- System.out.println(body);
+ logger.debug("***** Response to get:");
+ logger.debug(body);
if(httpDetailsGet.a == 200){
if(responseGet.request.requestStatus.requestState.equalsIgnoreCase("COMPLETE") ||
responseGet.request.requestStatus.requestState.equalsIgnoreCase("FAILED")){
- System.out.println("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState);
+ logger.debug("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState);
return responseGet;
}
}
Thread.sleep(20000);
}
+
if (responseGet != null
&& responseGet.request != null
&& responseGet.request.requestStatus != null
&& responseGet.request.requestStatus.requestState != null) {
logger.warn("***** ######## VF Module Creation timeout. Status: ( {})", responseGet.request.requestStatus.requestState);
}
+
return responseGet;
} catch (JsonSyntaxException e) {
logger.error("Failed to deserialize into MSOResponse: ", e);
diff --git a/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java b/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java
index c840894e8..2c8253f0b 100644
--- a/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java
+++ b/controlloop/common/model-impl/mso/src/test/java/org/onap/policy/mso/TestDemo.java
@@ -33,9 +33,11 @@ import org.onap.policy.mso.MSORequestDetails;
import org.onap.policy.mso.MSORequestInfo;
import org.onap.policy.mso.MSORequestParameters;
import org.onap.policy.mso.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
@Test
public void test() {
@@ -102,19 +104,19 @@ public class TestDemo {
request.requestDetails.requestParameters.userParams.add(userParam2);
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
//MSOResponse response = MSOManager.createModuleInstance("http://localhost:7780/", "my_username", "my_passwd", request);
//body = Serialization.gsonPretty.toJson(response);
- //System.out.println(body);
+ //logger.debug(body);
}
@Test
public void testHack() {
- System.out.println("** HACK **");
+ logger.debug("** HACK **");
MSORequest request = new MSORequest();
//
@@ -166,7 +168,7 @@ public class TestDemo {
request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
}
}
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 c38c1076c..9ea480981 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
@@ -55,14 +55,14 @@ public final class RESTManager {
CredentialsProvider credentials = new BasicCredentialsProvider();
credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
- System.out.println("HTTP REQUEST: " + url + " -> " + username + ((password!=null)?password.length():"-") + " -> " + contentType);
+ logger.debug("HTTP REQUEST: {} -> {} {} -> {}", url, username, ((password!=null)?password.length():"-"), contentType);
if (headers != null) {
- System.out.println("Headers: ");
+ logger.debug("Headers: ");
headers.forEach((name, value) -> {
- System.out.println(name + " -> " + value);
+ logger.debug("{} -> {}", name, value);
});
}
- System.out.println(body);
+ logger.debug(body);
try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
@@ -81,9 +81,9 @@ public final class RESTManager {
HttpResponse response = client.execute(post);
String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- System.out.println("HTTP POST Response Status Code: " + response.getStatusLine().getStatusCode());
- System.out.println("HTTP POST Response Body:");
- System.out.println(returnBody);
+ logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP POST Response Body:");
+ logger.debug(returnBody);
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
@@ -111,8 +111,10 @@ public final class RESTManager {
HttpResponse response = client.execute(get);
String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- logger.debug("HTTP GET Response Status Code: " + response.getStatusLine().getStatusCode());
- logger.debug("HTTP GET Response Body: " + returnBody);
+
+ logger.debug("HTTP GET Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP GET Response Body:");
+ logger.debug(returnBody);
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
diff --git a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
index 656234ca2..4b3599d43 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java
@@ -26,9 +26,11 @@ import org.onap.policy.vnf.trafficgenerator.PGRequest;
import org.onap.policy.vnf.trafficgenerator.PGStream;
import org.onap.policy.vnf.trafficgenerator.PGStreams;
import org.onap.policy.vnf.trafficgenerator.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
@Test
public void test() {
PGRequest request = new PGRequest();
@@ -43,7 +45,7 @@ public class TestDemo {
}
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
// fail("Not yet implemented");
}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
index 44f9905b2..0aade0744 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
@@ -24,6 +24,8 @@ import java.util.Map;
import org.onap.policy.vfc.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;
@@ -33,7 +35,8 @@ public final class VFCManager implements Runnable {
private String username;
private String password;
private VFCRequest vfcRequest;
-
+ private static final Logger logger = LoggerFactory.getLogger(VFCManager.class);
+
public VFCManager(VFCRequest request) {
vfcRequest = request;
// TODO: Get base URL, username and password from MSB?
@@ -67,8 +70,8 @@ public final class VFCManager implements Runnable {
VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
String body = Serialization.gsonPretty.toJson(response);
- System.out.println("Response to VFC Heal post:");
- System.out.println(body);
+ logger.debug("Response to VFC Heal post:");
+ logger.debug(body);
String jobId = response.jobId;
int attemptsLeft = 20;
@@ -81,27 +84,27 @@ public final class VFCManager implements Runnable {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class);
body = Serialization.gsonPretty.toJson(responseGet);
- System.out.println("Response to VFC Heal get:");
- System.out.println(body);
+ logger.debug("Response to VFC Heal get:");
+ logger.debug(body);
if (httpDetailsGet.a == 200) {
if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") ||
responseGet.responseDescriptor.status.equalsIgnoreCase("error")) {
- System.out.println("VFC Heal Status " + responseGet.responseDescriptor.status);
+ logger.debug("VFC Heal Status {}", responseGet.responseDescriptor.status);
break;
}
}
Thread.sleep(20000);
}
if (attemptsLeft <= 0)
- System.out.println("VFC timeout. Status: (" + responseGet.responseDescriptor.status + ")");
+ logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status);
} catch (JsonSyntaxException e) {
- System.err.println("Failed to deserialize into VFCResponse" + e.getLocalizedMessage());
+ logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e);
} catch (InterruptedException e) {
- System.err.println("Interrupted exception: " + e.getLocalizedMessage());
+ logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e);
}
} else {
- System.out.println("VFC Heal Restcall failed");
+ logger.warn("VFC Heal Restcall failed");
}
}
}