1710 Rebase - Second Attempt
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / CreateNetworkInstance.groovy
index 11de8d9..54f676f 100644 (file)
@@ -1,32 +1,32 @@
-/*-\r
- * ============LICENSE_START=======================================================\r
- * OPENECOMP - MSO\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
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
  */
-\r
-package org.openecomp.mso.bpmn.infrastructure.scripts;\r
+
+package org.openecomp.mso.bpmn.infrastructure.scripts;
 
 import groovy.xml.XmlUtil
 import groovy.json.*
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
-import org.openecomp.mso.bpmn.core.WorkflowException\r
-import org.openecomp.mso.bpmn.core.json.JsonUtils\r
-import org.openecomp.mso.rest.APIResponse\r
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.rest.APIResponse
 
 import java.util.UUID;
 
@@ -105,12 +105,12 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                            utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled)
                        }       
                        
-                       // get/set 'msoRequestId' and 'mso-request-id'\r
+                       // get/set 'msoRequestId' and 'mso-request-id'
                        String requestId = execution.getVariable("msoRequestId")
                        if (requestId != null) {
-                               execution.setVariable("mso-request-id", requestId)\r
+                               execution.setVariable("mso-request-id", requestId)
                        } else {
-                               requestId = execution.getVariable("mso-request-id")\r
+                               requestId = execution.getVariable("mso-request-id")
                        }
                        execution.setVariable(Prefix + "requestId", requestId)
                        
@@ -161,7 +161,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                utils.log("DEBUG", " ***** Inside sendSyncResponse() of CreateNetworkInstance ***** ", isDebugEnabled)
 
                try {
-                       String requestId = execution.getVariable("mso-request-id")\r
+                       String requestId = execution.getVariable("mso-request-id")
 
                        // RESTResponse (for API Handler (APIH) Reply Task)
                        String createNetworkRestRequest = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim()
@@ -186,14 +186,11 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                
                try {
                        
-                       // "networkModelInfo" is expected to be sent 
-                       String networkModelInfo = execution.getVariable("networkModelInfo")
-                       utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled)
-                       
-                       // "serviceModelInfo" is expected to be sent
-                       String serviceModelInfo = execution.getVariable("serviceModelInfo")
-                       utils.log("DEBUG", " serviceModelInfo - " + serviceModelInfo, isDebugEnabled)
-                                                
+                       // For Ala-Carte (sdnc = 1610): 
+                       // 1. the Network ModelInfo is expected to be sent 
+                       //     via requestDetails.modelInfo (modelType = network).
+                       // 2. the Service ModelInfo is expected to be sent but will be IGNORE 
+                       //     via requestDetails.relatedInstanceList.relatedInstance.modelInfo (modelType = service)
                                                                                 
                } catch (Exception ex) {
                        sendSyncError(execution)
@@ -214,7 +211,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                
                try {
 
-                       String requestId = execution.getVariable("mso-request-id")\r
+                       String requestId = execution.getVariable("mso-request-id")
 
                        // REST Error (for API Handler (APIH) Reply Task)
                        String syncError = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim()
@@ -234,6 +231,9 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                try {
                        utils.log("DEBUG", " ***** Inside prepareDBRequestError() of CreateNetworkInstance ***** ", isDebugEnabled)
 
+                       // set DB Header Authorization
+                       setBasicDBAuthHeader(execution, isDebugEnabled)
+                       
                        String statusMessage = ""
                        WorkflowException wfe = null
                        if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
@@ -248,7 +248,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                                        """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                                                <soapenv:Header/>
                                                <soapenv:Body>
-                                                       <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">\r
+                                                       <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
                                                                <requestId>${requestId}</requestId>
                                                                <lastModifiedBy>BPMN</lastModifiedBy>
                                                                <statusMessage>${statusMessage}</statusMessage>
@@ -280,13 +280,13 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
 
                try {
 
-                       String requestId = execution.getVariable("mso-request-id")\r
+                       String requestId = execution.getVariable("mso-request-id")
                        String source = execution.getVariable(Prefix + "source")
 
                        String msoCompletionRequest =
-                               """<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
+                               """<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>VID</source>
@@ -379,25 +379,29 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
+               utils.log("DEBUG", "DB updateInfraRequest ResponseCode: " + execution.getVariable(Prefix + "dbReturnCode"), isDebugEnabled)
+               utils.log("DEBUG", "DB updateInfraRequest Response: " + execution.getVariable(Prefix + "createDBResponse"), isDebugEnabled)
+               
                utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled)
 
                String falloutHandlerRequest = ""
-               String requestId = execution.getVariable("mso-request-id")\r
+               String requestId = execution.getVariable("mso-request-id")
 
                try {
+                       
                        WorkflowException wfe = execution.getVariable("WorkflowException")
                        String errorCode = String.valueOf(wfe.getErrorCode())
                        String errorMessage = wfe.getErrorMessage()
                        falloutHandlerRequest =
-                               """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"\r
-                                                                    xmlns:ns="http://org.openecomp/mso/request/types/v1"\r
-                                                                    xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">\r
-                                          <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
+                               """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+                                                                    xmlns:ns="http://org.openecomp/mso/request/types/v1"
+                                                                    xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
+                                          <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
                                              <request-id>${requestId}</request-id>
                                              <action>CREATE</action>
                                              <source>VID</source>
                                           </request-info>
-                                               <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">\r
+                                               <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
                                                        <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
                                                        <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
                                                </aetgt:WorkflowException>
@@ -408,18 +412,18 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
                        utils.log("DEBUG", "  Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled)
 
                } catch (Exception ex) {
-                       String errorException = "  Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest,  buildErrorResponse() - " + ex.getMessage()
-                       utils.log("DEBUG", errorException, isDebugEnabled)
+                       String errorException = "  Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest,  buildErrorResponse()"
+                       utils.log("DEBUG", "Exception error in CreateNetworkInstance flow,  buildErrorResponse(): "  + ex.getMessage(), isDebugEnabled)
                        falloutHandlerRequest =
-                       """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"\r
-                                                                    xmlns:ns="http://org.openecomp/mso/request/types/v1"\r
-                                                                    xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">\r
-                                          <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">\r
+                       """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+                                                                    xmlns:ns="http://org.openecomp/mso/request/types/v1"
+                                                                    xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
+                                          <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
                                              <request-id>${requestId}</request-id>
                                              <action>CREATE</action>
                                              <source>VID</source>
                                           </request-info>
-                                               <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">\r
+                                               <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
                                                        <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
                                                        <aetgt:ErrorCode>7000</aetgt:ErrorCode>
                                                </aetgt:WorkflowException>