summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2022-03-09 14:21:54 +0000
committerGerrit Code Review <gerrit@onap.org>2022-03-09 14:21:54 +0000
commit23494ae7b4c32281fd4deec06813bf6e211cf954 (patch)
treeaa63fb5373f52d93e0413e6bf87422b836f116f7
parent81cb197c2e60c37625d61447a9bcd97a7afb30af (diff)
parente1d0d1facd5f3c4f9316a3796e0e54e331a9d06c (diff)
Merge "Fixed issue of cnf adapter start without intsnaces in k8splugin"
-rw-r--r--so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/MulticloudClient.java20
1 files changed, 13 insertions, 7 deletions
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<InstanceResponse> getAllInstances() throws BadResponseException {
String endpoint = multicloudApiUrl.apiUrl("");
- ResponseEntity<String> 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<String> 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