summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/DeleteServiceInstanceInfra.groovy
blob: 7004004c257e7046afa10f1600e26a399fd1a653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
/*-
 * ============LICENSE_START=======================================================
 * OPENECOMP - MSO
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package com.att.bpm.scripts;

import groovy.xml.XmlUtil
import groovy.json.*

import org.openecomp.mso.bpmn.core.json.JsonUtils
import org.openecomp.mso.bpmn.core.WorkflowException
import org.openecomp.mso.rest.APIResponse
import org.openecomp.mso.rest.RESTClient
import org.openecomp.mso.rest.RESTConfig

import java.util.UUID;
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory

import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.runtime.Execution
import org.json.JSONObject;
import org.apache.commons.lang3.*
import org.apache.commons.codec.binary.Base64;
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.Node
import org.w3c.dom.NodeList
import org.xml.sax.InputSource
import static org.apache.commons.lang3.StringUtils.*;

import org.springframework.web.util.UriUtils;

/**
 * This groovy class supports the <class>CreateServiceInstance.bpmn</class> process.
 */
public class DeleteServiceInstanceInfra extends AbstractServiceTaskProcessor {

	String Prefix="DELSI_"
	ExceptionUtil exceptionUtil = new ExceptionUtil()
	JsonUtils jsonUtil = new JsonUtils()
	VidUtils vidUtils = new VidUtils()

	/**
	 * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.
	 * @param execution
	 */
	public InitializeProcessVariables(Execution execution){
		/* Initialize all the process variables in this block */

		execution.setVariable("DELSI_DeleteServiceInstanceJasonRequest", "")
		execution.setVariable("DELSI_requestDetails", "")
		execution.setVariable("DELSI_globalSubscriberId", "")
		execution.setVariable("DELSI_serviceInstanceName", "")
		execution.setVariable("DELSI_serviceInstanceId", "")
		execution.setVariable("DELSI_serviceInstance", "")
		execution.setVariable("DELSI_messageId", "")
		execution.setVariable("DELSI_serviceType", "")

		execution.setVariable("DELSI_queryAAISINameResponse", "")
		execution.setVariable("DELSI_queryAAISINameCode", "")

		execution.setVariable("DELSI_createDBRequest", "")
		execution.setVariable("DELSI_dbResponse", "")
		execution.setVariable("DELSI_dbReturnCode", "")

		execution.setVariable("DELSI_createDBInfraErrorRequest", "")
		execution.setVariable("DELSI_errorDBInfraErrorResponse", "")
		execution.setVariable("DELSI_errorDBInfraErrorErrorCode", "")

		execution.setVariable("DELSI_CompleteMsoProcessRequest", "")
		execution.setVariable("DELSI_FalloutHandlerRequest", "")
		execution.setVariable("DELSI_Success", false)
		execution.setVariable("DELSI_unexpectedError", "")
		execution.setVariable("DELSI_siInUse", false)

	}

	// **************************************************
	//     Pre or Prepare Request Section
	// **************************************************
	/**
	 * This method is executed during the preProcessRequest task of the <class>DeleteServiceInstance.bpmn</class> process.
	 * @param execution
	 */
	public void preProcessRequest (Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix",Prefix)

		utils.log("DEBUG", " ***** Inside preProcessRequest DeleteServiceInstance Request ***** ", isDebugEnabled)

		try {
			// initialize flow variables
			InitializeProcessVariables(execution)

			// check for incoming json message/input
			String deleteServiceInstanceIncoming = execution.getVariable("bpmnRequest")
			utils.logAudit(deleteServiceInstanceIncoming)
			execution.setVariable("DELSI_DeleteServiceInstanceJasonRequest", deleteServiceInstanceIncoming);

			// extract requestId
			String requestId = execution.getVariable("att-mso-request-id")
			execution.setVariable("DELSI_requestId", requestId)

			String serviceInstanceId = execution.getVariable("serviceInstanceId")
			execution.setVariable("DELSI_serviceInstanceId", serviceInstanceId)

			String requestAction = execution.getVariable("requestAction")
			execution.setVariable("requestAction", requestAction)

			String source = jsonUtil.getJsonValue(deleteServiceInstanceIncoming, "requestDetails.requestInfo.source")
			execution.setVariable("DELSI_source", source)

			// get variables
			// extract requestDetails
			String xmlRequestDetails = vidUtils.getJsonRequestDetailstoXml(deleteServiceInstanceIncoming)
			execution.setVariable("DELSI_requestDetails", xmlRequestDetails)

			utils.log("DEBUG", "xmlRequestDetails: " + xmlRequestDetails , isDebugEnabled)

			String xmlParameters = utils.getNodeXml(xmlRequestDetails, "requestParameters", false)
			utils.log("DEBUG","xmlParameters: " +  xmlParameters , isDebugEnabled)

			String serviceType = jsonUtil.getJsonValue(deleteServiceInstanceIncoming, "requestDetails.requestParameters.subscriptionServiceType")
			execution.setVariable("DELSI_serviceType", serviceType)

			// extract globalSubscriberId
			//String globalSubscriberId = jsonUtil.getJsonValue(deleteServiceInstanceIncoming, "requestDetails.subscriberInfo.globalSubscriberId")

			// prepare messageId
			String messageId = execution.getVariable("DELSI_messageId")  // for testing
			if (messageId == null || messageId == "") {
				messageId = UUID.randomUUID()
				utils.log("DEBUG", " DELSI_messageId, random generated: " + messageId, isDebugEnabled)
			} else {
				utils.log("DEBUG", " DELSI_messageId, pre-assigned: " + messageId, isDebugEnabled)
			}
			execution.setVariable("DELSI_messageId", messageId)

			AaiUtil aaiUriUtil = new AaiUtil(this)
			String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
			String aaiNamespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
			logDebug('AAI namespace is: ' + aaiNamespace, isDebugEnabled)
			execution.setVariable("DELSI_aaiNamespace","${aaiNamespace}")

			//Setting for Generic Sub Flows
			execution.setVariable("GENGS_type", "service-instance")

		} catch (BpmnError e) {
			throw e;

		} catch (Exception ex){
			String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected from method preProcessRequest() - " + ex.getMessage()
			exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
		}

	}

