diff options
author | Matthieu Geerebaert <matthieu.geerebaert@orange.com> | 2018-04-23 12:49:05 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-04-23 12:49:05 +0000 |
commit | f5ba6d31b9349027c54f24a0e0f563f0b9e58728 (patch) | |
tree | 8730ba2215591ca8c8c6987840dac8dda11748a3 | |
parent | 21550f32a8b416dacf248bdd89c8af066e6157d3 (diff) | |
parent | d748b3efcde68fcff85164898bdd35d529b4127b (diff) |
Merge "fix NPE on serviceInventory -service without VNF"
-rw-r--r-- | src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java | 19 |
1 files changed, 11 insertions, 8 deletions
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 707c9e9..a4347d4 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java @@ -102,16 +102,19 @@ public class ServiceInventoryService { List<LinkedHashMap> vnfs = new ArrayList<>(); LinkedHashMap relationShip = (LinkedHashMap) serviceResponse.get("relationship-list"); - List<LinkedHashMap> relationsList = (List<LinkedHashMap>) relationShip.get("relationship"); - for (LinkedHashMap relation : relationsList) { - String relatedLink = (String) relation.get("related-link"); - LinkedHashMap vnf = aaiClient.getVNF(relatedLink); - if (vnf != null) { - vnfs.add(vnf); + if(relationShip!=null) { + List<LinkedHashMap> relationsList = (List<LinkedHashMap>) relationShip.get("relationship"); + if(relationsList!=null) { + for (LinkedHashMap relation : relationsList) { + String relatedLink = (String) relation.get("related-link"); + LinkedHashMap vnf = aaiClient.getVNF(relatedLink); + if (vnf != null) { + vnfs.add(vnf); + } + } + serviceResponse.put("vnfs", vnfs); } } - serviceResponse.put("vnfs", vnfs); - } |