diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-10 16:31:01 +0300 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-12 08:51:25 +0300 |
commit | 2265215c803291e029add2db7912c7b1e25e0a8e (patch) | |
tree | 3082c232fa26483a0f1262efcc5c228d554280d1 /vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java | |
parent | 77e77f77c89ca1bef622b12c71897ab1ab256216 (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/asdc/rest/SdcRestClient.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java index 1de9715ee..9e139a02a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java @@ -30,7 +30,6 @@ import static org.onap.vid.client.SyncRestClientInterface.HEADERS.CONTENT_TYPE; import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID; import static org.onap.vid.client.UnirestPatchKt.extractRawAsString; import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY; -import static org.onap.vid.utils.Logging.logRequest; import com.att.eelf.configuration.EELFLogger; import com.google.common.collect.ImmutableMap; @@ -63,23 +62,25 @@ public class SdcRestClient implements AsdcClient { private String baseUrl; private String path; private String auth; - private static final EELFLogger LOGGER = Logging.getRequestsLogger("asdc"); + private static final EELFLogger LOGGER = Logging.getRequestsLogger("sdc"); private SyncRestClientInterface syncRestClient; + private Logging loggingService; - public SdcRestClient(String baseUrl, String auth, SyncRestClientInterface client) { + public SdcRestClient(String baseUrl, String auth, SyncRestClientInterface client, Logging loggingService) { this.syncRestClient = client; this.auth = auth; this.baseUrl = baseUrl; this.path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH); + this.loggingService = loggingService; } @Override public Service getService(UUID uuid) throws AsdcCatalogException { String finalUrl = String.format(METADATA_URL_TEMPLATE, baseUrl, path, uuid); - logRequest(LOGGER, HttpMethod.GET, finalUrl); + loggingService.logRequest(LOGGER, HttpMethod.GET, finalUrl); return Try .of(() -> syncRestClient.get(finalUrl, prepareHeaders(auth, APPLICATION_JSON), Collections.emptyMap(), Service.class)) @@ -94,7 +95,7 @@ public class SdcRestClient implements AsdcClient { HttpResponseWithRequestInfo<InputStream> responseWithRequestInfo = getServiceInputStream(uuid, false); if (responseWithRequestInfo.getResponse().getStatus()>399) { - Logging.logResponse(LOGGER, HttpMethod.GET, + loggingService.logRequest(LOGGER, HttpMethod.GET, responseWithRequestInfo.getRequestUrl(), responseWithRequestInfo.getResponse()); String body = extractRawAsString(responseWithRequestInfo.getResponse()); @@ -124,7 +125,7 @@ public class SdcRestClient implements AsdcClient { @Override public HttpResponseWithRequestInfo<InputStream> getServiceInputStream(UUID serviceUuid, boolean warpException) { String finalUrl = String.format(TOSCA_MODEL_URL_TEMPLATE, baseUrl, path, serviceUuid); - logRequest(LOGGER, HttpMethod.GET, finalUrl); + loggingService.logRequest(LOGGER, HttpMethod.GET, finalUrl); try { HttpResponse<InputStream> httpResponse = syncRestClient.getStream(finalUrl, prepareHeaders(auth, APPLICATION_OCTET_STREAM), Collections.emptyMap()); return new HttpResponseWithRequestInfo<>(httpResponse, finalUrl, HttpMethod.GET); |