Merge "Store NB Create req. userParam - Customer_Location"
authorRob Daugherty <rd472p@att.com>
Wed, 7 Mar 2018 18:48:37 +0000 (18:48 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 7 Mar 2018 18:48:37 +0000 (18:48 +0000)
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json
bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json
bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json

index dd6d451..e1cae80 100644 (file)
-/*\r
- * ============LICENSE_START=======================================================\r
- * ONAP - SO\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.openecomp.mso.bpmn.vcpe.scripts;\r
-\r
-import groovy.xml.XmlUtil\r
-import groovy.json.*\r
-\r
-import org.openecomp.mso.bpmn.core.json.JsonUtils\r
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
-import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils\r
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
-import org.openecomp.mso.bpmn.common.scripts.VidUtils\r
-import org.openecomp.mso.bpmn.core.RollbackData\r
-import org.openecomp.mso.bpmn.core.WorkflowException\r
-import org.openecomp.mso.bpmn.core.domain.*\r
-\r
-import java.util.UUID;\r
-\r
-import org.camunda.bpm.engine.delegate.BpmnError\r
-import org.camunda.bpm.engine.runtime.Execution\r
-import org.json.JSONObject;\r
-import org.json.JSONArray;\r
-import org.apache.commons.lang3.*\r
-import org.apache.commons.codec.binary.Base64;\r
-import org.springframework.web.util.UriUtils;\r
-import static org.apache.commons.lang3.StringUtils.*\r
-\r
-/**\r
- * This groovy class supports the <class>CreateVcpeResCustService.bpmn</class> process.\r
- *\r
- * @author ek1439\r
- *\r
- */\r
-public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {\r
-\r
-       private static final String DebugFlag = "isDebugLogEnabled"\r
-\r
-       String Prefix="CVRCS_"\r
-       ExceptionUtil exceptionUtil = new ExceptionUtil()\r
-       JsonUtils jsonUtil = new JsonUtils()\r
-       VidUtils vidUtils = new VidUtils()\r
-       CatalogDbUtils catalogDbUtils = new CatalogDbUtils()\r
-\r
-       /**\r
-        * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.\r
-        * @param execution\r
-        */\r
-       public InitializeProcessVariables(Execution execution){\r
-               /* Initialize all the process variables in this block */\r
-\r
-               execution.setVariable("createVcpeServiceRequest", "")\r
-               execution.setVariable("globalSubscriberId", "")\r
-               execution.setVariable("serviceInstanceName", "")\r
-               execution.setVariable("msoRequestId", "")\r
-               execution.setVariable(Prefix+"VnfsCreatedCount", 0)\r
-               execution.setVariable("productFamilyId", "")\r
-               execution.setVariable("brgWanMacAddress", "")\r
-\r
-               //TODO\r
-               execution.setVariable("sdncVersion", "1707")\r
-       }\r
-\r
-       // **************************************************\r
-       //     Pre or Prepare Request Section\r
-       // **************************************************\r
-       /**\r
-        * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.\r
-        * @param execution\r
-        */\r
-       public void preProcessRequest (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-               execution.setVariable("prefix",Prefix)\r
-\r
-               utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)\r
-\r
-               try {\r
-                       // initialize flow variables\r
-                       InitializeProcessVariables(execution)\r
-\r
-                       //Config Inputs\r
-                       String aaiDistDelay = execution.getVariable('URN_mso_workflow_aai_distribution_delay')\r
-                       if (isBlank(aaiDistDelay)) {\r
-                               msg = "URN_mso_workflow_aai_distribution_delay is null"\r
-                               utils.log("DEBUG", msg, isDebugEnabled)\r
-                               exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)\r
-                       }\r
-                       execution.setVariable("aaiDistDelay", aaiDistDelay)\r
-                       utils.log("DEBUG","AAI distribution delay: " + aaiDistDelay, isDebugEnabled)\r
-\r
-                       // check for incoming json message/input\r
-                       String createVcpeServiceRequest = execution.getVariable("bpmnRequest")\r
-                       utils.logAudit(createVcpeServiceRequest)\r
-                       execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest);\r
-                       println 'createVcpeServiceRequest - ' + createVcpeServiceRequest\r
-\r
-                       // extract requestId\r
-                       String requestId = execution.getVariable("mso-request-id")\r
-                       execution.setVariable("msoRequestId", requestId)\r
-\r
-                       String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
-\r
-                       if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {\r
-                               serviceInstanceId = UUID.randomUUID().toString()\r
-                               utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled)\r
-                       } else {\r
-                               utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled)\r
-                       }\r
-\r
-                       serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")\r
-                       execution.setVariable("serviceInstanceId", serviceInstanceId)\r
-\r
-                       String requestAction = execution.getVariable("requestAction")\r
-                       execution.setVariable("requestAction", requestAction)\r
-\r
-                       setBasicDBAuthHeader(execution, isDebugEnabled)\r
-                       \r
-                       String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source")\r
-                       if ((source == null) || (source.isEmpty())) {\r
-                               source = "VID"\r
-                       }\r
-                       execution.setVariable("source", source)\r
-\r
-                       // extract globalSubscriberId\r
-                       String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId")\r
-\r
-                       // verify element global-customer-id is sent from JSON input, throw exception if missing\r
-                       if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) {\r
-                               String dataErrorMessage = " Element 'globalSubscriberId' is missing. "\r
-                               exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
-\r
-                       } else {\r
-                               execution.setVariable("globalSubscriberId", globalSubscriberId)\r
-                               execution.setVariable("globalCustomerId", globalSubscriberId)\r
-                       }\r
-\r
-                       // extract subscriptionServiceType\r
-                       String subscriptionServiceType = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters.subscriptionServiceType")\r
-                       execution.setVariable("subscriptionServiceType", subscriptionServiceType)\r
-                       utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)\r
-\r
-                       String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.suppressRollback")\r
-                       execution.setVariable("disableRollback", suppressRollback)\r
-                       utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)\r
-\r
-                       String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")\r
-                       execution.setVariable("productFamilyId", productFamilyId)\r
-                       utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)\r
-                       \r
-                       String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo")\r
-                       execution.setVariable("subscriberInfo", subscriberInfo)\r
-                       utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled)\r
-\r
-                 /*\r
-                 * Extracting User Parameters from incoming Request and converting into a Map\r
-                 */\r
-                 def jsonSlurper = new JsonSlurper()\r
-                 def jsonOutput = new JsonOutput()\r
-\r
-                 Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest)\r
-\r  
-                 //InputParams\r
-                 def userParams = reqMap.requestDetails?.requestParameters?.userParams\r
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.mso.bpmn.vcpe.scripts;
+
+import groovy.xml.XmlUtil
+import groovy.json.*
+
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.common.scripts.VidUtils
+import org.openecomp.mso.bpmn.core.RollbackData
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.bpmn.core.domain.*
+
+import java.util.UUID;
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.runtime.Execution
+import org.json.JSONObject;
+import org.json.JSONArray;
+import org.apache.commons.lang3.*
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.web.util.UriUtils;
+import static org.apache.commons.lang3.StringUtils.*
+
+/**
+ * This groovy class supports the <class>CreateVcpeResCustService.bpmn</class> process.
+ *
+ * @author ek1439
+ *
+ */
+public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
+
+    private static final String DebugFlag = "isDebugLogEnabled"
+
+    String Prefix="CVRCS_"
+    ExceptionUtil exceptionUtil = new ExceptionUtil()
+    JsonUtils jsonUtil = new JsonUtils()
+    VidUtils vidUtils = new VidUtils()
+    CatalogDbUtils catalogDbUtils = new CatalogDbUtils()
+
+    /**
+     * This method is executed during the preProcessRequest task of the
+     * <class>CreateServiceInstance.bpmn</class> process.
+     * @param execution
+     */
+    public InitializeProcessVariables(Execution execution){
+        /* Initialize all the process variables in this block */
+
+        execution.setVariable("createVcpeServiceRequest", "")
+        execution.setVariable("globalSubscriberId", "")
+        execution.setVariable("serviceInstanceName", "")
+        execution.setVariable("msoRequestId", "")
+        execution.setVariable(Prefix+"VnfsCreatedCount", 0)
+        execution.setVariable("productFamilyId", "")
+        execution.setVariable("brgWanMacAddress", "")
+        execution.setVariable("customerLocation", "")
+
+        //TODO
+        execution.setVariable("sdncVersion", "1707")
+    }
+
+    // **************************************************
+    //     Pre or Prepare Request Section
+    // **************************************************
+    /**
+     * This method is executed during the preProcessRequest task of the
+     * <class>CreateServiceInstance.bpmn</class> process.
+     * @param execution
+     */
+    public void preProcessRequest (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+        execution.setVariable("prefix",Prefix)
+
+        utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)
+
+        try {
+            // initialize flow variables
+            InitializeProcessVariables(execution)
+
+            //Config Inputs
+            String aaiDistDelay = execution.getVariable('URN_mso_workflow_aai_distribution_delay')
+            if (isBlank(aaiDistDelay)) {
+                msg = "URN_mso_workflow_aai_distribution_delay is null"
+                utils.log("DEBUG", msg, isDebugEnabled)
+                exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+            }
+            execution.setVariable("aaiDistDelay", aaiDistDelay)
+            utils.log("DEBUG","AAI distribution delay: " + aaiDistDelay, isDebugEnabled)
+
+            // check for incoming json message/input
+            String createVcpeServiceRequest = execution.getVariable("bpmnRequest")
+            utils.logAudit(createVcpeServiceRequest)
+            execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest);
+            println 'createVcpeServiceRequest - ' + createVcpeServiceRequest
+
+            // extract requestId
+            String requestId = execution.getVariable("mso-request-id")
+            execution.setVariable("msoRequestId", requestId)
+
+            String serviceInstanceId = execution.getVariable("serviceInstanceId")
+
+            if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {
+                serviceInstanceId = UUID.randomUUID().toString()
+                utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled)
+            } else {
+                utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled)
+            }
+
+            serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")
+            execution.setVariable("serviceInstanceId", serviceInstanceId)
+
+            String requestAction = execution.getVariable("requestAction")
+            execution.setVariable("requestAction", requestAction)
+
+            setBasicDBAuthHeader(execution, isDebugEnabled)
+
+            String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source")
+            if ((source == null) || (source.isEmpty())) {
+                source = "VID"
+            }
+            execution.setVariable("source", source)
+
+            // extract globalSubscriberId
+            String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.subscriberInfo.globalSubscriberId")
+
+            // verify element global-customer-id is sent from JSON input, throw exception if missing
+            if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) {
+                String dataErrorMessage = " Element 'globalSubscriberId' is missing. "
+                exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+
+            } else {
+                execution.setVariable("globalSubscriberId", globalSubscriberId)
+                execution.setVariable("globalCustomerId", globalSubscriberId)
+            }
+
+            // extract subscriptionServiceType
+            String subscriptionServiceType = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.requestParameters.subscriptionServiceType")
+            execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+            utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)
+
+            String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.requestInfo.suppressRollback")
+            execution.setVariable("disableRollback", suppressRollback)
+            utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)
+
+            String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.requestInfo.productFamilyId")
+            execution.setVariable("productFamilyId", productFamilyId)
+            utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)
+
+            String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.subscriberInfo")
+            execution.setVariable("subscriberInfo", subscriberInfo)
+            utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled)
+
+          /*
+          * Extracting User Parameters from incoming Request and converting into a Map
+          */
+          def jsonSlurper = new JsonSlurper()
+          def jsonOutput = new JsonOutput()
+
+          Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest)
+
   
