3b24ebf54443232b492910dcb6805407b3d33319
[so.git] /
1 /*\r
2  * Â© 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.\r
3  */\r
4 package org.openecomp.mso.bpmn.vcpe.scripts;\r
5 \r
6 import groovy.xml.XmlUtil\r
7 import groovy.json.*\r
8 \r
9 import org.openecomp.mso.bpmn.core.json.JsonUtils\r
10 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
11 import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils\r
12 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
13 import org.openecomp.mso.bpmn.common.scripts.VidUtils\r
14 import org.openecomp.mso.bpmn.core.RollbackData\r
15 import org.openecomp.mso.bpmn.core.WorkflowException\r
16 import org.openecomp.mso.bpmn.core.domain.*\r
17 \r
18 import java.util.UUID;\r
19 \r
20 import org.camunda.bpm.engine.delegate.BpmnError\r
21 import org.camunda.bpm.engine.runtime.Execution\r
22 import org.json.JSONObject;\r
23 import org.json.JSONArray;\r
24 import org.apache.commons.lang3.*\r
25 import org.apache.commons.codec.binary.Base64;\r
26 import org.springframework.web.util.UriUtils;\r
27 \r
28 /**\r
29  * This groovy class supports the <class>CreateVcpeResCustService.bpmn</class> process.\r
30  *\r
31  * @author ek1439\r
32  *\r
33  */\r
34 public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {\r
35 \r
36         String Prefix="CVRCS_"\r
37         ExceptionUtil exceptionUtil = new ExceptionUtil()\r
38         JsonUtils jsonUtil = new JsonUtils()\r
39         VidUtils vidUtils = new VidUtils()\r
40         CatalogDbUtils catalogDbUtils = new CatalogDbUtils()\r
41 \r
42         /**\r
43          * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.\r
44          * @param execution\r
45          */\r
46         public InitializeProcessVariables(Execution execution){\r
47                 /* Initialize all the process variables in this block */\r
48 \r
49                 execution.setVariable("createVcpeServiceRequest", "")\r
50                 execution.setVariable("globalSubscriberId", "")\r
51                 execution.setVariable("serviceInstanceName", "")\r
52                 execution.setVariable("msoRequestId", "")\r
53                 execution.setVariable("CVRCS_NetworksCreatedCount", 0)\r
54                 execution.setVariable("CVRCS_VnfsCreatedCount", 0)\r
55                 execution.setVariable("productFamilyId", "")\r
56                 execution.setVariable("brgWanMacAddress", "")\r
57 \r
58                 //TODO\r
59                 execution.setVariable("sdncVersion", "1707")\r
60         }\r
61 \r
62         // **************************************************\r
63         //     Pre or Prepare Request Section\r
64         // **************************************************\r
65         /**\r
66          * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.\r
67          * @param execution\r
68          */\r
69         public void preProcessRequest (Execution execution) {\r
70                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
71                 execution.setVariable("prefix",Prefix)\r
72 \r
73                 utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)\r
74 \r
75                 try {\r
76                         // initialize flow variables\r
77                         InitializeProcessVariables(execution)\r
78 \r
79                         // check for incoming json message/input\r
80                         String createVcpeServiceRequest = execution.getVariable("bpmnRequest")\r
81                         utils.logAudit(createVcpeServiceRequest)\r
82                         execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest);\r
83                         println 'createVcpeServiceRequest - ' + createVcpeServiceRequest\r
84 \r
85                         // extract requestId\r
86                         String requestId = execution.getVariable("mso-request-id")\r
87                         execution.setVariable("msoRequestId", requestId)\r
88 \r
89                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
90 \r
91                         if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {\r
92                                 serviceInstanceId = UUID.randomUUID().toString()\r
93                                 utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled)\r
94                         } else {\r
95                                 utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled)\r
96                         }\r
97 \r
98                         serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")\r
99                         execution.setVariable("serviceInstanceId", serviceInstanceId)\r
100 \r
101                         String requestAction = execution.getVariable("requestAction")\r
102                         execution.setVariable("requestAction", requestAction)\r
103 \r
104                         setBasicDBAuthHeader(execution, isDebugEnabled)\r
105                         \r
106                         String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source")\r
107                         if ((source == null) || (source.isEmpty())) {\r
108                                 execution.setVariable("source", "VID")\r
109                         } else {\r
110                                 execution.setVariable("source", source)\r
111                         }\r
112 \r
113                         // extract globalSubscriberId\r
114                         String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId")\r
115 \r
116                         // verify element global-customer-id is sent from JSON input, throw exception if missing\r
117                         if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) {\r
118                                 String dataErrorMessage = " Element 'globalSubscriberId' is missing. "\r
119                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
120 \r
121                         } else {\r
122                                 execution.setVariable("globalSubscriberId", globalSubscriberId)\r
123                                 execution.setVariable("globalCustomerId", globalSubscriberId)\r
124                         }\r
125 \r
126                         // extract subscriptionServiceType\r
127                         String subscriptionServiceType = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters.subscriptionServiceType")\r
128                         execution.setVariable("subscriptionServiceType", subscriptionServiceType)\r
129                         utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)\r
130 \r
131                         String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.suppressRollback")\r
132                         execution.setVariable("disableRollback", suppressRollback)\r
133                         utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)\r
134 \r
135                         String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")\r
136                         execution.setVariable("productFamilyId", productFamilyId)\r
137                         utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)\r
138                         \r
139                         String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo")\r
140                         execution.setVariable("subscriberInfo", subscriberInfo)\r
141                         utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled)\r
142 \r
143                   /*
144                   * Extracting User Parameters from incoming Request and converting into a Map
145                   */
146                   def jsonSlurper = new JsonSlurper()
147                   def jsonOutput = new JsonOutput()
148   
149                   Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest)
150   
151                   //InputParams
152                   def userParams = reqMap.requestDetails?.requestParameters?.userParams
153   
154                   Map<String, String> inputMap = [:]
155                   if (userParams) {
156                           userParams.each {
157                                   name, value -> inputMap.put(name, value)
158                                         if (name.equals("BRG_WAN_MAC_Address"))
159                                                         execution.setVariable("brgWanMacAddress", value)\r
160                           }
161                   }
162
163                   utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)
164                   execution.setVariable("serviceInputParams", inputMap)
165
166                         utils.log("DEBUG", "Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress'), isDebugEnabled)\r
167 \r
168                         //For Completion Handler & Fallout Handler\r
169                         String requestInfo =\r
170                         """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
171                                         <request-id>${requestId}</request-id>\r
172                                         <action>CREATE</action>\r
173                                         <source>${source}</source>\r
174                                    </request-info>"""\r
175 \r
176                         execution.setVariable("CVRCS_requestInfo", requestInfo)\r
177 \r
178                         utils.log("DEBUG", " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)\r
179 \r
180                 } catch (BpmnError e) {\r
181                         throw e;\r
182 \r
183                 } catch (Exception ex){\r
184                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()\r
185                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
186                 }\r
187         }\r
188 \r
189         public void sendSyncResponse (Execution execution) {\r
190                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
191 \r
192                 utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled)\r
193 \r
194                 try {\r
195                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
196                         String requestId = execution.getVariable("mso-request-id")\r
197 \r
198                         // RESTResponse (for API Handler (APIH) Reply Task)\r
199                         String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()\r
200 \r
201                         utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)\r
202                         sendWorkflowResponse(execution, 202, syncResponse)\r
203 \r
204                 } catch (Exception ex) {\r
205                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage()\r
206                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
207                 }\r
208         }\r
209 \r
210         // *******************************\r
211         //\r
212         // *******************************\r
213         public void prepareDecomposeService(Execution execution) {\r
214                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
215 \r
216                 try {\r
217                         utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)\r
218 \r
219                         String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
220 \r
221                         //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB\r
222                         String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.modelInfo")\r
223                         execution.setVariable("serviceModelInfo", serviceModelInfo)\r
224 \r
225                         utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)\r
226                 } catch (Exception ex) {\r
227                         // try error in method block\r
228                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()\r
229                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
230                 }\r
231          }\r
232 \r
233         // *******************************\r
234         //\r
235         // *******************************\r
236         public void prepareCreateServiceInstance(Execution execution) {\r
237                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
238 \r
239                 try {\r
240                         utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)\r
241 \r
242                         /*\r
243                          * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject\r
244                          *              ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
245                          *              ModelInfo modelInfo = serviceDecomposition.getModelInfo()\r
246                          *\r
247                          */\r
248                         String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
249 //                      String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters")\r
250 //                      execution.setVariable("serviceInputParams", serviceInputParams)\r
251 \r
252
253                         String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName")\r
254                         execution.setVariable("serviceInstanceName", serviceInstanceName)\r
255 \r
256                         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
257                         execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString())\r
258 \r
259                         utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)\r
260                 } catch (Exception ex) {\r
261                         // try error in method block\r
262                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()\r
263                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
264                 }\r
265          }\r
266 \r
267         public void postProcessServiceInstanceCreate (Execution execution){\r
268                 def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')'\r
269                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
270                 logDebug('Entered ' + method, isDebugLogEnabled)\r
271 \r
272                 String source = execution.getVariable("source")\r
273                 String requestId = execution.getVariable("mso-request-id")\r
274                 String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
275                 String serviceInstanceName = execution.getVariable("serviceInstanceName")\r
276 \r
277                 try {\r
278 \r
279                         String payload = """\r
280                         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">\r
281                         <soapenv:Header/>\r
282                         <soapenv:Body>\r
283                         <req:updateInfraRequest>\r
284                                 <requestId>${requestId}</requestId>\r
285                                 <lastModifiedBy>BPEL</lastModifiedBy>\r
286                                 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>\r
287                                 <serviceInstanceName>${serviceInstanceName}</serviceInstanceName>\r
288                         </req:updateInfraRequest>\r
289                         </soapenv:Body>\r
290                         </soapenv:Envelope>\r
291                         """\r
292                         execution.setVariable("CVRCS_setUpdateDbInstancePayload", payload)\r
293                         utils.logAudit("CVRCS_setUpdateDbInstancePayload: " + payload)\r
294                         logDebug('Exited ' + method, isDebugLogEnabled)\r
295 \r
296                 } catch (BpmnError e) {\r
297                         throw e;\r
298                 } catch (Exception e) {\r
299                         logError('Caught exception in ' + method, e)\r
300                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)\r
301                 }\r
302         }\r
303 \r
304 \r
305         public void processDecomposition (Execution execution) {\r
306                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
307 \r
308                 utils.log("DEBUG", " ***** Inside getDataFromDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)\r
309 \r
310                 try {\r
311 \r
312                         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
313                         List<NetworkResource> networkList = serviceDecomposition.getServiceNetworks()\r
314 \r
315 \r
316                         execution.setVariable("networkList", networkList)\r
317                         execution.setVariable("networkListString", networkList.toString())\r
318 \r
319                         utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled)\r
320 \r
321                         if (networkList != null && networkList.size() > 0) {\r
322                                 execution.setVariable("CVRCS_NetworksCount", networkList.size())\r
323                                 utils.log("DEBUG", "networks to create: "+ networkList.size(), isDebugEnabled)\r
324                         } else {\r
325                                 execution.setVariable("CVRCS_NetworksCount", 0)\r
326                                 utils.log("DEBUG", "no networks to create based upon serviceDecomposition content", isDebugEnabled)\r
327                         }\r
328 \r
329                         // VNFs\r
330                         List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs()\r
331                         execution.setVariable("vnfList", vnfList)\r
332                         execution.setVariable("vnfListString", vnfList.toString())\r
333 \r
334                         String vnfModelInfoString = ""\r
335                         if (vnfList != null && vnfList.size() > 0) {\r
336                                 execution.setVariable("CVRCS_VNFsCount", vnfList.size())\r
337                                 utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled)\r
338                                 ModelInfo vnfModelInfo = vnfList[0].getModelInfo()\r
339 \r
340                                 vnfModelInfoString = vnfModelInfo.toString()\r
341                                 String vnfModelInfoWithRoot = vnfModelInfo.toString()\r
342                                 vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo")\r
343                         } else {\r
344                                         execution.setVariable("CVRCS_VNFsCount", 0)\r
345                                         utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled)\r
346                         }\r
347 \r
348                         execution.setVariable("vnfModelInfo", vnfModelInfoString)\r
349                         execution.setVariable("vnfModelInfoString", vnfModelInfoString)\r
350                         utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)\r
351 \r
352                         utils.log("DEBUG", " ***** Completed getDataFromDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)\r
353                 } catch (Exception ex) {\r
354                         sendSyncError(execution)\r
355                    String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. getDataFromDecomposition() - " + ex.getMessage()\r
356                    utils.log("DEBUG", exceptionMessage, isDebugEnabled)\r
357                    exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
358                 }\r
359         }\r
360 \r
361         // *******************************\r
362         //     Generate Network request Section\r
363         // *******************************\r
364         public void prepareNetworkCreate (Execution execution) {\r
365                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
366 \r
367                 try {\r
368                         utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
369 \r
370 \r
371                         String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
372 \r
373                         List<NetworkResource> networkList = execution.getVariable("networkList")\r
374                         utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled)\r
375 \r
376                         Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount")\r
377                         String networkModelInfoString = ""\r
378 \r
379                         if (networkList != null) {\r
380                                 utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled)\r
381                                 ModelInfo networkModelInfo = networkList[networksCreatedCount.intValue()].getModelInfo()\r
382                                 //Currently use String representation in JSON format as an input\r
383                                 //execution.setVariable("networkModelInfo", networkModelInfo)\r
384                                 networkModelInfoString = networkModelInfo.toJsonStringNoRootName()\r
385                         } else {\r
386                                 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected number of networks to create - " + ex.getMessage()\r
387                                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
388                         }\r
389 \r
390                         //Currently use String representation in JSON format as an input\r
391                         execution.setVariable("networkModelInfo", networkModelInfoString)\r
392                         utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled)\r
393 \r
394                         // extract cloud configuration\r
395                         String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")\r
396                         execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)\r
397                         utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)\r
398                         String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.tenantId")\r
399                         execution.setVariable("tenantId", tenantId)\r
400                         utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)\r
401 \r
402                         String sdncVersion = execution.getVariable("sdncVersion")\r
403                         utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)\r
404 \r
405 //                      List<VnfResource> vnfList = execution.getVariable("vnfList")\r
406 //                      utils.log("DEBUG", "vnfList: "+ vnfList.toString(), isDebugEnabled)\r
407 //\r
408 //                      String vnfModelInfo = execution.getVariable("vnfModelInfo")\r
409 //                      utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled)\r
410 \r
411                         utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
412                 } catch (Exception ex) {\r
413                         // try error in method block\r
414                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage()\r
415                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
416                 }\r
417          }\r
418 \r
419         // *******************************\r
420         //     Validate Network request Section -> increment count\r
421         // *******************************\r
422         public void validateNetworkCreate (Execution execution) {\r
423                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
424 \r
425                 try {\r
426                         utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
427 \r
428                         Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount")\r
429                         networksCreatedCount++\r
430                         execution.setVariable("CVRCS_NetworksCreatedCount", networksCreatedCount)\r
431 \r
432                         execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData"))\r
433 \r
434                         utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled)\r
435                         utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled)\r
436 \r
437 //                      JSONArray vnfList = execution.getVariable("vnfList")\r
438 //                      utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled)\r
439 \r
440                         String vnfModelInfo = execution.getVariable("vnfModelInfo")\r
441                         utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled)\r
442 \r
443                         List<NetworkResource> networkList = execution.getVariable("networkList")\r
444                         utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled)\r
445 \r
446                         utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateVcpeResCustService ***** "+" network # "+networksCreatedCount, isDebugEnabled)\r
447                 } catch (Exception ex) {\r
448                         // try error in method block\r
449                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage()\r
450                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
451                 }\r
452          }\r
453 \r
454 \r
455         public void prepareCreateAllottedResourceTXC(Execution execution) {\r
456                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
457 \r
458                 try {\r
459                         utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)\r
460 \r
461                         /*\r
462                          * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject\r
463                          *              ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
464                          *              ModelInfo modelInfo = serviceDecomposition.getModelInfo()\r
465                          *\r
466                          */\r
467                         String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
468                         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
469 \r
470                         //parentServiceInstanceId\r
471                         //The parentServiceInstanceId will be a Landing Network service.  This value will have been provided to the calling flow by SNIRO query (homing solution).\r
472                         //serviceDecomposition.getServiceNetworks()\r
473 \r
474                         //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW).\r
475                         //Beyond 1707, this would need to be captured somehow in TOSCA model and also provided by SNIRO.\r
476 \r
477                         //allottedResourceModelInfo\r
478                         //allottedResourceRole\r
479                         //The model Info parameters are a JSON structure as defined in the Service Instantiation API.\r
480                         //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB.\r
481                         List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()\r
482                         if (allottedResources != null) {\r
483                                 Iterator iter = allottedResources.iterator();\r
484                                 while (iter.hasNext()){\r
485                                         AllottedResource allottedResource = (AllottedResource)iter.next();\r
486 \r
487                                         utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonString(), isDebugEnabled)\r
488                                         utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)\r
489                                         if(allottedResource.getAllottedResourceType() != null && allottedResource.getAllottedResourceType().equalsIgnoreCase("TunnelXConn")){\r
490                                                 //set create flag to true\r
491                                                 execution.setVariable("createTXCAR", true)\r
492                                                 ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()\r
493                                                 execution.setVariable("allottedResourceModelInfoTXC", allottedResourceModelInfo.toJsonString())\r
494                                                 execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole())\r
495                                                 execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType())\r
496                                                 \r
497                                                 //from Homing Solution. This is the infraServiceInstanceId in the BRG Allotted Resource decomposition structure.\r
498                                                 execution.setVariable("parentServiceInstanceIdTXC", allottedResource.getHomingSolution().getServiceInstanceId())\r
499                                         }
500                                 }\r
501                         }\r
502 \r
503                         //Populate with the A&AI network ID (l3-network object) for the Tenant OAM network that was created in prior step\r
504                         //String sourceNetworkId = execution.getVariable("networkId")\r
505                         //execution.setVariable("sourceNetworkId", sourceNetworkId)\r
506                         //Populate with the network-role (from A&AI l3-network object) for the Tenant OAM network from prior step\r
507                         \r
508                         //List<NetworkResource> networkResources = serviceDecomposition.getServiceNetworks()\r
509                         //if (networkResources != null) {\r
510                                 //Iterator iter = networkResources.iterator();\r
511                                 //while (iter.hasNext()){\r
512                                         //NetworkResource networkResource = (NetworkResource)iter.next();\r
513                                         //execution.setVariable("sourceNetworkRole", networkResource.getNetworkRole())\r
514                                 //}\r
515                         //}\r
516 \r
517                         //unit test only\r
518                         String allottedResourceId = execution.getVariable("allottedResourceId")\r
519                         execution.setVariable("allottedResourceIdTXC", allottedResourceId)\r
520                         utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)\r
521                         \r
522                         utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)\r
523                 } catch (Exception ex) {\r
524                         // try error in method block\r
525                         String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()\r
526                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
527                 }\r
528          }\r
529         public void prepareCreateAllottedResourceBRG(Execution execution) {\r
530                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
531 \r
532                 try {\r
533                         utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)\r
534 \r
535                         /*\r
536                          * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject\r
537                          *              ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
538                          *              ModelInfo modelInfo = serviceDecomposition.getModelInfo()\r
539                          *\r
540                          */\r
541                         String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
542                         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
543 \r
544                         //parentServiceInstanceId\r
545                         //The parentServiceInstanceId will be a Landing Network service.  This value will have been provided to the calling flow by SNIRO query (homing solution).\r
546                         //serviceDecomposition.getServiceNetworks()\r
547 \r
548                         //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW).\r
549                         //Beyond 1707, this would need to be captured somehow in TOSCA model and also provided by SNIRO.\r
550 \r
551                         //allottedResourceModelInfo\r
552                         //allottedResourceRole\r
553                         //The model Info parameters are a JSON structure as defined in the Service Instantiation API.\r
554                         //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB.\r
555                         List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()\r
556                         if (allottedResources != null) {\r
557                                 Iterator iter = allottedResources.iterator();\r
558                                 while (iter.hasNext()){\r
559                                         AllottedResource allottedResource = (AllottedResource)iter.next();\r
560 \r
561                                         utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonString(), isDebugEnabled)\r
562                                         utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)\r
563                                         if (allottedResource.getAllottedResourceType() != null && allottedResource.getAllottedResourceType().equalsIgnoreCase("BRG")) {\r
564                                                 //set create flag to true\r
565                                                 execution.setVariable("createBRGAR", true)\r
566                                                 ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()\r
567                                                 execution.setVariable("allottedResourceModelInfoBRG", allottedResourceModelInfo.toJsonString())\r
568                                                 execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole())\r
569                                                 execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType())\r
570                                                 //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW).\r
571                                                 //This Id should be taken from the homing solution for the BRG resource. \r
572                                                 //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG, \r
573                                                 //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in BRG Allotted Resource structure) (which the Homing BB would have populated).\r
574                                                 \r
575                                                 //from Homing Solution. This is the infraServiceInstanceId in the BRG Allotted Resource decomposition structure.\r
576                                                 execution.setVariable("parentServiceInstanceIdBRG", allottedResource.getHomingSolution().getServiceInstanceId())\r
577                                         }\r
578                                 }\r
579                         }\r
580 \r
581                         //Populate with the A&AI network ID (l3-network object) for the Tenant OAM network that was created in prior step\r
582                         //String sourceNetworkId = execution.getVariable("networkId")\r
583                         //execution.setVariable("sourceNetworkId", sourceNetworkId)\r
584                         //Populate with the network-role (from A&AI l3-network object) for the Tenant OAM network from prior step\r
585                         \r
586                         //List<NetworkResource> networkResources = serviceDecomposition.getServiceNetworks()\r
587                         //if (networkResources != null) {\r
588                                 //Iterator iter = networkResources.iterator();\r
589                                 //while (iter.hasNext()){\r
590                                         //NetworkResource networkResource = (NetworkResource)iter.next();\r
591                                         //execution.setVariable("sourceNetworkRole", networkResource.getNetworkRole())\r
592                                 //}\r
593                         //}\r
594 \r
595                         //unit test only\r
596                         String allottedResourceId = execution.getVariable("allottedResourceId")\r
597                         execution.setVariable("allottedResourceIdBRG", allottedResourceId)\r
598                         utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)\r
599                         \r
600                         utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)\r
601                 } catch (Exception ex) {\r
602                         // try error in method block\r
603                         String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()\r
604                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
605                 }\r
606          }\r
607 \r
608
609
610         // *******************************\r
611         //     Generate Network request Section\r
612         // *******************************\r
613         public void prepareVnfAndModulesCreate (Execution execution) {\r
614                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
615 \r
616                 try {\r
617                         utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
618 \r
619                         //                      String disableRollback = execution.getVariable("disableRollback")\r
620                         //                      def backoutOnFailure = ""\r
621                         //                      if(disableRollback != null){\r
622                         //                              if ( disableRollback == true) {\r
623                         //                                      backoutOnFailure = "false"\r
624                         //                              } else if ( disableRollback == false) {\r
625                         //                                      backoutOnFailure = "true"\r
626                         //                              }\r
627                         //                      }\r
628                                                 //failIfExists - optional\r
629 \r
630                         String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
631                         String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")\r
632                         execution.setVariable("productFamilyId", productFamilyId)\r
633                         utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled)\r
634 \r
635                         List<VnfResource> vnfList = execution.getVariable("vnfList")\r
636 \r
637                         Integer vnfsCreatedCount = execution.getVariable("CVRCS_VnfsCreatedCount")\r
638                         String vnfModelInfoString = null;\r
639 \r
640                         if (vnfList != null && vnfList.size() > 0 ) {\r
641                                 utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled)\r
642                                 ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo()\r
643                                 utils.log("DEBUG", "got 0 ", isDebugEnabled)\r
644                                 ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo()\r
645                                 vnfModelInfoString = vnfModelInfo.toString()\r
646                         } else {\r
647                                 //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored\r
648                                 vnfModelInfoString = execution.getVariable("vnfModelInfo")\r
649                         }\r
650 \r
651                         utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)\r
652 \r
653                         // extract cloud configuration\r
654                         String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")\r
655                         execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)\r
656                         utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)\r
657                         String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.tenantId")\r
658                         execution.setVariable("tenantId", tenantId)\r
659                         utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)\r
660 \r
661                         String sdncVersion = execution.getVariable("sdncVersion")\r
662                         utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)\r
663 \r
664                         utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
665                 } catch (Exception ex) {\r
666                         // try error in method block\r
667                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage()\r
668                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
669                 }\r
670          }\r
671 \r
672         // *******************************\r
673         //     Validate Vnf request Section -> increment count\r
674         // *******************************\r
675         public void validateVnfCreate (Execution execution) {\r
676                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
677 \r
678                 try {\r
679                         utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
680 \r
681                         Integer vnfsCreatedCount = execution.getVariable("CVRCS_VnfsCreatedCount")\r
682                         vnfsCreatedCount++\r
683 \r
684                         execution.setVariable("CVRCS_VnfsCreatedCount", vnfsCreatedCount)\r
685 \r
686                         utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled)\r
687                 } catch (Exception ex) {\r
688                         // try error in method block\r
689                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage()\r
690                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
691                 }\r
692          }\r
693 \r
694         // *******************************\r
695         //     Validate Network request Section -> decrement count\r
696         // *******************************\r
697         public void validateNetworkRollback (Execution execution) {\r
698                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
699 \r
700                 try {\r
701                         utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateVcpeResCustService ***** ", isDebugEnabled)\r
702 \r
703                         Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount")\r
704                         networksCreatedCount--\r
705 \r
706                         execution.setVariable("CVRCS_NetworksCreatedCount", networksCreatedCount)\r
707 \r
708                         execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount))\r
709 \r
710                         utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateVcpeResCustService ***** "+" network # "+networksCreatedCount, isDebugEnabled)\r
711                 } catch (Exception ex) {\r
712                         // try error in method block\r
713                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage()\r
714                         //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
715                         utils.log("DEBUG", exceptionMessage, isDebugEnabled)\r
716                         execution.setVariable("CVRCS_NetworksCreatedCount", 0)\r
717                         utils.log("ERROR", exceptionMessage, true)\r
718                 }\r
719          }\r
720 \r
721         // *****************************************\r
722         //     Prepare Completion request Section\r
723         // *****************************************\r
724         public void postProcessResponse (Execution execution) {\r
725                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
726 \r
727                 utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled)\r
728 \r
729                 try {\r
730                         String source = execution.getVariable("source")\r
731                         String requestId = execution.getVariable("mso-request-id")\r
732                         String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
733 \r
734                         String msoCompletionRequest =\r
735                                         """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"\r
736                                                                         xmlns:ns="http://org.openecomp/mso/request/types/v1">\r
737                                                         <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
738                                                                 <request-id>${requestId}</request-id>\r
739                                                                 <action>CREATE</action>\r
740                                                                 <source>${source}</source>\r
741                                                         </request-info>\r
742                                                         <status-message>Service Instance has been created successfully via macro orchestration</status-message>\r
743                                                         <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>\r
744                                                         <mso-bpel-name>BPMN macro create</mso-bpel-name>\r
745                                                 </aetgt:MsoCompletionRequest>"""\r
746 \r
747                         // Format Response\r
748                         String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)\r
749 \r
750                         utils.logAudit(xmlMsoCompletionRequest)\r
751                         execution.setVariable("CVRCS_Success", true)\r
752                         execution.setVariable("CVRCS_CompleteMsoProcessRequest", xmlMsoCompletionRequest)\r
753                         utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)\r
754                 } catch (BpmnError e) {\r
755                         throw e;\r
756                 } catch (Exception ex) {\r
757                         // try error in method block\r
758                         String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()\r
759                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
760                 }\r
761         }\r
762 \r
763         public void preProcessRollback (Execution execution) {\r
764                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
765                 utils.log("DEBUG"," ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)\r
766                 try {\r
767 \r
768                         Object workflowException = execution.getVariable("WorkflowException");\r
769 \r
770                         if (workflowException instanceof WorkflowException) {\r
771                                 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)\r
772                                 execution.setVariable("prevWorkflowException", workflowException);\r
773                                 //execution.setVariable("WorkflowException", null);\r
774                         }\r
775                 } catch (BpmnError e) {\r
776                         utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)\r
777                 } catch(Exception ex) {\r
778                         String msg = "Exception in preProcessRollback. " + ex.getMessage()\r
779                         utils.log("DEBUG", msg, isDebugEnabled)\r
780                 }\r
781                 utils.log("DEBUG"," *** Exit preProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)\r
782         }\r
783 \r
784         public void postProcessRollback (Execution execution) {\r
785                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
786                 utils.log("DEBUG"," ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)\r
787                 String msg = ""\r
788                 try {\r
789                         Object workflowException = execution.getVariable("prevWorkflowException");\r
790                         if (workflowException instanceof WorkflowException) {\r
791                                 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)\r
792                                 execution.setVariable("WorkflowException", workflowException);\r
793                         }\r
794                 } catch (BpmnError b) {\r
795                         utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)\r
796                         throw b;\r
797                 } catch(Exception ex) {\r
798                         msg = "Exception in postProcessRollback. " + ex.getMessage()\r
799                         utils.log("DEBUG", msg, isDebugEnabled)\r
800                 }\r
801                 utils.log("DEBUG"," *** Exit postProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)\r
802         }\r
803 \r
804         public void prepareFalloutRequest(Execution execution){\r
805                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
806 \r
807                 utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)\r
808 \r
809                 try {\r
810                         WorkflowException wfex = execution.getVariable("WorkflowException")\r
811                         utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)\r
812                         String requestInfo = execution.getVariable("CVRCS_requestInfo")\r
813                         utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)\r
814 \r
815                         //TODO. hmmm. there is no way to UPDATE error message.\r
816 //                      String errorMessage = wfex.getErrorMessage()\r
817 //                      boolean successIndicator = execution.getVariable("DCRESI_rollbackSuccessful")\r
818 //                      if (successIndicator){\r
819 //                              errorMessage = errorMessage + ". Rollback successful."\r
820 //                      } else {\r
821 //                              errorMessage = errorMessage + ". Rollback not completed."\r
822 //                      }\r
823 \r
824                         String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)\r
825 \r
826                         execution.setVariable("CVRCS_falloutRequest", falloutRequest)\r
827 \r
828                 } catch (Exception ex) {\r
829                         utils.log("DEBUG", "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)\r
830                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process")\r
831                 }\r
832                 utils.log("DEBUG", "*** COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled)\r
833         }\r
834 \r
835 \r
836         public void sendSyncError (Execution execution) {\r
837                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
838                 execution.setVariable("prefix", Prefix)\r
839 \r
840                 utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled)\r
841 \r
842                 try {\r
843                         String errorMessage = ""\r
844                         if (execution.getVariable("WorkflowException") instanceof WorkflowException) {\r
845                                 WorkflowException wfe = execution.getVariable("WorkflowException")\r
846                                 errorMessage = wfe.getErrorMessage()\r
847                         } else {\r
848                                 errorMessage = "Sending Sync Error."\r
849                         }\r
850 \r
851                         String buildworkflowException =\r
852                                 """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">\r
853                                         <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>\r
854                                         <aetgt:ErrorCode>7000</aetgt:ErrorCode>\r
855                                    </aetgt:WorkflowException>"""\r
856 \r
857                         utils.logAudit(buildworkflowException)\r
858                         sendWorkflowResponse(execution, 500, buildworkflowException)\r
859                 } catch (Exception ex) {\r
860                         utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)\r
861                 }\r
862         }\r
863 \r
864         public void processJavaException(Execution execution){\r
865                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
866                 execution.setVariable("prefix",Prefix)\r
867                 try{\r
868                         utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)\r
869                         utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)\r
870                         utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)\r
871                         execution.setVariable("CRESI_unexpectedError", "Caught a Java Lang Exception")  // Adding this line temporarily until this flows error handling gets updated\r
872                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")\r
873                 }catch(BpmnError b){\r
874                         utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)\r
875                         throw b\r
876                 }catch(Exception e){\r
877                         utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)\r
878                         execution.setVariable("CRESI_unexpectedError", "Exception in processJavaException method")  // Adding this line temporarily until this flows error handling gets updated\r
879                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")\r
880                 }\r
881                 utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)\r
882         }\r
883 }\r