diff options
author | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-19 11:06:54 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-06-19 11:06:54 +0000 |
commit | 7f0e6936709cc19e3e1e1ad035e5b7d00809d6c6 (patch) | |
tree | 163542e67746e7693daf12e7835f5b2f6c78255a /vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java | |
parent | 46adb535d3af416773475b9aabb2ace8e1e9e1de (diff) | |
parent | 72b3fb69e548cf665204ec025d2778dcf3ce0216 (diff) |
Merge "Extend probe mechanism"
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java index 86c6f4aca..46bb6cef4 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java @@ -23,6 +23,7 @@ package org.onap.vid.aai; import io.joshworks.restclient.http.HttpResponse; import io.joshworks.restclient.http.JsonNode; import io.vavr.collection.HashMap; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.model.ResourceType; @@ -30,6 +31,10 @@ import org.onap.vid.aai.util.AAIProperties; import org.onap.vid.client.SyncRestClientInterface; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.model.SubscriberList; +import org.onap.vid.model.probes.ExternalComponentStatus; +import org.onap.vid.model.probes.HttpRequestMetadata; +import org.onap.vid.utils.Logging; +import org.springframework.http.HttpMethod; import javax.ws.rs.core.MediaType; import java.nio.charset.StandardCharsets; @@ -37,7 +42,11 @@ import java.util.Base64; import java.util.Collections; import java.util.Map; -import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.*; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.ACCEPT; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.CONTENT_TYPE; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.FROM_APP_ID_HEADER; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.REQUEST_ID; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.TRANSACTION_ID_HEADER; public class AaiOverTLSClient implements AaiOverTLSClientInterface { @@ -88,6 +97,29 @@ public class AaiOverTLSClient implements AaiOverTLSClientInterface { return syncRestClient.get(uri, getRequestHeaders(), Collections.emptyMap(), SubscriberList.class); } + @Override + public ExternalComponentStatus probeGetAllSubscribers() { + String url = urlBase + String.format(URIS.SUBSCRIBERS, 0); + long startTime = System.currentTimeMillis(); + ExternalComponentStatus externalComponentStatus; + + try { + HttpResponse<SubscriberList> allSubscribers = getAllSubscribers(); + + HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, allSubscribers.getStatus(), url, + IOUtils.toString(allSubscribers.getRawBody()), "VID-AAI connection using new client works", System.currentTimeMillis() - startTime); + externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, allSubscribers.isSuccessful(), httpRequestMetadata); + + } catch (Exception e) { + HttpRequestMetadata httpRequestMetadata = new HttpRequestMetadata(HttpMethod.GET, 0, + url, "", Logging.exceptionToDescription(e), System.currentTimeMillis() - startTime); + externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, false, httpRequestMetadata); + } + + return externalComponentStatus; + } + + private Map<String, String> getRequestHeaders() { Map<String, String> result = HashMap.of( TRANSACTION_ID_HEADER, propertySupplier.getRandomUUID(), |