AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / SDNCAdapterUtils.groovy
index 9de1708..20a8210 100644 (file)
@@ -22,9 +22,9 @@ package org.openecomp.mso.bpmn.common.scripts;
 \r
 import org.apache.commons.lang3.*\r
 import org.camunda.bpm.engine.delegate.BpmnError\r
-import org.camunda.bpm.engine.runtime.Execution\r
+import org.camunda.bpm.engine.delegate.DelegateExecution\r\r
 import org.openecomp.mso.bpmn.core.WorkflowException\r
-import org.openecomp.mso.bpmn.core.json.JsonUtils\r
+import org.openecomp.mso.bpmn.core.json.JsonUtils;\r
 import org.springframework.web.util.UriUtils\r
 \r
 \r
@@ -43,7 +43,7 @@ class SDNCAdapterUtils {
                this.taskProcessor = taskProcessor\r
        }\r
 \r
-       String SDNCAdapterFeatureRequest(Execution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {\r
+       String SDNCAdapterFeatureRequest(DelegateExecution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {\r\r
                def utils=new MsoUtils()\r
 \r
                def prefix = execution.getVariable('prefix')\r
@@ -88,7 +88,7 @@ class SDNCAdapterUtils {
                return sdncAdapterFeatureRequest\r
        }\r
 \r
-       String SDNCAdapterActivateVnfRequest(Execution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) {\r
+       String SDNCAdapterActivateVnfRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) {\r\r
                def utils=new MsoUtils()\r
 \r
                def prefix = execution.getVariable('prefix')\r
@@ -131,7 +131,7 @@ class SDNCAdapterUtils {
                return sdncAdapterActivateVnfRequest\r
        }\r
 \r
-       String SDNCAdapterL3ToHigherLayerRequest(Execution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {\r
+       String SDNCAdapterL3ToHigherLayerRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {\r\r
                def utils=new MsoUtils()\r
 \r
                def prefix = execution.getVariable('prefix')\r
@@ -230,7 +230,7 @@ class SDNCAdapterUtils {
 \r
 \r
 \r
-       private void SDNCAdapterActivateRequest(Execution execution, String resultVar, String svcAction,\r
+       private void SDNCAdapterActivateRequest(DelegateExecution execution, String resultVar, String svcAction,\r\r
                        String svcOperation, String additionalData) {\r
                        def utils=new MsoUtils()\r
 \r
@@ -273,6 +273,15 @@ class SDNCAdapterUtils {
                                additionalData = ""\r
                        }\r
 \r
+                       boolean isAic3 = execution.getVariable("isAic3")\r
+                       \r
+                       if(isAic3) {\r
+                               nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")\r
+                       }\r
+                       else {\r
+                               nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")\r
+                       }\r
+                                                                       \r
                        String content = """\r
                                <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"\r
                                                xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">\r
@@ -301,14 +310,27 @@ class SDNCAdapterUtils {
                        execution.setVariable(resultVar, content)\r
        }\r
 \r
+       /**\r
+        * Builds an SDNC "reserve" request and stores it in the specified execution\r
+        * variable. \r
+        * @param execution the execution\r
+        * @param action the type of action: reserve, turnup, etc\r
+        * @param resultVar the execution variable in which the result will be stored\r
+        */\r
+       public void sdncReservePrep(DelegateExecution execution, String action, String resultVar) {\r
+               sdncReservePrep(execution, action, resultVar, false)\r
+       }\r
+\r
        /**\r
         * Builds an SDNC "reserve" request and stores it in the specified execution\r
         * variable.\r
         * @param execution the execution\r
+        * @param action the type of action: reserve, turnup, etc\r
         * @param resultVar the execution variable in which the result will be stored\r
+        * @param isAic3 boolean to indicate whether request is for AIC3.0\r
         */\r
-       public void sdncReservePrep(Execution execution, String action, String resultVar) {\r
-               sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, this.taskProcessor)\r
+       public void sdncReservePrep(DelegateExecution execution, String action, String resultVar, boolean isAic3) {\r\r
+               sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3, this.taskProcessor)\r
        }\r
 \r
        /**\r
@@ -320,8 +342,22 @@ class SDNCAdapterUtils {
         * @param additionalData additional XML content to be inserted into the\r
         *        RequestData element (may be null)\r
         */\r
-       public void sdncPrep(Execution execution, String resultVar, String svcAction,\r
-                       String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) {\r
+       public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,\r
+               String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) {\r
+               sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false, taskProcessor)\r
+       }\r
+\r
+       /**\r
+        * Builds a basic SDNC request and stores it in the specified execution variable.\r
+        * @param execution the execution\r
+        * @param resultVar the execution variable in which the result will be stored\r
+        * @param svcAction the svcAction element value\r
+        * @param svcOperation the svcOperation element value\r
+        * @param additionalData additional XML content to be inserted into the RequestData element (may be null)\r
+        * @param isAic3 boolean to indicate whether request is for AIC3.0\r
+        */\r
+       public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,\r\r
+                       String svcOperation, String additionalData, boolean isAic3, AbstractServiceTaskProcessor taskProcessor) {\r
                def method = getClass().getSimpleName() + '.sdncPrep(' +\r
                        'execution=' + execution.getId() +\r
                        ', resultVar=' + resultVar +\r
@@ -382,6 +418,14 @@ class SDNCAdapterUtils {
                        if (additionalData == null) {\r
                                additionalData = ""\r
                        }\r
+                       \r
+                       if(isAic3) {\r
+                               nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")\r
+                       }\r
+                       else {\r
+                               nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")\r
+                       }\r
+\r
 \r
                        String content = """\r
                                <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"\r
@@ -420,7 +464,17 @@ class SDNCAdapterUtils {
                        exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error")\r
                }\r
        }\r
-\r
+       \r
+       public String updateHomingInfo(String homingInfo, String aicVersion) {\r
+               String newHomingInfo\r
+               if(homingInfo == null || homingInfo.trim().length() == 0) {\r
+                       newHomingInfo = "<l2-homing-information><aic-version>" + aicVersion + "</aic-version></l2-homing-information>"\r
+               }\r
+               else {\r
+                       newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>"\r
+               }\r
+       }\r
+       \r
        /**\r
         * Builds a topology SDNC request and return String request.\r
         * As V2 will use 1607-style request, region instead of aic clli code\r
@@ -435,7 +489,7 @@ class SDNCAdapterUtils {
         * @param additionalData additional XML content to be inserted into the\r
         *   RequestData element (may be null)\r
         */\r
-        public String sdncTopologyRequestV2 (Execution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) {\r
+        public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) {\r\r
                 def utils=new MsoUtils()\r
 \r
                 // SNDC is expecting request Id for header as unique each call.\r
@@ -553,7 +607,7 @@ class SDNCAdapterUtils {
          * @param additionalData additional XML content to be inserted into the\r
          *   RequestData element (may be null)\r
          */\r
-         public String sdncTopologyRequestRsrc (Execution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) {\r
+         public String sdncTopologyRequestRsrc (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) {\r\r
                  def utils=new MsoUtils()\r
 \r
                  // SNDC is expecting request Id for header as unique each call.\r
@@ -675,12 +729,12 @@ class SDNCAdapterUtils {
                                                   <service-information>\r
                                                      <service-id>${serviceId}</service-id>\r
                                                      <subscription-service-type>${subscriptionServiceType}</subscription-service-type>\r
-                                                         <onap-model-information>\r
+                                                         <ecomp-model-information>\r
                                                                   <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid>\r
                                                                   <model-uuid>${serviceModelUuid}</model-uuid>\r
                                                                   <model-version>${serviceModelVersion}</model-version>\r
                                                                   <model-name>${serviceModelName}</model-name>\r
-                              </onap-model-information>\r
+                              </ecomp-model-information>\r
                                                      <service-instance-id>${serviceInstanceId}</service-instance-id>\r
                                                      <global-customer-id>${globalCustomerId}</global-customer-id>\r
                                                      <subscriber-name>${subscriberName}</subscriber-name>\r
@@ -688,13 +742,13 @@ class SDNCAdapterUtils {
                                                   <network-information>\r
                                                      <network-id>${networkId}</network-id>\r
                                                      <network-type>${networkType}</network-type>\r
-                                                         <onap-model-information>\r
+                                                         <ecomp-model-information>\r
                                                                   <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>\r
                                                                   <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>\r
                                                                   <model-uuid>${modelUuid}</model-uuid>\r
                                                                   <model-version>${modelVersion}</model-version>\r
                                                                   <model-name>${modelName}</model-name>\r
-                                                         </onap-model-information>\r
+                                                         </ecomp-model-information>\r
                                                   </network-information>\r
                                                   <network-request-input>\r
                                                     <network-name>${networkName}</network-name>\r
@@ -715,7 +769,7 @@ class SDNCAdapterUtils {
                         * @param responseVar the execution variable in which the response is stored\r
                         * @param workflowException the WorkflowException Object returned from sdnc call\r
                         */\r
-       public void validateSDNCResponse(Execution execution, String response, WorkflowException workflowException, boolean successIndicator){\r
+       public void validateSDNCResponse(DelegateExecution execution, String response, WorkflowException workflowException, boolean successIndicator){\r\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                taskProcessor.utils.log("DEBUG", "SDNC Response is: " + response, isDebugLogEnabled)\r
                taskProcessor.utils.log("DEBUG", "SuccessIndicator is: " + successIndicator, isDebugLogEnabled)\r
@@ -730,8 +784,13 @@ class SDNCAdapterUtils {
                                        taskProcessor.utils.log("DEBUG", response + ' is empty');\r
                                        exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty")\r
                                }else{\r
+\r
                                        // we need to peer into the request data for error\r
-                                       def String decodedXml = taskProcessor.utils.getNodeText1(response, "RequestData")\r
+                                       def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false)\r
+                                       def String decodedXml = decodeXML(sdncAdapterWorkflowResponse).replace('<?xml version="1.0" encoding="UTF-8"?>', "")\r
+\r
+                                       // change '&' to "&amp; (if present as data, ex: subscriber-name = 'FOUR SEASONS HEATING & COOLING_8310006378683'\r
+                                       decodedXml = decodedXml.replace("&", "&amp;")\r
 \r
                                        taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled)\r
 \r
@@ -740,14 +799,12 @@ class SDNCAdapterUtils {
 \r
                                        try{\r
                                                if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {\r
-                                                       requestDataResponseMessage = taskProcessor.utils.getNodeText1(decodedXml, "response-message")\r
-                                                       \r
-                                                       // note: ResponseMessage appears within "response", not "decodedXml"\r
-                                               } else if (taskProcessor.utils.nodeExists(response, "ResponseMessage")) {\r
-                                                       requestDataResponseMessage = taskProcessor.utils.getNodeText1(response, "ResponseMessage")\r
+                                                       requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")\r
+                                               } else if (taskProcessor.utils.nodeExists(decodedXml, "ResponseMessage")) {\r
+                                                       requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "ResponseMessage")\r
                                                }\r
                                        }catch(Exception e){\r
-                                               taskProcessor.utils.log("DEBUG", 'Error caught while decoding response ' + e.getMessage(), isDebugLogEnabled)\r
+                                               taskProcessor.utils.log("DEBUG", 'Error caught while decoding resposne ' + e.getMessage(), isDebugLogEnabled)\r
                                        }\r
 \r
                                        if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) {\r
@@ -758,20 +815,18 @@ class SDNCAdapterUtils {
                                                        taskProcessor.utils.log("DEBUG","response-code node is empty", isDebugLogEnabled)\r
                                                        requestDataResponseCode = 0\r
                                                }else{\r
-                                                       requestDataResponseCode  = code as Integer\r
+                                                       requestDataResponseCode  = code.toInteger()\r
                                                        taskProcessor.utils.log("DEBUG","response-code is: " + requestDataResponseCode, isDebugLogEnabled)\r
                                                }\r
-                                               \r
-                                               // note: ResponseCode appears within "response", not "decodedXml"\r
-                                       }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){\r
+                                       }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){\r
                                                taskProcessor.utils.log("DEBUG","ResponseCode node Exist ", isDebugLogEnabled)\r
-                                               String code = taskProcessor.utils.getNodeText1(response, "ResponseCode")\r
+                                               String code = taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode")\r
                                                if(code.isEmpty() || code.equals("")){\r
                                                        // if ResponseCode blank then Success\r
                                                        taskProcessor.utils.log("DEBUG","ResponseCode node is empty", isDebugLogEnabled)\r
                                                        requestDataResponseCode = 0\r
                                                }else{\r
-                                                       requestDataResponseCode  = code as Integer\r
+                                                       requestDataResponseCode  = code.toInteger()\r
                                                        taskProcessor.utils.log("DEBUG","ResponseCode is: " + requestDataResponseCode, isDebugLogEnabled)\r
                                                }\r
                                        }else{\r
@@ -828,7 +883,7 @@ class SDNCAdapterUtils {
                         * @param responseCodeVar the execution variable in which the response code is stored\r
                         * @param errorResponseVar the execution variable in which the error response is stored\r
                         */\r
-                       public void validateL3BondingSDNCResp(Execution execution, String response, WorkflowException workflowException, boolean success) {\r
+                       public void validateL3BondingSDNCResp(DelegateExecution execution, String response, WorkflowException workflowException, boolean success) {\r\r
                                def method = getClass().getSimpleName() + '.validateL3BondingSDNCResp(' +\r
                                        'execution=' + execution.getId() +\r
                                        ', response=' + response +\r
@@ -951,13 +1006,13 @@ class SDNCAdapterUtils {
                }               \r
                String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName")\r
                String ecompModelInformation =\r
-                               """<onap-model-information>\r
+                               """<ecomp-model-information>\r
                                                <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>\r
                                                <model-uuid>${modelUuid}</model-uuid>\r
                                                ${modelCustomizationString}\r
                                                <model-version>${modelVersion}</model-version>\r
                                                <model-name>${modelName}</model-name>\r
-                               </onap-model-information>"""\r
+                               </ecomp-model-information>"""\r
 \r
                return ecompModelInformation            \r
        } \r