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