Remove unnecessary use of Calendar.getInstance()
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / CreateVnfInfra.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 java.util.UUID;
24
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.runtime.Execution;
27
28 import static org.apache.commons.lang3.StringUtils.*;
29
30 import org.openecomp.mso.bpmn.common.scripts.AaiUtil;
31 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
32 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
33 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils;
34 import org.openecomp.mso.bpmn.common.scripts.VidUtils;
35 import org.openecomp.mso.bpmn.core.WorkflowException
36 import org.openecomp.mso.bpmn.core.json.JsonUtils;
37
38
39 /**
40  * This class supports the CreateVnfInfra Flow
41  * with the creation of a generic vnf for
42  * infrastructure.
43  */
44 class CreateVnfInfra extends AbstractServiceTaskProcessor {
45
46         String Prefix="CREVI_"
47         ExceptionUtil exceptionUtil = new ExceptionUtil()
48         JsonUtils jsonUtil = new JsonUtils()
49         VidUtils vidUtils = new VidUtils(this)
50
51         /**
52          * This method gets and validates the incoming
53          * request.
54          *
55          * @param - execution
56          *
57          */
58         public void preProcessRequest(Execution execution) {
59                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
60                 execution.setVariable("prefix",Prefix)
61                 utils.log("DEBUG", " *** STARTED CreateVnfInfra PreProcessRequest Process*** ", isDebugEnabled)
62
63                 execution.setVariable("CREVI_sentSyncResponse", false)
64
65                 try{
66                         // Get Variables
67                         String createVnfRequest = execution.getVariable("bpmnRequest")
68                         execution.setVariable("CREVI_createVnfRequest", createVnfRequest)
69                         utils.logAudit("Incoming CreateVnfInfra Request is: \n" + createVnfRequest)
70
71                         if(createVnfRequest != null){
72
73                                 String requestId = execution.getVariable("mso-request-id")
74                                 execution.setVariable("CREVI_requestId", requestId)
75                                 utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled)
76
77                                 String serviceInstanceId = execution.getVariable("serviceInstanceId")
78                                 execution.setVariable("CREVI_serviceInstanceId", serviceInstanceId)
79                                 utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
80
81                                 String vnfType = execution.getVariable("vnfType")
82                                 execution.setVariable("CREVI_vnfType", vnfType)
83                                 utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled)
84
85                                 String vnfName = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.instanceName")
86                                 execution.setVariable("CREVI_vnfName", vnfName)
87                                 utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled)
88
89                                 String serviceId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.productFamilyId")
90                                 execution.setVariable("CREVI_serviceId", serviceId)
91                                 utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled)
92
93                                 String source = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.source")
94                                 execution.setVariable("CREVI_source", source)
95                                 utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled)
96
97                                 String suppressRollback = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.suppressRollback")
98                                 execution.setVariable("CREVI_suppressRollback", suppressRollback)
99                                 utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled)
100                                 
101                                 def vnfModelInfo = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo")
102                                 execution.setVariable("CREVI_vnfModelInfo", vnfModelInfo)
103
104                                 String modelInvariantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelInvariantId")
105                                 execution.setVariable("CREVI_modelInvariantId", modelInvariantId)
106                                 utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled)
107
108                                 String modelVersion = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelVersion")
109                                 execution.setVariable("CREVI_modelVersion", modelVersion)
110                                 utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled)
111                                 
112                                 def cloudConfiguration = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration")
113                                 execution.setVariable("CREVI_cloudConfiguration", cloudConfiguration)
114                                 
115                                 String cloudSiteId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")
116                                 execution.setVariable("CREVI_cloudSiteId", cloudSiteId)
117                                 utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled)
118                                 
119                                 String tenantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.tenantId")
120                                 execution.setVariable("CREVI_tenantId", tenantId)
121                                 utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled)
122
123                                 //For Completion Handler & Fallout Handler
124                                 String requestInfo =
125                                 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
126                                         <request-id>${requestId}</request-id>
127                                         <action>CREATE</action>
128                                         <source>${source}</source>
129                                    </request-info>"""
130
131                                 execution.setVariable("CREVI_requestInfo", requestInfo)
132
133                                 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
134                                 String orchStatus = "Created"
135                                 execution.setVariable("CREVI_orchStatus", orchStatus)
136
137                                 //TODO: Equipment Role - Should come from SDN-C Response in 1702
138                                 String equipmentRole = " "
139                                 execution.setVariable("CREVI_equipmentRole", equipmentRole)
140
141                                 String vnfId = execution.getVariable("testVnfId") // for junits
142                                 if(isBlank(vnfId)){
143                                         vnfId = UUID.randomUUID().toString()
144                                         utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled)
145                                 }
146                                 execution.setVariable("CREVI_vnfId", vnfId)
147
148                                 // Setting for Sub Flow Calls
149                                 execution.setVariable("CREVI_type", "generic-vnf")
150                                 execution.setVariable("GENGS_type", "service-instance")
151                                 
152                                 String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
153                                 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
154                                         def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
155                                         logError(msg)
156                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
157                                 }
158                                 execution.setVariable("CREVI_sdncCallbackUrl", sdncCallbackUrl)
159                                 
160                                 def vnfInputParameters = jsonUtil.getJsonValue(createVnfRequest, "requestParameters.userParams")
161                                 execution.setVariable("CREVI_vnfInputParameters", vnfInputParameters)
162                                 
163                                 
164                                 utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl)
165                                 logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled)
166
167                         }else{
168                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Bpmn Request is Null.")
169                         }
170
171                 }catch(BpmnError b){
172                         utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
173                         throw b
174                 }catch(Exception e){
175                         utils.log("DEBUG", " Error Occured in CreateVnfInfra PreProcessRequest method!" + e.getMessage(), isDebugEnabled)
176                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PreProcessRequest")
177
178                 }
179                 utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PreProcessRequest Process ***", isDebugEnabled)
180         }
181
182         public void sendSyncResponse (Execution execution) {
183                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
184                 execution.setVariable("prefix",Prefix)
185
186                 utils.log("DEBUG", " *** STARTED CreateVnfInfra SendSyncResponse Process *** ", isDebugEnabled)
187
188                 try {
189                         String requestId = execution.getVariable("CREVI_requestId")
190                         String vnfId = execution.getVariable("CREVI_vnfId")
191
192                         String createVnfResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim()
193
194                         utils.log("DEBUG", " CreateVnfInfra Sync Response is: \n"  + createVnfResponse, isDebugEnabled)
195
196                         sendWorkflowResponse(execution, 202, createVnfResponse)
197
198                         execution.setVariable("CREVI_sentSyncResponse", true)
199
200                 } catch (Exception ex) {
201                         utils.log("DEBUG", "Error Occured in CreateVnfInfra SendSyncResponse Process " + ex.getMessage(), isDebugEnabled)
202                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra SendSyncResponse Process")
203
204                 }
205                 utils.log("DEBUG", "*** COMPLETED CreateVnfInfra SendSyncResponse Process ***", isDebugEnabled)
206         }
207
208         public void prepareCreateGenericVnf (Execution execution) {
209                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
210                 execution.setVariable("prefix",Prefix)
211
212                 utils.log("DEBUG", " *** STARTED CreateVnfInfra PrepareCreateGenericVnf Process *** ", isDebugEnabled)
213                 try {
214                         //Get Vnf Info
215                         String vnfId = execution.getVariable("CREVI_vnfId")
216                         def vnfName = execution.getVariable("CREVI_vnfName")
217                         def vnfType = execution.getVariable("CREVI_vnfType")
218                         def serviceId = execution.getVariable("CREVI_serviceId")
219                         def orchStatus = execution.getVariable("CREVI_orchStatus")
220                         def modelInvariantId = execution.getVariable("CREVI_modelInvariantId")
221                         def modelVersion = execution.getVariable("CREVI_modelVersion")
222                         // TODO: 1702 Variable
223                         def equipmentRole = execution.getVariable("CREVI_equipmentRole")
224
225                         //Get Service Instance Info
226                         def serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId")
227                         String siRelatedLink = execution.getVariable("GENGS_siResourceLink")
228
229                         int custStart = siRelatedLink.indexOf("customer/")
230                         int custEnd = siRelatedLink.indexOf("/service-subscriptions")
231                         String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)
232                         int serviceStart = siRelatedLink.indexOf("service-subscription/")
233                         int serviceEnd = siRelatedLink.indexOf("/service-instances/")
234                         String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
235
236                         //Get Namespace
237                         AaiUtil aaiUtil = new AaiUtil(this)
238                         def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution)
239                         String namespace = aaiUtil.getNamespaceFromUri(aai_uri)
240
241                         String payload =
242                                         """<generic-vnf xmlns="${namespace}">
243                                 <vnf-id>${vnfId}</vnf-id>
244                                 <vnf-name>${vnfName}</vnf-name>
245                                 <service-id>${serviceId}</service-id>
246                                 <vnf-type>${vnfType}</vnf-type>
247                                 <orchestration-status>${orchStatus}</orchestration-status>
248                                 <persona-model-id>${modelInvariantId}</persona-model-id>
249                                 <persona-model-version>${modelVersion}</persona-model-version>
250                                 <relationship-list>
251                                         <relationship>
252                         <related-to>service-instance</related-to>
253                         <related-link>${siRelatedLink}</related-link>
254                         <relationship-data>
255                                 <relationship-key>customer.global-customer-id</relationship-key>
256                                 <relationship-value>${globalCustId}</relationship-value>
257                         </relationship-data>
258                         <relationship-data>
259                                 <relationship-key>service-subscription.service-type</relationship-key>
260                                 <relationship-value>${serviceType}</relationship-value>
261                         </relationship-data>
262                                         <relationship-data>
263                                 <relationship-key>service-instance.service-instance-id</relationship-key>
264                                 <relationship-value>${serviceInstanceId}</relationship-value>
265                         </relationship-data>
266                         </relationship>
267                                 </relationship-list>
268                         </generic-vnf>"""
269
270                         execution.setVariable("CREVI_genericVnfPayload", payload)
271
272                 }catch(Exception ex) {
273                         utils.log("DEBUG", "Error Occured in CreateVnfInfra PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
274                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PrepareCreateGenericVnf Process")
275                 }
276                 utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled)
277         }
278         
279         public void preProcessSDNCAssignRequest(Execution execution){
280                 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
281                 execution.setVariable("prefix", Prefix)
282                 logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
283                 def vnfId = execution.getVariable("CREVI_vnfId")                
284                 def serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId")
285                 logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled)
286                 utils.logAudit("NEW VNF ID: " + vnfId)
287
288                 try{
289                         //Build SDNC Request
290                         
291                         String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
292
293                         assignSDNCRequest = utils.formatXml(assignSDNCRequest)
294                         execution.setVariable("CREVI_assignSDNCRequest", assignSDNCRequest)
295                         logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled)
296                         utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
297
298                 }catch(Exception e){
299                         utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled)
300                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage())
301                 }
302                 logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
303         }
304         
305         public void preProcessSDNCActivateRequest(Execution execution) {
306                 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
307                         'execution=' + execution.getId() +
308                         ')'
309                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
310                 logDebug('Entered ' + method, isDebugLogEnabled)
311                 execution.setVariable("prefix", Prefix)
312                 logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
313                 try{
314                         String vnfId = execution.getVariable("CREVI_vnfId")                     
315                         String serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId")
316
317                         String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
318
319                         execution.setVariable("CREVI_activateSDNCRequest", activateSDNCRequest)
320                         logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled)
321                         utils.logAudit("Outgoing CommitSDNCRequest is: \n"  + activateSDNCRequest)
322
323                 }catch(Exception e){
324                         log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled)
325                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during  preProcessSDNCActivateRequest Method:\n" + e.getMessage())
326                 }
327                 logDebug("======== COMPLETED  preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
328         }
329         
330         public String buildSDNCRequest(Execution execution, String svcInstId, String action){
331                 
332                                 String uuid = execution.getVariable('testReqId') // for junits
333                                 if(uuid==null){
334                                         uuid = execution.getVariable("mso-request-id") + "-" +          System.currentTimeMillis()
335                                 }
336                                 def callbackURL = execution.getVariable("CREVI_sdncCallbackUrl")
337                                 def requestId = execution.getVariable("CREVI_requestId")
338                                 def serviceId = execution.getVariable("CREVI_serviceId")
339                                 def vnfType = execution.getVariable("CREVI_vnfType")
340                                 def vnfName = execution.getVariable("CREVI_vnfName")
341                                 def tenantId = execution.getVariable("CREVI_tenantId")
342                                 def source = execution.getVariable("CREVI_source")                              
343                                 def vnfId = execution.getVariable("CREVI_vnfId")
344                                 def cloudSiteId = execution.getVariable("CREVI_cloudSiteId")
345                 
346                                 String sdncVNFParamsXml = ""
347                 
348                                 if(execution.getVariable("CREVI_vnfParamsExistFlag") == true){
349                                         sdncVNFParamsXml = buildSDNCParamsXml(execution)
350                                 }else{
351                                         sdncVNFParamsXml = ""
352                                 }
353                 
354                                 String sdncRequest =
355                                 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
356                                                                                                         xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
357                                                                                                         xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
358            <sdncadapter:RequestHeader>
359                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
360                                 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
361                                 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
362                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
363                                 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
364                 </sdncadapter:RequestHeader>
365         <sdncadapterworkflow:SDNCRequestData>
366                 <request-information>
367                         <request-id>${requestId}</request-id>
368                         <request-action>VNFActivateRequest</request-action>
369                         <source>${source}</source>
370                         <notification-url/>
371                 </request-information>
372                 <service-information>
373                         <service-id>${serviceId}</service-id>
374                         <service-type>${serviceId}</service-type>
375                         <service-instance-id>${svcInstId}</service-instance-id>
376                         <subscriber-name>notsurewecare</subscriber-name>
377                 </service-information>
378                 <vnf-request-information>                       
379                         <vnf-id>${vnfId}</vnf-id>
380                         <vnf-name>${vnfName}</vnf-name>
381                         <vnf-type>${vnfType}</vnf-type>
382                         <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
383                         <tenant>${tenantId}</tenant>
384                 ${sdncVNFParamsXml}
385                 </vnf-request-information>
386         </sdncadapterworkflow:SDNCRequestData>
387         </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
388                 
389                         utils.logAudit("sdncRequest:  " + sdncRequest)
390                         return sdncRequest              
391         }
392                 
393         public void validateSDNCResponse(Execution execution, String response, String method){
394                 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
395                 execution.setVariable("prefix",Prefix)
396                 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
397
398                 WorkflowException workflowException = execution.getVariable("WorkflowException")
399                 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
400
401                 utils.logAudit("workflowException: " + workflowException)
402
403                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
404                 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
405
406                 utils.logAudit("SDNCResponse: " + response)
407
408                 String sdncResponse = response
409                 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
410                         logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + sdncResponse, isDebugLogEnabled)
411                         
412                 }else{
413                         logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
414                         throw new BpmnError("MSOWorkflowException")
415                 }
416                 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
417         }
418
419         public void prepareCompletionHandlerRequest(Execution execution){
420                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
421                 execution.setVariable("prefix",Prefix)
422
423                 utils.log("DEBUG", " *** STARTED CreateVnfInfra PrepareCompletionHandlerRequest Process *** ", isDebugEnabled)
424
425                 try {
426                         String requestInfo = execution.getVariable("CREVI_requestInfo")
427                         String vnfId = execution.getVariable("CREVI_vnfId")
428                         requestInfo = utils.removeXmlPreamble(requestInfo)
429
430                         String request =
431                                 """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
432                                                                         xmlns:ns="http://org.openecomp/mso/request/types/v1">
433                                                         ${requestInfo}
434                                                         <status-message>Vnf has been created successfully.</status-message>
435                                                         <vnfId>${vnfId}</vnfId>
436                                                         <mso-bpel-name>CreateVnfInfra</mso-bpel-name>
437                                                 </aetgt:MsoCompletionRequest>"""
438
439                         execution.setVariable("CREVI_completionHandlerRequest", request)
440                         utils.log("DEBUG", "Completion Handler Request is: " + request, isDebugEnabled)
441
442                         execution.setVariable("WorkflowResponse", "Success") // for junits
443
444                 } catch (Exception ex) {
445                         utils.log("DEBUG", "Error Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process " + ex.getMessage(), isDebugEnabled)
446                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process")
447
448                 }
449                 utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCompletionHandlerRequest Process ***", isDebugEnabled)
450         }
451
452         public void sendErrorResponse(Execution execution){
453                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
454                 execution.setVariable("prefix",Prefix)
455
456                 utils.log("DEBUG", " *** STARTED CreateVnfInfra sendErrorResponse Process *** ", isDebugEnabled)
457                 try {
458                         def sentSyncResponse = execution.getVariable("CREVI_sentSyncResponse")
459                         if(sentSyncResponse == false){
460                                 WorkflowException wfex = execution.getVariable("WorkflowException")
461                                 String response = exceptionUtil.buildErrorResponseXml(wfex)
462
463                                 utils.logAudit(response)
464                                 sendWorkflowResponse(execution, 500, response)
465                         }else{
466                                 utils.log("DEBUG", "Not Sending Error Response.  Sync Response Already Sent", isDebugEnabled)
467                         }
468
469                 } catch (Exception ex) {
470                         utils.log("DEBUG", "Error Occured in CreateVnfInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled)
471                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra sendErrorResponse Process")
472
473                 }
474                 utils.log("DEBUG", "*** COMPLETED CreateVnfInfra sendErrorResponse Process ***", isDebugEnabled)
475         }
476
477         public void prepareFalloutRequest(Execution execution){
478                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
479                 execution.setVariable("prefix",Prefix)
480
481                 utils.log("DEBUG", " *** STARTED CreateVnfInfra prepareFalloutRequest Process *** ", isDebugEnabled)
482
483                 try {
484                         WorkflowException wfex = execution.getVariable("WorkflowException")
485                         utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)
486                         String requestInfo = execution.getVariable("CREVI_requestInfo")
487                         utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)
488
489                         String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
490
491                         execution.setVariable("CREVI_falloutRequest", falloutRequest)
492
493
494                 } catch (Exception ex) {
495                         utils.log("DEBUG", "Error Occured in CreateVnfInfra prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)
496                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra prepareFalloutRequest Process")
497
498                 }
499                 utils.log("DEBUG", "*** COMPLETED CreateVnfInfra prepareFalloutRequest Process ***", isDebugEnabled)
500         }
501
502 }