From 6ffc97aad02be00b5c68c055f16df8ab600b9ea9 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Tue, 28 Aug 2018 09:55:49 -0400 Subject: fixed incorrect groovy method call 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) --- .../scripts/DoDeleteServiceInstance.groovy | 70 +++++++++++----------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy/org') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index a79483f6e9..eb736f8ffe 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -305,45 +305,47 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { } AAIResultWrapper wrapper = resourceClient.get(uri) - List 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 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 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 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 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 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") -- cgit 1.2.3-korg