Added log output to multiple drools applications. 93/19793/2
authorMagnusen, Drew (dm741q) <dm741q@att.com>
Thu, 19 Oct 2017 19:26:32 +0000 (14:26 -0500)
committerMagnusen, Drew (dm741q) <dm741q@att.com>
Fri, 20 Oct 2017 16:09:04 +0000 (11:09 -0500)
Added logger statments to network.log for AAI, SO,
PDPX Guard, and VFC for all inbound/outbound traffic.

Issue-Id: POLICY-356
Change-Id: I802d45d8136f987b4304baa8f17e166b1c8df165
Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
controlloop/common/model-impl/aai/pom.xml
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java
controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java

index 0ecfaa6..b24cc39 100644 (file)
@@ -51,6 +51,8 @@ public class PolicyGuardXacmlHelper {
 
        private static final Logger logger = LoggerFactory
                        .getLogger(PolicyGuardXacmlHelper.class);
+       
+       private static final Logger netLogger = LoggerFactory.getLogger(org.onap.policy.drools.event.comm.Topic.NETWORK_LOGGER);
 
        public PolicyGuardXacmlHelper() {
                init(PolicyEngine.manager.getEnvironment());
@@ -108,10 +110,12 @@ public class PolicyGuardXacmlHelper {
                        //
                        // Call RESTful PDP
                        //
+                       netLogger.info("[OUT|{}|{}|]{}{}", "GUARD", urlEntry.restURL, System.lineSeparator(), jsonReq.toString());
                        response = callRESTfulPDP(new ByteArrayInputStream(jsonReq
                                        .toString().getBytes()), urlEntry.restURL,
                                        urlEntry.authorization, urlEntry.clientAuth,
                                        urlEntry.environment);
+                       netLogger.info("[IN|{}{}|]{}{}", "GUARD", urlEntry.restURL, System.lineSeparator(), response);
                } catch (Exception e) {
                        logger.error("Error in sending RESTful request: ", e);
                }
index dcf6f37..04bd9fe 100644 (file)
                        <version>4.12</version>
                        <scope>test</scope>
                </dependency>
+               <dependency>
+                       <groupId>org.onap.policy.drools-pdp</groupId>
+                       <artifactId>policy-endpoints</artifactId>
+                       <version>1.1.0-SNAPSHOT</version>
+                       <scope>provided</scope>
+               </dependency>
        </dependencies>
 </project>
index b295a06..6a0fb3a 100644 (file)
@@ -34,6 +34,7 @@ import com.google.gson.JsonSyntaxException;
 
 public final class AAIManager {
        private static final Logger logger = LoggerFactory.getLogger(AAIManager.class);
+       private static final Logger netLogger = LoggerFactory.getLogger(org.onap.policy.drools.event.comm.Topic.NETWORK_LOGGER);
        
        public static AAINQResponse     postQuery(String url, String username, String password, AAINQRequest request, UUID requestID) {
                
@@ -44,8 +45,10 @@ public final class AAIManager {
                
                url = url + "/aai/search/named-query";
 
-               logger.debug("RESTManager.post before"); 
-               Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
+               logger.debug("RESTManager.post before");
+               String requestJson = Serialization.gsonPretty.toJson(request);
+               netLogger.info("[OUT|{}|{}|]{}{}", "AAI", url, System.lineSeparator(), requestJson);
+               Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", requestJson);
                logger.debug("RESTManager.post after"); 
                
                if (httpDetails == null) {
@@ -59,6 +62,7 @@ public final class AAIManager {
                if (httpDetails.b != null) {
                        try {
                                AAINQResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQResponse.class);
+                               netLogger.info("[IN|{}|{}|]{}{}", "AAI", url, System.lineSeparator(), response.toString());
                                return response;
                        } catch (JsonSyntaxException e) {
                                logger.error("postQuery threw: ", e);
@@ -80,7 +84,8 @@ public final class AAIManager {
                AAIGETVserverResponse responseGet = null;
                
                while(attemptsLeft-- > 0){
-               
+
+                       netLogger.info("[OUT|{}|{}|]", "AAI", urlGet);
                        Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
                        if (httpDetailsGet == null) {
                                logger.info("AAI GET Null Response to " + urlGet);
@@ -94,6 +99,7 @@ public final class AAIManager {
                        if (httpDetailsGet.a == 200) {
                                try {
                                        responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVserverResponse.class);
+                                       netLogger.info("[IN|{}|{}|]{}{}", "AAI", urlGet, System.lineSeparator(), responseGet.toString());
                                        return responseGet;
                                } catch (JsonSyntaxException e) {
                                        logger.error("postQuery threw: ", e);
@@ -120,7 +126,7 @@ public final class AAIManager {
                AAIGETVnfResponse responseGet = null;
                
                while(attemptsLeft-- > 0){
-               
+                       netLogger.info("[OUT|{}|{}|]", "AAI", urlGet);
                        Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
                        if (httpDetailsGet == null) {
                                logger.info("AAI GET Null Response to " + urlGet);
@@ -134,6 +140,7 @@ public final class AAIManager {
                        if (httpDetailsGet.a == 200) {
                                try {
                                        responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVnfResponse.class);
+                                       netLogger.info("[IN|{}|{}|]{}{}", "AAI", urlGet, System.lineSeparator(), responseGet.toString());
                                        return responseGet;
                                } catch (JsonSyntaxException e) {
                                        logger.error("postQuery threw: ", e);
@@ -161,7 +168,7 @@ public final class AAIManager {
                AAIGETVnfResponse responseGet = null;
                
                while(attemptsLeft-- > 0){
-               
+                       netLogger.info("[OUT|{}|{}|]", "AAI", urlGet);
                        Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
                        if (httpDetailsGet == null) {
                                logger.info("AAI GET Null Response to " + urlGet);
@@ -175,6 +182,7 @@ public final class AAIManager {
                        if (httpDetailsGet.a == 200) {
                                try {
                                        responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVnfResponse.class);
+                                       netLogger.info("[IN|{}|{}|]{}{}", "AAI", urlGet, System.lineSeparator(), responseGet.toString());
                                        return responseGet;
                                } catch (JsonSyntaxException e) {
                                        logger.error("postQuery threw: ", e);
index 2f5ffdc..93c3f4c 100644 (file)
@@ -29,8 +29,10 @@ import org.onap.policy.drools.system.PolicyEngine;
 import org.onap.policy.rest.RESTManager;
 import org.onap.policy.rest.RESTManager.Pair;
 import org.drools.core.WorkingMemory;
+
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,6 +43,7 @@ import com.google.gson.JsonSyntaxException;
 public final class SOManager {
 
        private static final Logger logger = LoggerFactory.getLogger(SOManager.class);
+       private static final Logger netLogger = LoggerFactory.getLogger(org.onap.policy.drools.event.comm.Topic.NETWORK_LOGGER);
        private static ExecutorService executors = Executors.newCachedThreadPool();
                
        public static SOResponse createModuleInstance(String url, String urlBase, String username, String password, SORequest request) {
@@ -56,8 +59,9 @@ public final class SOManager {
                //
                // 201 - CREATED - you are done just return 
                //
-               
-               Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
+               String requestJson = Serialization.gsonPretty.toJson(request);
+               netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, System.lineSeparator(), requestJson);
+               Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", requestJson);
                
                if (httpDetails == null) {
                        return null;
@@ -82,6 +86,8 @@ public final class SOManager {
                                        
                                        Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
                                        responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, SOResponse.class);
+                                       netLogger.info("[IN|{}|{}|]{}{}", "SO", urlGet, System.lineSeparator(), responseGet.toString());
+                    
                                        body = Serialization.gsonPretty.toJson(responseGet);
                                        logger.debug("***** Response to get:");
                                        logger.debug(body);
@@ -159,7 +165,10 @@ public final class SOManager {
                                String msoJson = gsonPretty.toJson(request);
                                
                                SOResponse mso = new SOResponse();
+                               netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, System.lineSeparator(), msoJson);
                                Pair<Integer, String> httpResponse = RESTManager.post(url, "policy", "policy", headers, "application/json", msoJson);
+                               netLogger.info("[IN|{}|{}|]{}{}", url, "SO", System.lineSeparator(), httpResponse.b);
+                                  
                                if (httpResponse != null) {
                                        Gson gson = new Gson();
                                        mso = gson.fromJson(httpResponse.b, SOResponse.class);
index 2d635b4..b0aa583 100644 (file)
@@ -39,7 +39,8 @@ public final class VFCManager implements Runnable {
     private VFCRequest vfcRequest;
     WorkingMemory workingMem;
     private static final Logger logger = LoggerFactory.getLogger(VFCManager.class);
-               
+    private static final Logger netLogger = LoggerFactory.getLogger(org.onap.policy.drools.event.comm.Topic.NETWORK_LOGGER);
+                       
     public VFCManager(WorkingMemory wm, VFCRequest request) {
         workingMem = wm;
         vfcRequest = request;
@@ -68,8 +69,11 @@ public final class VFCManager implements Runnable {
         headers.put("Accept", "application/json");
 
         String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.nsInstanceId + "/heal";
+        String vfcRequestJson = Serialization.gsonPretty.toJson(vfcRequest);
+       netLogger.info("[OUT|{}|{}|]{}{}", "VFC", vfcUrl, System.lineSeparator(), vfcRequestJson);
+               
         Pair<Integer, String> httpDetails = RESTManager.post(vfcUrl, username, password, headers,
-                "application/json", Serialization.gsonPretty.toJson(vfcRequest));
+                "application/json", vfcRequestJson);
 
         if (httpDetails == null) {
             return;
@@ -78,7 +82,8 @@ public final class VFCManager implements Runnable {
         if (httpDetails.a == 202) {
             try {
                 VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
-
+                netLogger.info("[IN|{}|{}|]{}{}", "VFC", vfcUrl, System.lineSeparator(), response.toString());
+                
                 String body = Serialization.gsonPretty.toJson(response);
                 logger.debug("Response to VFC Heal post:");
                 logger.debug(body);
@@ -91,9 +96,11 @@ public final class VFCManager implements Runnable {
 
                 while (attemptsLeft-- > 0) {
 
+                    netLogger.info("[OUT|{}|{}|]", "VFC", urlGet);
                     Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
                     responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class);
-                   responseGet.requestId = vfcRequest.requestId.toString();
+                    netLogger.info("[IN|{}|{}|]{}{}", "VFC", urlGet, System.lineSeparator(), responseGet.toString());
+                    responseGet.requestId = vfcRequest.requestId.toString();
                     body = Serialization.gsonPretty.toJson(responseGet);
                     logger.debug("Response to VFC Heal get:");
                     logger.debug(body);