960bb5cc7f18d2f0f906441300d2c27217ed8851
[so.git] /
1 /*\r
2  * Â© 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.\r
3  */\r
4 package org.openecomp.mso.bpmn.vcpe.scripts\r
5 \r
6 import groovy.xml.XmlUtil\r
7 import groovy.json.*\r
8 \r
9 import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils;\r
10 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
11 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils;\r
12 import org.openecomp.mso.bpmn.common.scripts.VidUtils;\r
13 import org.openecomp.mso.bpmn.core.json.JsonUtils\r
14 import org.openecomp.mso.bpmn.core.WorkflowException\r
15 import org.openecomp.mso.rest.APIResponse\r
16 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
17 \r
18 import java.util.UUID;\r
19 \r
20 import org.camunda.bpm.engine.delegate.BpmnError\r
21 import org.camunda.bpm.engine.runtime.Execution\r
22 import org.json.JSONObject;\r
23 import org.json.JSONArray;\r
24 import org.apache.commons.lang3.*\r
25 import org.apache.commons.codec.binary.Base64;\r
26 import org.springframework.web.util.UriUtils;\r
27 \r
28 /**\r
29  * This groovy class supports the <class>DeleteVcpeResCustService.bpmn</class> process.\r
30  *\r
31  * @author dm4252\r
32  *\r
33  */\r
34 public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor {\r
35 \r
36         String Prefix="DELVAS_"\r
37         ExceptionUtil exceptionUtil = new ExceptionUtil()\r
38         JsonUtils jsonUtil = new JsonUtils()\r
39         VidUtils vidUtils = new VidUtils()\r
40         CatalogDbUtils catalogDbUtils = new CatalogDbUtils()\r
41         NetworkUtils networkUtils = new NetworkUtils()\r
42 \r
43         /**\r
44          * This method is executed during the preProcessRequest task of the <class>DeleteVcpeResCustService.bpmn</class> process.\r
45          * @param execution\r
46          */\r
47         public InitializeProcessVariables(Execution execution){\r
48                 /* Initialize all the process variables in this block */\r
49 \r
50                 execution.setVariable("DeleteVcpeResCustServiceRequest", "")\r
51                 execution.setVariable("msoRequestId", "")\r
52                 execution.setVariable("DELVAS_vnfsDeletedCount", 0)\r
53                 execution.setVariable("DELVAS_vnfsCount", 0)\r
54                 execution.setVariable("DELVAS_networksCount", 0)\r
55                 execution.setVariable("DELVAS_networksDeletedCount", 0)\r
56         }\r
57 \r
58         // **************************************************\r
59         //     Pre or Prepare Request Section\r
60         // **************************************************\r
61         /**\r
62          * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.\r
63          * @param execution\r
64          */\r
65         public void preProcessRequest (Execution execution) {\r
66                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
67                 execution.setVariable("prefix",Prefix)\r
68 \r
69                 utils.log("DEBUG", " ***** Inside preProcessRequest DeleteVcpeResCustService Request ***** ", isDebugEnabled)\r
70 \r
71                 try {\r
72                         // initialize flow variables\r
73                         InitializeProcessVariables(execution)\r
74 \r
75                         // check for incoming json message/input\r
76                         String DeleteVcpeResCustServiceRequest = execution.getVariable("bpmnRequest")\r
77                         utils.logAudit(DeleteVcpeResCustServiceRequest)\r
78                         execution.setVariable("DeleteVcpeResCustServiceRequest", DeleteVcpeResCustServiceRequest);\r
79                         println 'DeleteVcpeResCustServiceRequest - ' + DeleteVcpeResCustServiceRequest\r
80 \r
81                         // extract requestId\r
82                         String requestId = execution.getVariable("mso-request-id")\r
83                         execution.setVariable("msoRequestId", requestId)\r
84 \r
85                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
86                         if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {\r
87                                 String dataErrorMessage = " Element 'serviceInstanceId' is missing. "\r
88                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
89                         }\r
90                         \r
91                         String requestAction = execution.getVariable("requestAction")\r
92                         execution.setVariable("requestAction", requestAction)\r
93 \r
94                         String source = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.source")\r
95                         if ((source == null) || (source.isEmpty())) {\r
96                                 execution.setVariable("source", "VID")\r
97                         } else {\r
98                                 execution.setVariable("source", source)\r
99                         }\r
100 \r
101                         // extract globalSubscriberId\r
102                         String globalSubscriberId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId")\r
103 \r
104                         // global-customer-id is optional on Delete\r
105 \r
106                         execution.setVariable("globalSubscriberId", globalSubscriberId)\r
107                         execution.setVariable("globalCustomerId", globalSubscriberId)\r
108                         \r
109                         String suppressRollback = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.suppressRollback")\r
110                         execution.setVariable("disableRollback", suppressRollback)\r
111                         utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)\r
112                         \r
113                         String productFamilyId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.productFamilyId")\r
114                         execution.setVariable("productFamilyId", productFamilyId)\r
115                         utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)\r
116                         \r
117                         // extract subscriptionServiceType\r
118                         String subscriptionServiceType = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestParameters.subscriptionServiceType")\r
119                         execution.setVariable("subscriptionServiceType", subscriptionServiceType)\r
120                         utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)\r
121                         \r
122                         // extract cloud configuration\r
123                         String lcpCloudRegionId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")\r
124                         execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)\r
125                         utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)\r
126                         String tenantId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration.tenantId")\r
127                         execution.setVariable("tenantId", tenantId)\r
128                         utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)\r
129 \r
130                         String sdncVersion = "1702"\r
131                         execution.setVariable("sdncVersion", sdncVersion)\r
132                         utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)\r
133                         \r
134                         //For Completion Handler & Fallout Handler\r
135                         String requestInfo =\r
136                         """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
137                                         <request-id>${requestId}</request-id>\r
138                                         <action>DELETE</action>\r
139                                         <source>${source}</source>\r
140                                    </request-info>"""\r
141 \r
142                         execution.setVariable("DELVAS_requestInfo", requestInfo)\r
143                         \r
144                         //Setting for Generic Sub Flows\r
145                         execution.setVariable("GENGS_type", "service-instance")\r
146                         \r
147                         utils.log("DEBUG", " ***** Completed preProcessRequest DeleteVcpeResCustServiceRequest Request ***** ", isDebugEnabled)\r
148 \r
149                 } catch (BpmnError e) {\r
150                         throw e;\r
151                 } catch (Exception ex){\r
152                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()\r
153                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
154                 }\r
155         }\r
156 \r
157         public void sendSyncResponse (Execution execution) {\r
158                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
159 \r
160                 utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
161 \r
162                 try {\r
163                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
164                         String requestId = execution.getVariable("mso-request-id")\r
165 \r
166                         // RESTResponse (for API Handler (APIH) Reply Task)\r
167                         String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()\r
168 \r
169                         utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)\r
170                         sendWorkflowResponse(execution, 202, syncResponse)\r
171                 } catch (Exception ex) {\r
172                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()^M
173                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
174                 }\r
175         }\r
176 \r
177         public void prepareServiceDelete (Execution execution) {\r
178                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
179                 utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
180                 \r
181                 try {\r
182                         \r
183                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
184                         \r
185                         // confirm if ServiceInstance was found\r
186                         if ( !execution.getVariable("GENGS_FoundIndicator") )\r
187                         {\r
188                                 String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId\r
189                                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
190                         }\r
191                         \r
192                         // get variable within incoming json\r
193                         String DeleteVcpeResCustServiceRequest = execution.getVariable("DeleteVcpeResCustServiceRequest");\r
194                         \r
195                         // get SI extracted by GenericGetService\r
196                         String serviceInstanceAaiRecord = execution.getVariable("GENGS_service");\r
197                         \r
198                         utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled)\r
199                         \r
200                         // determine if AR needs to be deleted\r
201                         boolean DELVAS_TunnelXConn = false\r
202                         boolean DELVAS_BRG = false\r
203                         String TXC_allottedResourceId\r
204                         String BRG_allottedResourceId\r
205                         XmlParser xmlParser = new XmlParser()\r
206                         def groovy.util.Node siNode = xmlParser.parseText(serviceInstanceAaiRecord)\r
207                         def groovy.util.Node arList = utils.getChildNode(siNode, 'allotted-resources')\r
208                         if (arList != null) {\r
209                                 def groovy.util.NodeList ars = utils.getIdenticalChildren(arList, 'allotted-resource')\r
210                                 for (groovy.util.Node ar in ars) {\r
211                                         def groovy.util.Node type = utils.getChildNode(ar, 'type')\r
212                                         if ((type != null) && (type.text().equals('TunnelXConn'))) {\r
213                                                 utils.log("DEBUG","TunnelXConn AR found", isDebugEnabled)\r
214                                                 def groovy.util.Node id = utils.getChildNode(ar, 'id')\r
215                                                 if (id != null){\r
216                                                         DELVAS_TunnelXConn = true\r
217                                                         TXC_allottedResourceId = id\r
218                                                 }\r
219                                         }\r
220                                         if ((type != null) && (type.text().equals('BRG'))) {\r
221                                                 utils.log("DEBUG","FW AR found", isDebugEnabled)\r
222                                                 def groovy.util.Node id = utils.getChildNode(ar, 'id')\r
223                                                 if (id != null){\r
224                                                         DELVAS_BRG = true\r
225                                                         BRG_allottedResourceId = id\r
226                                                 }\r
227                                         }\r
228                                 }\r
229                         }\r
230                         execution.setVariable("DELVAS_TunnelXConn", DELVAS_TunnelXConn)\r
231                         utils.log("DEBUG", "DELVAS_TunnelXConn : " + DELVAS_TunnelXConn, isDebugEnabled)\r
232                         execution.setVariable("TXC_allottedResourceId", TXC_allottedResourceId)\r
233                         utils.log("DEBUG", "TXC_allottedResourceId : " + TXC_allottedResourceId, isDebugEnabled)\r
234                         \r
235                         execution.setVariable("DELVAS_BRG", DELVAS_BRG)\r
236                         utils.log("DEBUG", "DELVAS_BRG : " + DELVAS_BRG, isDebugEnabled)\r
237                         execution.setVariable("BRG_allottedResourceId", BRG_allottedResourceId)\r
238                         utils.log("DEBUG", "BRG_allottedResourceId : " + BRG_allottedResourceId, isDebugEnabled)\r
239                 \r
240                         String relationship = ""\r
241                         try {\r
242                                 relationship = networkUtils.getFirstNodeXml(serviceInstanceAaiRecord, "relationship-list")\r
243                         } catch (Exception ex) {\r
244                                 //no relationships found\r
245                         }\r
246                         utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled)\r
247                         \r
248                         int vnfsCount = 0\r
249                         int networksCount = 0\r
250                         \r
251                         if (relationship != null && relationship.length() > 0){\r
252                                 relationship = relationship.trim().replace("tag0:","").replace(":tag0","")\r
253                                 \r
254                                 // Check if Network TableREf is present, then build a List of network policy\r
255                                 List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship)\r
256                                 vnfsCount = relatedVnfIdList.size()\r
257                                 execution.setVariable("DELVAS_vnfsCount", vnfsCount)\r
258                                 utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled)\r
259                                 execution.setVariable("DELVAS_relatedVnfIdList", relatedVnfIdList)\r
260                                 \r
261                                 // Check if Network TableREf is present, then build a List of network policy\r
262                                 List relatedNetworkIdList = networkUtils.getRelatedNetworkIdList(relationship)\r
263                                 networksCount = relatedNetworkIdList.size()\r
264                                 execution.setVariable("DELVAS_networksCount", networksCount)\r
265                                 utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled)\r
266                                 execution.setVariable("DELVAS_relatedNetworkIdList", relatedNetworkIdList)\r
267                         } else {\r
268                                 execution.setVariable("DELVAS_vnfsCount", 0)\r
269                                 utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled)\r
270                                 execution.setVariable("DELVAS_networksCount", 0)\r
271                                 utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled)\r
272                         }\r
273                         \r
274                         utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteVcpeCusRestService ***** ", isDebugEnabled)\r
275                 } catch (BpmnError e){\r
276                         throw e;\r
277                 } catch (Exception ex) {\r
278                         sendSyncError(execution)\r
279                    String exceptionMessage = "Bpmn error encountered in DeleteVcpeCusRestService flow. prepareServiceInstanceDelete() - " + ex.getMessage()\r
280                    utils.log("DEBUG", exceptionMessage, isDebugEnabled)\r
281                    exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
282                 }\r
283         }\r
284         \r
285         \r
286         // *******************************\r
287         //     \r
288         // *******************************\r
289         public void prepareVnfAndModulesDelete (Execution execution) {\r
290                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
291 \r
292                 try {\r
293                         utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled)\r
294 \r
295                         List vnfList = execution.getVariable("DELVAS_relatedVnfIdList")\r
296                         Integer vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount")\r
297                         String vnfModelInfoString = ""\r
298                         String vnfId = ""\r
299                         if (vnfList.size() > 0 ) {\r
300                                 vnfId = vnfList.get(vnfsDeletedCount.intValue())\r
301                         }\r
302                                                         \r
303                         execution.setVariable("vnfId", vnfId)\r
304                         utils.log("DEBUG", "need to delete vnfId:" + vnfId, isDebugEnabled)\r
305 \r
306                         utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled)\r
307                 } catch (Exception ex) {\r
308                         // try error in method block\r
309                         String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceMacro flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage()\r
310                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
311                 }\r
312          }\r
313         \r
314         // *******************************\r
315         //     Validate Vnf request Section -> increment count\r
316         // *******************************\r
317         public void validateVnfDelete (Execution execution) {\r
318                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
319 \r
320                 try {\r
321                         utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled)\r
322 \r
323                         String vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount")\r
324                         vnfsDeletedCount++\r
325                         \r
326                         execution.setVariable("DELVAS_vnfsDeletedCount", vnfsDeletedCount)\r
327                         \r
328                         utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteVcpeCusRestService ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled)\r
329                 } catch (Exception ex) {\r
330                         // try error in method block\r
331                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeCusRestService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage()\r
332                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
333                 }\r
334          }\r
335         \r
336         // *******************************\r
337         //     Generate Network request Section\r
338         // *******************************\r
339         public void prepareNetworkDelete (Execution execution) {\r
340                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
341 \r
342                 try {\r
343                         utils.log("DEBUG", " ***** Inside prepareNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled)\r
344 \r
345                         List networkList = execution.getVariable("DELVAS_relatedNetworkIdList")\r
346                         Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount")\r
347 \r
348                         String networkId = ""\r
349                         if (networkList.size() > 0) {\r
350                                 networkId = networkList.get(networksDeletedCount.intValue())\r
351                         }\r
352                                                         \r
353                         execution.setVariable("networkId", networkId)\r
354                         utils.log("DEBUG", "need to delete networkId:" + networkId, isDebugEnabled)\r
355                         \r
356                         utils.log("DEBUG", " ***** Completed prepareNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled)\r
357                 } catch (Exception ex) {\r
358                         // try error in method block\r
359                         String exceptionMessage = q"Bpmn error encountered in DeleteVcpeCusRestService flow. Unexpected Error from method prepareNetworkDelete() - " + ex.getMessage()\r
360                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
361                 }\r
362          }\r
363         \r
364         // *******************************\r
365         //     Validate Network request Section\r
366         // *******************************\r
367         public void validateNetworkDelete (Execution execution) {\r
368                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
369 \r
370                 try {\r
371                         utils.log("DEBUG", " ***** Inside validateNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled)\r
372 \r
373                         Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount")\r
374                         networksDeletedCount++\r
375                         \r
376                         execution.setVariable("DELVAS_networksDeletedCount", networksDeletedCount)\r
377                         \r
378                         utils.log("DEBUG", " ***** Completed validateNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled)\r
379                 } catch (Exception ex) {\r
380                         // try error in method block\r
381                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeCusRestService flow. Unexpected Error from method validateNetworkDelete() - " + ex.getMessage()\r
382                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
383                 }\r
384          }\r
385 \r
386         \r
387         // *****************************************\r
388         //     Prepare Completion request Section\r
389         // *****************************************\r
390         public void postProcessResponse (Execution execution) {\r
391                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
392                 utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteVcpeCusRestService ***** ", isDebugEnabled)\r
393 \r
394                 try {\r
395                         String source = execution.getVariable("source")\r
396                         String requestId = execution.getVariable("msoRequestId")\r
397 \r
398                         String msoCompletionRequest =\r
399                                         """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"\r
400                                                                         xmlns:ns="http://org.openecomp/mso/request/types/v1">\r
401                                                         <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
402                                                                 <request-id>${requestId}</request-id>\r
403                                                                 <action>DELETE</action>\r
404                                                                 <source>${source}</source>\r
405                                                            </request-info>\r
406                                                         <aetgt:status-message>vCPE Res Cust Service Instance has been deleted successfully.</aetgt:status-message>\r
407                                                            <aetgt:mso-bpel-name>BPMN Service Instance macro action: DELETE</aetgt:mso-bpel-name>\r
408                                                 </aetgt:MsoCompletionRequest>"""\r
409 \r
410                         // Format Response\r
411                         String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)\r
412 \r
413                         utils.logAudit(xmlMsoCompletionRequest)\r
414                         execution.setVariable("DELVAS_Success", true)\r
415                         execution.setVariable("DELVAS_CompleteMsoProcessRequest", xmlMsoCompletionRequest)\r
416                         utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)\r
417                 } catch (BpmnError e) {\r
418                 throw e;\r
419 \r
420                 } catch (Exception ex) {\r
421                         // try error in method block\r
422                         String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()\r
423                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
424                 }\r
425         }\r
426 \r
427         public void prepareFalloutRequest(Execution execution){\r
428                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
429                 utils.log("DEBUG", " *** STARTED DeleteVcpeCusRestService prepareFalloutRequest Process *** ", isDebugEnabled)\r
430 \r
431                 try {\r
432                         WorkflowException wfex = execution.getVariable("WorkflowException")\r
433                         utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)\r
434                         String requestInfo = execution.getVariable("DELVAS_requestInfo")\r
435                         utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)\r
436 \r
437                         String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)\r
438 \r
439                         execution.setVariable("DELVAS_falloutRequest", falloutRequest)\r
440                 } catch (Exception ex) {\r
441                         utils.log("DEBUG", "Error Occured in DeleteVcpeCusRestService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)\r
442                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVcpeCusRestService prepareFalloutRequest Process")\r
443                 }\r
444                 utils.log("DEBUG", "*** COMPLETED DeleteVcpeCusRestService prepareFalloutRequest Process ***", isDebugEnabled)\r
445         }\r
446 \r
447 \r
448         public void sendSyncError (Execution execution) {\r
449                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
450                 utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", isDebugEnabled)\r
451 \r
452                 try {\r
453                         String errorMessage = ""\r
454                         if (execution.getVariable("WorkflowException") instanceof WorkflowException) {\r
455                                 WorkflowException wfe = execution.getVariable("WorkflowException")\r
456                                 errorMessage = wfe.getErrorMessage()\r
457                         } else {\r
458                                 errorMessage = "Sending Sync Error."\r
459                         }\r
460 \r
461                         String buildworkflowException =\r
462                                 """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">\r
463                                         <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>\r
464                                         <aetgt:ErrorCode>7000</aetgt:ErrorCode>\r
465                                    </aetgt:WorkflowException>"""\r
466 \r
467                         utils.logAudit(buildworkflowException)\r
468                         sendWorkflowResponse(execution, 500, buildworkflowException)\r
469                 } catch (Exception ex) {\r
470                         utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)\r
471                 }\r
472         }\r
473 \r
474         public void processJavaException(Execution execution){\r
475                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
476                 execution.setVariable("prefix",Prefix)\r
477                 try{\r
478                         utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)\r
479                         utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)\r
480                         utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)\r
481                         execution.setVariable("DELVAS_unexpectedError", "Caught a Java Lang Exception")  // Adding this line temporarily until this flows error handling gets updated\r
482                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")\r
483                 }catch(BpmnError b){\r
484                         utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)\r
485                         throw b\r
486                 }catch(Exception e){\r
487                         utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)\r
488                         execution.setVariable("DELVAS_unexpectedError", "Exception in processJavaException method")  // Adding this line temporarily until this flows error handling gets updated\r
489                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")\r
490                 }\r
491                 utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)\r
492         }\r
493 \r
494 \r
495 }\r