Quick fix to unblock the issue of VoLTE creation
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / DoCustomDeleteE2EServiceInstance.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.openecomp.mso.bpmn.infrastructure.scripts;
22
23 import static org.apache.commons.lang3.StringUtils.*;
24 import groovy.xml.XmlUtil
25 import groovy.json.*
26
27 import org.openecomp.mso.bpmn.core.json.JsonUtils
28 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
29 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
30 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
31 import org.openecomp.mso.bpmn.core.WorkflowException
32 import org.openecomp.mso.rest.APIResponse;
33 import org.openecomp.mso.rest.RESTClient
34 import org.openecomp.mso.rest.RESTConfig
35
36 import java.util.UUID;
37 import javax.xml.parsers.DocumentBuilder
38 import javax.xml.parsers.DocumentBuilderFactory
39
40 import org.camunda.bpm.engine.delegate.BpmnError
41 import org.camunda.bpm.engine.runtime.Execution
42 import org.json.JSONObject;
43 import org.apache.commons.lang3.*
44 import org.apache.commons.codec.binary.Base64;
45 import org.springframework.web.util.UriUtils;
46 import org.w3c.dom.Document
47 import org.w3c.dom.Element
48 import org.w3c.dom.Node
49 import org.w3c.dom.NodeList
50 import org.xml.sax.InputSource
51
52 /**
53  * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
54  * 
55  * Inputs:
56  * @param - msoRequestId
57  * @param - globalSubscriberId - O
58  * @param - subscriptionServiceType - O
59  * @param - serviceInstanceId
60  * @param - serviceInstanceName - O
61  * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
62  * @param - sdncVersion 
63  * @param - failNotFound - TODO
64  * @param - serviceInputParams - TODO
65  *
66  * Outputs:
67  * @param - WorkflowException
68  * 
69  * Rollback - Deferred
70  */
71 public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
72
73         String Prefix="DDELSI_"
74         ExceptionUtil exceptionUtil = new ExceptionUtil()
75         JsonUtils jsonUtil = new JsonUtils()
76
77         public void preProcessRequest (Execution execution) {
78                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
79                 utils.log("DEBUG"," ***** preProcessRequest *****",  isDebugEnabled)
80                 String msg = ""
81
82                 try {
83                         String requestId = execution.getVariable("msoRequestId")
84                         execution.setVariable("prefix",Prefix)
85
86                         //Inputs
87                         //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
88                         String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
89                         if (globalSubscriberId == null)
90                         {
91                                 execution.setVariable("globalSubscriberId", "")
92                         }
93
94                         //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
95                         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
96                         if (subscriptionServiceType == null)
97                         {
98                                 execution.setVariable("subscriptionServiceType", "")
99                         }
100
101                         //Generated in parent for AAI PUT
102                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
103                         if (isBlank(serviceInstanceId)){
104                                 msg = "Input serviceInstanceId is null"
105                                 utils.log("DEBUG", msg, isDebugEnabled)
106                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
107                         }
108
109                         String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
110                         if (isBlank(sdncCallbackUrl)) {
111                                 msg = "URN_mso_workflow_sdncadapter_callback is null"
112                                 utils.log("DEBUG", msg, isDebugEnabled)
113                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
114                         }
115                         execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
116                         utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
117
118                         StringBuilder sbParams = new StringBuilder()
119                         Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
120                         if (paramsMap != null)
121                         {
122                                 sbParams.append("<service-input-parameters>")
123                                 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
124                                         String paramsXml
125                                         String paramName = entry.getKey()
126                                         String paramValue = entry.getValue()
127                                         paramsXml =
128                                                         """     <param>
129                                                         <name>${paramName}</name>
130                                                         <value>${paramValue}</value>
131                                                         </param>
132                                                         """
133                                         sbParams.append(paramsXml)
134                                 }
135                                 sbParams.append("</service-input-parameters>")
136                         }
137                         String siParamsXml = sbParams.toString()
138                         if (siParamsXml == null)
139                                 siParamsXml = ""
140                         execution.setVariable("siParamsXml", siParamsXml)
141
142                 } catch (BpmnError e) {
143                         throw e;
144                 } catch (Exception ex){
145                         msg = "Exception in preProcessRequest " + ex.getMessage()
146                         utils.log("DEBUG", msg, isDebugEnabled)
147                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
148                 }
149                 utils.log("DEBUG"," ***** Exit preProcessRequest *****",  isDebugEnabled)
150         }
151         
152
153         public void preProcessVFCDelete (Execution execution) {
154         }
155         
156         public void postProcessVFCDelete(Execution execution, String response, String method) {
157         }
158         
159         public void preProcessSDNCDelete (Execution execution) {
160                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
161                 utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled)
162                 String msg = ""
163
164                 try {
165                         def serviceInstanceId = execution.getVariable("serviceInstanceId")
166                         def serviceInstanceName = execution.getVariable("serviceInstanceName")
167                         def callbackURL = execution.getVariable("sdncCallbackUrl")
168                         def requestId = execution.getVariable("msoRequestId")
169                         def serviceId = execution.getVariable("productFamilyId")
170                         def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
171                         def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
172
173                         String serviceModelInfo = execution.getVariable("serviceModelInfo")
174                         def modelInvariantUuid = ""
175                         def modelVersion = ""
176                         def modelUuid = ""
177                         def modelName = ""
178                         if (!isBlank(serviceModelInfo))
179                         {
180                                 modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
181                                 modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
182                                 modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
183                                 modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
184
185                                 if (modelInvariantUuid == null) {
186                                         modelInvariantUuid = ""
187                                 }
188                                 if (modelVersion == null) {
189                                         modelVersion = ""
190                                 }
191                                 if (modelUuid == null) {
192                                         modelUuid = ""
193                                 }
194                                 if (modelName == null) {
195                                         modelName = ""
196                                 }
197                         }
198                         if (serviceInstanceName == null) {
199                                 serviceInstanceName = ""
200                         }
201                         if (serviceId == null) {
202                                 serviceId = ""
203                         }
204
205                         def siParamsXml = execution.getVariable("siParamsXml")
206                         def serviceType = execution.getVariable("serviceType")
207                         if (serviceType == null)
208                         {
209                                 serviceType = ""
210                         }
211
212                         def sdncRequestId = UUID.randomUUID().toString()
213
214                         String sdncDelete =
215                                         """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
216                                                                                                         xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
217                                                                                                         xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
218                                    <sdncadapter:RequestHeader>
219                                                         <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
220                                                         <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
221                                                         <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
222                                                         <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
223                                                         <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
224                                                         <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
225                                         </sdncadapter:RequestHeader>
226                                 <sdncadapterworkflow:SDNCRequestData>
227                                         <request-information>
228                                                 <request-id>${requestId}</request-id>
229                                                 <source>MSO</source>
230                                                 <notification-url/>
231                                                 <order-number/>
232                                                 <order-version/>
233                                                 <request-action>DeleteServiceInstance</request-action>
234                                         </request-information>
235                                         <service-information>
236                                                 <service-id>${serviceId}</service-id>
237                                                 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
238                                                 <ecomp-model-information>
239                                                  <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
240                                                  <model-uuid>${modelUuid}</model-uuid>
241                                                  <model-version>${modelVersion}</model-version>
242                                                  <model-name>${modelName}</model-name>
243                                             </ecomp-model-information>
244                                                 <service-instance-id>${serviceInstanceId}</service-instance-id>
245                                                 <subscriber-name/>
246                                                 <global-customer-id>${globalSubscriberId}</global-customer-id>
247                                         </service-information>
248                                         <service-request-input>
249                                                 <service-instance-name>${serviceInstanceName}</service-instance-name>
250                                                 ${siParamsXml}
251                                         </service-request-input>
252                                 </sdncadapterworkflow:SDNCRequestData>
253                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
254
255                         sdncDelete = utils.formatXml(sdncDelete)
256                         def sdncRequestId2 = UUID.randomUUID().toString()
257                         String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
258                         execution.setVariable("sdncDelete", sdncDelete)
259                         execution.setVariable("sdncDeactivate", sdncDeactivate)
260                         utils.log("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
261                         utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled)
262
263                 } catch (BpmnError e) {
264                         throw e;
265                 } catch(Exception ex) {
266                         msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
267                         utils.log("DEBUG", msg, isDebugEnabled)
268                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
269                 }
270                 utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled)
271         }
272
273         public void postProcessSDNCDelete(Execution execution, String response, String method) {
274
275                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
276                 utils.log("DEBUG"," ***** postProcessSDNC " + method + " *****", isDebugEnabled)
277                 String msg = ""
278
279                 try {
280                         WorkflowException workflowException = execution.getVariable("WorkflowException")
281                         boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
282                         utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled)
283                         utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled)
284
285                         SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
286                         sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
287
288                         if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
289                                 utils.log("DEBUG","Good response from SDNC Adapter for service-instance " + method + "response:\n" + response, isDebugEnabled)
290
291                         }else{
292                                 msg = "Bad Response from SDNC Adapter for service-instance " + method
293                                 utils.log("DEBUG", msg, isDebugEnabled)
294                                 exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
295                         }
296                 } catch (BpmnError e) {
297                         throw e;
298                 } catch(Exception ex) {
299                         msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage()
300                         utils.log("DEBUG", msg, isDebugEnabled)
301                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
302                 }
303                 utils.log("DEBUG"," *** Exit postProcessSDNC " + method + " ***", isDebugEnabled)
304         }
305
306         public void postProcessAAIGET(Execution execution) {
307                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
308                 utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled)
309                 String msg = ""
310
311                 try {
312
313                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
314                         boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
315                         String serviceType = ""
316
317                         if(foundInAAI == true){
318                                 utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled)
319
320                                 //Extract GlobalSubscriberId
321                                 String siRelatedLink = execution.getVariable("GENGS_siResourceLink")
322                                 if (isBlank(siRelatedLink))
323                                 {
324                                         msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
325                                         utils.log("DEBUG", msg, isDebugEnabled)
326                                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
327                                 }
328                                 else
329                                 {
330                                         utils.log("DEBUG","Found Service-instance in AAI. link: " + siRelatedLink, isDebugEnabled)
331                                         String  globalSubscriberId = execution.getVariable("globalSubscriberId")
332                                         if(isBlank(globalSubscriberId)){
333                                                 int custStart = siRelatedLink.indexOf("customer/")
334                                                 int custEnd = siRelatedLink.indexOf("/service-subscriptions")
335                                                 globalSubscriberId = siRelatedLink.substring(custStart + 9, custEnd)
336                                                 execution.setVariable("globalSubscriberId", globalSubscriberId)
337                                         }
338
339                                         //Extract Service Type if not provided on request
340                                         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
341                                         if(isBlank(subscriptionServiceType)){
342                                                 int serviceStart = siRelatedLink.indexOf("service-subscription/")
343                                                 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
344                                                 String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd)
345                                                 subscriptionServiceType = UriUtils.decode(serviceTypeEncoded, "UTF-8")
346                                                 execution.setVariable("subscriptionServiceType", subscriptionServiceType)
347                                         }
348
349                                         if (isBlank(globalSubscriberId) || isBlank(subscriptionServiceType))
350                                         {
351                                                 msg = "Could not retrive global-customer-id & subscription-service-type from AAI to delete id:" + serviceInstanceId
352                                                 utils.log("DEBUG", msg, isDebugEnabled)
353                                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
354                                         }
355                                 }
356
357                                 String siData = execution.getVariable("GENGS_service")
358                                 utils.log("DEBUG", "SI Data", isDebugEnabled)
359                                 if (isBlank(siData))
360                                 {
361                                         msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
362                                         utils.log("DEBUG", msg, isDebugEnabled)
363                                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
364                                 }
365                                 else
366                                 {
367                                         utils.log("DEBUG", "SI Data" + siData, isDebugEnabled)
368                                         serviceType = utils.getNodeText1(siData,"service-type")
369                                         execution.setVariable("serviceType", serviceType)
370                                         execution.setVariable("serviceRole", utils.getNodeText1(siData,"service-role"))
371                                         String orchestrationStatus =  utils.getNodeText1(siData,"orchestration-status")
372
373                                         //Confirm there are no related service instances (vnf/network or volume)
374                                         if (utils.nodeExists(siData, "relationship-list")) {
375                                                 utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled)
376                                                 InputSource source = new InputSource(new StringReader(siData));
377                                                 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
378                                                 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
379                                                 Document serviceXml = docBuilder.parse(source)
380
381                                                 NodeList nodeList = serviceXml.getElementsByTagName("relationship")
382                                                 for (int x = 0; x < nodeList.getLength(); x++) {
383                                                         Node node = nodeList.item(x)
384                                                         if (node.getNodeType() == Node.ELEMENT_NODE) {
385                                                                 Element eElement = (Element) node
386                                                                 def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()
387                                                                 if(e.equals("generic-vnf") || e.equals("l3-network") || e.equals("allotted-resource") ){
388                                                                         utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs, l3-networks or allotted-resources", isDebugEnabled)
389                                                                         execution.setVariable("siInUse", true)
390                                                                         //there are relationship dependencies to this Service Instance
391                                                                         msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId
392                                                                         utils.log("DEBUG", msg, isDebugEnabled)
393                                                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
394                                                                 }else{
395                                                                         utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)
396                                                                 }
397                                                         }
398                                                 }
399                                         }
400
401                                         if ("TRANSPORT".equalsIgnoreCase(serviceType))
402                                         {
403                                                 if ("PendingDelete".equals(orchestrationStatus))
404                                                 {
405                                                         execution.setVariable("skipDeactivate", true)
406                                                 }
407                                                 else
408                                                 {
409                                                         msg = "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status:" + orchestrationStatus
410                                                         utils.log("DEBUG", msg, isDebugEnabled)
411                                                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
412                                                 }
413
414                                         }
415                                 }
416                         }else{
417                                 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
418                                 if(succInAAI != true){
419                                         utils.log("DEBUG","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
420                                         WorkflowException workflowException = execution.getVariable("WorkflowException")
421                                         utils.logAudit("workflowException: " + workflowException)
422                                         if(workflowException != null){
423                                                 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
424                                         }
425                                         else
426                                         {
427                                                 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
428                                                 utils.log("DEBUG", msg, isDebugEnabled)
429                                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
430                                         }
431                                 }
432
433                                 utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
434                         }
435                 } catch (BpmnError e) {
436                         throw e;
437                 } catch (Exception ex) {
438                         msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage()
439                         utils.log("DEBUG", msg, isDebugEnabled)
440                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
441                 }
442                 utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
443         }
444
445         public void postProcessAAIDEL(Execution execution) {
446                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
447                 utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
448                 String msg = ""
449                 try {
450                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
451                         boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
452                         if(succInAAI != true){
453                                 msg = "Error deleting Service-instance in AAI" + serviceInstanceId
454                                 utils.log("DEBUG", msg, isDebugEnabled)
455                                 WorkflowException workflowException = execution.getVariable("WorkflowException")
456                                 utils.logAudit("workflowException: " + workflowException)
457                                 if(workflowException != null){
458                                         exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
459                                 }
460                                 else
461                                 {
462                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
463                                 }
464                         }
465                 } catch (BpmnError e) {
466                         throw e;
467                 } catch (Exception ex) {
468                         msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage()
469                         utils.log("DEBUG", msg, isDebugEnabled)
470                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
471                 }
472                 utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled)
473         }
474         
475    public void preInitResourcesOperStatus(Execution execution){
476         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
477
478         utils.log("DEBUG", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
479         try{
480             String serviceId = execution.getVariable("serviceInstanceId")
481             String operationId = execution.getVariable("operationId")
482             String operationType = execution.getVariable("operationType")
483             String resourceTemplateUUIDs = ""
484             String result = "processing"
485             String progress = "0"
486             String reason = ""
487             String operationContent = "Prepare service creation"
488             utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + oprationType, isDebugEnabled)
489             serviceId = UriUtils.encode(serviceId,"UTF-8")
490             execution.setVariable("serviceInstanceId", serviceId)
491             execution.setVariable("operationId", operationId)
492             execution.setVariable("operationType", operationType)
493             // we use resource instance ids for delete flow as resourceTemplateUUIDs
494             /*[
495              {
496                  "resourceInstanceId":"1111",
497                  "resourceType":"vIMS"
498              },
499              {
500                  "resourceInstanceId":"222",
501                  "resourceType":"vEPC"
502              },
503              {
504                  "resourceInstanceId":"3333",
505                  "resourceType":"overlay"
506              },
507              {
508                  "resourceInstanceId":"4444",
509                  "resourceType":"underlay"
510              }
511          ]*/
512             String serviceRelationShip = execution.getVariable("serviceRelationShip")
513             
514             def jsonSlurper = new JsonSlurper()
515             def jsonOutput = new JsonOutput()         
516             List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
517                     
518             if (relationShipList != null) {
519                 relationShipList.each {
520                     resourceTemplateUUIDs  = resourceTemplateUUIDs + it.resourceInstanceId + ":"
521                 }
522             }           
523
524             def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
525             execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
526             utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
527
528             String payload =
529                 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
530                         xmlns:ns="http://org.openecomp.mso/requestsdb">
531                         <soapenv:Header/>
532                         <soapenv:Body>
533                             <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
534                             <serviceId>${serviceId}</serviceId>
535                             <operationId>${operationId}</operationId>
536                             <operationType>${operationType}</operationType>
537                             <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
538                         </ns:initResourceOperationStatus>
539                     </soapenv:Body>
540                 </soapenv:Envelope>"""
541
542             payload = utils.formatXml(payload)
543             execution.setVariable("CVFMI_initResOperStatusRequest", payload)
544             utils.log("DEBUG", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
545             utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
546
547         }catch(Exception e){
548             utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
549             execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
550         }
551         utils.log("DEBUG", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)  
552     }
553    
554    /**
555     * prepare delete parameters
556     */
557    public void preResourceDelete(execution, resourceName){
558        // we use resource instance ids for delete flow as resourceTemplateUUIDs
559        /*[
560         {
561             "resourceInstanceId":"1111",
562             "resourceType":"vIMS"
563         },
564         {
565             "resourceInstanceId":"222",
566             "resourceType":"vEPC"
567         },
568         {
569             "resourceInstanceId":"3333",
570             "resourceType":"overlay"
571         },
572         {
573             "resourceInstanceId":"4444",
574             "resourceType":"underlay"
575         }
576     ]*/
577        String serviceRelationShip = execution.getVariable("serviceRelationShip")       
578        def jsonSlurper = new JsonSlurper()
579        def jsonOutput = new JsonOutput()         
580        List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
581                
582        if (relationShipList != null) {
583            relationShipList.each {
584                if(resouceName.equals(it.resouceType))
585                String resouceTemplateUUID = it.resourceInstanceId
586                String resouceInstanceUUID = it.resouceInstanceId
587                execution.setVariable("resouceTemplateUUID", resouceTemplateUUID)
588                execution.setVariable("resouceInstanceId", resouceInstanceUUID)
589                execution.setResourceType("resourceType", resouceName)
590            }
591        }    
592    }
593 }