rest api call node target entity
[ccsdk/sli/plugins.git] / restapi-call-node / provider / src / main / java / org / onap / ccsdk / sli / plugins / restapicall / RestapiCallNode.java
index b93887f..165eefd 100755 (executable)
@@ -72,8 +72,11 @@ import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.logging.filter.base.MetricLogClientFilter;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
 
 public class RestapiCallNode implements SvcLogicJavaPlugin {
 
@@ -222,6 +225,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
         p.accept = parseParam(paramMap, "accept", false, null);
         p.multipartFormData = valueOf(parseParam(paramMap, "multipartFormData", false, "false"));
         p.multipartFile = parseParam(paramMap, "multipartFile", false, null);
+        p.targetEntity = parseParam(paramMap, "targetEntity", false, null);
         return p;
     }
 
@@ -462,10 +466,13 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
     protected void sendRequest(Map<String, String> paramMap, SvcLogicContext ctx, RetryPolicy retryPolicy)
         throws SvcLogicException {
 
-        HttpResponse r = new HttpResponse();
+       HttpResponse r = new HttpResponse();
         try {
             handlePartner(paramMap);
             Parameters p = getParameters(paramMap, new Parameters());
+            if(p.targetEntity != null && !p.targetEntity.isEmpty()) {
+                MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, p.targetEntity);
+            }
             if (p.restapiUrl.contains(",") && retryPolicy == null) {
                 String[] urls = p.restapiUrl.split(",");
                 retryPolicy = new RetryPolicy(urls, urls.length * 2);
@@ -785,7 +792,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
         setClientTimeouts(client);
         // Needed to support additional HTTP methods such as PATCH
         client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
-
+        client.register(new MetricLogClientFilter());
         WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl);
 
         long t1 = System.currentTimeMillis();
@@ -819,8 +826,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
                 }
             }
 
-            invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID"));
-
             invocationBuilder.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
 
             Response response;
@@ -875,8 +880,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
                 }
             }
 
-            invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID"));
-
             Response response;
 
             try {