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