From e1d0d1facd5f3c4f9316a3796e0e54e331a9d06c Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Wed, 9 Mar 2022 15:05:45 +0100 Subject: Fixed issue of cnf adapter start without intsnaces in k8splugin Issue-ID: SO-3845 Signed-off-by: Lukasz Rajewski Change-Id: If993e0b1b29c49032009ead929f130a687482701 --- .../so/adapters/cnf/client/MulticloudClient.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'so-cnf-adapter-application/src') diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/MulticloudClient.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/MulticloudClient.java index 0f5df15..8c1a329 100644 --- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/MulticloudClient.java +++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/MulticloudClient.java @@ -44,6 +44,7 @@ import org.springframework.web.client.RestTemplate; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.springframework.http.HttpMethod.DELETE; @@ -67,14 +68,19 @@ public class MulticloudClient { public List getAllInstances() throws BadResponseException { String endpoint = multicloudApiUrl.apiUrl(""); - ResponseEntity result = restTemplate.exchange(endpoint, GET, getHttpEntity(), String.class); - checkResponseStatusCode(result); - log.info("getAllInstances response status: {}", result.getStatusCode()); - String body = result.getBody(); - log.debug("getAllInstances response body: {}", body); - try { + ResponseEntity result = restTemplate.exchange(endpoint, GET, getHttpEntity(), String.class); + checkResponseStatusCode(result); + log.info("getAllInstances response status: {}", result.getStatusCode()); + String body = result.getBody(); + log.debug("getAllInstances response body: {}", body); return Arrays.asList(objectMapper.readValue(body, InstanceResponse[].class)); + } catch (HttpServerErrorException e) { + if (e.getMessage().contains("no documents") || e.getMessage().contains("Did not find any")) { + log.info("getAllInstances response status: {}", 500); + return Collections.emptyList(); + } else + throw e; } catch (JsonProcessingException e) { throw new RuntimeException(e); } @@ -103,7 +109,7 @@ public class MulticloudClient { log.info("hasSubscription response status: {}", result.getStatusCode()); return true; } catch (HttpServerErrorException e) { - if (e.getMessage().contains("no documents")) { + if (e.getMessage().contains("no documents") || e.getMessage().contains("Did not find any")) { log.info("hasSubscription response status: {}", 500); return false; } else -- cgit 1.2.3-korg