aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-09-10 16:31:01 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-09-12 08:51:25 +0300
commit2265215c803291e029add2db7912c7b1e25e0a8e (patch)
tree3082c232fa26483a0f1262efcc5c228d554280d1 /vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
parent77e77f77c89ca1bef622b12c71897ab1ab256216 (diff)
make Logging a service and inject it to SyncRestClient
Issue-ID: VID-611 Change-Id: I120782884351c55b2e0d1b4ca8bae1e2479d1d0a Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
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.java27
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