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