b468a5116ccce6675f4618485075e2ae68a1a664
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / CreateVfModuleInfra.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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.openecomp.mso.bpmn.infrastructure.scripts;
22
23 import groovy.json.JsonSlurper
24 import groovy.json.JsonOutput
25
26 import org.camunda.bpm.engine.delegate.BpmnError
27 import org.camunda.bpm.engine.runtime.Execution
28 import org.apache.commons.lang3.*
29 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
30 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
31 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils;
32 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils;
33 import org.openecomp.mso.bpmn.common.scripts.VidUtils;
34 import org.openecomp.mso.bpmn.core.RollbackData
35 import org.openecomp.mso.bpmn.core.WorkflowException
36 import org.openecomp.mso.bpmn.core.json.JsonUtils
37
38 public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
39
40         ExceptionUtil exceptionUtil = new ExceptionUtil()
41         JsonUtils jsonUtil = new JsonUtils()
42
43         /**
44          * Validates the request message and sets up the workflow.
45          * @param execution the execution
46          */
47         public void preProcessRequest(Execution execution) {
48                 def method = getClass().getSimpleName() + '.preProcessRequest(' +
49                         'execution=' + execution.getId() +
50                         ')'
51                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
52                 logDebug('Entered ' + method, isDebugLogEnabled)
53
54                 def prefix = 'CVFMI_'
55                 logDebug('Entered 1' + method, isDebugLogEnabled)
56                 execution.setVariable('prefix', prefix)
57                 logDebug('Entered 2' + method, isDebugLogEnabled)
58                 execution.setVariable("isVidRequest", "false")
59
60                 logDebug("Set variables", isDebugLogEnabled)
61
62                 def rollbackData = execution.getVariable("RollbackData")
63                 if (rollbackData == null) {
64                         rollbackData = new RollbackData()
65                 }
66                 execution.setVariable("RollbackData", rollbackData)
67
68                 logDebug("Set rollback data", isDebugLogEnabled)
69                 def incomingRequest = execution.getVariable('bpmnRequest')
70
71                 utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
72                 utils.logAudit("CreateVfModule Infra incoming Request: " + incomingRequest)
73
74                 // check if request is xml or json
75                 try {
76                         def jsonSlurper = new JsonSlurper()
77                         def jsonOutput = new JsonOutput()
78                         Map reqMap = jsonSlurper.parseText(incomingRequest)
79                         utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
80
81                         def serviceInstanceId = execution.getVariable('serviceInstanceId')
82                         def vnfId = execution.getVariable('vnfId')
83                         
84                         execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId)
85                         execution.setVariable(prefix+'vnfId', vnfId)
86                         execution.setVariable("isVidRequest", "true")
87                         
88                         def vnfName = ''
89                         def asdcServiceModelVersion = ''
90                         def serviceModelInfo = null
91                         def vnfModelInfo = null
92                         
93                         def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
94                                                 
95                         if (relatedInstanceList != null) {
96                                 relatedInstanceList.each {
97                                         if (it.relatedInstance.modelInfo?.modelType == 'service') {
98                                                 asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
99                                                 serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
100                                                 
101                                         }
102                                         if (it.relatedInstance.modelInfo.modelType == 'vnf') {
103                                                 vnfName = it.relatedInstance.instanceName ?: ''
104                                                 vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
105                                         }
106                                 }
107                         }
108                         
109                         execution.setVariable(prefix + 'vnfName', vnfName)
110                         execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion)
111                         execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo)
112                         execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo)
113                         
114                         
115                         def vnfType = execution.getVariable('vnfType')
116                         execution.setVariable(prefix + 'vnfType', vnfType)      
117                         def vfModuleId = execution.getVariable('vfModuleId')
118                         execution.setVariable(prefix + 'vfModuleId', vfModuleId)
119                         def volumeGroupId = execution.getVariable('volumeGroupId')
120                         execution.setVariable(prefix + 'volumeGroupId', volumeGroupId)
121                         def userParams = reqMap.requestDetails?.requestParameters?.userParams                                   
122                         
123                         Map<String, String> userParamsMap = [:]
124                         if (userParams != null) {
125                                 userParams.each { userParam ->
126                                         userParamsMap.put(userParam.name, userParam.value)
127                                 }                                                       
128                         }               
129                                                 
130                         utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)                
131                         
132                         execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap)
133                         
134                         def isBaseVfModule = "false"
135                         if (execution.getVariable('isBaseVfModule') == true) {
136                                 isBaseVfModule = "true"
137                         }                       
138                         
139                         execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule)
140                                                 
141                         def requestId = execution.getVariable("mso-request-id")
142                         execution.setVariable(prefix + 'requestId', requestId)
143                         
144                         def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
145                         execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo)
146                         
147                         def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback
148                         
149                         
150                         def backoutOnFailure = ""
151                         if(suppressRollback != null){
152                                 if ( suppressRollback == true) {
153                                         backoutOnFailure = "false"
154                                 } else if ( suppressRollback == false) {
155                                         backoutOnFailure = "true"
156                                 }
157                         }
158                         
159                         execution.setVariable(prefix + 'disableRollback', suppressRollback)
160                         
161                         def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
162                         execution.setVariable(prefix + 'vfModuleName', vfModuleName)
163                         
164                         def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: ''
165                         execution.setVariable(prefix + 'serviceId', serviceId)
166                         
167                         def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
168                         execution.setVariable(prefix + 'usePreload', usePreload)
169                         
170                         def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
171                         def lcpCloudRegionId    = cloudConfiguration.lcpCloudRegionId
172                         execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId)
173                         def tenantId = cloudConfiguration.tenantId
174                         execution.setVariable(prefix + 'tenantId', tenantId)
175                         
176                         def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
177                         execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId)
178                         
179                         execution.setVariable(prefix + 'sdncVersion', '1702')
180
181                         execution.setVariable("CreateVfModuleInfraSuccessIndicator", false)
182                         execution.setVariable("RollbackCompleted", false)
183                         
184                         execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
185                         
186                         
187                         def source = reqMap.requestDetails?.requestInfo?.source
188                         execution.setVariable("CVFMI_source", source)
189                         
190                         //For Completion Handler & Fallout Handler
191                         String requestInfo =
192                         """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
193                                         <request-id>${requestId}</request-id>
194                                         <action>CREATE</action>
195                                         <source>${source}</source>
196                                    </request-info>"""
197                         
198                         execution.setVariable("CVFMI_requestInfo", requestInfo)
199                         
200                         //backoutOnFailure
201
202                         //NetworkUtils networkUtils = new NetworkUtils()
203                         //execution.setVariable("CVFMI_rollbackEnabled", networkUtils.isRollbackEnabled(execution,request))
204                         execution.setVariable("CVFMI_originalWorkflowException", null)
205                         
206
207                         def newVfModuleId = UUID.randomUUID().toString()
208                         execution.setVariable("newVfModuleId", newVfModuleId)
209                         execution.setVariable(prefix + 'vfModuleId', newVfModuleId)
210
211                         logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled)                       
212                         
213                         logDebug('rollbackEnabled: ' + execution.getVariable("CVFMI_rollbackEnabled"), isDebugLogEnabled)
214
215                         logDebug('Exited ' + method, isDebugLogEnabled)
216                 } catch (BpmnError bpmnError) {
217                         throw bpmnError
218                 }
219                 catch(groovy.json.JsonException je) {
220                         utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
221                         exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
222                 }
223                 catch(Exception e) {
224                         String restFaultMessage = e.getMessage()
225                         //execution.setVariable("CVFMODVOL2_RESTFault", restFaultMessage)
226                         //execution.setVariable("CVFMODVOL2_isDataOk", false)
227                         utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
228                         exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
229                 }
230
231         }
232
233         /**
234          * Validates a workflow response.
235          * @param execution the execution
236          * @param responseVar the execution variable in which the response is stored
237          * @param responseCodeVar the execution variable in which the response code is stored
238          * @param errorResponseVar the execution variable in which the error response is stored
239          */
240         public void validateWorkflowResponse(Execution execution, String responseVar,
241                         String responseCodeVar, String errorResponseVar) {
242                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
243                 sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar)
244         }
245
246
247         /**
248          * Sends the empty, synchronous response back to the API Handler.
249          * @param execution the execution
250          */
251         public void sendResponse(Execution execution) {
252                 def method = getClass().getSimpleName() + '.sendResponse(' +
253                         'execution=' + execution.getId() +
254                         ')'
255                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
256                 logDebug('Entered ' + method, isDebugLogEnabled)
257
258                 try {
259                         def requestInfo = execution.getVariable('CVFMI_requestInfo')
260                         def requestId = execution.getVariable('CVFMI_requestId')
261                         def source = execution.getVariable('CVFMI_source')                      
262                         
263                         // RESTResponse (for API Handler (APIH) Reply Task)
264                         def newVfModuleId = execution.getVariable("newVfModuleId")
265                         String synchResponse = """{"requestReferences":{"instanceId":"${newVfModuleId}","requestId":"${requestId}"}}""".trim()
266
267                         sendWorkflowResponse(execution, 200, synchResponse)
268
269                         utils.logAudit("CreateVfModule Infra Response: " + synchResponse)
270                         logDebug('Exited ' + method, isDebugLogEnabled)
271                 } catch (BpmnError e) {
272                         throw e;
273                 } catch (Exception e) {
274                         logError('Caught exception in ' + method, e)
275                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
276                 }
277         }
278
279         /**
280          *
281          * @param execution the execution
282          */
283         public void postProcessResponse(Execution execution){
284                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
285
286                 utils.log("DEBUG", " ======== STARTED PostProcessResponse Process ======== ", isDebugEnabled)
287                 try{                    
288                         def requestInfo = execution.getVariable("CVFMI_requestInfo")
289                         def action = utils.getNodeText1(requestInfo, "action")
290
291                         utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled)
292                         utils.log("DEBUG", "action is: " + action, isDebugEnabled)
293
294                         try {\r
295                                 String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")\r
296                                 utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled)\r
297                                 \r
298                                 def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))\r
299                                 execution.setVariable("BasicAuthHeaderValueDB",encodedString)\r
300                         } catch (IOException ex) {\r
301                                 String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()\r
302                                 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)\r
303                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
304                         }\r
305                         \r
306                         String payload =
307                                         """  <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
308                                xmlns:ns="http://org.openecomp/mso/request/types/v1"
309                                xmlns:ns8="http://org.openecomp/mso/workflow/schema/v1">
310                         <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
311                         ${requestInfo}
312                         </request-info>
313                         <ns8:status-message>Vf Module has been created successfully.</ns8:status-message>
314                         <ns8:mso-bpel-name>BPMN</ns8:mso-bpel-name>
315                         </aetgt:MsoCompletionRequest>"""
316
317                         payload = utils.formatXml(payload)
318                         execution.setVariable("CVFMI_SuccessFlag", true)
319                         execution.setVariable("CVFMI_msoCompletionRequest", payload)
320                         utils.logAudit("CreateVfModuleInfra completion request: " + payload)
321                         utils.log("DEBUG", "Outgoing MsoCompletionRequest: \n" + payload, isDebugEnabled)
322
323                 }catch(Exception e){
324                         utils.log("ERROR", "Exception Occured Processing PostProcessResponse. Exception is:\n" + e, isDebugEnabled)
325                         execution.setVariable("CVFMI_ErrorResponse", "Error Occured during PostProcessResponse Method:\n" + e.getMessage())
326                 }
327                 utils.log("DEBUG", "======== COMPLETED PostProcessResponse Process ======== ", isDebugEnabled)
328         }
329
330
331
332
333
334         /**
335          * Validates the request, request id and service instance id.  If a problem is found,
336          * a WorkflowException is generated and an MSOWorkflowException event is thrown. This
337          * method also sets up the log context for the workflow.
338          * @param execution the execution
339          * @return the validated request
340          */
341         public String validateInfraRequest(Execution execution) {
342                 def method = getClass().getSimpleName() + '.validateInfraRequest(' +
343                         'execution=' + execution.getId() +
344                         ')'
345                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
346                 logDebug('Entered ' + method, isDebugLogEnabled)
347
348                 String processKey = getProcessKey(execution);
349                 def prefix = execution.getVariable("prefix")
350
351                 if (prefix == null) {
352                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null")
353                 }
354
355                 try {
356                         def request = execution.getVariable(prefix + 'Request')
357
358                         if (request == null) {
359                                 request = execution.getVariable(processKey + 'Request')
360
361                                 if (request == null) {
362                                         request = execution.getVariable('bpmnRequest')
363                                 }
364
365                                 setVariable(execution, processKey + 'Request', null);
366                                 setVariable(execution, 'bpmnRequest', null);
367                                 setVariable(execution, prefix + 'Request', request);
368                         }
369
370                         if (request == null) {
371                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null")
372                         }
373
374                         /*
375
376                         def requestId = execution.getVariable("mso-request-id")
377
378                         if (requestId == null) {
379                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id")
380                         }
381
382                         setVariable(execution, prefix + 'requestId', requestId)
383
384                         def serviceInstanceId = execution.getVariable("mso-service-instance-id")
385
386                         if (serviceInstanceId == null) {
387                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id")
388                         }
389
390                         utils.logContext(requestId, serviceInstanceId)
391                         */
392                         utils.logAudit("CreateVfModule incoming request: " + request)
393                         logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled)
394                         logDebug('Exited ' + method, isDebugLogEnabled)
395                         return request
396                 } catch (BpmnError e) {
397                         throw e;
398                 } catch (Exception e) {
399                         logError('Caught exception in ' + method, e)
400                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
401                 }
402         }
403
404         public void prepareUpdateInfraRequest(Execution execution){
405                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
406
407                 utils.log("DEBUG", " ======== STARTED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
408                 try{
409                         
410                         
411                         String requestInfo = execution.getVariable("CVFMI_requestInfo")                 
412                         def aicCloudRegion      = execution.getVariable("CVFMI_lcpCloudRegionId")
413                         def tenantId = execution.getVariable("CVFMI_tenantId")
414                         def requestId = utils.getNodeText1(requestInfo, "request-id")
415                         def vnfId = execution.getVariable("CVFMI_vnfId")
416                         def vfModuleId = execution.getVariable("CVFMI_vfModuleId")
417                         // vfModuleName may be generated by DoCreateVfModule subprocess if it is not specified on the input
418                         def vfModuleName = execution.getVariable("CVFMI_vfModuleName")
419
420                         def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_db_endpoint")
421                         execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
422                         utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
423
424                         try {\r
425                                 String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")\r
426                                 utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled)\r
427                                 \r
428                                 def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))\r
429                                 execution.setVariable("BasicAuthHeaderValueDB",encodedString)\r
430                         } catch (IOException ex) {\r
431                                 String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()\r
432                                 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)\r
433                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
434                         }\r
435                         \r
436                         String payload =
437                                 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
438                                                 xmlns:ns="http://org.openecomp.mso/requestsdb">
439                                                 <soapenv:Header/>
440                                                 <soapenv:Body>
441                                                         <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
442                                                         <requestId>${requestId}</requestId>
443                                                         <lastModifiedBy>BPMN</lastModifiedBy>
444                                                         <statusMessage>VF Module successfully created</statusMessage>
445                                                         <responseBody></responseBody>
446                                                         <requestStatus>COMPLETE</requestStatus>
447                                                         <progress>100</progress>
448                                                         <vnfOutputs>&lt;vnf-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"&gt;&lt;vnf-id&gt;${vnfId}&lt;/vnf-id&gt;&lt;vf-module-id&gt;${vfModuleId}&lt;/vf-module-id&gt;&lt;/vnf-outputs&gt;</vnfOutputs>
449                                                         <vfModuleId>${vfModuleId}</vfModuleId>
450                                                         <vfModuleName>${vfModuleName}</vfModuleName>
451                                                 </ns:updateInfraRequest>
452                                         </soapenv:Body>
453                                 </soapenv:Envelope>"""
454
455                         payload = utils.formatXml(payload)
456                         execution.setVariable("CVFMI_updateInfraRequest", payload)
457                         utils.log("DEBUG", "Outgoing UpdateInfraRequest: \n" + payload, isDebugEnabled)
458                         utils.logAudit("CreateVfModuleInfra Outgoing UpdateInfra Request: " + payload)
459
460                 }catch(Exception e){
461                         utils.log("ERROR", "Exception Occured Processing prepareUpdateInfraRequest. Exception is:\n" + e, isDebugEnabled)
462                         execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareUpdateInfraRequest Method:\n" + e.getMessage())
463                 }
464                 utils.log("DEBUG", "======== COMPLETED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
465         }
466
467         /**
468          * Builds a "FalloutHandler" request and stores it in the specified execution variable.
469          *
470          * @param execution the execution
471          * @param resultVar the execution variable in which the result will be stored
472          */
473         public void falloutHandlerPrep(Execution execution, String resultVar) {
474                 def method = getClass().getSimpleName() + '.falloutHandlerPrep(' +
475                         'execution=' + execution.getId() +
476                         ', resultVar=' + resultVar +
477                         ')'
478                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
479                 logDebug('Entered ' + method, isDebugLogEnabled)
480
481
482                 try {
483                         def WorkflowException workflowException = execution.getVariable("WorkflowException")                    
484                         def requestInformation = execution.getVariable("CVFMI_requestInfo")
485                         def errorResponseCode = workflowException.getErrorCode()
486                         def errorResponseMsg = workflowException.getErrorMessage()
487                         def encErrorResponseMsg = ""
488                         if (errorResponseMsg != null) {
489                                 encErrorResponseMsg = errorResponseMsg.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
490                         }
491
492                         String content = """
493                                 <aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
494                                                 xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
495                                                 xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
496                                                 xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
497                                                 ${requestInformation}
498                                         <aetgt:WorkflowException>
499                                                 <aetgt:ErrorMessage>${encErrorResponseMsg}</aetgt:ErrorMessage>
500                                                 <aetgt:ErrorCode>${errorResponseCode}</aetgt:ErrorCode>
501                                         </aetgt:WorkflowException>
502                                 </aetgt:FalloutHandlerRequest>
503                         """
504
505                         logDebug("CONTENT before translation: " + content, isDebugLogEnabled)
506                         content = utils.formatXml(content)
507                         logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
508                         utils.logAudit("CreateVfModuleInfra FallOutHander Request: " + content)
509                         execution.setVariable(resultVar, content)
510
511                         logDebug('Exited ' + method, isDebugLogEnabled)
512                 } catch (BpmnError e) {
513                         throw e;
514                 } catch (Exception e) {
515                         logError('Caught exception in ' + method, e)
516                         exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error')
517                 }
518         }
519
520         public void logAndSaveOriginalException(Execution execution) {
521                 def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
522                         'execution=' + execution.getId() +
523                         ')'
524                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
525                 logDebug('Entered ' + method, isDebugLogEnabled)
526
527                 logWorkflowException(execution, 'CreateVfModuleInfra caught an event')
528                 saveWorkflowException(execution, 'CVFMI_originalWorkflowException')
529         }
530
531         public void validateRollbackResponse(Execution execution) {
532                 def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
533                         'execution=' + execution.getId() +
534                         ')'
535                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
536                 logDebug('Entered ' + method, isDebugLogEnabled)
537
538                 def originalException = execution.getVariable("CVFMI_originalWorkflowException")
539                 execution.setVariable("WorkflowException", originalException)
540
541                 execution.setVariable("RollbackCompleted", true)
542
543         }
544         
545         
546
547
548 }