use onap logging 1.6.1 with needed workarounds
[vid.git] / vid-app-common / src / main / java / org / onap / vid / mso / RestMsoImplementation.java
index 91b2889..a2d71d9 100644 (file)
 
 package org.onap.vid.mso;
 
-import static org.onap.vid.logging.Headers.INVOCATION_ID;
-import static org.onap.vid.logging.Headers.PARTNER_NAME;
-import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY;
-import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
 import static org.onap.vid.utils.Logging.getMethodCallerName;
 import static org.onap.vid.utils.Logging.getMethodName;
 
@@ -44,6 +40,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.vid.aai.util.HttpClientMode;
 import org.onap.vid.aai.util.HttpsAuthClient;
 import org.onap.vid.client.HttpBasicClient;
+import org.onap.vid.logging.VidMetricLogClientFilter;
 import org.onap.vid.utils.Logging;
 import org.onap.vid.utils.SystemPropertiesWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -107,12 +104,8 @@ public class RestMsoImplementation {
 
         MultivaluedHashMap<String, Object> commonHeaders = new MultivaluedHashMap();
         commonHeaders.put("Authorization",  Collections.singletonList(("Basic " + authStringEnc)));
-        commonHeaders.put(PARTNER_NAME.getHeaderName(), Collections.singletonList(PARTNER_NAME.getHeaderValue()));
 
         String requestIdValue = Logging.extractOrGenerateRequestId();
-        commonHeaders.put(REQUEST_ID_HEADER_KEY, Collections.singletonList(requestIdValue));
-        commonHeaders.put(ONAP_REQUEST_ID_HEADER_KEY, Collections.singletonList(requestIdValue));
-        commonHeaders.put(INVOCATION_ID.getHeaderName(), Collections.singletonList(INVOCATION_ID.getHeaderValue()));
 
         boolean useSsl = true;
         if ( (mso_url != null) && ( !(mso_url.isEmpty()) ) ) {
@@ -121,11 +114,13 @@ public class RestMsoImplementation {
         if (client == null) {
 
             try {
-                if ( useSsl ) {
-                    client = httpsAuthClient.getClient(HttpClientMode.WITHOUT_KEYSTORE);
-                }
+                    if ( useSsl ) {
+                        client = httpsAuthClient.getClient(HttpClientMode.WITHOUT_KEYSTORE);
+                        registerClientToMetricLogClientFilter(client);
+                    }
                 else {
                     client = HttpBasicClient.getClient();
+                    registerClientToMetricLogClientFilter(client);
                 }
             } catch (Exception e) {
                 logger.info(EELFLoggerDelegate.errorLogger,methodname + " Unable to get the SSL client");
@@ -135,6 +130,11 @@ public class RestMsoImplementation {
         return commonHeaders;
     }
 
+    private void registerClientToMetricLogClientFilter(Client client) {
+        VidMetricLogClientFilter metricLogClientFilter = new VidMetricLogClientFilter();
+        client.register(metricLogClientFilter);
+    }
+
     public <T> RestObject<T> GetForObject(String path, Class<T> clazz) {
         final String methodName = getMethodName();
         logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {})", getMethodCallerName(), methodName, path, clazz);