fixed incorrect groovy method call 69/63269/1
authorBenjamin, Max (mb388a) <mb388a@us.att.com>
Tue, 28 Aug 2018 13:55:49 +0000 (09:55 -0400)
committerBenjamin, Max (mb388a) <mb388a@us.att.com>
Tue, 28 Aug 2018 13:56:01 +0000 (09:56 -0400)
Added missing pers to isEmpty and also added relationship present check
to prevent null pointer.

Change-Id: I7f184c428694e55b75f255d517a53aac7be82aab
Issue-ID: SO-924
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy

index a79483f..eb736f8 100644 (file)
@@ -305,45 +305,47 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
                                }
 
                                AAIResultWrapper wrapper = resourceClient.get(uri)
-                               List<AAIResourceUri> uriList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE)
-                               uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF))
-                               uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK))
-
-                               if(uriList.isEmpty){
-                                       Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
-                                       String orchestrationStatus = si.get().getOrchestrationStatus()
-                                       String serviceType = si.get().getServiceType()
-                                       execution.setVariable("serviceType", serviceType)
-                                       execution.setVariable("serviceRole", si.get().getServiceRole())
-
-                                       if("TRANSPORT".equalsIgnoreCase(serviceType)){
-                                               if("PendingDelete".equals(orchestrationStatus)){
-                                                       execution.setVariable("skipDeactivate", true)
-                                               }else{
-                                                       exceptionUtil.buildAndThrowWorkflowException(execution, 500, "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status: " + orchestrationStatus)
+                               if(wrapper.getRelationships().isPresent()){
+                                       List<AAIResourceUri> uriList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE)
+                                       uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF))
+                                       uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK))
+
+                                       if(uriList.isEmpty()){
+                                               Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+                                               String orchestrationStatus = si.get().getOrchestrationStatus()
+                                               String serviceType = si.get().getServiceType()
+                                               execution.setVariable("serviceType", serviceType)
+                                               execution.setVariable("serviceRole", si.get().getServiceRole())
+
+                                               if("TRANSPORT".equalsIgnoreCase(serviceType)){
+                                                       if("PendingDelete".equals(orchestrationStatus)){
+                                                               execution.setVariable("skipDeactivate", true)
+                                                       }else{
+                                                               exceptionUtil.buildAndThrowWorkflowException(execution, 500, "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status: " + orchestrationStatus)
+                                                       }
                                                }
-                                       }
 
-                                       String svcTypes = UrnPropertiesReader.getVariable("sdnc.si.svc.types",execution) ?: ""
-                                       List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*"));
-                                       boolean isSdncService= false
-                                       for(String listEntry : svcList){
-                                               if(listEntry.equalsIgnoreCase(serviceType)){
-                                                       isSdncService = true
-                                                       break;
+                                               String svcTypes = UrnPropertiesReader.getVariable("sdnc.si.svc.types",execution) ?: ""
+                                               List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*"));
+                                               boolean isSdncService= false
+                                               for(String listEntry : svcList){
+                                                       if(listEntry.equalsIgnoreCase(serviceType)){
+                                                               isSdncService = true
+                                                               break;
+                                                       }
                                                }
-                                       }
-                                       execution.setVariable("sendToSDNC", true)
-                                       if(execution.getVariable("sdncVersion").equals("1610")){
-                                               if(!isSdncService){
-                                                       execution.setVariable("sendToSDNC", false)
+                                               execution.setVariable("sendToSDNC", true)
+                                               if(execution.getVariable("sdncVersion").equals("1610")){
+                                                       if(!isSdncService){
+                                                               execution.setVariable("sendToSDNC", false)
+                                                       }
                                                }
-                                       }
 
-                               }else{
-                                       execution.setVariable("siInUse", true)
-                                       msoLogger.debug("Stopped deleting Service Instance, it has dependencies")
-                                       exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Stopped deleting Service Instance, it has dependencies")
+                                       }else{
+                                               execution.setVariable("siInUse", true)
+                                               msoLogger.debug("Stopped deleting Service Instance, it has dependencies")
+                                               exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Stopped deleting Service Instance, it has dependencies")
+                                       }
                                }
                        }else{
                                exceptionUtil.buildAndThrowWorkflowException(execution, 500, "ServiceInstance not found in aai")