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