	public void sendSyncResponse (Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix",Prefix)

		utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteServiceInstance ***** ", isDebugEnabled)

		try {
			String requestId = execution.getVariable("att-mso-request-id")
			String serviceInstanceId = execution.getVariable("serviceInstanceId")

			// RESTResponse (for API Handler (APIH) Reply Task)
			String syncResponse = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()

			utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
			sendWorkflowResponse(execution, 202, syncResponse)

		} catch (Exception ex) {
			String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected from method sendSyncResponse() - " + ex.getMessage()
			exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
		}
	}


	public void processGetServiceInstanceResponse(Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix",Prefix)

		utils.log("DEBUG", " ***** Inside processGetServiceInstanceResponse of DeleteServiceInstance ***** " , isDebugEnabled)

		try {

			//Extract Global Sub Id
			String messageId = execution.getVariable("DELSI_requestId")
			String serviceInstanceId = execution.getVariable("serviceInstanceId")
			String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")

			int custStart = siRelatedLink.indexOf("customer/")
			int custEnd = siRelatedLink.indexOf("/service-subscriptions")
			String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)

			execution.setVariable("DELSI_globalSubscriberId",globalCustId)

			//Extract Service Type if not provided on request
			String serviceType = execution.getVariable("DELSI_serviceType")
			if(isBlank(serviceType)){
				int serviceStart = siRelatedLink.indexOf("service-subscription/")
				int serviceEnd = siRelatedLink.indexOf("/service-instances/")
				String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd)

				serviceType = UriUtils.decode(serviceTypeEncoded, "UTF-8")
			}
			execution.setVariable("serviceType", serviceType)

			String serviceInstanceData = execution.getVariable("DELSI_serviceInstance");
			utils.log("DEBUG", " DELSI_serviceInstance:  " + serviceInstanceData, isDebugEnabled)

