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