Springboot 2.0 upgrade
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoDeleteVnfAndModules.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.scripts
22
23 import org.onap.aai.domain.yang.GenericVnf
24 import org.onap.aai.domain.yang.VfModule
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.delegate.DelegateExecution;
27 import org.json.JSONArray;
28 import org.json.JSONObject
29 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
30 import org.onap.so.bpmn.common.scripts.ExceptionUtil
31 import org.onap.so.bpmn.common.scripts.MsoUtils
32 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
33 import org.onap.so.bpmn.common.scripts.VidUtils
34 import org.onap.so.bpmn.core.UrnPropertiesReader
35 import org.onap.so.bpmn.core.WorkflowException
36 import org.onap.so.bpmn.core.domain.ModelInfo
37 import org.onap.so.bpmn.core.domain.ModuleResource
38 import org.onap.so.bpmn.core.domain.ServiceDecomposition
39 import org.onap.so.bpmn.core.domain.VnfResource
40 import org.onap.so.bpmn.core.json.JsonUtils
41 import org.onap.so.client.graphinventory.entities.uri.Depth
42 import org.onap.so.client.aai.entities.uri.AAIResourceUri
43 import org.onap.so.client.aai.entities.uri.AAIUriFactory
44 import org.onap.so.client.aai.AAIObjectType
45 import org.onap.so.logger.MessageEnum
46 import org.onap.so.logger.MsoLogger
47
48 /**
49  * This class supports the macro VID Flow
50  * with the deletion of a generic vnf and related VF modules.
51  */
52 class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
53         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVnfAndModules.class);
54
55         String Prefix="DDVAM_"
56         ExceptionUtil exceptionUtil = new ExceptionUtil()
57         JsonUtils jsonUtil = new JsonUtils()
58         VidUtils vidUtils = new VidUtils(this)
59         SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
60
61         /**
62          * This method gets and validates the incoming
63          * request.
64          *
65          * @param - execution
66          *      
67          */
68         public void preProcessRequest(DelegateExecution execution) {
69
70                 execution.setVariable("prefix",Prefix)
71                 msoLogger.trace("STARTED DoDeleteVnfAndModules PreProcessRequest Process")
72
73                 try{
74                         // Get Variables                                
75                         
76                         String cloudConfiguration = execution.getVariable("cloudConfiguration")         
77                         msoLogger.debug("Cloud Configuration: " + cloudConfiguration)   
78                         
79                         String requestId = execution.getVariable("msoRequestId")
80                         execution.setVariable("requestId", requestId)                   
81                         execution.setVariable("mso-request-id", requestId)
82                         msoLogger.debug("Incoming Request Id is: " + requestId)
83
84                         String serviceInstanceId = execution.getVariable("serviceInstanceId")                   
85                         msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
86
87                         String vnfId = execution.getVariable("vnfId")                   
88                         msoLogger.debug("Incoming Vnf Id is: " + vnfId)                 
89                         
90                         String source = "VID"
91                         execution.setVariable("DDVAM_source", source)
92                         msoLogger.debug("Incoming Source is: " + source)
93                         
94                         execution.setVariable("DDVAM_isVidRequest", "true")
95                         
96                         String sdncVersion = execution.getVariable("sdncVersion")
97                         if (sdncVersion == null) {
98                                 sdncVersion = "1702"
99                         }
100                         execution.setVariable("DDVAM_sdncVersion", sdncVersion)
101                         msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion)
102                         
103                         // Set aLaCarte flag to false
104                         execution.setVariable("aLaCarte", false)
105                         
106                         String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback", execution)
107                         if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
108                                 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
109                                 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception");
110                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
111                         }
112                         execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
113                         msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl)
114                         msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl)     
115                         
116                         
117                         if (!sdncVersion.equals("1702")) {
118                                 //String vnfModelInfo = execution.getVariable("vnfModelInfo")
119                                 //String serviceModelInfo = execution.getVariable("serviceModelInfo")
120                                 
121                                 String serviceId = execution.getVariable("productFamilyId")
122                                 execution.setVariable("DDVAM_serviceId", serviceId)
123                                 msoLogger.debug("Incoming Service Id is: " + serviceId)
124                                 
125                                         
126                                 //String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId")
127                                 //execution.setVariable("DDVAM_modelInvariantId", modelInvariantId)
128                                 //msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId)
129                                 
130                                 //String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId")
131                                 //if (modelVersionId == null) {
132                                 //      modelVersionId = ""
133                                 //}
134                                 //execution.setVariable("DDVAM_modelVersionId", modelVersionId)
135                                 //msoLogger.debug("Incoming Version Id is: " + modelVersionId)
136         
137                                 //String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
138                                 //execution.setVariable("DDVAM_modelVersion", modelVersion)
139                                 //msoLogger.debug("Incoming Model Version is: " + modelVersion)
140                                 
141                                 //String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
142                                 //execution.setVariable("DDVAM_modelName", modelName)
143                                 //msoLogger.debug("Incoming Model Name is: " + modelName)
144                                 
145                                 //String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId")
146                                 //if (modelCustomizationId == null) {
147                                 //      modelCustomizationId = ""
148                                 //}
149                                 //execution.setVariable("DDVAM_modelCustomizationId", modelCustomizationId)
150                                 //msoLogger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
151                                         
152                                 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
153                                 execution.setVariable("DDVAM_cloudSiteId", cloudSiteId)
154                                 msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
155                                         
156                                 String tenantId = execution.getVariable("tenantId")
157                                 execution.setVariable("DDVAM_tenantId", tenantId)
158                                 msoLogger.debug("Incoming Tenant Id is: " + tenantId)
159                                 
160                                 String globalSubscriberId = execution.getVariable("globalSubscriberId")
161                                 if (globalSubscriberId == null) {
162                                         globalSubscriberId = ""
163                                 }
164                                 execution.setVariable("DDVAM_globalSubscriberId", globalSubscriberId)
165                                 msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)              
166                                 
167                         }
168                         execution.setVariable("DDVAM_vfModulesFromDecomposition", null)
169                         // Retrieve serviceDecomposition if present
170                         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
171                         if (serviceDecomposition != null) {
172                                 msoLogger.debug("Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString())
173                                 List<VnfResource> vnfs = serviceDecomposition.getVnfResources()
174                                 msoLogger.debug("Read vnfs")
175                                 if (vnfs == null) {
176                                         msoLogger.debug("Error - vnfs are empty in serviceDecomposition object")
177                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnfs are empty")
178                                 }
179                                 VnfResource vnf = vnfs[0]
180                                 
181                                 if (vnf == null) {
182                                         msoLogger.debug("Error - vnf is empty in serviceDecomposition object")
183                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnf is empty")
184                                 }
185                                 
186                                 List<ModuleResource> vfModules = vnf.getAllVfModuleObjects()
187                                 
188                                 execution.setVariable("DDVAM_vfModulesFromDecomposition", vfModules)                            
189                         }
190                         
191                         execution.setVariable("DDVAM_moduleCount", 0)
192                         execution.setVariable("DDVAM_nextModule", 0)
193                         
194                         
195                 }catch(BpmnError b){
196                         msoLogger.debug("Rethrowing MSOWorkflowException")
197                         throw b
198                 }catch(Exception e){
199                         msoLogger.debug(" Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage())
200                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
201
202                 }
203                 msoLogger.trace("COMPLETED DoDeleteVnfAndModules PreProcessRequest Process ")
204         }       
205
206         
207         
208         public void preProcessAddOnModule(DelegateExecution execution){
209
210                 execution.setVariable("prefix", Prefix)
211                 msoLogger.trace("STARTED preProcessAddOnModule ")
212                 
213                 try {                   
214                         JSONArray addOnModules = (JSONArray) execution.getVariable("addOnModules")
215                         int addOnIndex = (int) execution.getVariable("addOnModulesDeployed")
216                         
217                         JSONObject addOnModule = addOnModules[addOnIndex]
218                         
219                         def newVfModuleId = UUID.randomUUID().toString()
220                         execution.setVariable("addOnVfModuleId", newVfModuleId)
221                         
222                         execution.setVariable("instancesOfThisModelDeployed", 0)
223                         
224                         JSONObject addOnVfModuleModelInfoObject = jsonUtil.getJsonValueForKey(addOnModule, "modelInfo")
225                         String addOnVfModuleModelInfo = addOnVfModuleModelInfoObject.toString()
226                         execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo)
227                         String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel")
228                         execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel)
229                         String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantUuid")
230                         execution.setVariable("addOnPersonaModelId", addOnPersonaModelId)
231                         String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount")
232                         execution.setVariable("initialCount", addOnInitialCount)
233                                         
234                 
235                 }catch(Exception e){
236                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule." + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
237                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage())
238                 }
239                 msoLogger.trace("COMPLETED preProcessSDNCAssignRequest ")
240         }
241         
242         /**
243          * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
244          * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
245          *
246          * @param execution The flow's execution instance.
247          */
248         public void queryAAIVfModule(DelegateExecution execution) {
249
250                 def method = getClass().getSimpleName() + '.queryAAIVfModule(' +
251                         'execution=' + execution.getId() +
252                         ')'
253                 msoLogger.trace('Entered ' + method)
254
255                 try {
256                         def vnfId = execution.getVariable('vnfId')
257                         
258                         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
259
260                         try {
261                                 Optional<GenericVnf> genericVnfOp = getAAIClient().get(GenericVnf.class,uri)
262                                 //Map<String, String>[] vfModules = new HashMap<String,String>[]
263                                 List<ModuleResource> vfModulesFromDecomposition = execution.getVariable("DDVAM_vfModulesFromDecomposition")
264                                 def vfModulesList = new ArrayList<Map<String,String>>()
265                                 def vfModuleBaseEntry = null
266                                 if (genericVnfOp.isPresent()) {
267                                         execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 200)
268                                         execution.setVariable('DCVFM_queryAAIVfModuleResponse', genericVnfOp.get())
269
270                                         // Parse the VNF record from A&AI to find base module info
271                                                 if (genericVnfOp.get().getVfModules()!= null && !genericVnfOp.get().getVfModules().getVfModule().isEmpty() ) {
272                                                         List<VfModule> vfModules = genericVnfOp.get().getVfModules().getVfModule()
273                                                         execution.setVariable("DDVAM_moduleCount", vfModules.size())
274                                                         ModelInfo vfModuleModelInfo = null
275                                                         for (VfModule vfModule : vfModules) {
276                                                                 Map<String, String> vfModuleEntry = new HashMap<String, String>()
277                                                                 vfModuleEntry.put("vfModuleId", vfModule.getVfModuleId())
278                                                                 vfModuleEntry.put("vfModuleName", vfModule.getVfModuleName())
279                                                                 
280                                                                 // Find the model for this vf module in decomposition if specified
281                                                                 if (vfModulesFromDecomposition != null) {
282                                                                         msoLogger.debug("vfModulesFromDecomposition is not null")
283                                                                         def vfModuleUuid = vfModule.getModelVersionId()
284                                                                         if (vfModuleUuid == null) {
285                                                                                 vfModuleUuid = vfModule.getPersonaModelVersion()
286                                                                         }
287                                                                         msoLogger.debug("vfModule UUID is: " + vfModuleUuid)
288                                                                         for (j in 0..vfModulesFromDecomposition.size()-1) {
289                                                                                 ModuleResource mr = vfModulesFromDecomposition[j]
290                                                                                 if (mr.getModelInfo().getModelUuid() == vfModuleUuid) {
291                                                                                         msoLogger.debug("Found modelInfo")
292                                                                                         vfModuleModelInfo = mr.getModelInfo()
293                                                                                         break                                                                                   
294                                                                                 }
295                                                                                 
296                                                                         }                                                                       
297                                                                 }
298                                                                 if (vfModuleModelInfo != null) {
299                                                                         String vfModuleModelInfoString = vfModuleModelInfo.toString()
300                                                                         def vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfoString, "modelInfo")
301                                                                         vfModuleEntry.put("vfModuleModelInfo", vfModuleModelInfoValue)
302                                                                 }
303                                                                 else {
304                                                                         vfModuleEntry.put("vfModuleModelInfo", null)
305                                                                 }
306                                                                 
307                                                                 
308                                                                 // Save base vf module for last
309                                                                 if (vfModule.isIsBaseVfModule()) {
310                                                                         vfModuleBaseEntry = vfModuleEntry
311                                                                 }
312                                                                 else {                                          
313                                                                         vfModulesList.add(vfModuleEntry)
314                                                                 }
315                                                         }
316                                                         if (vfModuleBaseEntry != null) {
317                                                                 vfModulesList.add(vfModuleBaseEntry)
318                                                         }                                       
319                                                 }
320                                 }else{
321                                         execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 404)
322                                         execution.setVariable('DCVFM_queryAAIVfModuleResponse', "Generic Vnf not found")
323
324                                 }
325                                 execution.setVariable("DDVAM_vfModules", vfModulesList)
326                         } catch (Exception ex) {
327                                 ex.printStackTrace()
328                                 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
329                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
330                         }
331                         msoLogger.trace('Exited ' + method)
332                 } catch (BpmnError e) {
333                         throw e;
334                 } catch (Exception e) {
335                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
336                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
337                 }
338         }
339         
340         public void prepareNextModuleToDelete(DelegateExecution execution){
341
342                 execution.setVariable("prefix", Prefix)
343                 msoLogger.trace("STARTED prepareNextModuleToDelete ")
344                 
345                 try {
346                         int i = execution.getVariable("DDVAM_nextModule")
347                         def vfModules = execution.getVariable("DDVAM_vfModules")
348                         def vfModule = vfModules[i]
349                         
350                         def vfModuleId = vfModule.get("vfModuleId")
351                         execution.setVariable("DDVAM_vfModuleId", vfModuleId)
352                         
353                         def vfModuleName = vfModule.get("vfModuleName")
354                         execution.setVariable("DDVAM_vfModuleName", vfModuleName)                       
355                         
356                         def vfModuleModelInfo = vfModule.get("vfModuleModelInfo")
357                         msoLogger.debug("vfModuleModelInfo for module delete: " + vfModuleModelInfo)
358                         execution.setVariable("DDVAM_vfModuleModelInfo", vfModuleModelInfo)                     
359                         
360                 }catch(Exception e){
361                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule." + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
362                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToDelete Method:\n" + e.getMessage())
363                 }
364                 msoLogger.trace("COMPLETED prepareNextModuleToDelete ")
365         }
366         
367         public void preProcessSDNCDeactivateRequest(DelegateExecution execution){
368
369                 execution.setVariable("prefix", Prefix)
370                 msoLogger.trace("STARTED preProcessSDNCDeactivateRequest ")
371                 def vnfId = execution.getVariable("vnfId")
372                 def serviceInstanceId = execution.getVariable("serviceInstanceId")              
373
374                 try{
375                         //Build SDNC Request
376                         
377                         String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate")
378
379                         deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest)
380                         execution.setVariable("DDVAM_deactivateSDNCRequest", deactivateSDNCRequest)
381                         msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
382                         msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
383
384                 }catch(Exception e){
385                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCDeactivateRequest." + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
386                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage())
387                 }
388                 msoLogger.trace("COMPLETED preProcessSDNCDeactivateRequest ")
389         }
390         
391         public void preProcessSDNCUnassignRequest(DelegateExecution execution) {
392                 def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' +
393                         'execution=' + execution.getId() +
394                         ')'
395
396                 msoLogger.trace('Entered ' + method)
397                 execution.setVariable("prefix", Prefix)
398                 msoLogger.trace("STARTED preProcessSDNCUnassignRequest Process ")
399                 try{
400                         String vnfId = execution.getVariable("vnfId")
401                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
402
403                         String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign")
404
405                         execution.setVariable("DDVAM_unassignSDNCRequest", unassignSDNCRequest)
406                         msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest)
407                         msoLogger.debug("Outgoing UnassignSDNCRequest is: \n"  + unassignSDNCRequest)
408
409                 }catch(Exception e){
410                         msoLogger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e)
411                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during  preProcessSDNCUnassignRequest Method:\n" + e.getMessage())
412                 }
413                 msoLogger.trace("COMPLETED  preProcessSDNCUnassignRequest Process ")
414         }
415         
416         public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
417                 
418                                 String uuid = execution.getVariable('testReqId') // for junits
419                                 if(uuid==null){
420                                         uuid = execution.getVariable("msoRequestId") + "-" +    System.currentTimeMillis()
421                                 }
422                                 def callbackURL = execution.getVariable("sdncCallbackUrl")
423                                 def requestId = execution.getVariable("msoRequestId")
424                                 def serviceId = execution.getVariable("DDVAM_serviceId")                                
425                                 def tenantId = execution.getVariable("DDVAM_tenantId")
426                                 def source = execution.getVariable("DDVAM_source")
427                                 def vnfId = execution.getVariable("vnfId")
428                                 def serviceInstanceId = execution.getVariable("serviceInstanceId")
429                                 def cloudSiteId = execution.getVariable("DDVAM_cloudSiteId")                            
430                                 def modelCustomizationId = execution.getVariable("DDVAM_modelCustomizationId")                          
431                                 //def serviceModelInfo = execution.getVariable("serviceModelInfo")
432                                 //def vnfModelInfo = execution.getVariable("vnfModelInfo")
433                                 //String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
434                                 //String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)                             
435                                 def globalSubscriberId = execution.getVariable("DDVAM_globalSubscriberId")
436                                 def sdncVersion = execution.getVariable("DDVAM_sdncVersion")                                            
437                                 
438                                 String sdncRequest =
439                                 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
440                                                                                                         xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
441                                                                                                         xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
442            <sdncadapter:RequestHeader>
443                                 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
444                                 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
445                                 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
446                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
447                                 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
448                                 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
449                 </sdncadapter:RequestHeader>
450         <sdncadapterworkflow:SDNCRequestData>
451                 <request-information>
452                         <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
453                         <request-action>DeleteVnfInstance</request-action>
454                         <source>${MsoUtils.xmlEscape(source)}</source>
455                         <notification-url/>
456                         <order-number/>
457                         <order-version/>
458                 </request-information>
459                 <service-information>
460                         <service-id/>
461                         <subscription-service-type/>                    
462                         <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
463                         <global-customer-id/>
464                 </service-information>
465                 <vnf-information>
466                         <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
467                         <vnf-type/>                     
468                 </vnf-information>
469                 <vnf-request-input>                     
470                         <vnf-name/>
471                         <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
472                         <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>                 
473                 </vnf-request-input>
474         </sdncadapterworkflow:SDNCRequestData>
475         </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
476                 
477                         msoLogger.debug("sdncRequest:  " + sdncRequest)
478                         return sdncRequest
479         }
480                 
481         public void validateSDNCResponse(DelegateExecution execution, String response, String method){
482
483                 execution.setVariable("prefix",Prefix)
484                 msoLogger.trace("STARTED ValidateSDNCResponse Process")
485
486                 WorkflowException workflowException = execution.getVariable("WorkflowException")
487                 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
488
489                 msoLogger.debug("workflowException: " + workflowException)
490
491                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
492                 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
493
494                 msoLogger.debug("SDNCResponse: " + response)
495
496                 String sdncResponse = response
497                 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
498                         msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + sdncResponse)                     
499                 }else{
500                         msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
501                         throw new BpmnError("MSOWorkflowException")
502                 }
503                 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
504         }
505         
506         
507         
508         
509         
510         
511         
512 }