				//Confirm there are no related service instances (vnf/network or volume)
				if (utils.nodeExists(serviceInstanceData, "relationship-list")) {

					InputSource source = new InputSource(new StringReader(serviceInstanceData));
					DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
					DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
					Document serviceXml = docBuilder.parse(source)

					NodeList nodeList = serviceXml.getElementsByTagName("relationship")
					for (int x = 0; x < nodeList.getLength(); x++) {
						Node node = nodeList.item(x)
						if (node.getNodeType() == Node.ELEMENT_NODE) {
							Element eElement = (Element) node
							def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()
							if(e.equals("generic-vnf") || e.equals("l3-network")){
								utils.log("DEBUG", "ServiceInstance still has relationship(s) to OpenStack.", isDebugEnabled)
								execution.setVariable("DELSI_siInUse", true)
								//there are relationship dependencies to this Service Instance
								String errorMessage = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId
								utils.log("DEBUG", errorMessage, isDebugEnabled)
								exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
							}else{
								utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)
							}
						}
					}
				}

		} catch (BpmnError e) {
			throw e;
		} catch (Exception excp) {
			// try error for method block
			String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow in method processGetServiceInstanceResponse. Error was - " + excp.getMessage()
			exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
		}
		utils.log("DEBUG", " ***** Completed processGetServiceInstanceResponse of DeleteServiceInstance ***** " , isDebugEnabled)
	}

	// *******************************
	//     Build DB request Section
	// *******************************
	public void prepareDBRequest (Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix", Prefix)

		try {
			utils.log("DEBUG", " ***** Inside prepareDBRequest of DeleteServiceInstance ***** ", isDebugEnabled)

			String requestId = execution.getVariable("DELSI_requestId")
			String statusMessage = "Service Instance successfully deleted."

			//TODO - verify the format for Service Instance Delete,
			String dbRequest =
					"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
						<soapenv:Header/>
						<soapenv:Body>
							<ns:updateInfraRequest xmlns:ns="http://com.att.mso/requestsdb">
								<requestId>${requestId}</requestId>
								<lastModifiedBy>BPMN</lastModifiedBy>
								<statusMessage>${statusMessage}</statusMessage>
								<responseBody></responseBody>
								<requestStatus>COMPLETED</requestStatus>
								<progress>100</progress>
								<vnfOutputs/>
							</ns:updateInfraRequest>
						   </soapenv:Body>
					   </soapenv:Envelope>"""

		   String buildDeleteDBRequestAsString = utils.formatXml(dbRequest)
		   execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString)
		   utils.logAudit(buildDeleteDBRequestAsString)

		} catch (Exception ex) {
			// try error in method block
			String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage()
			exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)

		}

	 }


	// *****************************************
	//     Prepare Completion request Section
	// *****************************************
	public void postProcessResponse (Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix", Prefix)

		utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteServiceInstanceInfra ***** ", isDebugEnabled)

		try {
			// Display Success scenario for DB update Response:
			String dbReturnCode = execution.getVariable("DELSI_dbReturnCode")
			utils.log("DEBUG", " ***** Success DB Update Response Code  : " + dbReturnCode, isDebugEnabled)
			utils.log("DEBUG", " ***** Success DB Update Response String: " + '\n' + execution.getVariable("DELSI_dbResponse"), isDebugEnabled)

			if (dbReturnCode == "200") {
				String source = execution.getVariable("DELSI_source")
				String requestId = execution.getVariable("DELSI_requestId")

				String msoCompletionRequest =
					"""<aetgt:MsoCompletionRequest xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1"
									xmlns:ns="http://ecomp.att.com/mso/request/types/v1">
							<request-info xmlns="http://ecomp.att.com/mso/infra/vnf-request/v1">
								<request-id>${requestId}</request-id>
								<action>DELETE</action>
								<source>${source}</source>
							   </request-info>
							   <aetgt:status-message>Service Instance has been deleted successfully.</aetgt:status-message>
							   <aetgt:mso-bpel-name>BPMN Service Instance action: DELETE</aetgt:mso-bpel-name>
						</aetgt:MsoCompletionRequest>"""

					// Format Response
					String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)

					utils.logAudit(xmlMsoCompletionRequest)
					execution.setVariable("DELSI_Success", true)
					execution.setVariable("DELSI_CompleteMsoProcessRequest", xmlMsoCompletionRequest)
					utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)

			} else {
				String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceInfra flow. Unexpected Error from DB adapter, return code: " + dbReturnCode
				exceptionUtil.buildAndThrowWorkflowException(execution, 2500, exceptionMessage)

			}

		} catch (BpmnError e) {
		throw e;

		} catch (Exception ex) {
			// try error in method block
			String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceInfra flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()
			exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)

		}

	}


	// *******************************
	//     Build Error Section
	// *******************************
	public void prepareDBRequestError (Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix", Prefix)

		utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteServiceInstanceInfra ***** ", isDebugEnabled)

		try {
			String requestId = execution.getVariable("DELSI_requestId")
			String statusMessage = ""
			if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
				WorkflowException wfe = execution.getVariable("WorkflowException")
				statusMessage = wfe.getErrorMessage()

			} else {
				statusMessage = "Encountered Error during DeleteServiceInstanceInfra proccessing. "
			}

			//TODO - verify the format for Service Instance Create,
			String dbRequest =
					"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
						<soapenv:Header/>
						<soapenv:Body>
							<ns:updateInfraRequest xmlns:ns="http://com.att.mso/requestsdb">
								<requestId>${requestId}</requestId>
								<lastModifiedBy>BPMN</lastModifiedBy>
								<statusMessage>${statusMessage}</statusMessage>
								<responseBody></responseBody>
								<requestStatus>FAILED</requestStatus>
								<vnfOutputs/>
							</ns:updateInfraRequest>
						   </soapenv:Body>
					   </soapenv:Envelope>"""

		   String buildDBRequestAsString = utils.formatXml(dbRequest)
		   execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString)
		   utils.logAudit(buildDBRequestAsString)

		} catch (Exception ex) {
			// try error in method block
			String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceInfra flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage()
			exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)

		}

	 }

	// Prepare for FalloutHandler
	public void buildErrorResponse (Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix", Prefix)

		utils.log("ERROR", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled)

		String falloutHandlerRequest = ""
		try {
			// Display Success scenario for DB update Response:
			String dbReturnCode = execution.getVariable("DELSI_errorDBInfraErrorErrorCode")
			utils.log("DEBUG", " ***** Error DB Update Response Code  : " + dbReturnCode, isDebugEnabled)
			utils.log("DEBUG", " ***** Error DB Update Response String: " + '\n' + execution.getVariable("DELSI_errorDBInfraErrorResponse"), isDebugEnabled)

			String requestId = execution.getVariable("DELSI_requestId")
			String source = execution.getVariable("DELSI_source")

			execution.setVariable("DELSI_Success", false)
			String errorMessage = ""
			String errorCode = ""

			if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
				WorkflowException wfe = execution.getVariable("WorkflowException")
				errorMessage = wfe.getErrorMessage()
				errorCode = wfe.getErrorCode().toString()

			} else {
				errorMessage = "Bpmn error encountered in DeleteServiceInstanceInfra flow."
				errorCode = "2500"

			}

			falloutHandlerRequest =
				"""<aetgt:FalloutHandlerRequest xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1"
												 xmlns:ns="http://ecomp.att.com/mso/request/types/v1"
												 xmlns:wfsch="http://ecomp.att.com/mso/workflow/schema/v1">
					   <request-info xmlns="http://ecomp.att.com/mso/infra/vnf-request/v1">
						  <request-id>${requestId}</request-id>
						  <action>DELETE</action>
						  <source>${source}</source>
					   </request-info>
						<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
							<aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
							<aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
						</aetgt:WorkflowException>
					</aetgt:FalloutHandlerRequest>"""

			utils.logAudit(falloutHandlerRequest)
			execution.setVariable("DELSI_FalloutHandlerRequest", falloutHandlerRequest)
			utils.log("ERROR", "  Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled)

		} catch (Exception ex) {
			// rebuild workflow exception
			String requestId = execution.getVariable("DELSI_requestId")
			String source = execution.getVariable("DELSI_source")
			String errorException = " Build Error Response exception encountered during method buildErrorResponse(), preparing request for FalloutHandler: - " + ex.getMessage()
			utils.log("DEBUG", errorException, isDebugEnabled)
			falloutHandlerRequest =
			"""<aetgt:FalloutHandlerRequest xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1"
												 xmlns:ns="http://ecomp.att.com/mso/request/types/v1"
												 xmlns:wfsch="http://ecomp.att.com/mso/workflow/schema/v1">
					   <request-info xmlns="http://ecomp.att.com/mso/infra/vnf-request/v1">
						  <request-id>${requestId}</request-id>
						  <action>DELETE</action>
						  <source>${source}</source>
					   </request-info>
						<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
							<aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
							<aetgt:ErrorCode>7000</aetgt:ErrorCode>
						</aetgt:WorkflowException>
					</aetgt:FalloutHandlerRequest>"""
			execution.setVariable("DELSI_FalloutHandlerRequest", falloutHandlerRequest)
			utils.log("ERROR", "  Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled)

		}

	}

	public void sendSyncError (Execution execution) {
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix", Prefix)

		utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", isDebugEnabled)

		try {
			String errorMessage = ""
			if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
				WorkflowException wfe = execution.getVariable("WorkflowException")
				errorMessage = wfe.getErrorMessage()
			} else {
				errorMessage = "Sending Sync Error."
			}

			String buildworkflowException =
				"""<aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
					<aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
					<aetgt:ErrorCode>7000</aetgt:ErrorCode>
				   </aetgt:WorkflowException>"""

			utils.logAudit(buildworkflowException)
			sendWorkflowResponse(execution, 500, buildworkflowException)


		} catch (Exception ex) {
			utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
		}

	}

	public void processJavaException(Execution execution){
		def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
		execution.setVariable("prefix",Prefix)
		try{
			utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
			utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
			utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
			execution.setVariable("DELSI_unexpectedError", "Caught a Java Lang Exception")  // Adding this line temporarily until this flows error handling gets updated
			exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")
		}catch(BpmnError b){
			utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)
			throw b
		}catch(Exception e){
			utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
			execution.setVariable("DELSI_unexpectedError", "Exception in processJavaException method")  // Adding this line temporarily until this flows error handling gets updated
			exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")
		}
		utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
	}

}