diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-09-12 07:47:32 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-09-12 07:47:32 +0000 |
commit | ca6f40516028602d3551856301cd9d7cda65f812 (patch) | |
tree | c114fcde5bd53e1b1aaaaa8625eaa553a7b043fa /vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java | |
parent | 4996ccfb67d22533da5d5021284e41b6612e4aec (diff) | |
parent | 2265215c803291e029add2db7912c7b1e25e0a8e (diff) |
Merge "make Logging a service and inject it to SyncRestClient"
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java | 27 |
1 files changed, 19 insertions, 8 deletions
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 |