Changed files ecomp-model to onap-model
[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                                                 <onap-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                                             </onap-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                         execution.setVariable("serviceInstanceId","serviceInstanceId")
313                         execution.setVariable("GENGS_FoundIndicator",true)
314                         execution.setVariable("GENGS_siResourceLink","GENGS_siResourceLink")
315                         execution.setVariable("globalSubscriberId","globalSubscriberId")
316                         execution.setVariable("subscriptionServiceType","subscriptionServiceType")
317                         execution.setVariable("GENGS_service","GENGS_service")
318                         execution.setVariable("GENGS_SuccessIndicator",true)
319
320                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
321                         boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
322                         String serviceType = ""
323
324                         if(foundInAAI == true){
325                                 utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled)
326
327                                 //Extract GlobalSubscriberId
328                                 String siRelatedLink = execution.getVariable("GENGS_siResourceLink")
329                                 if (isBlank(siRelatedLink))
330                                 {
331                                         msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
332                                         utils.log("DEBUG", msg, isDebugEnabled)
333                                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
334                                 }
335                                 else
336                                 {
337                                         utils.log("DEBUG","Found Service-instance in AAI. link: " + siRelatedLink, isDebugEnabled)
338                                         String  globalSubscriberId = execution.getVariable("globalSubscriberId")
339                                         if(isBlank(globalSubscriberId)){
340                                                 int custStart = siRelatedLink.indexOf("customer/")
341                                                 int custEnd = siRelatedLink.indexOf("/service-subscriptions")
342                                                 globalSubscriberId = siRelatedLink.substring(custStart + 9, custEnd)
343                                                 execution.setVariable("globalSubscriberId", globalSubscriberId)
344                                         }
345
346                                         //Extract Service Type if not provided on request
347                                         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
348                                         if(isBlank(subscriptionServiceType)){
349                                                 int serviceStart = siRelatedLink.indexOf("service-subscription/")
350                                                 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
351                                                 String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd)
352                                                 subscriptionServiceType = UriUtils.decode(serviceTypeEncoded, "UTF-8")
353                                                 execution.setVariable("subscriptionServiceType", subscriptionServiceType)
354                                         }
355
356                                         if (isBlank(globalSubscriberId) || isBlank(subscriptionServiceType))
357                                         {
358                                                 msg = "Could not retrive global-customer-id & subscription-service-type from AAI to delete id:" + serviceInstanceId
359                                                 utils.log("DEBUG", msg, isDebugEnabled)
360                                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
361                                         }
362                                 }
363
364                                 String siData = execution.getVariable("GENGS_service")
365                                 utils.log("DEBUG", "SI Data", isDebugEnabled)
366                                 if (isBlank(siData))
367                                 {
368                                         msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
369                                         utils.log("DEBUG", msg, isDebugEnabled)
370                                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
371                                 }
372                         /*      else
373                                 {
374                                         utils.log("DEBUG", "SI Data" + siData, isDebugEnabled)
375                                         serviceType = utils.getNodeText1(siData,"service-type")
376                                         execution.setVariable("serviceType", serviceType)
377                                         execution.setVariable("serviceRole", utils.getNodeText1(siData,"service-role"))
378                                         String orchestrationStatus =  utils.getNodeText1(siData,"orchestration-status")
379
380                                         //Confirm there are no related service instances (vnf/network or volume)
381                                         if (utils.nodeExists(siData, "relationship-list")) {
382                                                 utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled)
383                                                 InputSource source = new InputSource(new StringReader(siData));
384                                                 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
385                                                 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
386                                                 Document serviceXml = docBuilder.parse(source)
387
388                                                 NodeList nodeList = serviceXml.getElementsByTagName("relationship")
389                                                 for (int x = 0; x < nodeList.getLength(); x++) {
390                                                         Node node = nodeList.item(x)
391                                                         if (node.getNodeType() == Node.ELEMENT_NODE) {
392                                                                 Element eElement = (Element) node
393                                                                 def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()
394                                                                 if(e.equals("generic-vnf") || e.equals("l3-network") || e.equals("allotted-resource") ){
395                                                                         utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs, l3-networks or allotted-resources", isDebugEnabled)
396                                                                         execution.setVariable("siInUse", true)
397                                                                         //there are relationship dependencies to this Service Instance
398                                                                         msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId
399                                                                         utils.log("DEBUG", msg, isDebugEnabled)
400                                                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
401                                                                 }else{
402                                                                         utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)
403                                                                 }
404                                                         }
405                                                 }
406                                         }
407
408                                         if ("TRANSPORT".equalsIgnoreCase(serviceType))
409                                         {
410                                                 if ("PendingDelete".equals(orchestrationStatus))
411                                                 {
412                                                         execution.setVariable("skipDeactivate", true)
413                                                 }
414                                                 else
415                                                 {
416                                                         msg = "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status:" + orchestrationStatus
417                                                         utils.log("DEBUG", msg, isDebugEnabled)
418                                                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
419                                                 }
420
421                                         }
422                                 }*/
423                         }else{
424                                 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
425                                 if(succInAAI != true){
426                                         utils.log("DEBUG","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
427                                         WorkflowException workflowException = execution.getVariable("WorkflowException")
428                                         utils.logAudit("workflowException: " + workflowException)
429                                         if(workflowException != null){
430                                                 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
431                                         }
432                                         else
433                                         {
434                                                 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
435                                                 utils.log("DEBUG", msg, isDebugEnabled)
436                                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
437                                         }
438                                 }
439
440                                 utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
441                         }
442                 } catch (BpmnError e) {
443                         throw e;
444                 } catch (Exception ex) {
445                         msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage()
446                         utils.log("DEBUG", msg, isDebugEnabled)
447                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
448                 }
449                 utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
450         }
451
452         public void postProcessAAIDEL(Execution execution) {
453                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
454                 utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
455                 String msg = ""
456                 try {
457                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
458                         boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
459                         if(succInAAI != true){
460                                 msg = "Error deleting Service-instance in AAI" + serviceInstanceId
461                                 utils.log("DEBUG", msg, isDebugEnabled)
462                                 WorkflowException workflowException = execution.getVariable("WorkflowException")
463                                 utils.logAudit("workflowException: " + workflowException)
464                                 if(workflowException != null){
465                                         exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
466                                 }
467                                 else
468                                 {
469                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
470                                 }
471                         }
472                 } catch (BpmnError e) {
473                         throw e;
474                 } catch (Exception ex) {
475                         msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage()
476                         utils.log("DEBUG", msg, isDebugEnabled)
477                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
478                 }
479                 utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled)
480         }
481         
482         public void preInitResourcesOperStatus(Execution execution){
483         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
484
485         utils.log("DEBUG", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
486         try{
487             String serviceId = execution.getVariable("serviceInstanceId")
488             String operationId = execution.getVariable("operationId")
489             String operationType = execution.getVariable("operationType")
490             String resourceTemplateUUIDs = ""
491             String result = "processing"
492             String progress = "0"
493             String reason = ""
494             String operationContent = "Prepare service creation"
495             utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + oprationType, isDebugEnabled)
496             serviceId = UriUtils.encode(serviceId,"UTF-8")
497             execution.setVariable("serviceInstanceId", serviceId)
498             execution.setVariable("operationId", operationId)
499             execution.setVariable("operationType", operationType)
500             // we use resource instance ids for delete flow as resourceTemplateUUIDs
501             /*[
502              {
503                  "resourceInstanceId":"1111",
504                  "resourceType":"vIMS"
505              },
506              {
507                  "resourceInstanceId":"222",
508                  "resourceType":"vEPC"
509              },
510              {
511                  "resourceInstanceId":"3333",
512                  "resourceType":"overlay"
513              },
514              {
515                  "resourceInstanceId":"4444",
516                  "resourceType":"underlay"
517              }
518          ]*/
519             String serviceRelationShip = execution.getVariable("serviceRelationShip")
520             
521             def jsonSlurper = new JsonSlurper()
522             def jsonOutput = new JsonOutput()         
523             List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
524                     
525             if (relationShipList != null) {
526                 relationShipList.each {
527                     resourceTemplateUUIDs  = resourceTemplateUUIDs + it.resourceInstanceId + ":"
528                 }
529             }           
530
531             def dbAdapterEndpoint = execution.getVariable("URN_mso_openecomp_adapters_db_endpoint")
532             execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
533             utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
534
535             String payload =
536                 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
537                         xmlns:ns="http://org.openecomp.mso/requestsdb">
538                         <soapenv:Header/>
539                         <soapenv:Body>
540                             <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
541                             <serviceId>${serviceId}</serviceId>
542                             <operationId>${operationId}</operationId>
543                             <operationType>${operationType}</operationType>
544                             <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
545                         </ns:initResourceOperationStatus>
546                     </soapenv:Body>
547                 </soapenv:Envelope>"""
548
549             payload = utils.formatXml(payload)
550             execution.setVariable("CVFMI_initResOperStatusRequest", payload)
551             utils.log("DEBUG", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
552             utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
553
554         }catch(Exception e){
555             utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
556             execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
557         }
558         utils.log("DEBUG", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)  
559     }
560     
561    /**
562     * prepare delete parameters
563     */
564    public void preResourceDelete(execution, resourceName){
565        // we use resource instance ids for delete flow as resourceTemplateUUIDs
566        /*[
567         {
568             "resourceInstanceId":"1111",
569             "resourceType":"vIMS"
570         },
571         {
572             "resourceInstanceId":"222",
573             "resourceType":"vEPC"
574         },
575         {
576             "resourceInstanceId":"3333",
577             "resourceType":"overlay"
578         },
579         {
580             "resourceInstanceId":"4444",
581             "resourceType":"underlay"
582         }
583     ]*/
584        String serviceRelationShip = execution.getVariable("serviceRelationShip")       
585        def jsonSlurper = new JsonSlurper()
586        def jsonOutput = new JsonOutput()         
587        List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
588                
589        if (relationShipList != null) {
590            relationShipList.each {
591                if(resourceName.equals(it.resourceType))
592                String resouceTemplateUUID = it.resourceInstanceId
593                String resouceInstanceUUID = it.resourceInstanceId
594                execution.setVariable("resouceTemplateUUID", resouceTemplateUUID)
595                execution.setVariable("resouceInstanceId", resouceInstanceUUID)
596                execution.setResourceType("resourceType", resourceName)
597            }
598        }    
599    }
600 }