From 2265215c803291e029add2db7912c7b1e25e0a8e Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Tue, 10 Sep 2019 16:31:01 +0300 Subject: make Logging a service and inject it to SyncRestClient Issue-ID: VID-611 Change-Id: I120782884351c55b2e0d1b4ca8bae1e2479d1d0a Signed-off-by: Eylon Malin --- .../java/org/onap/vid/client/SyncRestClient.java | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java') diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java index 50556e7ec..18f87223c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java @@ -23,6 +23,7 @@ package org.onap.vid.client; import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.onap.vid.client.UnirestPatchKt.patched; +import com.att.eelf.configuration.EELFLogger; import io.joshworks.restclient.http.HttpResponse; import io.joshworks.restclient.http.JsonNode; import io.joshworks.restclient.http.RestClient; @@ -42,6 +43,7 @@ import java.security.cert.CertificateException; import java.util.Map; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; +import org.apache.commons.lang3.ObjectUtils; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; @@ -51,29 +53,38 @@ import org.eclipse.jetty.util.security.Password; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.properties.VidProperties; +import org.onap.vid.utils.Logging; public class SyncRestClient implements SyncRestClientInterface { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SyncRestClient.class); private static final String[] SUPPORTED_SSL_VERSIONS = {"TLSv1", "TLSv1.2"}; private static final String HTTPS_SCHEMA = "https://"; private static final String HTTP_SCHEMA = "http://"; + private final Logging loggingService; + private final EELFLogger outgoingRequestsLogger; private RestClient restClient; - public SyncRestClient() { - restClient = RestClient.newClient().objectMapper(defaultObjectMapper()).httpClient(defaultHttpClient()).build(); + public SyncRestClient(Logging loggingService) { + this(null, null, loggingService); } - public SyncRestClient(ObjectMapper objectMapper) { - restClient = RestClient.newClient().objectMapper(objectMapper).httpClient(defaultHttpClient()).build(); + public SyncRestClient(ObjectMapper objectMapper, Logging loggingService) { + this(null, objectMapper, loggingService); } - public SyncRestClient(CloseableHttpClient httpClient) { - restClient = RestClient.newClient().objectMapper(defaultObjectMapper()).httpClient(httpClient).build(); + public SyncRestClient(CloseableHttpClient httpClient, Logging loggingService) { + this(httpClient, null, loggingService); } - public SyncRestClient(CloseableHttpClient httpClient, ObjectMapper objectMapper) { - restClient = RestClient.newClient().objectMapper(objectMapper).httpClient(httpClient).build(); + public SyncRestClient(CloseableHttpClient httpClient, ObjectMapper objectMapper, Logging loggingService) { + restClient = RestClient + .newClient() + .objectMapper(ObjectUtils.defaultIfNull(objectMapper, defaultObjectMapper())) + .httpClient(ObjectUtils.defaultIfNull(httpClient , defaultHttpClient())) + .build(); + this.loggingService = loggingService; + this.outgoingRequestsLogger = Logging.getRequestsLogger("syncRestClient"); } @Override -- cgit 1.2.3-korg