Springboot 2.0 upgrade
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoCustomDeleteE2EServiceInstanceV2.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.onap.so.bpmn.infrastructure.scripts
22
23 import org.onap.aai.domain.yang.AllottedResource
24
25 import javax.ws.rs.core.UriBuilder
26
27 import static org.apache.commons.lang3.StringUtils.*;
28
29 import org.apache.commons.lang3.*
30 import org.camunda.bpm.engine.delegate.BpmnError
31 import org.camunda.bpm.engine.delegate.DelegateExecution
32 import org.json.JSONArray;
33 import org.onap.so.bpmn.common.scripts.AaiUtil
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.json.JsonUtils
38 import org.onap.so.logger.MessageEnum
39 import org.onap.so.logger.MsoLogger
40 import org.onap.so.rest.APIResponse;
41 import org.springframework.web.util.UriUtils;
42 import org.onap.so.client.aai.AAIResourcesClient
43 import org.onap.so.client.aai.AAIObjectType
44 import org.onap.so.client.aai.entities.AAIResultWrapper
45 import org.onap.so.client.aai.entities.uri.AAIResourceUri
46 import org.onap.so.client.aai.entities.uri.AAIUriFactory
47 import org.json.JSONObject
48 import javax.ws.rs.NotFoundException
49 import groovy.json.*
50
51
52
53 /**
54  * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
55  *
56  * Inputs:
57  * @param - msoRequestId
58  * @param - globalSubscriberId - O
59  * @param - subscriptionServiceType - O
60  * @param - serviceInstanceId
61  * @param - serviceInstanceName - O
62  * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
63  * @param - sdncVersion
64  * @param - failNotFound - TODO
65  * @param - serviceInputParams - TODO
66  *
67  * Outputs:
68  * @param - WorkflowException
69  *
70  * Rollback - Deferred
71  */
72 public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProcessor {
73         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCustomDeleteE2EServiceInstanceV2.class);
74
75
76         String Prefix="DDELSI_"
77         private static final String DebugFlag = "isDebugEnabled"
78         ExceptionUtil exceptionUtil = new ExceptionUtil()
79         JsonUtils jsonUtil = new JsonUtils()
80
81         public void preProcessRequest (DelegateExecution execution) {
82
83                 def method = getClass().getSimpleName() + '.buildAPPCRequest(' +'execution=' + execution.getId() +')'
84                 msoLogger.info("Entered " + method)
85                 msoLogger.trace("preProcessRequest ")
86                 String msg = ""
87
88                 try {
89                         String requestId = execution.getVariable("msoRequestId")
90                         execution.setVariable("prefix",Prefix)
91
92                         //Inputs
93                         //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
94                         String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
95                         if (globalSubscriberId == null)
96                         {
97                                 execution.setVariable("globalSubscriberId", "")
98                         }
99
100                         //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
101                         String serviceType = execution.getVariable("serviceType")
102                         if (serviceType == null)
103                         {
104                                 execution.setVariable("serviceType", "")
105                         }
106
107                         //Generated in parent for AAI PUT
108                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
109                         if (isBlank(serviceInstanceId)){
110                                 msg = "Input serviceInstanceId is null"
111                                 msoLogger.info(msg)
112                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
113                         }
114
115                         String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
116                         if (isBlank(sdncCallbackUrl)) {
117                                 msg = "URN_mso_workflow_sdncadapter_callback is null"
118                                 msoLogger.info(msg)
119                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
120                         }
121                         execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
122                         msoLogger.info("SDNC Callback URL: " + sdncCallbackUrl)
123
124                         StringBuilder sbParams = new StringBuilder()
125                         Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
126                         if (paramsMap != null)
127                         {
128                                 sbParams.append("<service-input-parameters>")
129                                 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
130                                         String paramsXml
131                                         String paramName = entry.getKey()
132                                         String paramValue = entry.getValue()
133                                         paramsXml =
134                                                         """     <param>
135                                                         <name>${MsoUtils.xmlEscape(paramName)}</name>
136                                                         <value>${MsoUtils.xmlEscape(paramValue)}</value>
137                                                         </param>
138                                                         """
139                                         sbParams.append(paramsXml)
140                                 }
141                                 sbParams.append("</service-input-parameters>")
142                         }
143                         String siParamsXml = sbParams.toString()
144                         if (siParamsXml == null)
145                                 siParamsXml = ""
146                         execution.setVariable("siParamsXml", siParamsXml)
147                         execution.setVariable("operationStatus", "Waiting delete resource...")
148                         execution.setVariable("progress", "0")
149
150                 } catch (BpmnError e) {
151                         throw e;
152                 } catch (Exception ex){
153                         msg = "Exception in preProcessRequest " + ex.getMessage()
154                         msoLogger.info(msg)
155                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
156                 }
157                 msoLogger.info("Exited " + method)
158         }
159
160         /**
161          * Gets the service instance and its relationships from aai
162          *
163          * @author cb645j
164          */
165         public void getServiceInstance(DelegateExecution execution) {
166                 try {
167                         String serviceInstanceId = execution.getVariable('serviceInstanceId')
168                         String globalSubscriberId = execution.getVariable('globalSubscriberId')
169                         String serviceType = execution.getVariable('serviceType')
170
171                         AAIResourcesClient resourceClient = new AAIResourcesClient()
172                         AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
173                         AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
174                         String json = wrapper.getJson()
175
176                         execution.setVariable("serviceInstance", json)
177
178                 }catch(BpmnError e) {
179                         throw e;
180                 }catch(NotFoundException e) {
181                         msoLogger.info("SI not found in aai. Silent Success ")
182                 }catch(Exception ex) {
183                         String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
184                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
185                 }
186         }
187
188         private void loadResourcesProperties(DelegateExecution execution) {
189                 def method = getClass().getSimpleName() + '.loadResourcesProperties(' +'execution=' + execution.getId() +')'
190                 def isDebugEnabled = execution.getVariable("isDebugEnabled")
191                 msoLogger.info("Entered " + method)
192                 String loadFilePath = "/etc/mso/config.d/reources.json"
193                 try{
194                         def jsonPayload = new File(loadFilePath).text
195                         msoLogger.info("jsonPayload: " + jsonPayload)
196
197                         String resourcesProperties = jsonUtil.prettyJson(jsonPayload.toString())
198                         msoLogger.info("resourcesProperties: " + resourcesProperties)
199
200                         String createResourceSort = jsonUtil.getJsonValue(resourcesProperties, "CreateResourceSort")
201                         msoLogger.info("createResourceSort: " + createResourceSort)
202                         execution.setVariable("createResourceSort", createResourceSort)
203
204                         String deleteResourceSort = jsonUtil.getJsonValue(resourcesProperties, "DeleteResourceSort")
205                         msoLogger.info("deleteResourceSort: " + deleteResourceSort)
206                         execution.setVariable("deleteResourceSort", deleteResourceSort)
207
208
209                         String resourceControllerType = jsonUtil.getJsonValue(resourcesProperties, "ResourceControllerType")
210                         msoLogger.info("resourceControllerType: " + resourceControllerType)
211                         execution.setVariable("resourceControllerType", resourceControllerType)
212
213
214                 }catch(Exception ex){
215             // try error in method block
216                         String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
217                         msoLogger.debug(exceptionMessage)
218                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
219         }
220             msoLogger.info("Exited " + method)
221         }
222         private void sortDeleteResource(DelegateExecution execution) {
223                 def method = getClass().getSimpleName() + '.sortDeleteResource(' +'execution=' + execution.getId() +')'
224                 def isDebugEnabled = execution.getVariable("isDebugEnabled")
225                 msoLogger.info("Entered " + method)
226                 String deleteResourceSortDef = """[
227                 {
228                     "resourceType":"GRE_SAR"
229                 },
230                 {
231                     "resourceType":"VPN_SAR"
232                 },
233                 {
234                     "resourceType":"APN_AAR"
235                 },
236                                 {
237                     "resourceType":"GRE_AAR"
238                 },
239                 {
240                     "resourceType":"Overlay"
241                 },
242                                 {
243                     "resourceType":"Underlay"
244                 },
245                 {
246                     "resourceType":"vIMS"
247                 },
248                 {
249                     "resourceType":"vCPE"
250                 },
251                 {
252                     "resourceType":"vFW"
253                 },
254                 {
255                     "resourceType":"vEPC"
256                 }
257
258
259             ]""".trim()
260
261         try{
262                         loadResourcesProperties(execution)
263                         String deleteResourceSort = execution.getVariable("deleteResourceSort")
264                         if (isBlank(deleteResourceSort)) {
265                                 deleteResourceSort = deleteResourceSortDef;
266                         }
267
268                         List<String> sortResourceList = jsonUtil.StringArrayToList(execution, deleteResourceSort)
269                 msoLogger.info("sortResourceList : " + sortResourceList)
270
271                         JSONArray newResourceList      = new JSONArray()
272                         int resSortCount = sortResourceList.size()
273
274                         for ( int currentResource = 0 ; currentResource < resSortCount ; currentResource++ ) {
275                                 String currentSortResource = sortResourceList[currentResource]
276                                 String sortResourceType = jsonUtil.getJsonValue(currentSortResource, "resourceType")
277                                 List<String> resourceList = execution.getVariable(Prefix+"resourceList")
278
279                                 for (String resource : resourceList) {
280                                         msoLogger.info("resource : " + resource)
281                                         String resourceType = jsonUtil.getJsonValue(resource, "resourceType")
282
283                                         if (StringUtils.containsIgnoreCase(resourceType, sortResourceType)) {
284                                                 JSONObject jsonObj = new JSONObject(resource)
285                                                 newResourceList.put(jsonObj)
286                                         }
287                                         msoLogger.info("Get next sort type " )
288                                 }
289                         }
290
291             String newResourceStr = newResourceList.toString()
292             List<String> newResourceListStr = jsonUtil.StringArrayToList(execution, newResourceStr)
293
294                         execution.setVariable(Prefix+"resourceList", newResourceListStr)
295                         msoLogger.info("newResourceList : " + newResourceListStr)
296
297                 }catch(Exception ex){
298             // try error in method block
299                         String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
300                         msoLogger.debug(exceptionMessage)
301                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
302         }
303             msoLogger.info("Exited " + method)
304
305         }
306         public void prepareServiceDeleteResource(DelegateExecution execution) {
307                 def method = getClass().getSimpleName() + '.prepareServiceDeleteResource(' +'execution=' + execution.getId() +')'
308                 msoLogger.info("Entered " + method)
309
310                 try {
311
312                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
313
314
315                         execution.setVariable(Prefix+"resourceList", "")
316                         execution.setVariable(Prefix+"resourceCount", 0)
317                         execution.setVariable(Prefix+"nextResource", 0)
318                         execution.setVariable(Prefix+"resourceFinish", true)
319
320                         String aaiJsonRecord = execution.getVariable("serviceInstance");
321                         msoLogger.info("serviceInstanceAaiRecord: " +aaiJsonRecord)
322
323                         msoLogger.info("aaiJsonRecord: " +aaiJsonRecord)
324                         def serviceInstanceName = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-instance-name")
325                         execution.setVariable("serviceInstanceName",serviceInstanceName)
326
327                         def serviceType = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-type")
328                         execution.setVariable("serviceType",serviceType)
329
330
331                         String relationshipList = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.relationship-list")
332                         msoLogger.info("relationship-list:" + relationshipList)
333                         if (! isBlank(relationshipList)){
334                                 msoLogger.info("relationship-list exists" )
335                                 String relationShip = jsonUtil.getJsonValue(relationshipList, "relationship")
336                                 msoLogger.info("relationship: " + relationShip)
337                                 JSONArray allResources      = new JSONArray()
338                                 JSONArray serviceResources  = new JSONArray()
339                                 JSONArray networkResources  = new JSONArray()
340                                 JSONArray allottedResources = new JSONArray()
341
342
343                                 if (! isBlank(relationShip)){
344                                         JSONArray jsonArray = new JSONArray();
345                                         if (relationShip.startsWith("{") && relationShip.endsWith("}")) {
346                                                 JSONObject jsonObject = new JSONObject(relationShip);
347                                                 jsonArray.put(jsonObject);
348                                         } else if (relationShip.startsWith("[") && relationShip.endsWith("]")) {
349                                                 jsonArray = new JSONArray(relationShip);
350                                         } else {
351                                                 msoLogger.info("The relationShip fomart is error" )
352                                         }
353
354                                         List<String> relationList = jsonUtil.StringArrayToList(execution, jsonArray.toString())
355
356                                         msoLogger.info("relationList: " + relationList)
357
358                                         int relationNum =relationList.size()
359                                         msoLogger.info("**************relationList size: " + relationNum)
360
361                                         for ( int currentRelation = 0 ; currentRelation < relationNum ; currentRelation++ ) {
362                                                 msoLogger.info("current Relation num: " + currentRelation)
363                                                 String relation = relationList[currentRelation]
364                                                 msoLogger.info("relation: " + relation)
365
366                                                 String relatedTo = jsonUtil.getJsonValue(relation, "related-to")
367                                 msoLogger.info("relatedTo: " + relatedTo)
368
369                                                 String relatedLink = jsonUtil.getJsonValue(relation, "related-link")
370                                                 msoLogger.info("relatedLink: " + relatedLink)
371
372                                 if (StringUtils.equalsIgnoreCase(relatedTo, "allotted-resource")) {
373                                         msoLogger.info("allotted-resource exists ")
374
375                             Optional<AllottedResource>  aaiArRsp = getAaiAr(execution, relatedLink)
376                                                         msoLogger.info("aaiArRsp: " + aaiArRsp)
377                                                         if (aaiArRsp.isPresent()) {
378
379                                                                 JSONObject jObject = new JSONObject()
380                                                                 jObject.put("resourceType", aaiArRsp.get().getType())
381                                                                 jObject.put("resourceInstanceId", aaiArRsp.get().getId())
382                                                                 jObject.put("resourceRole", aaiArRsp.get().getRole())
383                                                                 jObject.put("resourceVersion", aaiArRsp.get().getResourceVersion())
384
385                                                                 allResources.put(jObject)
386                                                                 msoLogger.info("allResources: " + allResources)
387                                                                 allottedResources.put(jObject)
388                                                                 msoLogger.info("allottedResources: " + allottedResources)
389                                                         }
390                                                 }
391                                                 else if (StringUtils.equalsIgnoreCase(relatedTo, "service-instance")){
392                                         msoLogger.info("service-instance exists ")
393                                                         JSONObject jObject = new JSONObject()
394
395                                                         //relationship-data
396                                                         String rsDataStr  = jsonUtil.getJsonValue(relation, "relationship-data")
397                                                         msoLogger.info("rsDataStr: " + rsDataStr)
398                                                         List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
399                                                         msoLogger.info("rsDataList: " + rsDataList)
400                                                         for(String rsData : rsDataList){
401                                                                 msoLogger.info("rsData: " + rsData)
402                                                                 def eKey =  jsonUtil.getJsonValue(rsData, "relationship-key")
403                                                                 def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
404                                                                 if(eKey.equals("service-instance.service-instance-id")){
405                                                                         jObject.put("resourceInstanceId", eValue)
406                                                                 }
407                                                                 if(eKey.equals("service-subscription.service-type")){
408                                                                         jObject.put("resourceType", eValue)
409                                                                 }
410                                                         }
411
412                                                         //related-to-property
413                                                         String rPropertyStr  = jsonUtil.getJsonValue(relation, "related-to-property")
414                                                         msoLogger.info("related-to-property: " + rPropertyStr)
415                                                         if (rPropertyStr instanceof JSONArray){
416                                                                 List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
417                                                                 for (String rProperty : rPropertyList) {
418                                                                         msoLogger.info("rProperty: " + rProperty)
419                                                                         def eKey =  jsonUtil.getJsonValue(rProperty, "property-key")
420                                                                         def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
421                                                                         if(eKey.equals("service-instance.service-instance-name")){
422                                                                                 jObject.put("resourceName", eValue)
423                                                                         }
424                                                                 }
425                                                         }
426                                                         else {
427                                                                 String rProperty = rPropertyStr
428                                                                 msoLogger.info("rProperty: " + rProperty)
429                                                                 def eKey =  jsonUtil.getJsonValue(rProperty, "property-key")
430                                                                 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
431                                                                 if (eKey.equals("service-instance.service-instance-name")) {
432                                                                         jObject.put("resourceName", eValue)
433                                                                 }
434                                                         }
435
436                                                         allResources.put(jObject)
437                                                         msoLogger.info("allResources: " + allResources)
438
439                                                         serviceResources.put(jObject)
440                                                         msoLogger.info("serviceResources: " + serviceResources)
441                                                 }
442                                                 else if (StringUtils.equalsIgnoreCase(relatedTo, "configuration")) {
443                                         msoLogger.info("configuration ")
444                                                         JSONObject jObject = new JSONObject()
445
446                                                         //relationship-data
447                                                         String rsDataStr  = jsonUtil.getJsonValue(relation, "relationship-data")
448                                                         msoLogger.info("rsDataStr: " + rsDataStr)
449                                                         List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
450                                                         msoLogger.info("rsDataList: " + rsDataList)
451                                                         for (String rsData : rsDataList) {
452                                                                 msoLogger.info("rsData: " + rsData)
453                                                                 def eKey =  jsonUtil.getJsonValue(rsData, "relationship-key")
454                                                                 def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
455                                                                 if(eKey.equals("configuration.configuration-id")){
456                                                                         jObject.put("resourceInstanceId", eValue)
457                                                                 }
458                                                         }
459
460
461                                                         //related-to-property
462                                                         String rPropertyStr  = jsonUtil.getJsonValue(relation, "related-to-property")
463                                                         msoLogger.info("related-to-property: " + rPropertyStr)
464                                                         if (rPropertyStr instanceof JSONArray){
465                                                                 List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
466                                                                 for(String rProperty : rPropertyList){
467                                                                         msoLogger.info("rProperty: " + rProperty)
468                                                                         def eKey =  jsonUtil.getJsonValue(rProperty, "property-key")
469                                                                         def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
470                                                                         if(eKey.equals("configuration.configuration-type")){
471                                                                                 jObject.put("resourceType", eValue)
472                                                                         }
473                                                                 }
474                                                         }
475                                                         else {
476                                                                 String rProperty = rPropertyStr
477                                                                 msoLogger.info("rProperty: " + rProperty)
478                                                                 def eKey =  jsonUtil.getJsonValue(rProperty, "property-key")
479                                                                 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
480                                                                 if(eKey.equals("configuration.configuration-type")){
481                                                                         jObject.put("resourceType", eValue)
482                                                                 }
483                                                         }
484                                                         allResources.put(jObject)
485                                                         msoLogger.info("allResources: " + allResources)
486
487                                                         networkResources.put(jObject)
488                                                         msoLogger.info("networkResources: " + networkResources)
489                                                 }
490                                                 msoLogger.info("Get Next releation resource " )
491
492                                         }
493                                         msoLogger.info("Get releation finished. " )
494                                 }
495
496                                 execution.setVariable("serviceRelationShip", allResources.toString())
497                             msoLogger.info("allResources: " + allResources.toString())
498                                 String serviceRelationShip = execution.getVariable("serviceRelationShip")
499                                 msoLogger.info("serviceRelationShip: " + serviceRelationShip)
500                                 if ((! isBlank(serviceRelationShip)) && (! serviceRelationShip.isEmpty())) {
501
502                                         List<String> relationShipList = jsonUtil.StringArrayToList(execution, serviceRelationShip)
503                                         msoLogger.info("relationShipList: " + relationShipList)
504                                         execution.setVariable(Prefix+"resourceList", relationShipList)
505
506                                         int resourceCount = relationShipList.size()
507                                         msoLogger.info("resourceCount: " + resourceCount)
508                                         execution.setVariable(Prefix+"resourceCount",resourceCount )
509
510                                         int resourceNum = 0
511                                         execution.setVariable(Prefix+"nextResource", resourceNum)
512                                         msoLogger.info("start sort delete resource: ")
513                                         sortDeleteResource(execution)
514
515
516                                         if (resourceNum < resourceCount) {
517                                                 execution.setVariable(Prefix+"resourceFinish", false)
518                                         }
519                                         else {
520                                         execution.setVariable(Prefix+"resourceFinish", true)
521                                         }
522                                         msoLogger.info("Resource  list set end : " + resourceCount)
523                 }
524
525                                 execution.setVariable("serviceResources", serviceResources.toString())
526                                 msoLogger.info("serviceResources: " + serviceResources)
527                                 String serviceResourcesShip = execution.getVariable("serviceResources")
528                                 msoLogger.info("serviceResourcesShip: " + serviceResourcesShip)
529
530                                 if ((! isBlank(serviceResourcesShip)) && (! serviceResourcesShip.isEmpty())) {
531                     List<String> serviceResourcesList = jsonUtil.StringArrayToList(execution, serviceResourcesShip)
532                                         msoLogger.info("serviceResourcesList: " + serviceResourcesList)
533                                         execution.setVariable(Prefix+"serviceResourceList", serviceResourcesList)
534                                 execution.setVariable(Prefix+"serviceResourceCount", serviceResourcesList.size())
535                                 execution.setVariable(Prefix+"nextServiceResource", 0)
536                                 msoLogger.info("Service Resource  list set end : " + serviceResourcesList.size())
537
538                 }
539
540                                 execution.setVariable("allottedResources", allottedResources.toString())
541                                 msoLogger.info("allottedResources: " + allottedResources)
542                                 String allottedResourcesShip = execution.getVariable("allottedResources")
543                                 msoLogger.info("allottedResourcesShip: " + allottedResourcesShip)
544                                 if ((! isBlank(allottedResourcesShip)) && (! allottedResourcesShip.isEmpty())) {
545                     List<String> allottedResourcesList = jsonUtil.StringArrayToList(execution, allottedResourcesShip)
546                                         msoLogger.info("allottedResourcesList: " + allottedResourcesList)
547                                         execution.setVariable(Prefix+"allottedResourcesList", allottedResourcesList)
548                                 execution.setVariable(Prefix+"allottedResourcesListCount", allottedResourcesList.size())
549                                 execution.setVariable(Prefix+"nextAllottedResourcesList", 0)
550                                 msoLogger.info("Allotted Resource  list set end : " + allottedResourcesList.size())
551
552                 }
553                                 execution.setVariable("networkResources", networkResources.toString())
554                                 msoLogger.info("networkResources: " + networkResources)
555                                 String networkResourcesShip = execution.getVariable("networkResources")
556                                 msoLogger.info("networkResourcesShip: " + networkResourcesShip)
557                                 if ((! isBlank(networkResourcesShip)) && (! networkResourcesShip.isEmpty())) {
558                     List<String> networkResourcesList = jsonUtil.StringArrayToList(execution, networkResourcesShip)
559                                         msoLogger.info("networkResourcesList: " + networkResourcesList)
560                                         execution.setVariable(Prefix+"networkResourcesList", networkResourcesList)
561                                 execution.setVariable(Prefix+"networkResourcesListCount", networkResourcesList.size())
562                                 execution.setVariable(Prefix+"nextNetworkResourcesList", 0)
563                                 msoLogger.info("Network Resource  list set end : " + networkResourcesList.size())
564
565                 }
566                         }
567                 } catch (BpmnError e){
568                         throw e;
569                 } catch (Exception ex) {
570                     String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. prepareServiceDeleteResource() - " + ex.getMessage()
571                     msoLogger.debug(exceptionMessage)
572                     exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
573                 }
574                 msoLogger.info("Exited " + method)
575         }
576
577         private Optional<AllottedResource>  getAaiAr(DelegateExecution execution, String relink) {
578                 def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
579                 msoLogger.info("Entered " + method)
580                 AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build())
581         return getAAIClient().get(AllottedResource.class,uri)
582         }
583         /**
584          * prepare Decompose next resource to create request
585          */
586         public void preProcessDecomposeNextResource(DelegateExecution execution){
587         def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
588                 msoLogger.info("Entered " + method)
589         msoLogger.trace("STARTED preProcessDecomposeNextResource Process ")
590         try{
591             int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
592                         List<String> serviceResourceList = execution.getVariable(Prefix+"serviceResourceList")
593                         msoLogger.info("Service Resource List : " + serviceResourceList)
594
595                         String serviceResource = serviceResourceList[resourceNum]
596             execution.setVariable(Prefix+"serviceResource", serviceResource)
597                         msoLogger.info("Current Service Resource : " + serviceResource)
598
599                         String resourceType  = jsonUtil.getJsonValue(serviceResource, "resourceType")
600                         execution.setVariable("resourceType", resourceType)
601                         msoLogger.info("resourceType : " + resourceType)
602
603                         String resourceInstanceId  = jsonUtil.getJsonValue(serviceResource, "resourceInstanceId")
604                         execution.setVariable("resourceInstanceId", resourceInstanceId)
605                         msoLogger.info("resourceInstanceId : " + resourceInstanceId)
606
607                         String resourceRole  = jsonUtil.getJsonValue(serviceResource, "resourceRole")
608                         execution.setVariable("resourceRole", resourceRole)
609                         msoLogger.info("resourceRole : " + resourceRole)
610
611                         String resourceVersion  = jsonUtil.getJsonValue(serviceResource, "resourceVersion")
612                         execution.setVariable("resourceVersion", resourceVersion)
613                         msoLogger.info("resourceVersion : " + resourceVersion)
614
615                         String resourceName = jsonUtil.getJsonValue(serviceResource, "resourceName")
616                         if (isBlank(resourceName)){
617                                 resourceName = resourceInstanceId
618                         }
619                         execution.setVariable(Prefix+"resourceName", resourceName)
620                         msoLogger.info("resource Name : " + resourceName)
621
622
623                         execution.setVariable(Prefix+"nextServiceResource", resourceNum + 1)
624
625                         int serviceResourceCount = execution.getVariable(Prefix+"serviceResourceCount")
626                         if (serviceResourceCount >0 ){
627                             int progress = (resourceNum*100) / serviceResourceCount
628                                 execution.setVariable("progress", progress.toString() )
629                         }
630                         execution.setVariable("operationStatus", resourceName )
631
632         }catch(Exception e){
633             // try error in method block
634                         String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method preProcessDecomposeNextResource() - " + ex.getMessage()
635                         msoLogger.debug(exceptionMessage)
636                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
637         }
638             msoLogger.info("Exited " + method)
639         }
640         /**
641          * post Decompose next resource to create request
642          */
643         public void postProcessDecomposeNextResource(DelegateExecution execution){
644         def method = getClass().getSimpleName() + '.postProcessDecomposeNextResource(' +'execution=' + execution.getId() +')'
645                 msoLogger.info("Entered " + method)
646         msoLogger.trace("STARTED postProcessDecomposeNextResource Process ")
647         try{
648             String resourceName = execution.getVariable(Prefix+"resourceName")
649                         int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
650                         msoLogger.debug("Current Resource count:"+ execution.getVariable(Prefix+"nextServiceResource"))
651
652                         int resourceCount = execution.getVariable(Prefix+"serviceResourceCount")
653                         msoLogger.debug("Total Resource count:"+ execution.getVariable(Prefix+"serviceResourceCount"))
654
655             if (resourceNum < resourceCount) {
656                                 execution.setVariable(Prefix+"resourceFinish", false)
657                         }
658                         else {
659                             execution.setVariable(Prefix+"resourceFinish", true)
660                         }
661
662                         msoLogger.debug("Resource Finished:"+ execution.getVariable(Prefix+"resourceFinish"))
663
664                         if (resourceCount >0 ){
665                             int progress = (resourceNum*100) / resourceCount
666
667                                 execution.setVariable("progress", progress.toString() )
668                                 msoLogger.trace(":"+ execution.getVariable(""))
669                         }
670                         execution.setVariable("operationStatus", resourceName )
671
672
673         }catch(Exception e){
674             // try error in method block
675                         String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method postProcessDecomposeNextResource() - " + ex.getMessage()
676                         msoLogger.debug(exceptionMessage)
677                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
678         }
679             msoLogger.info("Exited " + method)
680         }
681         /**
682         * prepare post Unkown Resource Type
683         */
684         public void postOtherControllerType(DelegateExecution execution){
685         def method = getClass().getSimpleName() + '.postOtherControllerType(' +'execution=' + execution.getId() +')'
686                 def isDebugEnabled = execution.getVariable("isDebugEnabled")
687                 msoLogger.info("Entered " + method)
688
689         try{
690
691             String resourceName = execution.getVariable(Prefix+"resourceName")
692                         String resourceType = execution.getVariable(Prefix+"resourceType")
693                         String controllerType = execution.getVariable("controllerType")
694
695                     String msg = "Resource name: "+ resourceName + " resource Type: " + resourceType+ " controller Type: " + controllerType + " can not be processed  n the workflow"
696                         msoLogger.debug(msg)
697
698         }catch(Exception e){
699             // try error in method block
700                         String exceptionMessage = "Bpmn error encountered in DoCreateMobileAPNServiceInstance flow. Unexpected Error from method postOtherControllerType() - " + ex.getMessage()
701                         msoLogger.debug(exceptionMessage)
702                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
703         }
704             msoLogger.info("Exited " + method)
705         }
706
707         /**
708     * prepare delete parameters
709     */
710     public void preSDNCResourceDelete(execution, resourceName){
711         // we use resource instance ids for delete flow as resourceTemplateUUIDs
712
713         def method = getClass().getSimpleName() + '.preSDNCResourceDelete(' +'execution=' + execution.getId() +')'
714                 msoLogger.info("Entered " + method)
715
716         msoLogger.trace("STARTED preSDNCResourceDelete Process ")
717         String networkResources = execution.getVariable("networkResources")
718
719
720         execution.setVariable("foundResource", false)
721         if (networkResources != null) {
722             def jsonSlurper = new JsonSlurper()
723             List relationShipList =  jsonSlurper.parseText(networkResources)
724                         relationShipList.each {
725                 if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) {
726                                     String resourceInstanceUUID = it.resourceInstanceId
727                                     String resourceTemplateUUID = it.resourceInstanceId
728                                     execution.setVariable("resourceTemplateId", resourceTemplateUUID)
729                                     execution.setVariable("resourceInstanceId", resourceInstanceUUID)
730                                     execution.setVariable("resourceType", resourceName)
731                                         execution.setVariable("foundResource", true)
732                                 msoLogger.info("Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + "  resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName)
733                                 }
734             }
735         }
736         msoLogger.info("Exited " + method)
737     }
738         public void preProcessSDNCDelete (DelegateExecution execution) {
739                 def method = getClass().getSimpleName() + '.preProcessSDNCDelete(' +'execution=' + execution.getId() +')'
740                 msoLogger.info("Entered " + method)
741                 msoLogger.trace("preProcessSDNCDelete ")
742                 String msg = ""
743
744                 try {
745                         def serviceInstanceId = execution.getVariable("serviceInstanceId")
746                         def serviceInstanceName = execution.getVariable("serviceInstanceName")
747                         def callbackURL = execution.getVariable("sdncCallbackUrl")
748                         def requestId = execution.getVariable("msoRequestId")
749                         def serviceId = execution.getVariable("productFamilyId")
750                         def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
751                         def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
752
753                         String serviceModelInfo = execution.getVariable("serviceModelInfo")
754                         def modelInvariantUuid = ""
755                         def modelVersion = ""
756                         def modelUuid = ""
757                         def modelName = ""
758                         if (!isBlank(serviceModelInfo))
759                         {
760                                 modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
761                                 modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
762                                 modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
763                                 modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
764
765                                 if (modelInvariantUuid == null) {
766                                         modelInvariantUuid = ""
767                                 }
768                                 if (modelVersion == null) {
769                                         modelVersion = ""
770                                 }
771                                 if (modelUuid == null) {
772                                         modelUuid = ""
773                                 }
774                                 if (modelName == null) {
775                                         modelName = ""
776                                 }
777                         }
778                         if (serviceInstanceName == null) {
779                                 serviceInstanceName = ""
780                         }
781                         if (serviceId == null) {
782                                 serviceId = ""
783                         }
784
785                         def siParamsXml = execution.getVariable("siParamsXml")
786                         def serviceType = execution.getVariable("serviceType")
787                         if (serviceType == null)
788                         {
789                                 serviceType = ""
790                         }
791
792                         def sdncRequestId = UUID.randomUUID().toString()
793
794                         String sdncDelete =
795                                         """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
796                                                                                                         xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
797                                                                                                         xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
798                                    <sdncadapter:RequestHeader>
799                                                         <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>
800                                                         <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
801                                                         <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
802                                                         <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
803                                                         <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
804                                                         <sdncadapter:MsoAction>${MsoUtils.xmlEscape(serviceType)}</sdncadapter:MsoAction>
805                                         </sdncadapter:RequestHeader>
806                                 <sdncadapterworkflow:SDNCRequestData>
807                                         <request-information>
808                                                 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
809                                                 <source>MSO</source>
810                                                 <notification-url/>
811                                                 <order-number/>
812                                                 <order-version/>
813                                                 <request-action>DeleteServiceInstance</request-action>
814                                         </request-information>
815                                         <service-information>
816                                                 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
817                                                 <subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type>
818                                                 <onap-model-information>
819                                                  <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
820                                                  <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
821                                                  <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
822                                                  <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
823                                             </onap-model-information>
824                                                 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
825                                                 <subscriber-name/>
826                                                 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
827                                         </service-information>
828                                         <service-request-input>
829                                                 <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name>
830                                                 ${siParamsXml}
831                                         </service-request-input>
832                                 </sdncadapterworkflow:SDNCRequestData>
833                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
834
835                         sdncDelete = utils.formatXml(sdncDelete)
836                         def sdncRequestId2 = UUID.randomUUID().toString()
837                         String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
838                         execution.setVariable("sdncDelete", sdncDelete)
839                         execution.setVariable("sdncDeactivate", sdncDeactivate)
840                         msoLogger.info("sdncDeactivate:\n" + sdncDeactivate)
841                         msoLogger.info("sdncDelete:\n" + sdncDelete)
842
843                 } catch (BpmnError e) {
844                         throw e;
845                 } catch(Exception ex) {
846                         msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
847                         msoLogger.info(msg)
848                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
849                 }
850                 msoLogger.info("Exited " + method)
851         }
852
853         public void postProcessSDNCDelete(DelegateExecution execution, String response, String action) {
854
855                 def method = getClass().getSimpleName() + '.postProcessSDNCDelete(' +'execution=' + execution.getId() +')'
856                 msoLogger.info("Entered " + method)
857                 msoLogger.trace("postProcessSDNC " + action + " ")
858                 String msg = ""
859
860                 /*try {
861                         WorkflowException workflowException = execution.getVariable("WorkflowException")
862                         boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
863                         msoLogger.info("SDNCResponse: " + response)
864                         msoLogger.info("workflowException: " + workflowException)
865
866                         SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
867                         sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
868                         if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){
869                                 msoLogger.info("Good response from SDNC Adapter for service-instance " + action + "response:\n" + response)
870
871                         }else{
872                                 msg = "Bad Response from SDNC Adapter for service-instance " + action
873                                 msoLogger.info(msg)
874                                 exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
875                         }
876                 } catch (BpmnError e) {
877                         throw e;
878                 } catch(Exception ex) {
879                         msg = "Exception in postProcessSDNC " + action + " Exception:" + ex.getMessage()
880                         msoLogger.info(msg)
881                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
882                 }*/
883                 msoLogger.info("Exited " + method)
884         }
885
886         /**
887          * Init the service Operation Status
888          */
889         public void preUpdateServiceOperationStatus(DelegateExecution execution){
890         def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')'
891                 msoLogger.info("Entered " + method)
892
893         try{
894             String serviceId = execution.getVariable("serviceInstanceId")
895             String operationId = execution.getVariable("operationId")
896             String serviceName = execution.getVariable("serviceInstanceName")
897             String operationType = "DELETE"
898             String userId = ""
899             String result = "processing"
900             String progress = execution.getVariable("progress")
901                         msoLogger.info("progress: " + progress )
902                         if ("100".equalsIgnoreCase(progress))
903                         {
904                                 result = "finished"
905                         }
906             String reason = ""
907             String operationContent = "Prepare service delete: " + execution.getVariable("operationStatus")
908             msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
909             serviceId = UriUtils.encode(serviceId,"UTF-8")
910             execution.setVariable("serviceInstanceId", serviceId)
911             execution.setVariable("operationId", operationId)
912             execution.setVariable("operationType", operationType)
913
914             def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
915             execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
916             msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint)
917
918             execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
919
920                         String payload =
921                 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
922                         xmlns:ns="http://org.onap.so/requestsdb">
923                         <soapenv:Header/>
924                         <soapenv:Body>
925                             <ns:updateServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
926                             <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
927                             <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
928                             <serviceName>${MsoUtils.xmlEscape(serviceName)}</serviceName>
929                             <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
930                             <userId>${MsoUtils.xmlEscape(userId)}</userId>
931                             <result>${MsoUtils.xmlEscape(result)}</result>
932                             <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
933                             <progress>${MsoUtils.xmlEscape(progress)}</progress>
934                             <reason>${MsoUtils.xmlEscape(reason)}</reason>
935                         </ns:updateServiceOperationStatus>
936                     </soapenv:Body>
937                 </soapenv:Envelope>"""
938
939             payload = utils.formatXml(payload)
940             execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
941             msoLogger.info("Outgoing preUpdateServiceOperationStatus: \n" + payload)
942
943
944         }catch(Exception e){
945             msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preUpdateServiceOperationStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
946             execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage())
947         }
948         msoLogger.trace("COMPLETED preUpdateServiceOperationStatus Process ")
949         msoLogger.info("Exited " + method)
950         }
951
952         public void preInitResourcesOperStatus(DelegateExecution execution){
953         def method = getClass().getSimpleName() + '.preInitResourcesOperStatus(' +'execution=' + execution.getId() +')'
954                 msoLogger.info("Entered " + method)
955
956         msoLogger.trace("STARTED preInitResourcesOperStatus Process ")
957                 String msg=""
958         try{
959             String serviceId = execution.getVariable("serviceInstanceId")
960             String operationId = execution.getVariable("operationId")
961             String operationType = "DELETE"
962             String resourceTemplateUUIDs = ""
963             String result = "processing"
964             String progress = "0"
965             String reason = ""
966             String operationContent = "Prepare service delete"
967             msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType)
968             serviceId = UriUtils.encode(serviceId,"UTF-8")
969             execution.setVariable("serviceInstanceId", serviceId)
970             execution.setVariable("operationId", operationId)
971             execution.setVariable("operationType", operationType)
972
973             String serviceRelationShip = execution.getVariable("serviceRelationShip")
974             msoLogger.info("serviceRelationShip: " + serviceRelationShip)
975                         if (! isBlank(serviceRelationShip)) {
976                 def jsonSlurper = new JsonSlurper()
977                 def jsonOutput = new JsonOutput()
978                 List relationShipList =  jsonSlurper.parseText(serviceRelationShip)
979
980                 if (relationShipList != null) {
981                     relationShipList.each {
982                         resourceTemplateUUIDs  = resourceTemplateUUIDs + it.resourceInstanceId + ":"
983                     }
984                 }
985             }
986             def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
987             execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
988             msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint)
989
990             String payload =
991                 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
992                         xmlns:ns="http://org.onap.so/requestsdb">
993                         <soapenv:Header/>
994                         <soapenv:Body>
995                             <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
996                             <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
997                             <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
998                             <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
999                             <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUIDs)}</resourceTemplateUUIDs>
1000                         </ns:initResourceOperationStatus>
1001                     </soapenv:Body>
1002                 </soapenv:Envelope>"""
1003
1004             payload = utils.formatXml(payload)
1005             execution.setVariable("CVFMI_initResOperStatusRequest", payload)
1006             msoLogger.info("Outgoing initResourceOperationStatus: \n" + payload)
1007             msoLogger.debug("DoCustomDeleteE2EServiceInstanceV2 Outgoing initResourceOperationStatus Request: " + payload)
1008
1009                 }catch (BpmnError e) {
1010                         throw e;
1011                 } catch (Exception ex) {
1012                         msg = "Exception in DoCustomDeleteE2EServiceInstanceV2.preInitResourcesOperStatus. " + ex.getMessage()
1013                         msoLogger.info(msg)
1014                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
1015                 }
1016         msoLogger.info("Exited " + method)
1017     }
1018
1019
1020
1021         /**
1022     * prepare delete parameters
1023     */
1024         public void preProcessVFCResourceDelete(execution){
1025                 // we use resource instance ids for delete flow as resourceTemplateUUIDs
1026
1027                 def method = getClass().getSimpleName() + '.preProcessVFCResourceDelete(' +'execution=' + execution.getId() +')'
1028                 msoLogger.info("Entered " + method)
1029
1030                 msoLogger.trace("STARTED preProcessVFCResourceDelete Process ")
1031                 try{
1032                         String serviceResource = execution.getVariable("serviceResource")
1033                         msoLogger.info("serviceResource : " + serviceResource)
1034
1035                         String resourceInstanceId  =  execution.getVariable("resourceInstanceId")
1036                         msoLogger.info("resourceInstanceId : " + resourceInstanceId)
1037
1038                         execution.setVariable("resourceTemplateId", resourceInstanceId)
1039                         msoLogger.info("resourceTemplateId : " + resourceInstanceId)
1040
1041                         String resourceType = execution.getVariable("resourceType")
1042                         msoLogger.info("resourceType : " + resourceType)
1043
1044
1045                         String resourceName = execution.getVariable(Prefix+"resourceName")
1046                         if (isBlank(resourceName)){
1047                                 resourceName = resourceInstanceId
1048                         }
1049                         execution.setVariable("resourceName", resourceName)
1050                         msoLogger.info("resource Name : " + resourceName)
1051
1052                         msoLogger.info("Delete Resource Info: resourceInstanceId :" + resourceInstanceId + "  resourceTemplateId: " + resourceInstanceId + " resourceType: " + resourceType)
1053                 }catch (BpmnError e) {
1054                         throw e;
1055                 } catch (Exception ex) {
1056                         msg = "Exception in DoDeleteE2EServiceInstance.preProcessVFCResourceDelete. " + ex.getMessage()
1057                         msoLogger.info(msg)
1058                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
1059                 }
1060                 msoLogger.info("Exited " + method)
1061         }
1062
1063         public void postProcessVFCDelete(DelegateExecution execution, String response, String action) {
1064                 def method = getClass().getSimpleName() + '.postProcessVFCDelete(' +'execution=' + execution.getId() +')'
1065                 msoLogger.info("Entered " + method)
1066
1067                 msoLogger.trace("STARTED postProcessVFCDelete Process ")
1068                 try{
1069
1070                 }catch (BpmnError e) {
1071                         throw e;
1072                 } catch (Exception ex) {
1073                         msg = "Exception in DoDeleteE2EServiceInstance.postProcessVFCDelete. " + ex.getMessage()
1074                         msoLogger.info(msg)
1075                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
1076                 }
1077                 msoLogger.info("Exited " + method)
1078         }
1079 }
1080