2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
 
   7  * ================================================================================
 
   8  * Modifications Copyright (c) 2019 Samsung
 
   9  * ================================================================================
 
  10  * Licensed under the Apache License, Version 2.0 (the "License")
 
  11  * you may not use this file except in compliance with the License.
 
  12  * You may obtain a copy of the License at
 
  14  *      http://www.apache.org/licenses/LICENSE-2.0
 
  16  * Unless required by applicable law or agreed to in writing, software
 
  17  * distributed under the License is distributed on an "AS IS" BASIS,
 
  18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  19  * See the License for the specific language governing permissions and
 
  20  * limitations under the License.
 
  21  * ============LICENSE_END=========================================================
 
  23 package org.onap.so.bpmn.infrastructure.scripts
 
  25 import org.onap.so.logger.LoggingAnchor
 
  26 import org.onap.logging.filter.base.ErrorCode
 
  28 import static org.apache.commons.lang3.StringUtils.*
 
  30 import javax.xml.parsers.DocumentBuilder
 
  31 import javax.xml.parsers.DocumentBuilderFactory
 
  33 import org.apache.commons.lang3.*
 
  34 import org.camunda.bpm.engine.delegate.BpmnError
 
  35 import org.camunda.bpm.engine.delegate.DelegateExecution
 
  36 import org.json.JSONArray
 
  37 import org.json.JSONObject
 
  38 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 
  39 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 
  40 import org.onap.so.bpmn.common.scripts.MsoUtils
 
  41 import org.onap.so.bpmn.core.UrnPropertiesReader
 
  42 import org.onap.so.bpmn.core.WorkflowException
 
  43 import org.onap.so.bpmn.core.json.JsonUtils
 
  44 import org.onap.so.logger.MessageEnum
 
  45 import org.slf4j.Logger
 
  46 import org.slf4j.LoggerFactory
 
  47 import org.springframework.web.util.UriUtils
 
  48 import org.w3c.dom.Document
 
  49 import org.w3c.dom.Element
 
  50 import org.w3c.dom.Node
 
  51 import org.w3c.dom.NodeList
 
  52 import org.xml.sax.InputSource
 
  53 import org.onap.so.client.aai.entities.uri.AAIResourceUri
 
  54 import org.onap.so.client.aai.entities.uri.AAIUriFactory
 
  55 import org.onap.so.client.aai.AAIObjectType
 
  56 import org.onap.so.client.aai.AAIResourcesClient
 
  63  * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
 
  66  * @param - msoRequestId
 
  67  * @param - globalSubscriberId - O
 
  68  * @param - subscriptionServiceType - O
 
  69  * @param - serviceInstanceId
 
  70  * @param - serviceInstanceName - O
 
  71  * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
 
  72  * @param - sdncVersion
 
  73  * @param - failNotFound - TODO
 
  74  * @param - serviceInputParams - TODO
 
  77  * @param - WorkflowException
 
  81 public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
 
  82     private static final Logger logger = LoggerFactory.getLogger( DoCustomDeleteE2EServiceInstance.class)
 
  85         String Prefix="DDELSI_"
 
  86         ExceptionUtil exceptionUtil = new ExceptionUtil()
 
  87         JsonUtils jsonUtil = new JsonUtils()
 
  89         public void preProcessRequest (DelegateExecution execution) {
 
  90                 logger.trace("preProcessRequest ")
 
  94                         String requestId = execution.getVariable("msoRequestId")
 
  95                         execution.setVariable("prefix",Prefix)
 
  98                         //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
 
  99                         String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
 
 100                         if (globalSubscriberId == null)
 
 102                                 execution.setVariable("globalSubscriberId", "")
 
 105                         //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
 
 106                         String serviceType = execution.getVariable("serviceType")
 
 107                         if (serviceType == null)
 
 109                                 execution.setVariable("serviceType", "")
 
 112                         //Generated in parent for AAI PUT
 
 113                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
 
 114                         if (isBlank(serviceInstanceId)){
 
 115                                 msg = "Input serviceInstanceId is null"
 
 117                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
 
 120                         String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution)
 
 121                         if (isBlank(sdncCallbackUrl)) {
 
 122                                 msg = "URN_mso_workflow_sdncadapter_callback is null"
 
 124                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
 
 126                         execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
 
 127                         logger.info("SDNC Callback URL: " + sdncCallbackUrl)
 
 129                         StringBuilder sbParams = new StringBuilder()
 
 130                         Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
 
 131                         if (paramsMap != null)
 
 133                                 sbParams.append("<service-input-parameters>")
 
 134                                 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
 
 136                                         String paramName = entry.getKey()
 
 137                                         String paramValue = entry.getValue()
 
 140                                                         <name>${MsoUtils.xmlEscape(paramName)}</name>
 
 141                                                         <value>${MsoUtils.xmlEscape(paramValue)}</value>
 
 144                                         sbParams.append(paramsXml)
 
 146                                 sbParams.append("</service-input-parameters>")
 
 148                         String siParamsXml = sbParams.toString()
 
 149                         if (siParamsXml == null)
 
 151                         execution.setVariable("siParamsXml", siParamsXml)
 
 153                 } catch (BpmnError e) {
 
 155                 } catch (Exception ex){
 
 156                         msg = "Exception in preProcessRequest " + ex.getMessage()
 
 158                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 160                 logger.trace("Exit preProcessRequest ")
 
 164         public void preProcessVFCDelete (DelegateExecution execution) {
 
 167         public void postProcessVFCDelete(DelegateExecution execution, String response, String method) {
 
 170         public void preProcessSDNCDelete (DelegateExecution execution) {
 
 171                 logger.trace("preProcessSDNCDelete ")
 
 175                         def serviceInstanceId = execution.getVariable("serviceInstanceId")
 
 176                         def serviceInstanceName = execution.getVariable("serviceInstanceName")
 
 177                         def callbackURL = execution.getVariable("sdncCallbackUrl")
 
 178                         def requestId = execution.getVariable("msoRequestId")
 
 179                         def serviceId = execution.getVariable("productFamilyId")
 
 180                         def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
 
 181                         def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
 
 183                         String serviceModelInfo = execution.getVariable("serviceModelInfo")
 
 184                         def modelInvariantUuid = ""
 
 185                         def modelVersion = ""
 
 188                         if (!isBlank(serviceModelInfo))
 
 190                                 modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
 
 191                                 modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
 
 192                                 modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
 
 193                                 modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
 
 195                                 if (modelInvariantUuid == null) {
 
 196                                         modelInvariantUuid = ""
 
 198                                 if (modelVersion == null) {
 
 201                                 if (modelUuid == null) {
 
 204                                 if (modelName == null) {
 
 208                         if (serviceInstanceName == null) {
 
 209                                 serviceInstanceName = ""
 
 211                         if (serviceId == null) {
 
 215                         def siParamsXml = execution.getVariable("siParamsXml")
 
 216                         def serviceType = execution.getVariable("serviceType")
 
 217                         if (serviceType == null)
 
 222                         def sdncRequestId = UUID.randomUUID().toString()
 
 225                                         """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
 
 226                                                                                                         xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
 
 227                                                                                                         xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
 
 228                                    <sdncadapter:RequestHeader>
 
 229                                                         <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>
 
 230                                                         <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
 
 231                                                         <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
 
 232                                                         <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
 
 233                                                         <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
 
 234                                                         <sdncadapter:MsoAction>${MsoUtils.xmlEscape(serviceType)}</sdncadapter:MsoAction>
 
 235                                         </sdncadapter:RequestHeader>
 
 236                                 <sdncadapterworkflow:SDNCRequestData>
 
 237                                         <request-information>
 
 238                                                 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
 
 243                                                 <request-action>DeleteServiceInstance</request-action>
 
 244                                         </request-information>
 
 245                                         <service-information>
 
 246                                                 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
 
 247                                                 <subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type>
 
 248                                                 <onap-model-information>
 
 249                                                  <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
 
 250                                                  <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
 
 251                                                  <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
 
 252                                                  <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
 
 253                                             </onap-model-information>
 
 254                                                 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
 
 256                                                 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
 
 257                                         </service-information>
 
 258                                         <service-request-input>
 
 259                                                 <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name>
 
 261                                         </service-request-input>
 
 262                                 </sdncadapterworkflow:SDNCRequestData>
 
 263                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
 
 265                         sdncDelete = utils.formatXml(sdncDelete)
 
 266                         def sdncRequestId2 = UUID.randomUUID().toString()
 
 267                         String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
 
 268                         execution.setVariable("sdncDelete", sdncDelete)
 
 269                         execution.setVariable("sdncDeactivate", sdncDeactivate)
 
 270                         logger.info("sdncDeactivate:\n" + sdncDeactivate)
 
 271                         logger.info("sdncDelete:\n" + sdncDelete)
 
 273                 } catch (BpmnError e) {
 
 275                 } catch(Exception ex) {
 
 276                         msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
 
 278                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
 
 280                 logger.info(" *****Exit preProcessSDNCDelete *****")
 
 283         public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) {
 
 285                 logger.trace("postProcessSDNC " + method + " ")
 
 289                         WorkflowException workflowException = execution.getVariable("WorkflowException")
 
 290                         boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
 
 291                         logger.info("SDNCResponse: " + response)
 
 292                         logger.info("workflowException: " + workflowException)
 
 294                         SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
 
 295                         sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
 
 296                         if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){
 
 297                                 logger.info("Good response from SDNC Adapter for service-instance " + method + "response:\n" + response)
 
 300                                 msg = "Bad Response from SDNC Adapter for service-instance " + method
 
 302                                 exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
 
 304                 } catch (BpmnError e) {
 
 306                 } catch(Exception ex) {
 
 307                         msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage()
 
 309                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 311                 logger.trace("Exit postProcessSDNC " + method + " ")
 
 314         public void postProcessAAIGET(DelegateExecution execution) {
 
 315                 logger.trace("postProcessAAIGET ")
 
 319                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
 
 320                         boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
 
 321                         String serviceType = ""
 
 324                                 logger.info("Found Service-instance in AAI")
 
 326                                 String siData = execution.getVariable("GENGS_service")
 
 327                                 logger.info("SI Data")
 
 330                                         msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
 
 332                                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
 
 336                                         logger.info("SI Data" + siData)
 
 337                                         //Confirm there are no related service instances (vnf/network or volume)
 
 338                                         if (utils.nodeExists(siData, "relationship-list")) {
 
 339                                                 logger.info("SI Data relationship-list exists:")
 
 340                                                 InputSource source = new InputSource(new StringReader(siData))
 
 341                                                 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance()
 
 342                                                 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
 
 343                                                 Document serviceXml = docBuilder.parse(source)
 
 344                                                 serviceXml.getDocumentElement().normalize()
 
 346                                                 NodeList nodeList = serviceXml.getElementsByTagName("relationship")
 
 347                             JSONArray jArray = new JSONArray()
 
 348                                                 for (int x = 0; x < nodeList.getLength(); x++) {
 
 349                                                         Node node = nodeList.item(x)
 
 350                                                         if (node.getNodeType() == Node.ELEMENT_NODE) {
 
 351                                                                 Element eElement = (Element) node
 
 352                                                                 def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()                                                                    //for ns
 
 353                                                                 if(e.equals("service-instance")){
 
 354                                                                     def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
 
 355                                                                         logger.info("ServiceInstance Related NS :" + relatedObject)
 
 356                                     NodeList dataList = node.getChildNodes()
 
 357                                     if(null != dataList) {
 
 358                                         JSONObject jObj = new JSONObject()
 
 359                                         for (int i = 0; i < dataList.getLength(); i++) {
 
 360                                             Node dNode = dataList.item(i)
 
 361                                             if(dNode.getNodeName() == "relationship-data") {
 
 362                                                 Element rDataEle = (Element)dNode
 
 363                                                 def eKey =  rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
 
 364                                                 def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
 
 365                                                 if(eKey.equals("service-instance.service-instance-id")){
 
 366                                                     jObj.put("resourceInstanceId", eValue)
 
 369                                             else if(dNode.getNodeName() == "related-to-property"){
 
 370                                                  Element rDataEle = (Element)dNode
 
 371                                                  def eKey =  rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
 
 372                                                  def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
 
 373                                                  if(eKey.equals("service-instance.service-instance-name")){
 
 374                                                         jObj.put("resourceType", eValue)
 
 378                                         logger.info("Relationship related to Resource:" + jObj.toString())
 
 381                                                         //for overlay/underlay
 
 382                                                                 }else if (e.equals("configuration")){
 
 383                                     def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
 
 384                                     logger.info("ServiceInstance Related Configuration :" + relatedObject)
 
 385                                                                         NodeList dataList = node.getChildNodes()
 
 386                                                                         if(null != dataList) {
 
 387                                                                                 JSONObject jObj = new JSONObject()
 
 388                                                                                 for (int i = 0; i < dataList.getLength(); i++) {
 
 389                                                                                         Node dNode = dataList.item(i)
 
 390                                                                                         if(dNode.getNodeName() == "relationship-data") {
 
 391                                                                                                 Element rDataEle = (Element)dNode
 
 392                                                                                                 def eKey =  rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
 
 393                                                                                                 def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
 
 394                                                                                                 if(eKey.equals("configuration.configuration-id")){
 
 395                                                                                                     jObj.put("resourceInstanceId", eValue)
 
 398                                                                                         else if(dNode.getNodeName() == "related-to-property"){
 
 399                                                      Element rDataEle = (Element)dNode
 
 400                                                      def eKey =  rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
 
 401                                                      def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
 
 402                                                      if(eKey.equals("configuration.configuration-type")){
 
 403                                                             jObj.put("resourceType", eValue)
 
 407                                                                                 logger.info("Relationship related to Resource:" + jObj.toString())
 
 413                         execution.setVariable("serviceRelationShip", jArray.toString())
 
 417                                 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
 
 419                                         logger.info("Error getting Service-instance from AAI", + serviceInstanceId)
 
 420                                         WorkflowException workflowException = execution.getVariable("WorkflowException")
 
 421                                         logger.debug("workflowException: " + workflowException)
 
 422                                         if(workflowException != null){
 
 423                                                 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
 
 427                                                 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
 
 429                                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
 
 433                                 logger.info("Service-instance NOT found in AAI. Silent Success")
 
 435                 }catch (BpmnError e) {
 
 437                 } catch (Exception ex) {
 
 438                         msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage()
 
 440                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 442                 logger.trace("Exit postProcessAAIGET ")
 
 446          * Deletes the service instance in aai
 
 448         public void deleteServiceInstance(DelegateExecution execution) {
 
 449                 logger.trace("Entered deleteServiceInstance")
 
 451                         String globalCustId = execution.getVariable("globalSubscriberId")
 
 452                         String serviceType = execution.getVariable("serviceType")
 
 453                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
 
 455                         AAIResourcesClient resourceClient = new AAIResourcesClient()
 
 456                         AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId)
 
 457                         resourceClient.delete(serviceInstanceUri)
 
 459                         logger.trace("Exited deleteServiceInstance")
 
 461                         logger.debug("Error occured within deleteServiceInstance method: " + e)
 
 462                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during deleteServiceInstance from aai")
 
 466    public void preInitResourcesOperStatus(DelegateExecution execution){
 
 467         logger.trace("STARTED preInitResourcesOperStatus Process ")
 
 469             String serviceId = execution.getVariable("serviceInstanceId")
 
 470             String operationId = execution.getVariable("operationId")
 
 471             String operationType = execution.getVariable("operationType")
 
 472             String resourceTemplateUUIDs = ""
 
 473             String result = "processing"
 
 474             String progress = "0"
 
 476             String operationContent = "Prepare service creation"
 
 477             logger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType)
 
 478             serviceId = UriUtils.encode(serviceId,"UTF-8")
 
 479             execution.setVariable("serviceInstanceId", serviceId)
 
 480             execution.setVariable("operationId", operationId)
 
 481             execution.setVariable("operationType", operationType)
 
 482             // we use resource instance ids for delete flow as resourceTemplateUUIDs
 
 485                  "resourceInstanceId":"1111",
 
 486                  "resourceType":"vIMS"
 
 489                  "resourceInstanceId":"222",
 
 490                  "resourceType":"vEPC"
 
 493                  "resourceInstanceId":"3333",
 
 494                  "resourceType":"overlay"
 
 497                  "resourceInstanceId":"4444",
 
 498                  "resourceType":"underlay"
 
 501             String serviceRelationShip = execution.getVariable("serviceRelationShip")
 
 503             def jsonSlurper = new JsonSlurper()
 
 504             def jsonOutput = new JsonOutput()
 
 505             List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
 
 507             if (relationShipList != null) {
 
 508                 relationShipList.each {
 
 509                     resourceTemplateUUIDs  = resourceTemplateUUIDs + it.resourceInstanceId + ":"
 
 513             def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
 
 514             execution.setVariable("URN_mso_adapters_openecomp_db_endpoint", dbAdapterEndpoint)
 
 517                 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 
 518                         xmlns:ns="http://org.onap.so/requestsdb">
 
 521                             <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
 
 522                             <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
 
 523                             <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
 
 524                             <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
 
 525                             <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUIDs)}</resourceTemplateUUIDs>
 
 526                         </ns:initResourceOperationStatus>
 
 528                 </soapenv:Envelope>"""
 
 530             payload = utils.formatXml(payload)
 
 531             execution.setVariable("CVFMI_initResOperStatusRequest", payload)
 
 532             logger.info("Outgoing initResourceOperationStatus: \n" + payload)
 
 533             logger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
 
 536                         logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
 
 537                                         "Exception Occured Processing preInitResourcesOperStatus.", "BPMN",
 
 538                                         ErrorCode.UnknownError.getValue(), e)
 
 539             execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
 
 541         logger.trace("COMPLETED preInitResourcesOperStatus Process ")
 
 545     * prepare delete parameters
 
 547    public void preResourceDelete(execution, resourceName){
 
 548        // we use resource instance ids for delete flow as resourceTemplateUUIDs
 
 551             "resourceInstanceId":"1111",
 
 552             "resourceType":"vIMS"
 
 555             "resourceInstanceId":"222",
 
 556             "resourceType":"vEPC"
 
 559             "resourceInstanceId":"3333",
 
 560             "resourceType":"overlay"
 
 563             "resourceInstanceId":"4444",
 
 564             "resourceType":"underlay"
 
 567        logger.trace("STARTED preResourceDelete Process ")
 
 568        String serviceRelationShip = execution.getVariable("serviceRelationShip")
 
 569        def jsonSlurper = new JsonSlurper()
 
 570        def jsonOutput = new JsonOutput()
 
 571        List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
 
 573        if (relationShipList != null) {
 
 574            relationShipList.each {
 
 575                if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) {
 
 576                                    String resourceInstanceUUID = it.resourceInstanceId
 
 577                                    String resourceTemplateUUID = it.resourceInstanceId
 
 578                                    execution.setVariable("resourceTemplateId", resourceTemplateUUID)
 
 579                                    execution.setVariable("resourceInstanceId", resourceInstanceUUID)
 
 580                                    execution.setVariable("resourceType", resourceName)
 
 581                                logger.info("Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + "  resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName)
 
 585        logger.trace("END preResourceDelete Process ")
 
 588    public void sequenceResource(execution){
 
 589        logger.trace("STARTED sequenceResource Process ")
 
 590        List<String> nsResources = new ArrayList<String>()
 
 591        List<String> wanResources = new ArrayList<String>()
 
 592        List<String> resourceSequence = new  ArrayList<String>()
 
 594        String serviceRelationShip = execution.getVariable("serviceRelationShip")
 
 597        def jsonSlurper = new JsonSlurper()
 
 598        def jsonOutput = new JsonOutput()
 
 599        List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
 
 601        if (relationShipList != null) {
 
 602            relationShipList.each {
 
 603                if(StringUtils.containsIgnoreCase(it.resourceType, "overlay") || StringUtils.containsIgnoreCase(it.resourceType, "underlay")){
 
 604                    wanResources.add(it.resourceType)
 
 606                    nsResources.add(it.resourceType)
 
 610        resourceSequence.addAll(wanResources)
 
 611        resourceSequence.addAll(nsResources)
 
 612        String isContainsWanResource = wanResources.isEmpty() ? "false" : "true"
 
 613        execution.setVariable("isContainsWanResource", isContainsWanResource)
 
 614        execution.setVariable("currentResourceIndex", 0)
 
 615        execution.setVariable("resourceSequence", resourceSequence)
 
 616        logger.info("resourceSequence: " + resourceSequence)
 
 617        execution.setVariable("wanResources", wanResources)
 
 618        logger.trace("END sequenceResource Process ")
 
 621    public void getCurrentResource(execution){
 
 622        logger.trace("Start getCurrentResoure Process ")
 
 623        def currentIndex = execution.getVariable("currentResourceIndex")
 
 624        List<String> resourceSequence = execution.getVariable("resourceSequence")
 
 625        List<String> wanResources = execution.getVariable("wanResources")
 
 626        String resourceName =  resourceSequence.get(currentIndex)
 
 627        execution.setVariable("resourceType",resourceName)
 
 628        if(wanResources.contains(resourceName)){
 
 629            execution.setVariable("controllerInfo", "SDN-C")
 
 631            execution.setVariable("controllerInfo", "VF-C")
 
 633        logger.trace("COMPLETED getCurrentResoure Process ")
 
 636    public void parseNextResource(execution){
 
 637        logger.trace("Start parseNextResource Process ")
 
 638        def currentIndex = execution.getVariable("currentResourceIndex")
 
 639        def nextIndex =  currentIndex + 1
 
 640        execution.setVariable("currentResourceIndex", nextIndex)
 
 641        List<String> resourceSequence = execution.getVariable("resourceSequence")
 
 642        if(nextIndex >= resourceSequence.size()){
 
 643            execution.setVariable("allResourceFinished", "true")
 
 645            execution.setVariable("allResourceFinished", "false")
 
 647        logger.trace("COMPLETED parseNextResource Process ")