Containerization feature of SO
[so.git] / bpmn / so-bpmn-infrastructure-flows / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / ReplaceVnfInfra.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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  *      http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ============LICENSE_END=========================================================
18  */
19
20 package org.onap.so.bpmn.infrastructure.scripts
21
22 import org.camunda.bpm.engine.delegate.BpmnError
23 import org.camunda.bpm.engine.delegate.DelegateExecution
24 import org.onap.appc.client.lcm.model.Action;
25 import org.onap.appc.client.lcm.model.Status
26 import org.onap.so.bpmn.common.scripts.ExceptionUtil
27 import org.onap.so.bpmn.common.scripts.MsoUtils
28 import org.onap.so.bpmn.core.domain.ModelInfo
29 import org.onap.so.bpmn.core.domain.ServiceDecomposition
30 import org.onap.so.bpmn.core.domain.VnfResource
31 import org.onap.so.bpmn.core.json.JsonUtils
32 import org.onap.so.client.aai.*
33 import org.onap.so.client.appc.ApplicationControllerOrchestrator
34 import org.onap.so.client.appc.ApplicationControllerSupport
35 import org.onap.so.logger.MessageEnum
36 import org.onap.so.logger.MsoLogger
37
38 import groovy.json.JsonOutput
39 import groovy.json.JsonSlurper
40
41 public class ReplaceVnfInfra extends VnfCmBase {
42         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ReplaceVnfInfra.class);
43
44         ExceptionUtil exceptionUtil = new ExceptionUtil()
45         JsonUtils jsonUtils = new JsonUtils()           
46         def prefix = "RPLVnfI_"
47
48         /**
49          * Initialize the flow's variables.
50          *
51          * @param execution The flow's execution instance.
52          */
53         public void initProcessVariables(DelegateExecution execution) {
54                 execution.setVariable('prefix', 'RPLVnfI_')
55                 execution.setVariable('Request', null)
56                 execution.setVariable('requestInfo', null)              
57                 execution.setVariable('source', null)
58                 execution.setVariable('vnfInputs', null)                
59                 execution.setVariable('tenantId', null)         
60                 execution.setVariable('vnfParams', null)
61                 execution.setVariable('controllerType', null)
62                 execution.setVariable('cloudConfiguration', null)               
63                 execution.setVariable('ReplaceVnfSuccessIndicator', false)
64                 execution.setVariable('serviceType', null)
65                 execution.setVariable('nfRole', null)
66                 execution.setVariable('currentActivity', 'RPLVnfI')
67                 execution.setVariable('workStep', null)
68                 execution.setVariable('failedActivity', null)
69                 execution.setVariable('errorCode', "0")
70                 execution.setVariable('errorText', null)
71                 execution.setVariable('healthCheckIndex', 1)
72                 execution.setVariable('retainResources', true)
73                 execution.setVariable('productFamilyId', null)
74                 execution.setVariable('healthCheckIndex0', 0)
75                 execution.setVariable('healthCheckIndex1', 1)
76                 execution.setVariable("rollbackSetClosedLoopDisabledFlag", false)
77                 execution.setVariable("rollbackVnfStop", false)
78                 execution.setVariable("rollbackVnfLock", false)
79                 execution.setVariable("rollbackQuiesceTraffic", false)
80                 execution.setVariable("rollbackSetVnfInMaintenanceFlag", false)
81                 execution.setVariable("platform", null)
82                 execution.setVariable("lineOfBusiness", null)
83         }
84
85         /**
86          * Check for missing elements in the received request.
87          *
88          * @param execution The flow's execution instance.
89          */
90         public void preProcessRequest(DelegateExecution execution) {
91                 def method = getClass().getSimpleName() + '.preProcessRequest(' +
92                 'execution=' + execution.getId() +
93                 ')'
94                 initProcessVariables(execution)
95
96                 msoLogger.trace('Entered ' + method)
97
98                 initProcessVariables(execution)         
99
100                 def incomingRequest = execution.getVariable('bpmnRequest')
101
102                 msoLogger.debug("Incoming Infra Request: " + incomingRequest)
103                 try {
104                         def jsonSlurper = new JsonSlurper()
105                         def jsonOutput = new JsonOutput()
106                         Map reqMap = jsonSlurper.parseText(incomingRequest)
107                         msoLogger.debug(" Request is in JSON format.")
108
109                         def serviceInstanceId = execution.getVariable('serviceInstanceId')
110                         def vnfId = execution.getVariable('vnfId')
111                         
112                         execution.setVariable('serviceInstanceId', serviceInstanceId)                   
113                         execution.setVariable("isVidRequest", "true")
114                         execution.setVariable('serviceType', 'Mobility')
115                         execution.setVariable('retainResources', true)
116                         execution.setVariable('disableRollback', true)
117                         execution.setVariable('payload', "")
118                         execution.setVariable('actionLock', Action.Lock)
119                         execution.setVariable('actionUnlock', Action.Unlock)
120                         execution.setVariable('actionHealthCheck', Action.HealthCheck)
121                         execution.setVariable('actionStart', Action.Start)
122                         execution.setVariable('actionStop', Action.Stop)
123                         
124                         def asdcServiceModelVersion = ''
125                         def serviceModelInfo = null
126                         
127                         def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
128                                                 
129                         if (relatedInstanceList != null) {
130                                 relatedInstanceList.each {
131                                         if (it.relatedInstance.modelInfo?.modelType == 'service') {
132                                                 msoLogger.debug("PROCESSING SERVICE INFO")
133                                                 asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
134                                                 serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
135                                                 msoLogger.debug("ServiceModelInfo: " + serviceModelInfo)
136                                                 def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")
137                                                 msoLogger.debug("modelInvariant: " + modelInvariant)
138                                         }
139                                         
140                                 }
141                         }               
142                         
143                         execution.setVariable('asdcServiceModelVersion', asdcServiceModelVersion)
144                         execution.setVariable('serviceModelInfo', serviceModelInfo)                     
145                         def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
146                         execution.setVariable('vnfModelInfo', vnfModelInfo)
147                         def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid")
148                         execution.setVariable('vnfModelInvariantUuid', vnfModelInvariantUuid)   
149                         msoLogger.debug("vnfModelInvariantUuid: " + vnfModelInvariantUuid)      
150                         
151                         def vnfType = execution.getVariable('vnfType')
152                         execution.setVariable('vnfType', vnfType)       
153                         
154
155                         def controllerType = reqMap.requestDetails?.requestParameters?.controllerType
156                         execution.setVariable('controllerType', controllerType)
157                         
158                         msoLogger.debug('Controller Type: ' + controllerType)   
159                         
160                         def userParams = reqMap.requestDetails?.requestParameters?.userParams                                   
161                         
162                         Map<String, String> userParamsMap = [:]
163                         if (userParams != null) {
164                                 userParams.each { userParam ->
165                                         userParamsMap.put(userParam.name, userParam.value.toString())
166                                 }                                                       
167                         }               
168                                                 
169                         msoLogger.debug('Processed user params: ' + userParamsMap)              
170                         
171                         execution.setVariable('vfModuleInputParams', userParamsMap)                     
172                                                 
173                         def requestId = execution.getVariable("requestId")              
174                         execution.setVariable('msoRequestId', requestId)
175                         msoLogger.debug("requestId is: " + requestId)
176                         
177                         def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
178                         execution.setVariable('vnfName', vnfName)
179                         
180                         def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null
181                         execution.setVariable('requestorId', requestorId)
182                         
183                         def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
184                         execution.setVariable('usePreload', usePreload)
185                         
186                         def productFamilyId = reqMap.requestDetails?.requestInfo?.productFamilyId ?: null
187                         execution.setVariable('productFamilyId', productFamilyId)
188                         
189                         def cloudConfiguration = jsonOutput.toJson(reqMap.requestDetails?.cloudConfiguration)           
190                         execution.setVariable('cloudConfiguration', cloudConfiguration)
191                         def lcpCloudRegionId    = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId")
192                         execution.setVariable('lcpCloudRegionId', lcpCloudRegionId)
193                         def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId")
194                         execution.setVariable('tenantId', tenantId)
195                         
196                         def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
197                         execution.setVariable('globalSubscriberId', globalSubscriberId)
198                         
199                         execution.setVariable('sdncVersion', '1702')
200
201                         execution.setVariable("ReplaceVnfInfraSuccessIndicator", false)
202                                                 
203
204                         
205                         def source = reqMap.requestDetails?.requestInfo?.source
206                         execution.setVariable("source", source)
207                         
208                         //For Completion Handler & Fallout Handler
209                         String requestInfo =
210                         """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
211                                         <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
212                                         <action>REPLACE</action>
213                                         <source>${MsoUtils.xmlEscape(source)}</source>
214                                    </request-info>"""
215                         
216                         execution.setVariable("requestInfo", requestInfo)                       
217                         
218                         msoLogger.debug('RequestInfo: ' + execution.getVariable("requestInfo"))         
219                         
220                         msoLogger.trace('Exited ' + method)
221
222                 }
223                 catch(groovy.json.JsonException je) {
224                         msoLogger.debug(" Request is not in JSON format.")
225                         exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format")
226
227                 }
228                 catch(Exception e) {
229                         String restFaultMessage = e.getMessage()
230                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
231                         exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
232                 }       
233         }
234
235         /**
236          * Prepare and send the sychronous response for this flow.
237          *
238          * @param execution The flow's execution instance.
239          */
240         public void sendSynchResponse(DelegateExecution execution) {
241                 def method = getClass().getSimpleName() + '.sendSynchResponse(' +
242                         'execution=' + execution.getId() +
243                         ')'
244
245                 msoLogger.trace('Entered ' + method)
246
247
248                 try {
249                         def requestInfo = execution.getVariable('requestInfo')
250                         def requestId = execution.getVariable('requestId')
251                         def source = execution.getVariable('source')
252                         def progress = getNodeTextForce(requestInfo, 'progress')
253                         if (progress.isEmpty()) {
254                                 progress = '0'
255                         }
256                         def startTime = getNodeTextForce(requestInfo, 'start-time')
257                         if (startTime.isEmpty()) {
258                                 startTime = System.currentTimeMillis()
259                         }
260
261                         // RESTResponse (for API Handler (APIH) Reply Task)
262                         def vnfId = execution.getVariable("vnfId")
263                         String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim()
264
265                         sendWorkflowResponse(execution, 200, synchResponse)
266
267                         msoLogger.trace('Exited ' + method)
268                 } catch (BpmnError e) {
269                         throw e;
270                 } catch (Exception e) {
271                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
272                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
273                 }
274         }
275         
276         
277
278         /**
279          * Get VnfResource decomposition object for this VNF.
280          *      
281          *
282          * @param execution The flow's execution instance.
283          */
284         public void getVnfResourceDecomposition(DelegateExecution execution) {
285                 def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' +
286                         'execution=' + execution.getId() +
287                         ')'
288
289                 msoLogger.trace('Entered ' + method)
290
291                 try {
292                         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
293                         String vnfModelInvariantUuid = execution.getVariable('vnfModelInvariantUuid')
294                         msoLogger.debug("vnfModelInvariantUuid: " + vnfModelInvariantUuid)
295                         List<VnfResource> vnfResources = serviceDecomposition.getVnfResources()
296                         
297                         for (i in 0..vnfResources.size()-1) {
298                                 ModelInfo modelInfo = vnfResources[i].getModelInfo()
299                                 String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid()
300                                 msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition)
301                                 
302                                 if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) {
303                                         VnfResource vnfResourceDecomposition = vnfResources[i]
304                                         execution.setVariable('vnfResourceDecomposition', vnfResourceDecomposition)
305                                         def nfRole = vnfResourceDecomposition.getNfRole()                                       
306                                         execution.setVariable('nfRole', nfRole)
307                                         msoLogger.debug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString())                                 
308                                         break
309                                 }
310                                 else {
311                                         //exception!
312                                 }
313                                 
314                         }
315
316                         msoLogger.trace('Exited ' + method)
317                 } catch (BpmnError e) {
318                         throw e;
319                 } catch (Exception e) {
320                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
321                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage())
322                 }
323         }
324         
325         /**
326          * Check if this VNF is already in maintenance in A&AI.
327          *
328          *
329          * @param execution The flow's execution instance.
330          */
331         public void checkIfVnfInMaintInAAI(DelegateExecution execution) {
332                 def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' +
333                         'execution=' + execution.getId() +
334                         ')'
335
336                 execution.setVariable('errorCode', "0")
337                 execution.setVariable("workStep", "checkIfVnfInMaintInAAI")
338                 execution.setVariable("failedActivity", "AAI")
339                 msoLogger.trace('Entered ' + method)
340
341                 try {
342                         def transactionLoggingUuid = UUID.randomUUID().toString()
343                         AAIRestClientImpl client = new AAIRestClientImpl()
344                         AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
345                         aaiValidator.setClient(client)
346                         def vnfId = execution.getVariable("vnfId")
347                         boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid)
348                         msoLogger.debug("isInMaint result: " + isInMaint)
349                         execution.setVariable('isVnfInMaintenance', isInMaint)
350                         
351                         if (isInMaint) {
352                                 execution.setVariable("errorCode", "1003")
353                                 execution.setVariable("errorText", "VNF is in maintenance in A&AI")
354                         }
355
356
357                         msoLogger.trace('Exited ' + method)
358                 } catch (BpmnError e) {
359                         throw e;
360                 } catch (Exception e) {
361                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
362                         execution.setVariable("errorCode", "1002")
363                         execution.setVariable("errorText", e.getMessage())
364                         //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
365                 }
366         }
367         
368         
369         /**
370          * Check if this VNF's pservers are locked in A&AI.
371          *
372          *
373          * @param execution The flow's execution instance.
374          */
375         public void checkIfPserversInMaintInAAI(DelegateExecution execution) {
376                 def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' +
377                         'execution=' + execution.getId() +
378                         ')'
379
380                 execution.setVariable('errorCode', "0")
381                 msoLogger.trace('Entered ' + method)
382                 execution.setVariable("workStep", "checkIfPserversInMaintInAAI")
383                 execution.setVariable("failedActivity", "AAI")
384
385                 try {
386                         def transactionLoggingUuid = UUID.randomUUID().toString()
387                         AAIRestClientImpl client = new AAIRestClientImpl()
388                         AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
389                         aaiValidator.setClient(client)
390                         def vnfId = execution.getVariable("vnfId")                      
391                         boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid)
392                         msoLogger.debug("areLocked result: " + areLocked)
393                         execution.setVariable('arePserversLocked', areLocked)
394                         
395                         if (areLocked) {
396                                 execution.setVariable("errorCode", "1003")
397                                 execution.setVariable("errorText", "pServers are locked in A&AI")
398                         }
399
400                         msoLogger.trace('Exited ' + method)
401                 } catch (BpmnError e) {
402                         throw e;
403                 } catch (Exception e) {
404                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
405                         execution.setVariable("errorCode", "1002")
406                         execution.setVariable("errorText", e.getMessage())
407                         //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage())
408                 }
409         }
410         
411         /**
412          * Set inMaint flag for this VNF to the specified value in A&AI.
413          *
414          *
415          * @param execution The flow's execution instance.
416          * @param inMaint The boolean value of the flag to set
417          */
418         public void setVnfInMaintFlagInAAI(DelegateExecution execution, boolean inMaint) {
419                 def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' +
420                         'execution=' + execution.getId() +
421                         ')'
422
423                 execution.setVariable('errorCode', "0")
424                 msoLogger.trace('Entered ' + method)
425                 if (inMaint) {
426                         execution.setVariable("workStep", "setVnfInMaintFlagInAAI")
427                 }
428                 else {
429                         execution.setVariable("workStep", "unsetVnfInMaintFlagInAAI")
430                 }
431                 execution.setVariable("failedActivity", "AAI")
432
433                 try {
434                         def transactionLoggingUuid = UUID.randomUUID().toString()
435                         AAIRestClientImpl client = new AAIRestClientImpl()
436                         AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl()
437                         aaiUpdator.setClient(client)
438                         def vnfId = execution.getVariable("vnfId")
439                         if (inMaint) {
440                                 aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid)
441                                 execution.setVariable("rollbackSetVnfInMaintenanceFlag", true)
442                         }
443                         else {
444                                 aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid)
445                         }
446                                                         
447                         msoLogger.trace('Exited ' + method)
448                 } catch (BpmnError e) {
449                         throw e;
450                 } catch (Exception e) {
451                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
452                         execution.setVariable("errorCode", "1002")
453                         execution.setVariable("errorText", e.getMessage())
454                         //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage())
455                 }
456         }
457         
458         /**
459          * Call APP-C client to execute specified APP-C command for this VNF.
460          *
461          *
462          * @param execution The flow's execution instance.
463          * @param action The action to take in APP-C.
464          */
465         public void runAppcCommand(DelegateExecution execution, Action action) {
466                 def method = getClass().getSimpleName() + '.runAppcCommand(' +
467                         'execution=' + execution.getId() +
468                         ')'
469
470                 execution.setVariable('errorCode', "0")
471                 msoLogger.trace('Entered ' + method)            
472                 
473                 try {
474                         msoLogger.debug("Running APP-C action: " + action.toString())
475                         String vnfId = execution.getVariable('vnfId')
476                         String msoRequestId = execution.getVariable('requestId')
477                         execution.setVariable('msoRequestId', msoRequestId)
478                         execution.setVariable("failedActivity", "APP-C")
479                         execution.setVariable("workStep", action.toString() + "VNF")
480                         
481                         ApplicationControllerOrchestrator appcClient = new ApplicationControllerOrchestrator()                  
482                         Status appcStatus = null
483                         switch(action) {
484                                 case Action.Lock:
485                                         execution.setVariable('workStep', "LockVNF")
486                                         appcStatus = appcClient.runCommand(Action.Lock,msoRequestId,vnfId,null)
487                                         break
488                                 case Action.Unlock:
489                                         execution.setVariable('workStep', "UnlockVNF")
490                                         appcStatus = appcClient.runCommand(Action.Unlock,msoRequestId,vnfId,null)
491                                         break
492                                 case Action.HealthCheck:
493                                         def healthCheckIndex = execution.getVariable('healthCheckIndex')
494                                         execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex)
495                                         execution.setVariable('healthCheckIndex', healthCheckIndex + 1)
496                                         appcStatus = appcClient.runCommand(Action.HealthCheck,msoRequestId,vnfId,null)
497                                         break
498                                 case Action.Start:
499                                         execution.setVariable('workStep', "StartVNF")
500                                         appcStatus = appcClient.runCommand(Action.Start,msoRequestId,vnfId,null)
501                                         break
502                                 case Action.Stop:
503                                         execution.setVariable('workStep', "StopVNF")
504                                         appcStatus = appcClient.runCommand(Action.Stop,msoRequestId,vnfId,null)
505                                         break
506                                 default:
507                                         break
508                         }
509                         msoLogger.debug("Completed AppC request")
510                         int appcCode = appcStatus.getCode()
511                         msoLogger.debug("AppC status code is: " + appcCode)
512                         msoLogger.debug("AppC status message is: " + appcStatus.getMessage())
513                         if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) {
514                                 execution.setVariable("errorCode", Integer.toString(appcCode))
515                                 execution.setVariable("errorText", appcStatus.getMessage())
516                         }
517                         
518                         msoLogger.trace('Exited ' + method)
519                 } catch (BpmnError e) {
520                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
521                         execution.setVariable("errorCode", "1002")
522                         execution.setVariable("errorText", e.getMessage())                      
523                 } catch (java.lang.NoSuchMethodError e) {
524                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
525                         execution.setVariable("errorCode", "1002")
526                         execution.setVariable("errorText", e.getMessage())                              
527                 } catch (Exception e) {
528                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
529                         execution.setVariable("errorCode", "1002")
530                         execution.setVariable("errorText", e.getMessage())                      
531                 }
532         }
533
534
535         
536         /**
537         * Prepare DoDeleteVnfAndModules call.
538         *
539         *
540         * @param execution The flow's execution instance.
541         */
542    public void prepDoDeleteVnfAndModules(DelegateExecution execution) {
543            def method = getClass().getSimpleName() + '.prepDoDeleteVnfAndModules(' +
544                    'execution=' + execution.getId() +
545                    ')'
546
547            execution.setVariable('errorCode', "0")
548            msoLogger.trace('Entered ' + method)
549            execution.setVariable("workStep", "doDeleteVnfAndModules")
550            execution.setVariable("failedActivity", "MSO Delete VNF")
551            msoLogger.trace('Exited ' + method)
552            
553    }
554    
555    /**
556         * Prepare DoCreateVnfAndModules call.
557         *
558         *
559         * @param execution The flow's execution instance.
560         */
561    public void prepDoCreateVnfAndModules(DelegateExecution execution) {
562            def method = getClass().getSimpleName() + '.prepDoReplaceVnfAndModules(' +
563                    'execution=' + execution.getId() +
564                    ')'
565
566            execution.setVariable('errorCode', "0")
567            msoLogger.trace('Entered ' + method)
568            execution.setVariable("workStep", "doCreateVnfAndModules")
569            execution.setVariable("failedActivity", "MSO Create VNF")
570            msoLogger.trace('Exited ' + method)
571            
572    }
573         
574         
575         /**
576          * Handle Abort disposition from RainyDayHandler
577          *       
578          * @param execution The flow's execution instance.      
579          */
580         public void abortProcessing(DelegateExecution execution) {
581                 def method = getClass().getSimpleName() + '.abortProcessing(' +
582                         'execution=' + execution.getId() +
583                         ')'
584
585                 msoLogger.trace('Entered ' + method)
586                 
587                 def errorText = execution.getVariable("errorText")
588                 def errorCode = execution.getVariable("errorCode")
589                 
590                 exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText)
591         }
592         
593         /**
594          * Handle Manual disposition from RainyDayHandler
595          *
596          * @param execution The flow's execution instance.
597          */
598         public void manualProcessing(DelegateExecution execution) {
599                 def method = getClass().getSimpleName() + '.manualProcessing(' +
600                         'execution=' + execution.getId() +
601                         ')'
602
603                 msoLogger.trace('Entered ' + method)
604                 
605                 def taskId = execution.getVariable("taskId")
606                 
607                 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Processing halted - manual task created: " + taskId)
608         }
609
610         
611 }