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