Merge "Reorder modifiers"
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / vcpe / scripts / DeleteVcpeResCustService.groovy
1 /*\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP - SO\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 package org.openecomp.mso.bpmn.vcpe.scripts\r
21 \r
22 import groovy.xml.XmlUtil\r
23 import groovy.json.*\r
24 \r
25 import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils;\r
26 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
27 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils;\r
28 import org.openecomp.mso.bpmn.common.scripts.VidUtils;\r
29 import org.openecomp.mso.bpmn.core.json.JsonUtils\r
30 import org.openecomp.mso.bpmn.core.WorkflowException\r
31 import org.openecomp.mso.rest.APIResponse\r
32 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
33 import org.openecomp.mso.bpmn.common.scripts.AaiUtil\r
34 \r
35 import java.util.UUID;\r
36 \r
37 import org.camunda.bpm.engine.delegate.BpmnError\r
38 import org.camunda.bpm.engine.delegate.DelegateExecution\r
39 import org.json.JSONObject;\r
40 import org.json.JSONArray;\r
41 import org.apache.commons.lang3.*\r
42 import org.apache.commons.codec.binary.Base64;\r
43 import org.springframework.web.util.UriUtils;\r
44 import static org.apache.commons.lang3.StringUtils.*\r
45 \r
46 /**\r
47  * This groovy class supports the <class>DeleteVcpeResCustService.bpmn</class> process.\r
48  *\r
49  * @author dm4252\r
50  *\r
51  */\r
52 public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor {\r
53 \r
54         private static final String DebugFlag = "isDebugLogEnabled"\r
55 \r
56         String Prefix = "DVRCS_"\r
57         ExceptionUtil exceptionUtil = new ExceptionUtil()\r
58         JsonUtils jsonUtil = new JsonUtils()\r
59         VidUtils vidUtils = new VidUtils()\r
60         CatalogDbUtils catalogDbUtils = new CatalogDbUtils()\r
61         NetworkUtils networkUtils = new NetworkUtils()\r
62 \r
63         /**\r
64          * This method is executed during the preProcessRequest task of the <class>DeleteVcpeResCustService.bpmn</class> process.\r
65          * @param execution\r
66          */\r
67         public InitializeProcessVariables(DelegateExecution execution){\r
68                 /* Initialize all the process variables in this block */\r
69 \r
70                 execution.setVariable("DeleteVcpeResCustServiceRequest", "")\r
71                 execution.setVariable("msoRequestId", "")\r
72                 execution.setVariable(Prefix+"vnfsDeletedCount", 0)\r
73                 execution.setVariable(Prefix+"vnfsCount", 0)\r
74         }\r
75 \r
76         // **************************************************\r
77         //     Pre or Prepare Request Section\r
78         // **************************************************\r
79         /**\r
80          * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.\r
81          * @param execution\r
82          */\r
83         public void preProcessRequest (DelegateExecution execution) {\r
84                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
85                 execution.setVariable("prefix",Prefix)\r
86 \r
87                 utils.log("DEBUG", " ***** Inside preProcessRequest DeleteVcpeResCustService Request ***** ", isDebugEnabled)\r
88 \r
89                 try {\r
90                         // initialize flow variables\r
91                         InitializeProcessVariables(execution)\r
92 \r
93                         // check for incoming json message/input\r
94                         String DeleteVcpeResCustServiceRequest = execution.getVariable("bpmnRequest")\r
95                         utils.logAudit(DeleteVcpeResCustServiceRequest)\r
96                         execution.setVariable("DeleteVcpeResCustServiceRequest", DeleteVcpeResCustServiceRequest);\r
97                         println 'DeleteVcpeResCustServiceRequest - ' + DeleteVcpeResCustServiceRequest\r
98 \r
99                         // extract requestId\r
100                         String requestId = execution.getVariable("mso-request-id")\r
101                         execution.setVariable("msoRequestId", requestId)\r
102 \r
103                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
104                         if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {\r
105                                 String dataErrorMessage = " Element 'serviceInstanceId' is missing. "\r
106                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
107                         }\r
108                         \r
109                         String requestAction = execution.getVariable("requestAction")\r
110                         execution.setVariable("requestAction", requestAction)\r
111 \r
112                         String source = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.source")\r
113                         if ((source == null) || (source.isEmpty())) {\r
114                                 source = "VID"\r
115                         }\r
116                         execution.setVariable("source", source)\r
117 \r
118                         // extract globalSubscriberId\r
119                         String globalSubscriberId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId")\r
120 \r
121                         // global-customer-id is optional on Delete\r
122 \r
123                         execution.setVariable("globalSubscriberId", globalSubscriberId)\r
124                         execution.setVariable("globalCustomerId", globalSubscriberId)\r
125                         \r
126                         String suppressRollback = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.suppressRollback")\r
127                         execution.setVariable("disableRollback", suppressRollback)\r
128                         utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)\r
129                         \r
130                         String productFamilyId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.productFamilyId")\r
131                         execution.setVariable("productFamilyId", productFamilyId)\r
132                         utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)\r
133                         \r
134                         // extract subscriptionServiceType\r
135                         String subscriptionServiceType = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestParameters.subscriptionServiceType")\r
136                         execution.setVariable("subscriptionServiceType", subscriptionServiceType)\r
137                         utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)\r
138                         \r
139                         // extract cloud configuration\r
140                         String cloudConfiguration = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration")\r
141                         execution.setVariable("cloudConfiguration", cloudConfiguration)\r
142                         utils.log("DEBUG","cloudConfiguration: "+ cloudConfiguration, isDebugEnabled)\r
143                         String lcpCloudRegionId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId")\r
144                         execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)\r
145                         utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)\r
146                         String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId")\r
147                         execution.setVariable("tenantId", tenantId)\r
148                         utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)\r
149 \r
150                         String sdncVersion = "1707"\r
151                         execution.setVariable("sdncVersion", sdncVersion)\r
152                         utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)\r
153                         \r
154                         //For Completion Handler & Fallout Handler\r
155                         String requestInfo =\r
156                         """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
157                                         <request-id>${requestId}</request-id>\r
158                                         <action>DELETE</action>\r
159                                         <source>${source}</source>\r
160                                    </request-info>"""\r
161 \r
162                         execution.setVariable(Prefix+"requestInfo", requestInfo)\r
163                         \r
164                         //Setting for Generic Sub Flows\r
165                         execution.setVariable("GENGS_type", "service-instance")\r
166                         \r
167                         utils.log("DEBUG", " ***** Completed preProcessRequest DeleteVcpeResCustServiceRequest Request ***** ", isDebugEnabled)\r
168 \r
169                 } catch (BpmnError e) {\r
170                         throw e;\r
171                 } catch (Exception ex){\r
172                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()\r
173                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
174                 }\r
175         }\r
176 \r
177         public void sendSyncResponse(DelegateExecution execution) {\r
178                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
179 \r
180                 utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
181 \r
182                 try {\r
183                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
184                         String requestId = execution.getVariable("mso-request-id")\r
185 \r
186                         // RESTResponse (for API Handler (APIH) Reply Task)\r
187                         String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()\r
188 \r
189                         utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)\r
190                         sendWorkflowResponse(execution, 202, syncResponse)\r
191                 } catch (Exception ex) {\r
192                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()\r
193                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
194                 }\r
195         }\r
196 \r
197         public void prepareServiceDelete(DelegateExecution execution) {\r
198                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
199                 utils.log("DEBUG", " ***** Inside prepareServiceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
200                 \r
201                 try {\r
202                         \r
203                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
204                         \r
205                         // confirm if ServiceInstance was found\r
206                         if ( !execution.getVariable("GENGS_FoundIndicator") )\r
207                         {\r
208                                 String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId\r
209                                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
210                         }\r
211                         \r
212                         // get variable within incoming json\r
213                         String DeleteVcpeResCustServiceRequest = execution.getVariable("DeleteVcpeResCustServiceRequest");\r
214                         \r
215                         // get SI extracted by GenericGetService\r
216                         String serviceInstanceAaiRecord = execution.getVariable("GENGS_service");\r
217                         \r
218                         utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled)\r
219                         serviceInstanceAaiRecord = utils.removeXmlNamespaces(serviceInstanceAaiRecord)\r
220                         \r
221                         def (TXC_found, TXC_id) = new Tuple(false, null)\r
222                         def (BRG_found, BRG_id) = new Tuple(false, null)\r
223                         List relatedVnfIdList = []\r
224                         \r
225                         for(Node rel: utils.getMultNodeObjects(serviceInstanceAaiRecord, "relationship")) {\r
226                                 def relto = utils.getChildNodeText(rel, "related-to")\r
227                                 def relink = utils.getChildNodeText(rel, "related-link")\r
228                                 utils.log("DEBUG", "check: "+relto+" link: "+relink, isDebugEnabled)\r
229                                 \r
230                                 if(isBlank(relto) || isBlank(relink)) {\r
231                                         \r
232                                 } else if(relto == "generic-vnf") {\r
233                                         def id = relink.substring(relink.indexOf("/generic-vnf/")+13)\r
234                                         if(id.endsWith("/")) {\r
235                                                 id = id.substring(0, id.length()-1)\r
236                                         }\r
237                                         \r
238                                         relatedVnfIdList.add(id)\r
239                                         \r
240                                 } else if(relto == "allotted-resource") {\r
241                                         def (type, id) = getAaiAr(execution, relink)\r
242                                         \r
243                                         if(isBlank(type) || isBlank(id)) {\r
244                                                 \r
245                                         } else if(type == "TunnelXConn" || type == "Tunnel XConn") {\r
246                                                 utils.log("DEBUG","Tunnel XConn AR found", isDebugEnabled)\r
247                                                 TXC_found = true\r
248                                                 TXC_id = id\r
249                                                 \r
250                                         } else if(type == "BRG") {\r
251                                                 utils.log("DEBUG","BRG AR found", isDebugEnabled)\r
252                                                 BRG_found = true\r
253                                                 BRG_id = id\r
254                                         }\r
255                                 }\r
256                         }\r
257                         \r
258                         execution.setVariable(Prefix+"TunnelXConn", TXC_found)\r
259                         execution.setVariable("TXC_allottedResourceId", TXC_id)\r
260                         utils.log("DEBUG", "TXC_allottedResourceId: " + TXC_id, isDebugEnabled)\r
261                                                 \r
262                         execution.setVariable(Prefix+"BRG", BRG_found)\r
263                         execution.setVariable("BRG_allottedResourceId", BRG_id)\r
264                         utils.log("DEBUG", "BRG_allottedResourceId: " + BRG_id, isDebugEnabled)\r
265                         \r
266                         int vnfsCount = relatedVnfIdList.size()\r
267                         execution.setVariable(Prefix+"vnfsCount", vnfsCount)\r
268                         utils.log("DEBUG", " "+Prefix+"vnfsCount : " + vnfsCount, isDebugEnabled)\r
269                         if(vnfsCount > 0) {\r
270                                 execution.setVariable(Prefix+"relatedVnfIdList", relatedVnfIdList)\r
271                         }\r
272                         \r
273                         utils.log("DEBUG", " ***** Completed prepareServiceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
274                 } catch (BpmnError e){\r
275                         throw e;\r
276                 } catch (Exception ex) {\r
277                         sendSyncError(execution)\r
278                     String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. prepareServiceDelete() - " + ex.getMessage()\r
279                     utils.log("DEBUG", exceptionMessage, isDebugEnabled)\r
280                     exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
281                 }\r
282         }\r
283         \r
284         private getAaiAr(DelegateExecution execution, String relink) {\r
285                 def isDebugEnabled = execution.getVariable(DebugFlag)\r
286                 AaiUtil aaiUtil = new AaiUtil(this)\r
287                 String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink\r
288                 \r
289                 utils.log("DEBUG", "get AR info " + aaiEndpoint, isDebugEnabled)\r
290                 APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint)\r
291                 \r
292                 int responseCode = response.getStatusCode()\r
293                 utils.log("DEBUG", "get AR info responseCode:" + responseCode, isDebugEnabled)\r
294                 \r
295                 String aaiResponse = response.getResponseBodyAsString()\r
296                 utils.log("DEBUG", "get AR info " + aaiResponse, isDebugEnabled)\r
297                 \r
298                 if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) {\r
299                         return new Tuple2(null, null)\r
300                 }\r
301                 \r
302                 def type = utils.getNodeText1(aaiResponse, "type")\r
303                 def id = utils.getNodeText1(aaiResponse, "id")\r
304                 \r
305                 return new Tuple2(type, id)\r
306         }\r
307         \r
308         \r
309         // *******************************\r
310         //     \r
311         // *******************************\r
312         public void prepareVnfAndModulesDelete (DelegateExecution execution) {\r
313                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
314                 utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
315 \r
316                 try {\r
317                         List vnfList = execution.getVariable(Prefix+"relatedVnfIdList")\r
318                         int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount")\r
319                         String vnfModelInfoString = ""\r
320                         String vnfId = ""\r
321                         if (vnfList.size() > 0 ) {\r
322                                 vnfId = vnfList.get(vnfsDeletedCount.intValue())\r
323                         }\r
324                                                         \r
325                         execution.setVariable("vnfId", vnfId)\r
326                         utils.log("DEBUG", "need to delete vnfId:" + vnfId, isDebugEnabled)\r
327 \r
328                         utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
329                 } catch (Exception ex) {\r
330                         // try error in method block\r
331                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage()\r
332                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
333                 }\r
334          }\r
335         \r
336         // *******************************\r
337         //     Validate Vnf request Section -> increment count\r
338         // *******************************\r
339         public void validateVnfDelete (DelegateExecution execution) {\r
340                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
341                 utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
342 \r
343                 try {\r
344                         int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount")\r
345                         vnfsDeletedCount++\r
346                         \r
347                         execution.setVariable(Prefix+"vnfsDeletedCount", vnfsDeletedCount)\r
348                         \r
349                         utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteVcpeResCustService ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled)\r
350                 } catch (Exception ex) {\r
351                         // try error in method block\r
352                         String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage()\r
353                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
354                 }\r
355          }\r
356 \r
357         \r
358         // *****************************************\r
359         //     Prepare Completion request Section\r
360         // *****************************************\r
361         public void postProcessResponse (DelegateExecution execution) {\r
362                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
363                 utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
364 \r
365                 try {\r
366                         String source = execution.getVariable("source")\r
367                         String requestId = execution.getVariable("msoRequestId")\r
368 \r
369                         String msoCompletionRequest =\r
370                                         """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"\r
371                                                                         xmlns:ns="http://org.openecomp/mso/request/types/v1">\r
372                                                         <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
373                                                                 <request-id>${requestId}</request-id>\r
374                                                                 <action>DELETE</action>\r
375                                                                 <source>${source}</source>\r
376                                                            </request-info>\r
377                                                         <aetgt:status-message>vCPE Res Cust Service Instance has been deleted successfully.</aetgt:status-message>\r
378                                                            <aetgt:mso-bpel-name>BPMN Service Instance macro action: DELETE</aetgt:mso-bpel-name>\r
379                                                 </aetgt:MsoCompletionRequest>"""\r
380 \r
381                         // Format Response\r
382                         String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)\r
383 \r
384                         utils.logAudit(xmlMsoCompletionRequest)\r
385                         execution.setVariable(Prefix+"Success", true)\r
386                         execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest)\r
387                         utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)\r
388                 } catch (BpmnError e) {\r
389                 throw e;\r
390 \r
391                 } catch (Exception ex) {\r
392                         // try error in method block\r
393                         String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()\r
394                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
395                 }\r
396         }\r
397 \r
398         public void prepareFalloutRequest(DelegateExecution execution){\r
399                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
400                 utils.log("DEBUG", " *** STARTED DeleteVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)\r
401 \r
402                 try {\r
403                         WorkflowException wfex = execution.getVariable("WorkflowException")\r
404                         utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)\r
405                         String requestInfo = execution.getVariable(Prefix+"requestInfo")\r
406                         utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)\r
407 \r
408                         String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)\r
409 \r
410                         execution.setVariable(Prefix+"falloutRequest", falloutRequest)\r
411                 } catch (Exception ex) {\r
412                         utils.log("DEBUG", "Error Occured in DeleteVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)\r
413                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVcpeResCustService prepareFalloutRequest Process")\r
414                 }\r
415                 utils.log("DEBUG", "*** COMPLETED DeleteVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled)\r
416         }\r
417 \r
418 \r
419         public void sendSyncError (DelegateExecution execution) {\r
420                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
421                 utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
422 \r
423                 try {\r
424                         String errorMessage = ""\r
425                         if (execution.getVariable("WorkflowException") instanceof WorkflowException) {\r
426                                 WorkflowException wfe = execution.getVariable("WorkflowException")\r
427                                 errorMessage = wfe.getErrorMessage()\r
428                         } else {\r
429                                 errorMessage = "Sending Sync Error."\r
430                         }\r
431 \r
432                         String buildworkflowException =\r
433                                 """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">\r
434                                         <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>\r
435                                         <aetgt:ErrorCode>7000</aetgt:ErrorCode>\r
436                                    </aetgt:WorkflowException>"""\r
437 \r
438                         utils.logAudit(buildworkflowException)\r
439                         sendWorkflowResponse(execution, 500, buildworkflowException)\r
440                 } catch (Exception ex) {\r
441                         utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)\r
442                 }\r
443         }\r
444 \r
445         public void processJavaException(DelegateExecution execution){\r
446                 def isDebugEnabled=execution.getVariable(DebugFlag)\r
447                 execution.setVariable("prefix",Prefix)\r
448                 try{\r
449                         utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)\r
450                         utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)\r
451                         utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)\r
452                         execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception")  // Adding this line temporarily until this flows error handling gets updated\r
453                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")\r
454                 }catch(BpmnError b){\r
455                         utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)\r
456                         throw b\r
457                 }catch(Exception e){\r
458                         utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)\r
459                         execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method")  // Adding this line temporarily until this flows error handling gets updated\r
460                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")\r
461                 }\r
462                 utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)\r
463         }\r
464 \r
465 \r
466 }\r