summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java13
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java12
2 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
index 8fd3002..698981b 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
@@ -17,6 +17,9 @@ package org.onap.nbi.apis.serviceinventory;
import java.util.LinkedHashMap;
import org.onap.nbi.OnapComponentsUrlPaths;
+import org.onap.nbi.exceptions.BackendFunctionalException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -39,6 +42,7 @@ public class AaiClient extends BaseClient {
private static final String HEADER_AUTHORIZATION = "Authorization";
private static final String X_FROM_APP_ID = "X-FromAppId";
+ private static final Logger LOGGER = LoggerFactory.getLogger(AaiClient.class);
private HttpHeaders buildRequestHeaderForAAI() {
@@ -91,7 +95,12 @@ public class AaiClient extends BaseClient {
String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId);
callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceType);
- ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
- return (LinkedHashMap) response.getBody();
+ try{
+ ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
+ return (LinkedHashMap) response.getBody();
+ } catch (BackendFunctionalException e) {
+ LOGGER.error("error on calling {0} , {1}" , callUrlFormated, e);
+ return null;
+ }
}
}
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java
index a4347d4..3208de4 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java
@@ -24,6 +24,7 @@ import org.onap.nbi.exceptions.BackendFunctionalException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
@@ -156,11 +157,14 @@ public class ServiceInventoryService {
List<LinkedHashMap> serviceInstancesForServiceType =
(List<LinkedHashMap>) serviceInstancesInAaiForCustomer.get("service-instance");
- // add service type for jolt
- for (LinkedHashMap serviceInstanceForServiceType : serviceInstancesForServiceType) {
- serviceInstanceForServiceType.put("service-type", serviceType);
+ if(!CollectionUtils.isEmpty(serviceInstancesForServiceType)){
+ // add service type for jolt
+ for (LinkedHashMap serviceInstanceForServiceType : serviceInstancesForServiceType) {
+ serviceInstanceForServiceType.put("service-type", serviceType);
+ }
+ serviceInstances.addAll(serviceInstancesForServiceType);
}
- serviceInstances.addAll(serviceInstancesForServiceType);
+
}