8ec267dd19fa17751a3f3e5d64ecdf7db7f130dd
[so.git] / bpmn / MSOGammaBPMN / src / main / groovy / com / att / bpm / scripts / CompleteMsoProcess.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package com.att.bpm.scripts
22
23 import java.text.SimpleDateFormat
24
25 import org.apache.commons.lang3.*
26 import org.camunda.bpm.engine.delegate.BpmnError
27 import org.camunda.bpm.engine.runtime.Execution
28
29
30 public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
31
32         String Prefix="CMSO_"
33         ExceptionUtil exceptionUtil = new ExceptionUtil()
34
35         // Complete MSO Request processing
36         public initializeProcessVariables(Execution execution){
37
38                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
39                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
40                 logDebug('Entered ' + method, isDebugLogEnabled)
41                 try {
42
43                         /* Initialize all the process request variables in this block */
44                         execution.setVariable("prefix",Prefix)
45                         //execution.setVariable("getLayer3ServiceDetailsV1Response","")
46                         execution.setVariable("CMSO_request_id","")
47                         execution.setVariable("CMSO_notification-url","")
48                         execution.setVariable("CMSO_mso-bpel-name","")
49                         execution.setVariable("CMSO_request_action","")
50
51                         execution.setVariable("CMSO_notification-url-Ok", false)
52                         execution.setVariable("CMSO_request_id-Ok", false)
53
54                         //These variabels are for Get Mso Aai Password Adapter
55                         execution.setVariable("CMSO_deliveryStatus", false)
56
57                         //updateRequest Adapter process variables
58                         execution.setVariable("CMSO_updateRequestResponse", "")
59                         execution.setVariable("CMSO_updateRequestResponseCode", "")
60                         execution.setVariable("CMSO_updateFinalNotifyAckStatusSuccessPayload", "")
61                         execution.setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "")
62                         execution.setVariable("CMSO_gSendManagedNetworkStatusNotificationResponse", "")
63
64                         //Set DB adapter variables here
65                         execution.setVariable("CMSO_updateFinalStatusSuccessPayload", "")
66                         execution.setVariable("CMSO_updateDBStatusToSuccessPayload", "")
67                         execution.setVariable("CMSO_updateInfraRequestDBPayload", "")
68                         execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "")
69                         execution.setVariable("CMSO_setUpdateFinalNotifyAckStatusPayload", "")
70
71                         //NotifyOMXSuccessFailureViaCSI Adapter variables
72                         execution.setVariable("CMSO_notifyOMXSuccessFailureViaCSIPayload", "")
73                         execution.setVariable("CMSO_notifyOMXSuccessFailureViaCSIResponseCode", null)
74                         execution.setVariable("CMSO_notifyOMXSuccessFailureViaCSIResponse", "")
75
76                         //Auth variables
77                         execution.setVariable("BasicAuthHeaderValue","")
78
79                         //Response variables
80                         execution.setVariable("CompletionHandlerResponse","")
81                         execution.setVariable("CMSO_ErrorResponse", null)
82                         execution.setVariable("CMSO_ResponseCode", "")
83
84                         setSuccessIndicator(execution, false)
85
86                 } catch (BpmnError e) {
87                         throw e;
88                 } catch (Exception e) {
89                         logError('Caught exception in ' + method, e)
90                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
91                 }
92
93         }
94
95         public void preProcessRequest (Execution execution) {
96
97                 initializeProcessVariables(execution)
98                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
99                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
100                 utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
101                 logDebug('Entered ' + method, isDebugLogEnabled)
102                 try {
103                         def xml = execution.getVariable("CompleteMsoProcessRequest")
104
105                         utils.logAudit("CompleteMsoProcess Request: " + xml)
106                         utils.log("DEBUG", "Incoming Request is: "+ xml, isDebugLogEnabled)
107
108                         //mso-bpel-name from the incoming request
109                         def msoBpelName = utils.getNodeText1(xml,"mso-bpel-name")
110                         execution.setVariable("CMSO_mso-bpel-name",msoBpelName)
111
112                         //Check the incoming request type
113                         //Incoming request can be ACTIVE_REQUESTS (request-information node) or  INFRA_ACTIVE_REQUESTS (request-info node)
114                         if (utils.nodeExists(xml, "request-information")) {
115                                 execution.setVariable("CMSO_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS
116                         }
117
118                         //Check notification-url for the incoming request type
119                         //ACTIVE_REQUESTS may have notificationurl node
120                         //INFRA_ACTIVE_REQUESTS notificationurl node does not exist
121                         def notificationurl = ""
122                         if (utils.nodeExists(xml, "notification-url")) {
123                                 notificationurl = utils.getNodeText(xml,"notification-url")
124                                 if(notificationurl != null && !notificationurl.isEmpty()) {
125                                         execution.setVariable("CMSO_notification-url-Ok", true)
126                                         execution.setVariable("CMSO_notification-url",notificationurl)
127                                 }
128                         }
129
130                         //Check request_id for the incoming request type
131                         //For INFRA_ACTIVE_REQUESTS payload request-id IS optional (Not sure why this is option since req id is primary key ... also tried exe through SOAP UI to check if MSO code handles null like auto generated seq not it does not)
132                         //For ACTIVE_REQUESTS payload request-id is NOT optional
133                         def request_id = ""
134                         if (utils.nodeExists(xml, "request-id")) {
135                                 execution.setVariable("CMSO_request_id",utils.getNodeText(xml,"request-id"))
136                         }
137
138
139                         // INFRA_ACTIVE_REQUESTS         have "action" element ... mandatory
140                         // ACTIVE_REQUEST have "request-action" ... mandatory
141                         if (utils.nodeExists(xml, "request-action")) {
142                                 execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"request-action"))
143                         } else if (utils.nodeExists(xml, "action")) {
144                                 execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"action"))
145                         }
146
147                         //Check source for the incoming request type
148                         //For INFRA_ACTIVE_REQUESTS payload source IS optional
149                         //For ACTIVE_REQUESTS payload source is NOT optional
150                         def source = ""
151                         if (utils.nodeExists(xml, "source")) {
152                                 execution.setVariable("CMSO_source",utils.getNodeText(xml,"source"))
153                         }
154
155                         utils.log("DEBUG", "CMSO_notification-url-Ok --> " + execution.getVariable("CMSO_notification-url-Ok"), isDebugLogEnabled)
156                         utils.log("DEBUG", "CMSO_request_id-Ok --> " + execution.getVariable("CMSO_request_id-Ok"), isDebugLogEnabled)
157
158                         logDebug('Exited ' + method, isDebugLogEnabled)
159                 } catch (BpmnError e) {
160                         throw e;
161                 } catch (Exception e) {
162                         utils.log("DEBUG", "Exception Occured During PreProcessRequest: " + e, isDebugLogEnabled);
163                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
164                 }
165
166                 utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
167         }
168
169         public void postProcessResponse (Execution execution) {
170
171                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
172                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
173                 logDebug('Entered ' + method, isDebugLogEnabled)
174                 utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
175                 try {
176
177                         def msoCompletionResponse = """
178                         <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://ecomp.att.com/mso/workflow/schema/v1">
179                            <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed</sdncadapterworkflow:out>
180                         </sdncadapterworkflow:MsoCompletionResponse>
181                         """.trim()
182
183                         // Format Response
184                         def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse)
185                         String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
186                         // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
187                         execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString)
188                         utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
189                         execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
190                         execution.setVariable("CMSO_ResponseCode", "200")
191
192                         setSuccessIndicator(execution, true)
193
194                         utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled)
195
196                         logDebug('Exited ' + method, isDebugLogEnabled)
197                 } catch (BpmnError e) {
198                         throw e;
199                 } catch (Exception e) {
200                         logError('Caught exception in ' + method, e)
201                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
202                 }
203                 utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
204
205         }
206
207         public void updateFinalNotifyAckStatusSuccessPayload (Execution execution){
208                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
209                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
210                 logDebug('Entered ' + method, isDebugLogEnabled)
211                 try {
212
213                         def deliveryStatus = execution.getVariable("CMSO_deliveryStatus")
214                         String responseStatus = ""
215                         String responseCode = ""
216                         String responseBodyXml = ""
217
218                         if(deliveryStatus == true){
219                                 responseStatus = "SUCCESS"
220                                 responseCode = "200"
221                                 responseBodyXml = """<responseBody>${execution.getVariable("CMSO_gSendManagedNetworkStatusNotificationResponse")}</responseBody>"""
222                         }else{
223                                 responseStatus = "FAILED"
224                                 responseCode = execution.getVariable("CCDStatusCode")
225                         }
226
227                         String payload = """
228                         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
229                         <soapenv:Header/>
230                         <soapenv:Body>
231                            <req:updateRequest>
232                                   <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
233                                   <lastModifiedBy>BPEL</lastModifiedBy>
234                                   <responseStatus>${responseStatus}</responseStatus>
235                                   <responseCode>${responseCode}</responseCode>
236                                   ${responseBodyXml}
237                            </req:updateRequest>
238                         </soapenv:Body>
239                  </soapenv:Envelope>"""
240
241                         execution.setVariable("CMSO_updateFinalNotifyAckStatusSuccessPayload", payload)
242                         utils.logAudit("updateFinalNotifyAckStatusPayload: " + payload)
243                         logDebug('Exited ' + method, isDebugLogEnabled)
244
245                 } catch (BpmnError e) {
246                         throw e;
247                 } catch (Exception e) {
248                         logError('Caught exception in ' + method, e)
249                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
250                 }
251         }
252
253
254         public String updateFinalStatusSuccessPayload (Execution execution){
255
256                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
257                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
258                 logDebug('Entered ' + method, isDebugLogEnabled)
259                 try {
260                         String payload = """
261                         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
262                         <soapenv:Header/>
263                         <soapenv:Body>
264                            <req:updateRequest>
265                                   <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
266                                   <lastModifiedBy>BPEL</lastModifiedBy>
267                                   <responseStatus>SUCCESS</responseStatus>
268                            </req:updateRequest>
269                         </soapenv:Body>
270                  </soapenv:Envelope>
271                 """
272                         execution.setVariable("CMSO_updateFinalStatusSuccessPayload", payload)
273                         utils.logAudit("updateFinalStatusSuccessPayload: " + payload)
274                         logDebug('Exited ' + method, isDebugLogEnabled)
275                         //println("CMSO_updateFinalStatusSuccessPayload --> " + execution.getVariable("CMSO_updateFinalStatusSuccessPayload"))
276
277                         return execution.getVariable("CMSO_updateFinalStatusSuccessPayload")
278
279                 } catch (BpmnError e) {
280                         throw e;
281                 } catch (Exception e) {
282                         logError('Caught exception in ' + method, e)
283                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
284                 }
285         }
286
287         public void updateDBStatusToSuccessPayload (Execution execution){
288                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
289                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
290                 logDebug('Entered ' + method, isDebugLogEnabled)
291                 try {
292
293                         String payload = """
294                         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
295                         <soapenv:Header/>
296                         <soapenv:Body>
297                            <req:updateStatus>
298                                   <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
299                                   <lastModifiedBy>BPEL</lastModifiedBy>
300                                   <status>COMPLETED</status>
301                            </req:updateStatus>
302                         </soapenv:Body>
303                  </soapenv:Envelope>
304                 """
305                         execution.setVariable("CMSO_updateDBStatusToSuccessPayload", payload)
306                         utils.logAudit("updateDBStatusToSuccessPayload: " + payload)
307                         logDebug('Exited ' + method, isDebugLogEnabled)
308                         //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload"))
309
310                 } catch (BpmnError e) {
311                         throw e;
312                 } catch (Exception e) {
313                         logError('Caught exception in ' + method, e)
314                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
315                 }
316         }
317
318         public void setUpdateDBstatustoSuccessPayload (Execution execution){
319
320                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
321                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
322                 logDebug('Entered ' + method, isDebugLogEnabled)
323                 try {
324
325                         def xml = execution.getVariable("CompleteMsoProcessRequest")
326
327                         //Get statusMessage if exists
328                         def statusMessage
329                         if(utils.nodeExists(xml, "status-message")){
330                                 statusMessage = utils.getNodeText1(xml, "status-message")
331                         }else{
332                                 statusMessage = "Resource Completed Successfully"
333                         }
334
335                         //Get instance Id if exist
336                         String idXml = ""
337                         if(utils.nodeExists(xml, "vnfId")){
338                                 idXml = utils.getNodeXml(xml, "vnfId")
339                         }else if(utils.nodeExists(xml, "networkId")){
340                                 idXml = utils.getNodeXml(xml, "networkId")
341                         }else if(utils.nodeExists(xml, "serviceInstanceId")){
342                                 idXml = utils.getNodeXml(xml, "serviceInstanceId")
343                         }else if(utils.nodeExists(xml, "vfModuleId")){
344                                 idXml = utils.getNodeXml(xml, "vfModuleId")
345                         }else if(utils.nodeExists(xml, "volumeGroupId")){
346                                 idXml = utils.getNodeXml(xml, "volumeGroupId")
347                         }else{
348                                 idXml = ""
349                         }
350                         idXml = utils.removeXmlPreamble(idXml)
351                         utils.log("DEBUG", "Incoming Instance Id Xml: " + idXml, isDebugLogEnabled)
352
353                         String payload = """
354                                                 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
355                                                    <soapenv:Header/>
356                                                    <soapenv:Body>
357                                                       <req:updateInfraRequest>
358                                                          <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
359                                                          <lastModifiedBy>${execution.getVariable("CMSO_mso-bpel-name")}</lastModifiedBy>
360                                                          <statusMessage>${statusMessage}</statusMessage>
361                                                          <requestStatus>COMPLETE</requestStatus>
362                                                                  <progress>100</progress>
363                                                                  ${idXml}
364                                                       </req:updateInfraRequest>
365                                                    </soapenv:Body>
366                                                 </soapenv:Envelope>"""
367
368                         execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", payload)
369                         utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled)
370                         utils.logAudit("setUpdateDBstatustoSuccessPayload: " + payload)
371
372                 } catch (BpmnError e) {
373                         throw e;
374                 } catch (Exception e) {
375                         logError('Caught exception in ' + method, e)
376                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
377                 }
378                 logDebug('Exited ' + method, isDebugLogEnabled)
379         }
380
381         public String updateFinalNotifyAckStatusPayload (Execution execution){
382
383                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
384                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
385                 logDebug('Entered ' + method, isDebugLogEnabled)
386                 try {
387                         String payload = """
388                                                 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
389                                                    <soapenv:Header/>
390                                                    <soapenv:Body>
391                                                       <req:updateResponseStatus>
392                                                          <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
393                                                          <lastModifiedBy>BPEL</lastModifiedBy>
394                                                          <responseStatus>SENDING_FINAL_NOTIFY</responseStatus>
395                                                       </req:updateResponseStatus>
396                                                    </soapenv:Body>
397                                                 </soapenv:Envelope>
398                 """
399                         execution.setVariable("CMSO_setUpdateFinalNotifyAckStatusPayload", payload)
400                         utils.logAudit("updateFinalNotifyAckStatusPayload: " + payload)
401                         logDebug('Exited ' + method, isDebugLogEnabled)
402
403                         return execution.getVariable("CMSO_setUpdateFinalNotifyAckStatusPayload")
404
405                 } catch (BpmnError e) {
406                         throw e;
407                 } catch (Exception e) {
408                         logError('Caught exception in ' + method, e)
409                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
410                 }
411
412         }
413
414         //      public void decryptMsoPassword (Execution execution) {
415         //
416         //              def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
417         //              def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
418         //              logDebug('Entered ' + method, isDebugLogEnabled)
419         //              try {
420         //                      def encryptedPwd=execution.getVariable("URN_mso_csi_pwd")
421         //                      def msoKey = execution.getVariable("URN_mso_msoKey")
422         //
423         //                      String basicAuthValue = utils.getBasicAuth(encryptedPwd, msoKey)
424         //                      execution.setVariable("BasicAuthHeaderValueCSI",basicAuthValue)
425         //                      logDebug('Exited ' + method, isDebugLogEnabled)
426         //              } catch (BpmnError e) {
427         //                      throw e;
428         //              } catch (IOException e) {
429         //                      logError('Caught exception in ' + method, e)
430         //                      workflowException(execution, 'Internal Error', 2000)
431         //              }
432         //      }
433
434         public String notifyOMXSuccessFailureViaCSIPayload (Execution execution) {
435
436                 return "";
437         }
438
439         public String notifyCCDSuccessPayload (Execution execution) {
440
441                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
442                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
443                 logDebug('Entered ' + method, isDebugLogEnabled)
444                 try {
445
446                         String payload ="""
447                 <ns:status-notification xmlns:ns="http://ecomp.att.com/mso/statusnotification/schema/v1" xmlns:msoservtypes="http://ecomp.att.com/mso/request/types/v1">
448                                 <msoservtypes:request-id>${execution.getVariable("CMSO_request_id")}</msoservtypes:request-id>
449                                 <msoservtypes:request-action>${execution.getVariable("CMSO_request_action")}</msoservtypes:request-action>
450                                 <msoservtypes:source>${execution.getVariable("CMSO_source")}</msoservtypes:source>
451                                 <msoservtypes:ack-final-indicator>Y</msoservtypes:ack-final-indicator>
452                 </ns:status-notification>
453                 """
454                         execution.setVariable("CMSO_notifyCCDSuccessPayload", payload)
455                         utils.logAudit("notifyCCDSuccessPayload: " + payload)
456                         logDebug('Exited ' + method, isDebugLogEnabled)
457
458                         return execution.getVariable("CMSO_notifyCCDSuccessPayload")
459
460                 } catch (BpmnError e) {
461                         throw e;
462                 } catch (Exception e) {
463                         logError('Caught exception in ' + method, e)
464                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
465                 }
466
467
468         }
469
470         public void buildDataError (Execution execution, String message) {
471
472                 def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
473                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
474                 logDebug('Entered ' + method, isDebugLogEnabled)
475                 try {
476
477                         def msoCompletionResponse = """
478                         <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://ecomp.att.com/mso/workflow/schema/v1">
479                            <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} FAILED</sdncadapterworkflow:out>
480                         </sdncadapterworkflow:MsoCompletionResponse>
481                         """.trim()
482
483                         // Format Response
484                         def xmlMsoCompletionResponse = utils.formatXml(msoCompletionResponse)
485                         String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
486                         utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
487                         execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
488                         utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"), isDebugLogEnabled)
489
490                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, message)
491
492                 } catch (BpmnError e) {
493                         utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugLogEnabled)
494                         throw e;
495                 } catch (Exception e) {
496                         logError('Caught exception in ' + method, e)
497                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
498                 }
499
500         }
501
502 }