1710 Rebase - Second Attempt
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / CreateVfModuleInfra.groovy
index b468a51..74234f8 100644 (file)
@@ -51,6 +51,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
                logDebug('Entered ' + method, isDebugLogEnabled)
 
+               execution.setVariable("CVFMI_sentSyncResponse", false)
+               
                def prefix = 'CVFMI_'
                logDebug('Entered 1' + method, isDebugLogEnabled)
                execution.setVariable('prefix', prefix)
@@ -71,6 +73,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
                utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
                utils.logAudit("CreateVfModule Infra incoming Request: " + incomingRequest)
 
+               setBasicDBAuthHeader(execution, isDebugLogEnabled)
+               
                // check if request is xml or json
                try {
                        def jsonSlurper = new JsonSlurper()
@@ -156,7 +160,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
                                }
                        }
                        
-                       execution.setVariable(prefix + 'disableRollback', suppressRollback)
+                       execution.setVariable('disableRollback', suppressRollback)
                        
                        def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
                        execution.setVariable(prefix + 'vfModuleName', vfModuleName)
@@ -198,9 +202,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
                        execution.setVariable("CVFMI_requestInfo", requestInfo)
                        
                        //backoutOnFailure
-
-                       //NetworkUtils networkUtils = new NetworkUtils()
-                       //execution.setVariable("CVFMI_rollbackEnabled", networkUtils.isRollbackEnabled(execution,request))
+                       
                        execution.setVariable("CVFMI_originalWorkflowException", null)
                        
 
@@ -266,6 +268,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
 
                        sendWorkflowResponse(execution, 200, synchResponse)
 
+                       execution.setVariable("CVFMI_sentSyncResponse", true)
                        utils.logAudit("CreateVfModule Infra Response: " + synchResponse)
                        logDebug('Exited ' + method, isDebugLogEnabled)
                } catch (BpmnError e) {
@@ -291,18 +294,6 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
                        utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled)
                        utils.log("DEBUG", "action is: " + action, isDebugEnabled)
 
-                       try {\r
-                               String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")\r
-                               utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled)\r
-                               \r
-                               def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))\r
-                               execution.setVariable("BasicAuthHeaderValueDB",encodedString)\r
-                       } catch (IOException ex) {\r
-                               String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()\r
-                               utils.log("DEBUG", dataErrorMessage, isDebugEnabled)\r
-                               exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
-                       }\r
-                       \r
                        String payload =
                                        """  <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
                                xmlns:ns="http://org.openecomp/mso/request/types/v1"
@@ -417,22 +408,10 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
                        // vfModuleName may be generated by DoCreateVfModule subprocess if it is not specified on the input
                        def vfModuleName = execution.getVariable("CVFMI_vfModuleName")
 
-                       def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_db_endpoint")
+                       def dbAdapterEndpoint = execution.getVariable("URN_mso_openecomp_adapters_db_endpoint")
                        execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
                        utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
 
-                       try {\r
-                               String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")\r
-                               utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled)\r
-                               \r
-                               def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))\r
-                               execution.setVariable("BasicAuthHeaderValueDB",encodedString)\r
-                       } catch (IOException ex) {\r
-                               String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()\r
-                               utils.log("DEBUG", dataErrorMessage, isDebugEnabled)\r
-                               exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)\r
-                       }\r
-                       \r
                        String payload =
                                """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                                xmlns:ns="http://org.openecomp.mso/requestsdb">
@@ -542,7 +521,29 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
 
        }
        
-       
+       public void sendErrorResponse(Execution execution){
+               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+
+               utils.log("DEBUG", " *** STARTED CreateVfModulenfra sendErrorResponse Process *** ", isDebugEnabled)
+               try {
+                       def sentSyncResponse = execution.getVariable("CVFMI_sentSyncResponse")
+                       if(sentSyncResponse == false){
+                               WorkflowException wfex = execution.getVariable("WorkflowException")
+                               String response = exceptionUtil.buildErrorResponseXml(wfex)
+
+                               utils.logAudit(response)
+                               sendWorkflowResponse(execution, 500, response)
+                       }else{
+                               utils.log("DEBUG", "Not Sending Error Response.  Sync Response Already Sent", isDebugEnabled)
+                       }
+
+               } catch (Exception ex) {
+                       utils.log("DEBUG", "Error Occured in CreateVfModuleInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled)
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVfModuleInfra sendErrorResponse Process")
+
+               }
+               utils.log("DEBUG", "*** COMPLETED CreateVfModuleInfra sendErrorResponse Process ***", isDebugEnabled)
+       }
 
 
 }