diff options
author | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-14 11:34:27 +0200 |
---|---|---|
committer | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-18 14:53:37 +0200 |
commit | 72b3fb69e548cf665204ec025d2778dcf3ce0216 (patch) | |
tree | ac7126066bbcd2986052da905e9d359d9f949328 /vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java | |
parent | dd3ba9800ec14898f50858ecd67db0f9245ffc01 (diff) |
Extend probe mechanism
added methods to:
- new aai client
- sdc client
- so client
Change-Id: Ib7beb5a5ac58c2ac9767f5e8dc4f988ac0a44c3e
Issue-ID: VID-490
Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
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(), |