AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / AaiUtil.groovy
index f5f011f..5a4b25d 100644 (file)
@@ -20,7 +20,7 @@
 \r
 package org.openecomp.mso.bpmn.common.scripts\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
 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;\r
 import org.openecomp.mso.rest.APIResponse;\r
 import org.openecomp.mso.rest.RESTClient\r
@@ -40,7 +40,7 @@ class AaiUtil {
                this.taskProcessor = taskProcessor\r
        }\r
 \r
-       public String getNetworkGenericVnfEndpoint(Execution execution) {\r
+       public String getNetworkGenericVnfEndpoint(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                String endpoint = execution.getVariable("URN_aai_endpoint")\r
                def uri = getNetworkGenericVnfUri(execution)\r
@@ -48,56 +48,56 @@ class AaiUtil {
                return endpoint + uri\r
        }\r
 \r
-       public String getNetworkGenericVnfUri(Execution execution) {\r
+       public String getNetworkGenericVnfUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'generic_vnf')\r
                taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getNetworkVpnBindingUri(Execution execution) {\r
+       public String getNetworkVpnBindingUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'vpn_binding')\r
                taskProcessor.logDebug('AaiUtil.getNetworkVpnBindingUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getNetworkPolicyUri(Execution execution) {\r
+       public String getNetworkPolicyUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'network_policy')\r
                taskProcessor.logDebug('AaiUtil.getNetworkPolicyUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getNetworkTableReferencesUri(Execution execution) {\r
+       public String getNetworkTableReferencesUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'route_table_reference')\r
                taskProcessor.logDebug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getNetworkVceUri(Execution execution) {\r
+       public String getNetworkVceUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'vce')\r
                taskProcessor.logDebug('AaiUtil.getNetworkVceUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getNetworkL3NetworkUri(Execution execution) {\r
+       public String getNetworkL3NetworkUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'l3_network')\r
                taskProcessor.logDebug('AaiUtil.getNetworkL3NetworkUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getBusinessCustomerUri(Execution execution) {\r
+       public String getBusinessCustomerUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'customer')\r
                taskProcessor.logDebug('AaiUtil.getBusinessCustomerUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       //public String getBusinessCustomerUriv7(Execution execution) {\r
+       //public String getBusinessCustomerUriv7(DelegateExecution execution) {\r
        //      def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
        //      //def uri = getUri(execution, BUSINESS_CUSTOMERV7)\r
        //      def uri = getUri(execution, 'Customer')\r
@@ -105,7 +105,7 @@ class AaiUtil {
        //      return uri\r
        //}\r
 \r
-       public String getCloudInfrastructureCloudRegionEndpoint(Execution execution) {\r
+       public String getCloudInfrastructureCloudRegionEndpoint(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                String endpoint = execution.getVariable("URN_aai_endpoint")\r
                def uri = getCloudInfrastructureCloudRegionUri(execution)\r
@@ -113,28 +113,28 @@ class AaiUtil {
                return endpoint + uri\r
        }\r
 \r
-       public String getCloudInfrastructureCloudRegionUri(Execution execution) {\r
+       public String getCloudInfrastructureCloudRegionUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'cloud_region')\r
                taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getCloudInfrastructureTenantUri(Execution execution) {\r
+       public String getCloudInfrastructureTenantUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'tenant')\r
                taskProcessor.logDebug('AaiUtil.getCloudInfrastructureTenantUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getSearchNodesQueryUri(Execution execution) {\r
+       public String getSearchNodesQueryUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'nodes_query')\r
                taskProcessor.logDebug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getSearchNodesQueryEndpoint(Execution execution) {\r
+       public String getSearchNodesQueryEndpoint(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                String endpoint = execution.getVariable("URN_aai_endpoint")\r
                def uri = getSearchNodesQueryUri(execution)\r
@@ -142,14 +142,14 @@ class AaiUtil {
                return endpoint + uri\r
        }\r
 \r
-       public String getSearchGenericQueryUri(Execution execution) {\r
+       public String getSearchGenericQueryUri(DelegateExecution execution) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def uri = getUri(execution, 'generic_query')\r
                taskProcessor.logDebug('AaiUtil.getSearchGenericQueryUri() - AAI URI: ' + uri, isDebugLogEnabled)\r
                return uri\r
        }\r
 \r
-       public String getVersion(Execution execution, resourceName, processKey) {\r
+       public String getVersion(DelegateExecution execution, resourceName, processKey) {\r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
 \r
                resourceName = resourceName.replaceAll('-', '_')\r
@@ -178,7 +178,7 @@ class AaiUtil {
                (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}")\r
        }\r
 \r
-       public String getUri(Execution execution, resourceName) {\r
+       public String getUri(DelegateExecution execution, resourceName) {\r
 \r
                def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
                def processKey = taskProcessor.getMainProcessKey(execution)\r
@@ -208,7 +208,7 @@ class AaiUtil {
                (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file')\r
        }\r
 \r
-       public String setNamespace(Execution execution) {\r
+       public String setNamespace(DelegateExecution execution) {\r
                def key = AAI_NAMESPACE_STRING_KEY\r
                aaiNamespace = execution.getVariable(key)\r
                if (aaiNamespace == null ) {\r
@@ -219,7 +219,7 @@ class AaiUtil {
        /**\r
         * This method can be used for getting the building namespace out of uri.\r
         *  NOTE: A getUri() method needs to be invoked first.\r
-        *        Alternative method is the getNamespaceFromUri(Execution execution, String uri)\r
+        *        Alternative method is the getNamespaceFromUri(DelegateExecution execution, String uri)\r
         * return namespace (plus version from uri)\r
         *\r
         * @param url\r
@@ -242,13 +242,13 @@ class AaiUtil {
 \r
        /**\r
         * This method can be used for building namespace with aai version out of uri.\r
-        *   NOTE: 2 arguments: Execution execution & String uri\r
+        *   NOTE: 2 arguments: DelegateExecution execution & String uri\r
         * @param execution\r
         * @param url\r
         *\r
         * @return namespace\r
         */\r
-       public String getNamespaceFromUri(Execution execution, String uri) {\r
+       public String getNamespaceFromUri(DelegateExecution execution, String uri) {\r
           String namespace = execution.getVariable(AAI_NAMESPACE_STRING_KEY)\r
           if (namespace == null ) {\r
                   (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + AAI_NAMESPACE_STRING_KEY + ' not defined in the MSO URN properties file')\r
@@ -293,7 +293,7 @@ class AaiUtil {
         * @return APIResponse\r
         *\r
         */\r
-       public APIResponse executeAAIGetCall(Execution execution, String url){\r
+       public APIResponse executeAAIGetCall(DelegateExecution execution, String url){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                taskProcessor.logDebug(" ======== STARTED Execute AAI Get Process ======== ", isDebugEnabled)\r
                APIResponse apiResponse = null\r
@@ -315,7 +315,7 @@ class AaiUtil {
                        taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled)\r
                }catch(Exception e){\r
                        taskProcessor.logDebug("Exception occured while executing AAI Get Call. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return apiResponse\r
        }\r
@@ -333,7 +333,7 @@ class AaiUtil {
         * @return APIResponse\r
         *\r
         */\r
-       public APIResponse executeAAIPutCall(Execution execution, String url, String payload){\r
+       public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                taskProcessor.logDebug( " ======== Started Execute AAI Put Process ======== ", isDebugEnabled)\r
                APIResponse apiResponse = null\r
@@ -354,7 +354,7 @@ class AaiUtil {
                        taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled)\r
                }catch(Exception e){\r
                        taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return apiResponse\r
        }\r
@@ -371,7 +371,7 @@ class AaiUtil {
         * @return APIResponse\r
         *\r
         */\r
-       public APIResponse executeAAIPatchCall(Execution execution, String url, String payload){\r
+       public APIResponse executeAAIPatchCall(DelegateExecution execution, String url, String payload){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                taskProcessor.logDebug( " ======== Started Execute AAI Patch Process ======== ", isDebugEnabled)\r
                APIResponse apiResponse = null\r
@@ -393,7 +393,7 @@ class AaiUtil {
                        taskProcessor.logDebug( "======== Completed Execute AAI Patch Process ======== ", isDebugEnabled)\r
                }catch(Exception e){\r
                        taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Patch Call. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return apiResponse\r
        }\r
@@ -410,7 +410,7 @@ class AaiUtil {
         * @return APIResponse\r
         *\r
         */\r
-       public APIResponse executeAAIDeleteCall(Execution execution, String url){\r
+       public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)\r
                APIResponse apiResponse = null\r
@@ -431,7 +431,7 @@ class AaiUtil {
                        taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)\r
                }catch(Exception e){\r
                        taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return apiResponse\r
        }\r
@@ -448,7 +448,7 @@ class AaiUtil {
         * @return APIResponse\r
         *\r
         */\r
-       public APIResponse executeAAIDeleteCall(Execution execution, String url, String payload, String authHeader){\r
+       public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url, String payload, String authHeader){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)\r
                APIResponse apiResponse = null\r
@@ -469,7 +469,7 @@ class AaiUtil {
                        taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)\r
                }catch(Exception e){\r
                        taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return apiResponse\r
        }\r
@@ -486,7 +486,7 @@ class AaiUtil {
         * @return APIResponse\r
         *\r
         */\r
-       public APIResponse executeAAIPostCall(Execution execution, String url, String payload){\r
+       public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled)\r
                APIResponse apiResponse = null\r
@@ -507,7 +507,7 @@ class AaiUtil {
                        taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)\r
                }catch(Exception e){\r
                        taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return apiResponse\r
        }\r
@@ -527,7 +527,7 @@ class AaiUtil {
         * @return APIResponse\r
         *\r
         */\r
-       public APIResponse executeAAIPostCall(Execution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){\r
+       public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled)\r
                APIResponse apiResponse = null\r
@@ -546,7 +546,7 @@ class AaiUtil {
                        taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)\r
                }catch(Exception e){\r
                        taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return apiResponse\r
        }\r
@@ -559,7 +559,7 @@ class AaiUtil {
         * @param backend - "PO" - real region, or "SDNC" - v2.5 (fake region).\r
         */\r
 \r
-       public String getAAICloudReqion(Execution execution, String url, String backend, inputCloudRegion){\r
+       public String getAAICloudReqion(DelegateExecution execution, String url, String backend, inputCloudRegion){\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                String regionId = ""\r
                try{\r
@@ -600,7 +600,7 @@ class AaiUtil {
                        }\r
                }catch(Exception e) {\r
                        taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled)\r
-                       throw new BpmnError("MSOWorkflowException")\r
+                       (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())\r
                }\r
                return regionId\r
        }\r
@@ -631,7 +631,7 @@ class AaiUtil {
         * @return moduleIndex\r
         *\r
         */\r
-       public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(Execution execution, String aaiVnfResponse, String key, String value) {\r
+       public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(DelegateExecution execution, String aaiVnfResponse, String key, String value) {\r
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
                if (aaiVnfResponse != null) {\r
                        String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules")\r