-                 Map<String, String> inputMap = [:]\r
-\r
-\r
-                 if (userParams) {\r
-                               userParams.each {\r
-                                                               userParam ->\r
-                                                               if("BRG_WAN_MAC_Address".equals(userParam?.name)) {\r
-                                                                                               execution.setVariable("brgWanMacAddress", userParam.value)\r
-                                                                                               inputMap.put("BRG_WAN_MAC_Address", userParam.value)\r
-                                       }\r
-                               }\r
-                 }\r
-\r
-                 utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)\r
-                 execution.setVariable("serviceInputParams", inputMap)\r
-\r
-                       utils.log("DEBUG", "Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress'), isDebugEnabled)\r
-\r
-                       //For Completion Handler & Fallout Handler\r
-                       String requestInfo =\r
-                       """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
-                                       <request-id>${requestId}</request-id>\r
-                                       <action>CREATE</action>\r
-                                       <source>${source}</source>\r
-                                  </request-info>"""\r
-\r
-                       execution.setVariable(Prefix+"requestInfo", requestInfo)\r
-\r
-                       utils.log("DEBUG", " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)\r
-\r
-               } catch (BpmnError e) {\r
-                       throw e;\r
-\r
-               } catch (Exception ex){\r
-                       String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-       }\r
-\r
-       public void sendSyncResponse(Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-               try {\r
-                       String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
-                       String requestId = execution.getVariable("mso-request-id")\r
-\r
-                       // RESTResponse (for API Handler (APIH) Reply Task)\r
-                       String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()\r
-\r
-                       utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)\r
-                       sendWorkflowResponse(execution, 202, syncResponse)\r
-\r
-               } catch (Exception ex) {\r
-                       String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-       }\r
-\r
-       // *******************************\r
-       //\r
-       // *******************************\r
-       public void prepareDecomposeService(Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               try {\r
-                       utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-                       String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
-\r
-                       //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB\r
-                       String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.modelInfo")\r
-                       execution.setVariable("serviceModelInfo", serviceModelInfo)\r
-\r
-                       utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               } catch (Exception ex) {\r
-                       // try error in method block\r
-                       String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-        }\r
-\r
-       // *******************************\r
-       //\r
-       // *******************************\r
-       public void prepareCreateServiceInstance(Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               try {\r
-                       utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-                       /*\r
-                        * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject\r
-                        *              ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
-                        *              ModelInfo modelInfo = serviceDecomposition.getModelInfo()\r
-                        *\r
-                        */\r
-                       String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
-//                     String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters")\r
-//                     execution.setVariable("serviceInputParams", serviceInputParams)\r
-\r
-
-                       String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName")\r
-                       execution.setVariable("serviceInstanceName", serviceInstanceName)\r
-\r
-                       ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
-                       execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonStringNoRootName())\r
-\r
-                       utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               } catch (Exception ex) {\r
-                       // try error in method block\r
-                       String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-        }\r
-\r
-       public void postProcessServiceInstanceCreate (Execution execution){\r
-               def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')'\r
-               def isDebugLogEnabled = execution.getVariable(DebugFlag)\r
-               logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
-               String requestId = execution.getVariable("mso-request-id")\r
-               String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
-               String serviceInstanceName = execution.getVariable("serviceInstanceName")\r
-\r
-               try {\r
-\r
-                       String payload = """\r
-                       <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">\r
-                       <soapenv:Header/>\r
-                       <soapenv:Body>\r
-                       <req:updateInfraRequest>\r
-                               <requestId>${requestId}</requestId>\r
-                               <lastModifiedBy>BPEL</lastModifiedBy>\r
-                               <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>\r
-                               <serviceInstanceName>${serviceInstanceName}</serviceInstanceName>\r
-                       </req:updateInfraRequest>\r
-                       </soapenv:Body>\r
-                       </soapenv:Envelope>\r
-                       """\r
-                       execution.setVariable(Prefix+"setUpdateDbInstancePayload", payload)\r
-                       utils.logAudit(Prefix+"setUpdateDbInstancePayload: " + payload)\r
-                       logDebug('Exited ' + method, isDebugLogEnabled)\r
-\r
-               } catch (BpmnError e) {\r
-                       throw e;\r
-               } catch (Exception e) {\r
-                       logError('Caught exception in ' + method, e)\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)\r
-               }\r
-       }\r
-\r
-\r
-       public void processDecomposition (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               utils.log("DEBUG", " ***** Inside processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-               try {\r
-\r
-                       ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
-\r
-                       // VNFs\r
-                       List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs()\r
-                       filterVnfs(vnfList)\r
-                       serviceDecomposition.setServiceVnfs(vnfList)\r
-                       \r
-                       execution.setVariable("vnfList", vnfList)\r
-                       execution.setVariable("vnfListString", vnfList.toString())\r
-\r
-                       String vnfModelInfoString = ""\r
-                       if (vnfList != null && vnfList.size() > 0) {\r
-                               execution.setVariable(Prefix+"VNFsCount", vnfList.size())\r
-                               utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled)\r
-                               ModelInfo vnfModelInfo = vnfList[0].getModelInfo()\r
-\r
-                               vnfModelInfoString = vnfModelInfo.toString()\r
-                               String vnfModelInfoWithRoot = vnfModelInfo.toString()\r
-                               vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo")\r
-                       } else {\r
-                                       execution.setVariable(Prefix+"VNFsCount", 0)\r
-                                       utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled)\r
-                       }\r
-\r
-                       execution.setVariable("vnfModelInfo", vnfModelInfoString)\r
-                       execution.setVariable("vnfModelInfoString", vnfModelInfoString)\r
-                       utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)\r
-\r
-                       utils.log("DEBUG", " ***** Completed processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               } catch (Exception ex) {\r
-                       sendSyncError(execution)\r
-                  String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. processDecomposition() - " + ex.getMessage()\r
-                  utils.log("DEBUG", exceptionMessage, isDebugEnabled)\r
-                  exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-       }\r
-       \r
-       private void filterVnfs(List<VnfResource> vnfList) {\r
-               if(vnfList == null) {\r
-                       return\r
-               }\r
-               \r
-               // remove BRG & TXC from VNF list\r
-               \r
-               Iterator<VnfResource> it = vnfList.iterator()\r
-               while(it.hasNext()) {\r
-                       VnfResource vr = it.next()\r
-                       \r
-                       String role = vr.getNfRole()\r
-                       if(role == "BRG" || role == "TunnelXConn") {\r
-                               it.remove()\r
-                       }\r
-               }\r
-       }\r
-\r
-\r
-       public void prepareCreateAllottedResourceTXC(Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               try {\r
-                       utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-                       /*\r
-                        * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject\r
-                        *              ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
-                        *              ModelInfo modelInfo = serviceDecomposition.getModelInfo()\r
-                        *\r
-                        */\r
-                       String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
-                       ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
-\r
-                       //allottedResourceModelInfo\r
-                       //allottedResourceRole\r
-                       //The model Info parameters are a JSON structure as defined in the Service Instantiation API.\r
-                       //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
-                       List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()\r
-                       if (allottedResources != null) {\r
-                               Iterator iter = allottedResources.iterator();\r
-                               while (iter.hasNext()){\r
-                                       AllottedResource allottedResource = (AllottedResource)iter.next();\r
-\r
-                                       utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName(), isDebugEnabled)\r
-                                       utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)\r
-                                       if("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())){\r
-                                               //set create flag to true\r
-                                               execution.setVariable("createTXCAR", true)\r
-                                               ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()\r
-                                               execution.setVariable("allottedResourceModelInfoTXC", allottedResourceModelInfo.toJsonStringNoRootName())\r
-                                               execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole())\r
-                                               execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType())\r
-                                               //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the TXC,\r
-                                               //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in TXC Allotted Resource structure) (which the Homing BB would have populated).\r
-                                               execution.setVariable("parentServiceInstanceIdTXC", allottedResource.getHomingSolution().getServiceInstanceId())\r
-                                       }
-                               }\r
-                       }\r
-\r
-                       //unit test only\r
-                       String allottedResourceId = execution.getVariable("allottedResourceId")\r
-                       execution.setVariable("allottedResourceIdTXC", allottedResourceId)\r
-                       utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)\r
-                       \r
-                       utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               } catch (Exception ex) {\r
-                       // try error in method block\r
-                       String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-        }\r
-       public void prepareCreateAllottedResourceBRG(Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               try {\r
-                       utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-                       /*\r
-                        * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject\r
-                        *              ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
-                        *              ModelInfo modelInfo = serviceDecomposition.getModelInfo()\r
-                        *\r
-                        */\r
-                       String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
-                       ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
-\r
-                       //allottedResourceModelInfo\r
-                       //allottedResourceRole\r
-                       //The model Info parameters are a JSON structure as defined in the Service Instantiation API.\r
-                       //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
-                       List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()\r
-                       if (allottedResources != null) {\r
-                               Iterator iter = allottedResources.iterator();\r
-                               while (iter.hasNext()){\r
-                                       AllottedResource allottedResource = (AllottedResource)iter.next();\r
-\r
-                                       utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName(), isDebugEnabled)\r
-                                       utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)\r
-                                       if("BRG".equalsIgnoreCase(allottedResource.getAllottedResourceType())){\r
-                                               //set create flag to true\r
-                                               execution.setVariable("createBRGAR", true)\r
-                                               ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()\r
-                                               execution.setVariable("allottedResourceModelInfoBRG", allottedResourceModelInfo.toJsonStringNoRootName())\r
-                                               execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole())\r
-                                               execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType())\r
-                                               //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG,\r
-                                               //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
-                                               execution.setVariable("parentServiceInstanceIdBRG", allottedResource.getHomingSolution().getServiceInstanceId())\r
-                                       }\r
-                               }\r
-                       }\r
-\r
-                       //unit test only\r
-                       String allottedResourceId = execution.getVariable("allottedResourceId")\r
-                       execution.setVariable("allottedResourceIdBRG", allottedResourceId)\r
-                       utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)\r
-                       \r
-                       utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               } catch (Exception ex) {\r
-                       // try error in method block\r
-                       String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-        }\r
-\r
-
-
-       // *******************************\r
-       //     Generate Network request Section\r
-       // *******************************\r
-       public void prepareVnfAndModulesCreate (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               try {\r
-                       utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-                       //                      String disableRollback = execution.getVariable("disableRollback")\r
-                       //                      def backoutOnFailure = ""\r
-                       //                      if(disableRollback != null){\r
-                       //                              if ( disableRollback == true) {\r
-                       //                                      backoutOnFailure = "false"\r
-                       //                              } else if ( disableRollback == false) {\r
-                       //                                      backoutOnFailure = "true"\r
-                       //                              }\r
-                       //                      }\r
-                                               //failIfExists - optional\r
-\r
-                       String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")\r
-                       String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")\r
-                       execution.setVariable("productFamilyId", productFamilyId)\r
-                       utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled)\r
-\r
-                       List<VnfResource> vnfList = execution.getVariable("vnfList")\r
-\r
-                       Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount")\r
-                       String vnfModelInfoString = null;\r
-\r
-                       if (vnfList != null && vnfList.size() > 0 ) {\r
-                               utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled)\r
-                               ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo()\r
-                               utils.log("DEBUG", "got 0 ", isDebugEnabled)\r
-                               ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo()\r
-                               vnfModelInfoString = vnfModelInfo.toString()\r
-                       } else {\r
-                               //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored\r
-                               vnfModelInfoString = execution.getVariable("vnfModelInfo")\r
-                       }\r
-\r
-                       utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)\r
-\r
-                       // extract cloud configuration\r
-                       String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")\r
-                       execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)\r
-                       utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)\r
-                       String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.tenantId")\r
-                       execution.setVariable("tenantId", tenantId)\r
-                       utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)\r
-\r
-                       String sdncVersion = execution.getVariable("sdncVersion")\r
-                       utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)\r
-\r
-                       utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               } catch (Exception ex) {\r
-                       // try error in method block\r
-                       String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-        }\r
-\r
-       // *******************************\r
-       //     Validate Vnf request Section -> increment count\r
-       // *******************************\r
-       public void validateVnfCreate (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               try {\r
-                       utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-                       Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount")\r
-                       vnfsCreatedCount++\r
-\r
-                       execution.setVariable(Prefix+"VnfsCreatedCount", vnfsCreatedCount)\r
-\r
-                       utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled)\r
-               } catch (Exception ex) {\r
-                       // try error in method block\r
-                       String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-        }\r
-\r
-       // *****************************************\r
-       //     Prepare Completion request Section\r
-       // *****************************************\r
-       public void postProcessResponse (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-               try {\r
-                       String source = execution.getVariable("source")\r
-                       String requestId = execution.getVariable("mso-request-id")\r
-                       String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
-\r
-                       String msoCompletionRequest =\r
-                                       """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"\r
-                                                                       xmlns:ns="http://org.openecomp/mso/request/types/v1">\r
-                                                       <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
-                                                               <request-id>${requestId}</request-id>\r
-                                                               <action>CREATE</action>\r
-                                                               <source>${source}</source>\r
-                                                       </request-info>\r
-                                                       <status-message>Service Instance has been created successfully via macro orchestration</status-message>\r
-                                                       <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>\r
-                                                       <mso-bpel-name>BPMN macro create</mso-bpel-name>\r
-                                               </aetgt:MsoCompletionRequest>"""\r
-\r
-                       // Format Response\r
-                       String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)\r
-\r
-                       utils.logAudit(xmlMsoCompletionRequest)\r
-                       execution.setVariable(Prefix+"Success", true)\r
-                       execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest)\r
-                       utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)\r
-               } catch (BpmnError e) {\r
-                       throw e;\r
-               } catch (Exception ex) {\r
-                       // try error in method block\r
-                       String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
-               }\r
-       }\r
-\r
-       public void preProcessRollback (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-               utils.log("DEBUG"," ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               try {\r
-\r
-                       Object workflowException = execution.getVariable("WorkflowException");\r
-\r
-                       if (workflowException instanceof WorkflowException) {\r
-                               utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)\r
-                               execution.setVariable("prevWorkflowException", workflowException);\r
-                               //execution.setVariable("WorkflowException", null);\r
-                       }\r
-               } catch (BpmnError e) {\r
-                       utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)\r
-               } catch(Exception ex) {\r
-                       String msg = "Exception in preProcessRollback. " + ex.getMessage()\r
-                       utils.log("DEBUG", msg, isDebugEnabled)\r
-               }\r
-               utils.log("DEBUG"," *** Exit preProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)\r
-       }\r
-\r
-       public void postProcessRollback (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-               utils.log("DEBUG"," ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-               String msg = ""\r
-               try {\r
-                       Object workflowException = execution.getVariable("prevWorkflowException");\r
-                       if (workflowException instanceof WorkflowException) {\r
-                               utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)\r
-                               execution.setVariable("WorkflowException", workflowException);\r
-                       }\r
-               } catch (BpmnError b) {\r
-                       utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)\r
-                       throw b;\r
-               } catch(Exception ex) {\r
-                       msg = "Exception in postProcessRollback. " + ex.getMessage()\r
-                       utils.log("DEBUG", msg, isDebugEnabled)\r
-               }\r
-               utils.log("DEBUG"," *** Exit postProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)\r
-       }\r
-\r
-       public void prepareFalloutRequest(Execution execution){\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-\r
-               utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)\r
-\r
-               try {\r
-                       WorkflowException wfex = execution.getVariable("WorkflowException")\r
-                       utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)\r
-                       String requestInfo = execution.getVariable(Prefix+"requestInfo")\r
-                       utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)\r
-\r
-                       //TODO. hmmm. there is no way to UPDATE error message.\r
-//                     String errorMessage = wfex.getErrorMessage()\r
-//                     boolean successIndicator = execution.getVariable("DCRESI_rolledBack")\r
-//                     if (successIndicator){\r
-//                             errorMessage = errorMessage + ". Rollback successful."\r
-//                     } else {\r
-//                             errorMessage = errorMessage + ". Rollback not completed."\r
-//                     }\r
-\r
-                       String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)\r
-\r
-                       execution.setVariable(Prefix+"falloutRequest", falloutRequest)\r
-\r
-               } catch (Exception ex) {\r
-                       utils.log("DEBUG", "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process")\r
-               }\r
-               utils.log("DEBUG", "*** COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled)\r
-       }\r
-\r
-\r
-       public void sendSyncError (Execution execution) {\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-               execution.setVariable("prefix", Prefix)\r
-\r
-               utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled)\r
-\r
-               try {\r
-                       String errorMessage = ""\r
-                       def wfe = execution.getVariable("WorkflowException")\r
-                       if (wfe instanceof WorkflowException) {\r
-                               errorMessage = wfe.getErrorMessage()\r
-                       } else {\r
-                               errorMessage = "Sending Sync Error."\r
-                       }\r
-\r
-                       String buildworkflowException =\r
-                               """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">\r
-                                       <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>\r
-                                       <aetgt:ErrorCode>7000</aetgt:ErrorCode>\r
-                                  </aetgt:WorkflowException>"""\r
-\r
-                       utils.logAudit(buildworkflowException)\r
-                       sendWorkflowResponse(execution, 500, buildworkflowException)\r
-               } catch (Exception ex) {\r
-                       utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)\r
-               }\r
-       }\r
-\r
-       public void processJavaException(Execution execution){\r
-               def isDebugEnabled=execution.getVariable(DebugFlag)\r
-               execution.setVariable("prefix",Prefix)\r
-               try{\r
-                       utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)\r
-                       utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)\r
-                       utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)\r
-                       execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception")  // Adding this line temporarily until this flows error handling gets updated\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")\r
-               }catch(BpmnError b){\r
-                       utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)\r
-                       throw b\r
-               }catch(Exception e){\r
-                       utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)\r
-                       execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method")  // Adding this line temporarily until this flows error handling gets updated\r
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")\r
-               }\r
-               utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)\r
-       }\r
-}\r
+          //InputParams
+          def userParams = reqMap.requestDetails?.requestParameters?.userParams
+  
+          Map<String, String> inputMap = [:]
+
+
+          if (userParams) {
+                userParams.each {
+                                userParam ->
+                                if("BRG_WAN_MAC_Address".equals(userParam?.name)) {
+                                                execution.setVariable("brgWanMacAddress", userParam.value)
+                                                inputMap.put("BRG_WAN_MAC_Address", userParam.value)
+                    }
+                                if("Customer_Location".equals(userParam?.name)) {
+                                    execution.setVariable("customerLocation", userParam.value)
+                                    userParam.value.each {
+                                        customerLocParam ->
+                                        inputMap.put(customerLocParam.key, customerLocParam.value)
+                                    }
+                                }
+                }
+          }
+
+          utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)
+          execution.setVariable("serviceInputParams", inputMap)
+
+            utils.log("DEBUG", "Incoming brgWanMacAddress is: " +
+                    execution.getVariable('brgWanMacAddress'), isDebugEnabled)
+            utils.log("DEBUG", "Incoming customerLocation is: " +
+                    execution.getVariable('customerLocation'), isDebugEnabled)
+
+            //For Completion Handler & Fallout Handler
+            String requestInfo =
+            """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+                    <request-id>${requestId}</request-id>
+                    <action>CREATE</action>
+                    <source>${source}</source>
+                   </request-info>"""
+
+            execution.setVariable(Prefix+"requestInfo", requestInfo)
+
+            utils.log("DEBUG",
+                    " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)
+
+        } catch (BpmnError e) {
+            throw e;
+
+        } catch (Exception ex){
+            String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow." +
+                    " Unexpected from method preProcessRequest() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+    }
+
+    public void sendSyncResponse(Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+        try {
+            String serviceInstanceId = execution.getVariable("serviceInstanceId")
+            String requestId = execution.getVariable("mso-request-id")
+
+            // RESTResponse (for API Handler (APIH) Reply Task)
+            String syncResponse ="""{"requestReferences":{
+                        "instanceId":"${serviceInstanceId}",
+                        "requestId":"${requestId}"
+                        }}""".trim()
+
+            utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
+            sendWorkflowResponse(execution, 202, syncResponse)
+
+        } catch (Exception ex) {
+            String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " +
+                    "Unexpected from method sendSyncResponse() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+    }
+
+    // *******************************
+    //
+    // *******************************
+    public void prepareDecomposeService(Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        try {
+            utils.log("DEBUG",
+                    " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+            String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
+
+            //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB
+            String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.modelInfo")
+            execution.setVariable("serviceModelInfo", serviceModelInfo)
+
+            utils.log("DEBUG",
+                    " ***** Completed prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)
+        } catch (Exception ex) {
+            // try error in method block
+            String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " +
+                    "Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+     }
+
+    // *******************************
+    //
+    // *******************************
+    public void prepareCreateServiceInstance(Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        try {
+            utils.log("DEBUG",
+                    " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+            /*
+             * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from
+             * DecompositionObject
+             *      ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+             *      ModelInfo modelInfo = serviceDecomposition.getModelInfo()
+             *
+             */
+            String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
+//          String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest,
+//                  "requestDetails.requestParameters")
+//          execution.setVariable("serviceInputParams", serviceInputParams)
+
+
+            String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.requestInfo.instanceName")
+            execution.setVariable("serviceInstanceName", serviceInstanceName)
+
+            ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+            execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonStringNoRootName())
+
+            utils.log("DEBUG",
+                    " ***** Completed prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)
+        } catch (Exception ex) {
+            // try error in method block
+            String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " +
+                    "Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+     }
+
+    public void postProcessServiceInstanceCreate (Execution execution){
+        def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +
+                'execution=' + execution.getId() +')'
+        def isDebugLogEnabled = execution.getVariable(DebugFlag)
+        logDebug('Entered ' + method, isDebugLogEnabled)
+
+        String requestId = execution.getVariable("mso-request-id")
+        String serviceInstanceId = execution.getVariable("serviceInstanceId")
+        String serviceInstanceName = execution.getVariable("serviceInstanceName")
+
+        try {
+
+            String payload = """
+            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
+xmlns:req="http://org.openecomp.mso/requestsdb">
+            <soapenv:Header/>
+            <soapenv:Body>
+            <req:updateInfraRequest>
+                <requestId>${requestId}</requestId>
+                <lastModifiedBy>BPEL</lastModifiedBy>
+                <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+                <serviceInstanceName>${serviceInstanceName}</serviceInstanceName>
+            </req:updateInfraRequest>
+            </soapenv:Body>
+            </soapenv:Envelope>
+            """
+            execution.setVariable(Prefix+"setUpdateDbInstancePayload", payload)
+            utils.logAudit(Prefix+"setUpdateDbInstancePayload: " + payload)
+            logDebug('Exited ' + method, isDebugLogEnabled)
+
+        } catch (BpmnError e) {
+            throw e;
+        } catch (Exception e) {
+            logError('Caught exception in ' + method, e)
+            exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
+        }
+    }
+
+
+    public void processDecomposition (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        utils.log("DEBUG", " ***** Inside processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+        try {
+
+            ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+
+            // VNFs
+            List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs()
+            filterVnfs(vnfList)
+            serviceDecomposition.setServiceVnfs(vnfList)
+
+            execution.setVariable("vnfList", vnfList)
+            execution.setVariable("vnfListString", vnfList.toString())
+
+            String vnfModelInfoString = ""
+            if (vnfList != null && vnfList.size() > 0) {
+                execution.setVariable(Prefix+"VNFsCount", vnfList.size())
+                utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled)
+                ModelInfo vnfModelInfo = vnfList[0].getModelInfo()
+
+                vnfModelInfoString = vnfModelInfo.toString()
+                String vnfModelInfoWithRoot = vnfModelInfo.toString()
+                vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo")
+            } else {
+                    execution.setVariable(Prefix+"VNFsCount", 0)
+                    utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled)
+            }
+
+            execution.setVariable("vnfModelInfo", vnfModelInfoString)
+            execution.setVariable("vnfModelInfoString", vnfModelInfoString)
+            utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)
+
+            utils.log("DEBUG",
+                    " ***** Completed processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)
+        } catch (Exception ex) {
+            sendSyncError(execution)
+           String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " +
+                   "processDecomposition() - " + ex.getMessage()
+           utils.log("DEBUG", exceptionMessage, isDebugEnabled)
+           exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+    }
+
+    private void filterVnfs(List<VnfResource> vnfList) {
+        if(vnfList == null) {
+            return
+        }
+
+        // remove BRG & TXC from VNF list
+
+        Iterator<VnfResource> it = vnfList.iterator()
+        while(it.hasNext()) {
+            VnfResource vr = it.next()
+
+            String role = vr.getNfRole()
+            if(role == "BRG" || role == "TunnelXConn") {
+                it.remove()
+            }
+        }
+    }
+
+
+    public void prepareCreateAllottedResourceTXC(Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        try {
+            utils.log("DEBUG",
+                    " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+            /*
+             * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from
+             * DecompositionObject
+             *      ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+             *      ModelInfo modelInfo = serviceDecomposition.getModelInfo()
+             *
+             */
+            String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
+            ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+
+            //allottedResourceModelInfo
+            //allottedResourceRole
+            //The model Info parameters are a JSON structure as defined in the Service Instantiation API.
+            //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.
+            List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()
+            if (allottedResources != null) {
+                Iterator iter = allottedResources.iterator();
+                while (iter.hasNext()){
+                    AllottedResource allottedResource = (AllottedResource)iter.next();
+
+                    utils.log("DEBUG", " getting model info for AllottedResource # :" +
+                            allottedResource.toJsonStringNoRootName(), isDebugEnabled)
+                    utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" +
+                            allottedResource.getAllottedResourceType(), isDebugEnabled)
+                    if("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())){
+                        //set create flag to true
+                        execution.setVariable("createTXCAR", true)
+                        ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()
+                        execution.setVariable("allottedResourceModelInfoTXC",
+                                allottedResourceModelInfo.toJsonStringNoRootName())
+                        execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole())
+                        execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType())
+                        //After decomposition and homing BBs, there should be an allotted resource object in the
+                        // decomposition that represents the TXC,
+                        //and in its homingSolution section should be found the infraServiceInstanceId
+                        // (i.e. infraServiceInstanceId in TXC Allotted Resource structure) (which the Homing
+                        // BB would have populated).
+                        execution.setVariable("parentServiceInstanceIdTXC",
+                                allottedResource.getHomingSolution().getServiceInstanceId())
+                    }
+                }
+            }
+
+            //unit test only
+            String allottedResourceId = execution.getVariable("allottedResourceId")
+            execution.setVariable("allottedResourceIdTXC", allottedResourceId)
+            utils.log("DEBUG",
+                    "setting allottedResourceId CreateVcpeResCustService "+ allottedResourceId, isDebugEnabled)
+
+            utils.log("DEBUG",
+                    " ***** Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ",
+                    isDebugEnabled)
+        } catch (Exception ex) {
+            // try error in method block
+            String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. " +
+                    "Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+     }
+    public void prepareCreateAllottedResourceBRG(Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        try {
+            utils.log("DEBUG",
+                    " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+            /*
+             * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from
+             * DecompositionObject
+             *      ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+             *      ModelInfo modelInfo = serviceDecomposition.getModelInfo()
+             *
+             */
+            String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
+            ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+
+            //allottedResourceModelInfo
+            //allottedResourceRole
+            //The model Info parameters are a JSON structure as defined in the Service Instantiation API.
+            //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.
+            List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()
+            if (allottedResources != null) {
+                Iterator iter = allottedResources.iterator();
+                while (iter.hasNext()){
+                    AllottedResource allottedResource = (AllottedResource)iter.next();
+
+                    utils.log("DEBUG", " getting model info for AllottedResource # :" +
+                            allottedResource.toJsonStringNoRootName(), isDebugEnabled)
+                    utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" +
+                            allottedResource.getAllottedResourceType(), isDebugEnabled)
+                    if("BRG".equalsIgnoreCase(allottedResource.getAllottedResourceType())){
+                        //set create flag to true
+                        execution.setVariable("createBRGAR", true)
+                        ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()
+                        execution.setVariable("allottedResourceModelInfoBRG",
+                                allottedResourceModelInfo.toJsonStringNoRootName())
+                        execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole())
+                        execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType())
+                        //After decomposition and homing BBs, there should be an allotted resource object in the
+                        // decomposition that represents the BRG,
+                        //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).
+                        execution.setVariable("parentServiceInstanceIdBRG",
+                                allottedResource.getHomingSolution().getServiceInstanceId())
+                    }
+                }
+            }
+
+            //unit test only
+            String allottedResourceId = execution.getVariable("allottedResourceId")
+            execution.setVariable("allottedResourceIdBRG", allottedResourceId)
+            utils.log("DEBUG",
+                    "setting allottedResourceId CreateVcpeResCustService " + allottedResourceId, isDebugEnabled)
+
+            utils.log("DEBUG",
+                    " ***** Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ",
+                    isDebugEnabled)
+        } catch (Exception ex) {
+            // try error in method block
+            String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. " +
+                    "Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+     }
+
+
+
+    // *******************************
+    //     Generate Network request Section
+    // *******************************
+    public void prepareVnfAndModulesCreate (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        try {
+            utils.log("DEBUG",
+                    " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+            //          String disableRollback = execution.getVariable("disableRollback")
+            //          def backoutOnFailure = ""
+            //          if(disableRollback != null){
+            //              if ( disableRollback == true) {
+            //                  backoutOnFailure = "false"
+            //              } else if ( disableRollback == false) {
+            //                  backoutOnFailure = "true"
+            //              }
+            //          }
+                        //failIfExists - optional
+
+            String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
+            String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.requestInfo.productFamilyId")
+            execution.setVariable("productFamilyId", productFamilyId)
+            utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled)
+
+            List<VnfResource> vnfList = execution.getVariable("vnfList")
+
+            Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount")
+            String vnfModelInfoString = null;
+
+            if (vnfList != null && vnfList.size() > 0 ) {
+                utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled)
+                ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo()
+                utils.log("DEBUG", "got 0 ", isDebugEnabled)
+                ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo()
+                vnfModelInfoString = vnfModelInfo.toString()
+            } else {
+                //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored
+                vnfModelInfoString = execution.getVariable("vnfModelInfo")
+            }
+
+            utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)
+
+            // extract cloud configuration
+            String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.cloudConfiguration.lcpCloudRegionId")
+            execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)
+            utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)
+            String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest,
+                    "requestDetails.cloudConfiguration.tenantId")
+            execution.setVariable("tenantId", tenantId)
+            utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)
+
+            String sdncVersion = execution.getVariable("sdncVersion")
+            utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)
+
+            utils.log("DEBUG",
+                    " ***** Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
+        } catch (Exception ex) {
+            // try error in method block
+            String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " +
+                    "Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+     }
+
+    // *******************************
+    //     Validate Vnf request Section -> increment count
+    // *******************************
+    public void validateVnfCreate (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        try {
+            utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+            Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount")
+            vnfsCreatedCount++
+
+            execution.setVariable(Prefix+"VnfsCreatedCount", vnfsCreatedCount)
+
+            utils.log("DEBUG",
+                    " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled)
+        } catch (Exception ex) {
+            // try error in method block
+            String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " +
+                    "Unexpected Error from method validateVnfCreate() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+     }
+
+    // *****************************************
+    //     Prepare Completion request Section
+    // *****************************************
+    public void postProcessResponse (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+        try {
+            String source = execution.getVariable("source")
+            String requestId = execution.getVariable("mso-request-id")
+            String serviceInstanceId = execution.getVariable("serviceInstanceId")
+
+            String msoCompletionRequest =
+                    """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+                                    xmlns:ns="http://org.openecomp/mso/request/types/v1">
+                            <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+                                <request-id>${requestId}</request-id>
+                                <action>CREATE</action>
+                                <source>${source}</source>
+                            </request-info>
+                            <status-message>Service Instance has been created successfully via macro orchestration</status-message>
+                            <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+                            <mso-bpel-name>BPMN macro create</mso-bpel-name>
+                        </aetgt:MsoCompletionRequest>"""
+
+            // Format Response
+            String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+            utils.logAudit(xmlMsoCompletionRequest)
+            execution.setVariable(Prefix+"Success", true)
+            execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest)
+            utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
+        } catch (BpmnError e) {
+            throw e;
+        } catch (Exception ex) {
+            // try error in method block
+            String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. " +
+                    "Unexpected Error from method postProcessResponse() - " + ex.getMessage()
+            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+        }
+    }
+
+    public void preProcessRollback (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+        utils.log("DEBUG"," ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)
+        try {
+
+            Object workflowException = execution.getVariable("WorkflowException");
+
+            if (workflowException instanceof WorkflowException) {
+                utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
+                execution.setVariable("prevWorkflowException", workflowException);
+                //execution.setVariable("WorkflowException", null);
+            }
+        } catch (BpmnError e) {
+            utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
+        } catch(Exception ex) {
+            String msg = "Exception in preProcessRollback. " + ex.getMessage()
+            utils.log("DEBUG", msg, isDebugEnabled)
+        }
+        utils.log("DEBUG"," *** Exit preProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)
+    }
+
+    public void postProcessRollback (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+        utils.log("DEBUG"," ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)
+        String msg = ""
+        try {
+            Object workflowException = execution.getVariable("prevWorkflowException");
+            if (workflowException instanceof WorkflowException) {
+                utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
+                execution.setVariable("WorkflowException", workflowException);
+            }
+        } catch (BpmnError b) {
+            utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
+            throw b;
+        } catch(Exception ex) {
+            msg = "Exception in postProcessRollback. " + ex.getMessage()
+            utils.log("DEBUG", msg, isDebugEnabled)
+        }
+        utils.log("DEBUG"," *** Exit postProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)
+    }
+
+    public void prepareFalloutRequest(Execution execution){
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+
+        utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)
+
+        try {
+            WorkflowException wfex = execution.getVariable("WorkflowException")
+            utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)
+            String requestInfo = execution.getVariable(Prefix+"requestInfo")
+            utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)
+
+            //TODO. hmmm. there is no way to UPDATE error message.
+//          String errorMessage = wfex.getErrorMessage()
+//          boolean successIndicator = execution.getVariable("DCRESI_rolledBack")
+//          if (successIndicator){
+//              errorMessage = errorMessage + ". Rollback successful."
+//          } else {
+//              errorMessage = errorMessage + ". Rollback not completed."
+//          }
+
+            String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
+
+            execution.setVariable(Prefix+"falloutRequest", falloutRequest)
+
+        } catch (Exception ex) {
+            utils.log("DEBUG",
+                    "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(),
+                    isDebugEnabled)
+            exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
+                    "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process")
+        }
+        utils.log("DEBUG",
+                "*** COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled)
+    }
+
+
+    public void sendSyncError (Execution execution) {
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+        execution.setVariable("prefix", Prefix)
+
+        utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled)
+
+        try {
+            String errorMessage = ""
+            def wfe = execution.getVariable("WorkflowException")
+            if (wfe instanceof WorkflowException) {
+                errorMessage = wfe.getErrorMessage()
+            } else {
+                errorMessage = "Sending Sync Error."
+            }
+
+            String buildworkflowException =
+                """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
+                    <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
+                    <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+                   </aetgt:WorkflowException>"""
+
+            utils.logAudit(buildworkflowException)
+            sendWorkflowResponse(execution, 500, buildworkflowException)
+        } catch (Exception ex) {
+            utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
+        }
+    }
+
+    public void processJavaException(Execution execution){
+        def isDebugEnabled=execution.getVariable(DebugFlag)
+        execution.setVariable("prefix",Prefix)
+        try{
+            utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
+            utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
+            utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
+            // Adding below line temporarily until this flows error handling gets updated
+            execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception")
+            exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")
+        }catch(BpmnError b){
+            utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)
+            throw b
+        }catch(Exception e){
+            utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
+            // Adding below line temporarily until this flows error handling gets updated
+            execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method")
+            exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")
+        }
+        utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
+    }
+}
index 3b97cad..7a494db 100644 (file)
@@ -109,6 +109,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
                assertTrue(map.containsKey("subscriberInfo"))
                
                verify(mex).setVariable("brgWanMacAddress", "brgmac")
+               verify(mex).setVariable("customerLocation", ["customerLatitude":"32.897480", "customerLongitude":"-97.040443", "customerName":"some_company"])
                assertTrue(map.containsKey("serviceInputParams"))
                assertTrue(map.containsKey(Prefix+"requestInfo"))
                
@@ -141,6 +142,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
                def req = request
                                        .replace('"source"', '"sourceXXX"')
                                        .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"')
+                                       .replace('"Customer_Location"', '"Customer_LocationXXX"')
                
                when(mex.getVariable("bpmnRequest")).thenReturn(req)
                when(mex.getVariable("serviceInstanceId")).thenReturn(null)
@@ -164,6 +166,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
                assertTrue(map.containsKey("subscriberInfo"))
                
                assertEquals("", map.get("brgWanMacAddress"))
+               assertEquals("", map.get("customerLocation"))
                assertTrue(map.containsKey("serviceInputParams"))
                assertTrue(map.containsKey(Prefix+"requestInfo"))
                
index a0168bd..3e05ba0 100644 (file)
                                        "aLaCarte":"false",
                                        "userParams":
                                           [
-                                               {
-                                                       "name":"BRG_WAN_MAC_Address",
-                                                       "value":"brgmac"
-                                               }
-                                          ]
+                                                       {
+                                                               "name":"BRG_WAN_MAC_Address",
+                                                               "value":"brgmac"
+                                                       },
+                                                       {
+                                                               "name": "Customer_Location",
+                                                               "value": {
+                                                                       "customerLatitude": "32.897480",
+                                                                       "customerLongitude": "-97.040443",
+                                                                       "customerName": "some_company"
+                                                               }
+                                                       }
+                                               ]
                                }
-                               
                }
 }
index 17c6d15..cf02444 100644 (file)
                                {
                                        "subscriptionServiceType":"123456789",
                                        "aLaCarte":"false",
-                    "userParams":
-                       [
-                            {
-                                "name":"BRG_WAN_MAC_Address",
-                                "value":"brgmac"
-                            }
-                       ]
+                                       "userParams":
+                                          [
+                                                       {
+                                                               "name":"BRG_WAN_MAC_Address",
+                                                               "value":"brgmac"
+                                                       },
+                                                       {
+                                                               "name": "Customer_Location",
+                                                               "value": {
+                                                                       "customerLatitude": "32.897480",
+                                                                       "customerLongitude": "-97.040443",
+                                                                       "customerName": "some_company"
+                                                               }
+                                                       }
+                                               ]
                                }
-                               
                }
 }
index 8583e66..39be40a 100644 (file)
                                {
                                        "subscriptionServiceType":"123456789",
                                        "aLaCarte":"false",
-                    "userParams":
-                       [
-                            {
-                                "name":"BRG_WAN_MAC_Address",
-                                "value":"brgmac"
-                            }
-                       ]
+                                       "userParams":
+                                          [
+                                                       {
+                                                               "name":"BRG_WAN_MAC_Address",
+                                                               "value":"brgmac"
+                                                       },
+                                                       {
+                                                               "name": "Customer_Location",
+                                                               "value": {
+                                                                       "customerLatitude": "32.897480",
+                                                                       "customerLongitude": "-97.040443",
+                                                                       "customerName": "some_company"
+                                                               }
+                                                       }
+                                               ]
                                }
-                               
                }
 }