a981abf011d214cc89f20c03581ecb668067abdf
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.bpmn.infrastructure.scripts
21
22 import static org.apache.commons.lang3.StringUtils.*;
23
24 import javax.ws.rs.core.Response
25 import javax.xml.parsers.DocumentBuilder
26 import javax.xml.parsers.DocumentBuilderFactory
27
28 import org.apache.commons.lang3.*
29 import org.camunda.bpm.engine.delegate.BpmnError
30 import org.camunda.bpm.engine.delegate.DelegateExecution
31 import org.json.JSONArray
32 import org.json.JSONObject
33
34 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
35 import org.onap.so.bpmn.common.scripts.ExceptionUtil
36 import org.onap.so.bpmn.common.scripts.MsoUtils
37 import org.onap.so.bpmn.core.WorkflowException
38 import org.onap.so.bpmn.core.domain.Resource
39 import org.onap.so.bpmn.core.domain.ServiceDecomposition
40 import org.onap.so.bpmn.core.UrnPropertiesReader
41
42 import org.onap.so.utils.TargetEntity
43 import org.onap.so.bpmn.core.json.JsonUtils
44 import org.onap.so.client.HttpClient
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 import groovy.json.*
53
54 /**
55  * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
56  *
57  * Inputs:
58  * @param - msoRequestId
59  * @param - globalSubscriberId - O
60  * @param - subscriptionServiceType - O
61  * @param - serviceInstanceId
62  * @param - serviceInstanceName - O
63  * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
64  * @param - sdncVersion
65  * @param - failNotFound - TODO
66  * @param - serviceInputParams - TODO
67  *
68  * @param - delResourceList
69  * @param - serviceRelationShip
70  *
71  * Outputs:
72  * @param - WorkflowException
73  *
74  * Rollback - Deferred
75  */
76 public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
77
78         String Prefix="DDEESI_"
79     ExceptionUtil exceptionUtil = new ExceptionUtil()
80     JsonUtils jsonUtil = new JsonUtils()
81
82     public void preProcessRequest (DelegateExecution execution) {
83         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
84         utils.log("INFO"," ***** preProcessRequest *****",  isDebugEnabled)
85         String msg = ""
86
87         try {
88             String requestId = execution.getVariable("msoRequestId")
89             execution.setVariable("prefix",Prefix)
90
91             //Inputs
92             //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
93             String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
94             if (globalSubscriberId == null)
95             {
96                 execution.setVariable("globalSubscriberId", "")
97             }
98
99             //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
100             String serviceType = execution.getVariable("serviceType")
101             if (serviceType == null)
102             {
103                 execution.setVariable("serviceType", "")
104             }
105
106             //Generated in parent for AAI PUT
107             String serviceInstanceId = execution.getVariable("serviceInstanceId")
108             if (isBlank(serviceInstanceId)){
109                 msg = "Input serviceInstanceId is null"
110                 utils.log("INFO", msg, isDebugEnabled)
111                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
112             }
113
114             String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
115             if (isBlank(sdncCallbackUrl)) {
116                 msg = "URN_mso_workflow_sdncadapter_callback is null"
117                 utils.log("INFO", msg, isDebugEnabled)
118                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
119             }
120             execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
121             utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
122
123             StringBuilder sbParams = new StringBuilder()
124             Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
125             if (paramsMap != null)
126             {
127                 sbParams.append("<service-input-parameters>")
128                 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
129                     String paramsXml
130                     String paramName = entry.getKey()
131                     String paramValue = entry.getValue()
132                     paramsXml =
133                             """ <param>
134                                                         <name>${MsoUtils.xmlEscape(paramName)}</name>
135                                                         <value>${MsoUtils.xmlEscape(paramValue)}</value>
136                                                         </param>
137                                                         """
138                     sbParams.append(paramsXml)
139                 }
140                 sbParams.append("</service-input-parameters>")
141             }
142             String siParamsXml = sbParams.toString()
143             if (siParamsXml == null)
144                 siParamsXml = ""
145             execution.setVariable("siParamsXml", siParamsXml)
146
147         } catch (BpmnError e) {
148             throw e;
149         } catch (Exception ex){
150             msg = "Exception in preProcessRequest " + ex.getMessage()
151             utils.log("INFO", msg, isDebugEnabled)
152             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
153         }
154         utils.log("INFO"," ***** Exit preProcessRequest *****",  isDebugEnabled)
155     }
156
157     public void postProcessAAIGET(DelegateExecution execution) {
158         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
159         utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled)
160         String msg = ""
161
162         try {
163             String serviceInstanceId = execution.getVariable("serviceInstanceId")
164             boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
165             String serviceType = ""
166
167             if(foundInAAI){
168                 utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
169
170                 String siData = execution.getVariable("GENGS_service")
171                 utils.log("INFO", "SI Data", isDebugEnabled)
172                 if (isBlank(siData))
173                 {
174                     msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
175                     utils.log("INFO", msg, isDebugEnabled)
176                     exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
177                 }
178                 else
179                 {
180                     InputSource source = new InputSource(new StringReader(siData));
181                     DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
182                     DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
183                     Document serviceXml = docBuilder.parse(source)
184                     serviceXml.getDocumentElement().normalize()
185                     // get model invariant id
186                     // Get Template uuid and version
187                     if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) {
188                         utils.log("INFO", "SI Data model-invariant-id and model-version-id exist:", isDebugEnabled)
189                         def modelInvariantId  = serviceXml.getElementsByTagName("model-invariant-id").item(0).getTextContent()
190                         def modelVersionId  = serviceXml.getElementsByTagName("model-version-id").item(0).getTextContent()
191
192                         // Set Original Template info
193                         execution.setVariable("model-invariant-id-original", modelInvariantId)
194                         execution.setVariable("model-version-id-original", modelVersionId)
195                     }
196
197                     utils.log("INFO", "SI Data" + siData, isDebugEnabled)
198                     //Confirm there are no related service instances (vnf/network or volume)
199                     if (utils.nodeExists(siData, "relationship-list")) {
200                         utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled)
201                         JSONArray jArray = new JSONArray()
202
203                         XmlParser xmlParser = new XmlParser()
204                         Node root = xmlParser.parseText(siData)
205                         def relation_list = utils.getChildNode(root, 'relationship-list')
206                         def relationships = utils.getIdenticalChildren(relation_list, 'relationship')
207
208                         for (def relation: relationships) {
209                                 def jObj = getRelationShipData(relation, isDebugEnabled)
210                                 jArray.put(jObj)
211                         }
212
213                         execution.setVariable("serviceRelationShip", jArray.toString())
214
215 //                        //test(siData)
216 //                        NodeList nodeList = serviceXml.getElementsByTagName("relationship")
217 //                        JSONArray jArray = new JSONArray()
218 //                        for (int x = 0; x < nodeList.getLength(); x++) {
219 //                            Node node = nodeList.item(x)
220 //                            if (node.getNodeType() == Node.ELEMENT_NODE) {
221 //                                Element eElement = (Element) node
222 //                                def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()                                                                  //for ns
223 //                                if(e.equals("service-instance")){
224 //                                    def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
225 //                                    utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled)
226 //                                    NodeList dataList = node.getChildNodes()
227 //                                    if(null != dataList) {
228 //                                        JSONObject jObj = new JSONObject()
229 //                                        for (int i = 0; i < dataList.getLength(); i++) {
230 //                                            Node dNode = dataList.item(i)
231 //                                            if(dNode.getNodeName() == "relationship-data") {
232 //                                                Element rDataEle = (Element)dNode
233 //                                                def eKey =  rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
234 //                                                def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
235 //                                                if(eKey.equals("service-instance.service-instance-id")){
236 //                                                    jObj.put("resourceInstanceId", eValue)
237 //                                                }
238 //
239 //                                            }
240 //                                            else if(dNode.getNodeName() == "related-to-property"){
241 //                                                Element rDataEle = (Element)dNode
242 //                                                def eKey =  rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
243 //                                                def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
244 //                                                if(eKey.equals("service-instance.service-instance-name")){
245 //                                                    jObj.put("resourceType", eValue)
246 //                                                }
247 //                                            }
248 //                                        }
249 //                                        utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
250 //                                        jArray.put(jObj)
251 //                                    }
252 //                                    //for overlay/underlay
253 //                                }else if (e.equals("configuration")){
254 //                                    def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
255 //                                    utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled)
256 //                                    NodeList dataList = node.getChildNodes()
257 //                                    if(null != dataList) {
258 //                                        JSONObject jObj = new JSONObject()
259 //                                        for (int i = 0; i < dataList.getLength(); i++) {
260 //                                            Node dNode = dataList.item(i)
261 //                                            if(dNode.getNodeName() == "relationship-data") {
262 //                                                Element rDataEle = (Element)dNode
263 //                                                def eKey =  rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
264 //                                                def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
265 //                                                if(eKey.equals("configuration.configuration-id")){
266 //                                                    jObj.put("resourceInstanceId", eValue)
267 //                                                }
268 //                                            }
269 //                                            else if(dNode.getNodeName() == "related-to-property"){
270 //                                                Element rDataEle = (Element)dNode
271 //                                                def eKey =  rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
272 //                                                def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
273 //                                                if(eKey.equals("configuration.configuration-type")){
274 //                                                    jObj.put("resourceType", eValue)
275 //                                                }
276 //                                            }
277 //                                        }
278 //                                        utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
279 //                                        jArray.put(jObj)
280 //                                    }
281 //                                // for SP-Partner
282 //                                }else if (e.equals("sp-partner")){
283 //
284 //                                                              }
285 //                            }
286 //                        }
287 //                        execution.setVariable("serviceRelationShip", jArray.toString())
288                     }
289                 }
290             }else{
291                 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
292                 if(!succInAAI){
293                     utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
294                     WorkflowException workflowException = execution.getVariable("WorkflowException")
295                     utils.logAudit("workflowException: " + workflowException)
296                     if(workflowException != null){
297                         exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
298                     }
299                     else
300                     {
301                         msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
302                         utils.log("INFO", msg, isDebugEnabled)
303                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
304                     }
305                 }
306
307                 utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
308             }
309         }catch (BpmnError e) {
310             throw e;
311         } catch (Exception ex) {
312             msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage()
313             utils.log("INFO", msg, isDebugEnabled)
314             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
315         }
316         utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
317     }
318
319         private JSONObject getRelationShipData(node, isDebugEnabled){
320                 JSONObject jObj = new JSONObject()
321
322                 def relation  = utils.nodeToString(node)
323                 def rt  = utils.getNodeText(relation, "related-to")
324
325                 def rl  = utils.getNodeText(relation, "related-link")
326                 utils.log("INFO", "ServiceInstance Related NS/Configuration :" + rl, isDebugEnabled)
327
328                 def rl_datas = utils.getIdenticalChildren(node, "relationship-data")
329                 for(def rl_data : rl_datas) {
330                         def eKey =  utils.getChildNodeText(rl_data, "relationship-key")
331                         def eValue = utils.getChildNodeText(rl_data, "relationship-value")
332
333                         if ((rt == "service-instance" && eKey.equals("service-instance.service-instance-id"))
334                         //for overlay/underlay
335                         || (rt == "configuration" && eKey.equals("configuration.configuration-id")
336                         )){
337                                 jObj.put("resourceInstanceId", eValue)
338                         }
339                         // for sp-partner and others
340                         else if(eKey.endsWith("-id")){
341                                 jObj.put("resourceInstanceId", eValue)
342                                 String resourceName = rt + eValue;
343                                 jObj.put("resourceType", resourceName)
344                         }
345
346                         jObj.put("resourceLinkUrl", rl)
347                 }
348
349                 def rl_props = utils.getIdenticalChildren(node, "related-to-property")
350                 for(def rl_prop : rl_props) {
351                         def eKey =  utils.getChildNodeText(rl_prop, "property-key")
352                         def eValue = utils.getChildNodeText(rl_prop, "property-value")
353                         if((rt == "service-instance" && eKey.equals("service-instance.service-instance-name"))
354                         //for overlay/underlay
355                         || (rt == "configuration" && eKey.equals("configuration.configuration-type"))){
356                                 jObj.put("resourceType", eValue)
357                         }
358                 }
359
360                 utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
361
362                 return jObj
363         }
364
365    public void getCurrentNS(DelegateExecution execution){
366        def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
367        utils.log("INFO", "======== Start getCurrentNS Process ======== ", isDebugEnabled)
368
369        def currentIndex = execution.getVariable("currentNSIndex")
370        List<String> nsSequence = execution.getVariable("nsSequence")
371        String nsResourceType =  nsSequence.get(currentIndex)
372
373        // GET AAI by Name, not ID, for process convenient
374        execution.setVariable("GENGS_type", "service-instance")
375        execution.setVariable("GENGS_serviceInstanceId", "")
376        execution.setVariable("GENGS_serviceInstanceName", nsResourceType)
377
378        utils.log("INFO", "======== COMPLETED getCurrentNS Process ======== ", isDebugEnabled)
379    }
380
381     public void prepareDecomposeService(DelegateExecution execution) {
382         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
383
384         try {
385             utils.log("DEBUG", " ***** Inside prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled)
386             String modelInvariantUuid = execution.getVariable("model-invariant-id-original")
387             String modelVersionId = execution.getVariable("model-version-id-original")
388
389             String serviceModelInfo = """{
390             "modelInvariantUuid":"${modelInvariantUuid}",
391             "modelUuid":"${modelVersionId}",
392             "modelVersion":""
393              }"""
394             execution.setVariable("serviceModelInfo", serviceModelInfo)
395
396             utils.log("DEBUG", " ***** Completed prepareDecomposeService of  create generic e2e service ***** ", isDebugEnabled)
397         } catch (Exception ex) {
398             // try error in method block
399             String exceptionMessage = "Bpmn error encountered in  create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()
400             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
401         }
402     }
403
404         private void generateRelatedResourceInfo(String response, JSONObject jObj){
405
406                 def xml = new XmlSlurper().parseText(response)
407                 def rtn = xml.childNodes()
408                 while (rtn.hasNext()) {
409                         groovy.util.slurpersupport.Node node = rtn.next()
410                         def key = node.name()
411                         def value = node.text()
412                         jObj.put(key, value)
413                 }
414         }
415
416         private JSONObject getRelatedResourceInAAI (DelegateExecution execution, JSONObject jObj)
417         {
418                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
419                 utils.log("INFO"," ***** Started getRelatedResourceInAAI *****",  isDebugEnabled)
420
421 //              AaiUtil aaiUriUtil = new AaiUtil()
422 //              String aai_endpoint = execution.getVariable("URN_aai_endpoint")
423         String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
424                 String urlLink = jObj.get("resourceLinkUrl")
425                 String serviceAaiPath = "${aai_endpoint}${urlLink}"
426
427                 URL url = new URL(serviceAaiPath)
428                 HttpClient client = new HttpClient(url, "application/xml", TargetEntity.AAI)
429
430
431                 Response response = client.get()
432                 int responseCode = response.getStatus()
433                 execution.setVariable(Prefix + "GeRelatedResourceResponseCode", responseCode)
434                 utils.log("DEBUG", "  Get RelatedResource code is: " + responseCode, isDebugEnabled)
435
436                 String aaiResponse = response.readEntity(String.class)
437                 execution.setVariable(Prefix + "GetRelatedResourceResponse", aaiResponse)
438
439                 //Process Response
440                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
441                         //200 OK 201 CREATED 202 ACCEPTED
442                 {
443                         utils.log("DEBUG", "GET RelatedResource Received a Good Response", isDebugEnabled)
444                         execution.setVariable(Prefix + "SuccessIndicator", true)
445                         execution.setVariable(Prefix + "FoundIndicator", true)
446
447                         generateRelatedResourceInfo(aaiResponse, jObj)
448
449                         //get model-invariant-uuid and model-uuid
450                         String modelInvariantId = ""
451                         String modelUuid = ""
452                         String modelCustomizationId = ""
453                         if(jObj.has("model-invariant-id")) {
454                                 modelInvariantId = jObj.get("model-invariant-id")
455                                 modelUuid = jObj.get("model-version-id")
456                                 modelCustomizationId = jObj.get("model-customization-id")
457                         }
458
459                         jObj.put("modelInvariantId", modelInvariantId)
460                         jObj.put("modelVersionId", modelUuid)
461                         jObj.put("modelCustomizationId", modelCustomizationId)
462                 }
463                 else
464                 {
465                         utils.log("ERROR", "Get RelatedResource Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
466                 }
467
468                 utils.log("INFO", " ***** Exit getRelatedResourceInAAI *****", isDebugEnabled)
469                 return jObj;
470
471         }
472
473     public void postDecomposeService(DelegateExecution execution) {
474         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
475
476         utils.log("DEBUG", " ***** Inside processDecomposition() of  delete generic e2e service flow ***** ", isDebugEnabled)
477         try {
478             ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
479
480             // service model info
481             execution.setVariable("serviceModelInfo", serviceDecomposition.getModelInfo())
482
483             List<Resource> deleteResourceList = serviceDecomposition.getServiceResources()
484             String serviceRelationShip = execution.getVariable("serviceRelationShip")
485             def jsonSlurper = new JsonSlurper()
486             def jsonOutput = new JsonOutput()
487
488             List relationShipList = null
489             if (serviceRelationShip != null) {
490                 relationShipList = jsonSlurper.parseText(serviceRelationShip)
491             }
492
493             List<Resource> deleteRealResourceList = new ArrayList<Resource>()
494
495             //Set the real resource instance id to the decomosed resource list
496             //reset the resource instance id , because in the decompose flow ,its a random one.
497             //match the resource-instance-name and the model name
498             if (relationShipList != null) {
499                 relationShipList.each {
500
501                     JSONObject obj = getRelatedResourceInAAI(execution, (JSONObject)it)
502
503                     for (Resource resource : deleteResourceList) {
504
505                         String modelName = resource.getModelInfo().getModelName()
506
507                         String modelCustomizationUuid = resource.getModelInfo().getModelCustomizationUuid()
508                         if (StringUtils.containsIgnoreCase(obj.get("resourceType"), modelName)) {
509                             resource.setResourceId(obj.get("resourceInstanceId"))
510                             deleteRealResourceList.add(resource)
511                         }
512                         else if (modelCustomizationUuid.equals(obj.get("modelCustomizationId"))) {
513                             resource.setResourceId(obj.get("resourceInstanceId"))
514                             resource.setResourceInstanceName(obj.get("resourceType"))
515                             deleteRealResourceList.add(resource)
516                         }
517                     }
518                 }
519             }
520
521             // only delete real existing resources
522             execution.setVariable("deleteResourceList", deleteRealResourceList)
523             
524             boolean isDeleteResourceListValid = false
525             if(deleteRealResourceList.size() > 0) {
526                 isDeleteResourceListValid = true
527             }
528             execution.setVariable("isDeleteResourceListValid", isDeleteResourceListValid)
529
530             utils.log("DEBUG", "delete resource list : " + deleteRealResourceList, isDebugEnabled)
531         } catch (Exception ex) {
532             String exceptionMessage = "Bpmn error encountered in  create generic e2e service flow. processDecomposition() - " + ex.getMessage()
533             utils.log("DEBUG", exceptionMessage, isDebugEnabled)
534             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
535         }
536         utils.log("DEBUG", " ***** exit processDecomposition() of  delete generic e2e service flow ***** ", isDebugEnabled)
537     }
538
539     public void preInitResourcesOperStatus(DelegateExecution execution){
540         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
541
542         utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
543         try{
544             String serviceId = execution.getVariable("serviceInstanceId")
545             String operationId = execution.getVariable("operationId")
546             String operationType = execution.getVariable("operationType")
547             String resourceTemplateUUIDs = ""
548             String result = "processing"
549             String progress = "0"
550             String reason = ""
551             String operationContent = "Prepare service creation"
552             utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
553             serviceId = UriUtils.encode(serviceId,"UTF-8")
554             execution.setVariable("serviceInstanceId", serviceId)
555             execution.setVariable("operationId", operationId)
556             execution.setVariable("operationType", operationType)
557             List<Resource> deleteResourceList = execution.getVariable("deleteResourceList")
558
559             String serviceRelationShip = execution.getVariable("serviceRelationShip")
560             for(Resource resource : deleteResourceList){
561                     resourceTemplateUUIDs  = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
562             }
563
564             def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
565             execution.setVariable("URN_mso_adapters_openecomp_db_endpoint", dbAdapterEndpoint)
566
567             String payload =
568                     """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
569                         xmlns:ns="http://org.onap.so/requestsdb">
570                         <soapenv:Header/>
571                         <soapenv:Body>
572                             <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
573                             <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
574                             <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
575                             <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
576                             <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUIDs)}</resourceTemplateUUIDs>
577                         </ns:initResourceOperationStatus>
578                     </soapenv:Body>
579                 </soapenv:Envelope>"""
580
581             payload = utils.formatXml(payload)
582             execution.setVariable("CVFMI_initResOperStatusRequest", payload)
583             utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
584             utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
585
586         }catch(Exception e){
587             utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
588             execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
589         }
590         utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
591     }
592     
593     public void prepareUpdateServiceOperationStatus(DelegateExecution execution){
594         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
595         utils.log("DEBUG", " ======== STARTED prepareUpdateServiceOperationStatus Process ======== ", isDebugEnabled)
596         try{
597             String serviceId = execution.getVariable("serviceInstanceId")
598             String operationId = execution.getVariable("operationId")
599             String userId = ""
600             String result = execution.getVariable("result")
601             String progress = execution.getVariable("progress")
602             String reason = ""
603             String operationContent = execution.getVariable("operationContent")
604             
605             serviceId = UriUtils.encode(serviceId,"UTF-8")
606
607             def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
608             execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
609             utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
610
611             String payload =
612                     """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
613                         xmlns:ns="http://org.onap.so/requestsdb">
614                         <soapenv:Header/>
615                         <soapenv:Body>
616                             <ns:updateServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
617                             <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
618                             <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
619                             <operationType>DELETE</operationType>
620                             <userId>${MsoUtils.xmlEscape(userId)}</userId>
621                             <result>${MsoUtils.xmlEscape(result)}</result>
622                             <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
623                             <progress>${MsoUtils.xmlEscape(progress)}</progress>
624                             <reason>${MsoUtils.xmlEscape(reason)}</reason>
625                         </ns:updateServiceOperationStatus>
626                     </soapenv:Body>
627                 </soapenv:Envelope>"""
628
629             payload = utils.formatXml(payload)
630             execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
631             utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled)
632
633         }catch(Exception e){
634             utils.log("ERROR", "Exception Occured Processing prepareUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
635             execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareUpdateServiceOperationStatus Method:\n" + e.getMessage())
636         }
637         utils.log("DEBUG", "======== COMPLETED prepareUpdateServiceOperationStatus Process ======== ", isDebugEnabled)
638     }
639
640      /**
641       * post config request.
642       */
643      public void postConfigRequest(execution){
644          //to do
645      }
646
647 }