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