Merge "Remove unneeded param type definition"
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / DoUpdateNetworkInstance.groovy
index 5bd9f96..829e4d9 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
+ * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -34,7 +34,7 @@ import org.openecomp.mso.rest.APIResponse
 import java.util.UUID;
 
 import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
+import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.apache.commons.lang3.*
 import org.apache.commons.codec.binary.Base64;
 import org.springframework.web.util.UriUtils
@@ -55,7 +55,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
         * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process.
         * @param execution
         */
-       public InitializeProcessVariables(Execution execution){
+       public InitializeProcessVariables(DelegateExecution execution){
                /* Initialize all the process variables in this block */
 
                execution.setVariable(Prefix + "messageId", "")
@@ -146,7 +146,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
         * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process.
         * @param execution
         */
-       public void preProcessRequest (Execution execution) {
+       public void preProcessRequest (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix",Prefix)
 
@@ -303,7 +303,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                }
        }
 
-       public void callRESTQueryAAICloudRegion (Execution execution) {
+       public void callRESTQueryAAICloudRegion (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -353,7 +353,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void callRESTQueryAAINetworkId(Execution execution) {
+       public void callRESTQueryAAINetworkId(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -370,7 +370,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                        String aai_endpoint = execution.getVariable("URN_aai_endpoint")
                        AaiUtil aaiUriUtil = new AaiUtil(this)
                        String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
-                       String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=1"
+                       String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all"
                        utils.logAudit(queryIdAAIRequest)
                        execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest)
                        utils.log("DEBUG", Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest, isDebugEnabled)
@@ -421,7 +421,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void callRESTReQueryAAINetworkId(Execution execution) {
+       public void callRESTReQueryAAINetworkId(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -437,7 +437,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                        String aai_endpoint = execution.getVariable("URN_aai_endpoint")
                        AaiUtil aaiUriUtil = new AaiUtil(this)
                        String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
-                       String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=1"
+                       String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all"
                        utils.logAudit(requeryIdAAIRequest)
                        execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest)
                        utils.log("DEBUG", " UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest, isDebugEnabled)
@@ -498,7 +498,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void callRESTQueryAAINetworkVpnBinding(Execution execution) {
+       public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -539,9 +539,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                                        if (aai_uri == null || aai_uri == "") {
                                                // using value of 'related-link' from response
                                                if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') {
-                                                   queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1)
+                                                   queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all"
                                                } else {
-                                                   queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i]
+                                                   queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all"
                                                }
 
                                        } else {
@@ -550,7 +550,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                                                if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') {
                                                        vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1)
                                                }
-                                           queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId
+                                           queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all"
                                        }
 
                                        utils.logAudit(queryVpnBindingAAIRequest)
@@ -570,9 +570,19 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                                                utils.log("DEBUG", " AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled)
 
                                                String routeTarget = ""
-                                               if (utils.nodeExists(aaiResponseAsString, "global-route-target")) {
-                                                       routeTarget  = utils.getNodeText1(aaiResponseAsString, "global-route-target")
-                                                       routeTargets += "<routeTargets>" + routeTarget + "</routeTargets>" + '\n'
+                                               String routeRole = ""
+                                               if (utils.nodeExists(aaiResponseAsString, "route-targets")) {
+                                                       String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false)
+                                                       def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets)
+                                                       def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"}
+                                                       for (j in 0..aaiRouteTarget.size()-1) {
+                                                               routeTarget  = utils.getNodeText1(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target")
+                                                               routeRole  = utils.getNodeText1(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role")
+                                                               routeTargets += "<routeTargets>" + '\n' +
+                                                                               " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' +
+                                                                                               " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' +
+                                                                                               "</routeTargets>" + '\n'
+                                                       }
                                                }
 
                                        } else {
@@ -632,7 +642,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void callRESTQueryAAINetworkPolicy(Execution execution) {
+       public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -673,9 +683,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                                        if (aai_uri == null || aai_uri == "") {
                                                // using value of 'related-link' from response
                                                if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') {
-                                                       queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1)
+                                                       queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all"
                                                } else {
-                                                       queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i]
+                                                       queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all"
                                                }
                                        } else {
                                                // using uri value in URN mapping
@@ -684,7 +694,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                                                if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') {
                                                        networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1)
                                                }
-                                               queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId
+                                               queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all"
 
                                        }
 
@@ -768,7 +778,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void callRESTQueryAAINetworkTableRef(Execution execution) {
+       public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -809,9 +819,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                                        if (aai_uri == null || aai_uri == "") {
                                                // using value of 'related-link' from response
                                                if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') {
-                                                       queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1)
+                                                       queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all"
                                                } else {
-                                                       queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i]
+                                                       queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all"
                                                }
                                        } else {
                                                // using uri value in URN mapping
@@ -820,7 +830,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                                                if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') {
                                                        networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1)
                                                }
-                                               queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId
+                                               queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all"
 
                                        }
 
@@ -904,7 +914,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
        
-       public void callRESTUpdateContrailAAINetwork(Execution execution) {
+       public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -922,7 +932,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                        String aai_endpoint = execution.getVariable("URN_aai_endpoint")
                        AaiUtil aaiUriUtil = new AaiUtil(this)
                        String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
-                       String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=1"
+                       String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all"
 
                        utils.logAudit(updateContrailAAIUrlRequest)
                        execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest)
@@ -984,7 +994,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void prepareUpdateNetworkRequest (Execution execution) {
+       public void prepareUpdateNetworkRequest (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -1024,7 +1034,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void prepareSDNCRequest (Execution execution) {
+       public void prepareSDNCRequest (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -1069,7 +1079,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
        //     Post or Validate Response Section
        // **************************************************
 
-       public void validateUpdateNetworkResponse (Execution execution) {
+       public void validateUpdateNetworkResponse (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -1142,7 +1152,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void validateSDNCResponse (Execution execution) {
+       public void validateSDNCResponse (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -1178,7 +1188,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
        }
 
 
-       public void postProcessResponse (Execution execution) {
+       public void postProcessResponse (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -1230,7 +1240,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void prepareSDNCRollbackRequest (Execution execution) {
+       public void prepareSDNCRollbackRequest (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix", Prefix)
 
@@ -1264,7 +1274,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
 
        }
 
-       public void prepareRollbackData(Execution execution) {
+       public void prepareRollbackData(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix",Prefix)
                
@@ -1300,7 +1310,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                
        }
        
-       public void prepareSuccessRollbackData(Execution execution) {
+       public void prepareSuccessRollbackData(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix",Prefix)
                
@@ -1308,7 +1318,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                
                try {
                        
-                       if (execution.getVariable("sdncVersion") == '1702') {
+                       if (execution.getVariable("sdncVersion") != '1610') {
                                // skip: 1702 for 'changeassign' or equivalent not yet defined in SNDC, so no rollback.
                        } else {
                                prepareSDNCRollbackRequest(execution)
@@ -1342,7 +1352,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
                
        }
        
-       public void setExceptionFlag(Execution execution){
+       public void setExceptionFlag(DelegateExecution execution){
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix",Prefix)
                
@@ -1372,7 +1382,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
        //     Build Error Section
        // *******************************
 
-       public void processJavaException(Execution execution){
+       public void processJavaException(DelegateExecution execution){
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                execution.setVariable("prefix",Prefix)
                try{