diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
5 files changed, 2 insertions, 1229 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index f1eab6601b..103326a693 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -22,17 +22,12 @@ package org.onap.so.bpmn.common.scripts import org.json.JSONObject; import org.json.JSONArray; -import org.json.XML import org.onap.logging.ref.slf4j.ONAPLogConstants import org.onap.so.bpmn.core.UrnPropertiesReader; import org.springframework.web.util.UriUtils; import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient -import groovy.json.JsonBuilder -import groovy.json.JsonSlurper -import groovy.util.slurpersupport.GPathResult -import groovy.xml.QName; import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response @@ -57,365 +52,6 @@ class CatalogDbUtils { JsonUtils jsonUtils = new JsonUtils() static private String defaultDbAdapterVersion = "v2" - public JSONArray getAllNetworksByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - networksList = responseJson.getJSONArray("serviceNetworks") - } - else { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - networksList = responseJson.getJSONArray("serviceNetworks") - } - else { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - networksList = responseJson.getJSONArray("serviceNetworks") - } - else { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByNetworkModelCustomizationUuid(DelegateExecution execution, String networkModelCustomizationUuid) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByNetworkModelCustomizationUuid(DelegateExecution execution, String networkModelCustomizationUuid, String catalogUtilsVersion) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - networksList = responseJson.getJSONArray("serviceNetworks") - } - else { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByNetworkType(DelegateExecution execution, String networkType) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - public JSONArray getAllNetworksByNetworkType(DelegateExecution execution, String networkType, String catalogUtilsVersion) { - JSONArray networksList = null - String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - networksList = responseJson.getJSONArray("serviceNetworks") - } - else { - networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return networksList - } - - - public JSONArray getAllVnfsByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { - JSONArray vnfsList = null - String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllVnfsByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - vnfsList = responseJson.getJSONArray("serviceVnfs") - } - else { - vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllVnfsByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { - JSONArray vnfsList = null - String endPoint ="/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllVnfsByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - vnfsList = responseJson.getJSONArray("serviceVnfs") - } - else { - vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - vnfsList = responseJson.getJSONArray("serviceVnfs") - } - else { - vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - public JSONArray getAllVnfsByVnfModelCustomizationUuid(DelegateExecution execution, String vnfModelCustomizationUuid) { JSONArray vnfsList = null String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8") @@ -436,33 +72,6 @@ class CatalogDbUtils { return vnfsList } - /** - * This method gets a all vnfs for a particular - * service from the catalog database using the - * service model's model name. - * - * @param catalogDbEndpoint - * @param serviceModelModelName - * @return vnfsList * - * - */ - public JSONArray getAllVnfsByServiceModelModelName(DelegateExecution execution, String serviceModelModelName) { - JSONArray vnfsList = null - String endPoint = "/serviceVnfs?serviceModelName=" + UriUtils.encode(serviceModelModelName, "UTF-8") - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", defaultDbAdapterVersion) - } - }catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - return vnfsList - } - public JSONArray getAllVnfsByVnfModelCustomizationUuid(DelegateExecution execution, String vnfModelCustomizationUuid, String catalogUtilsVersion) { JSONArray vnfsList = null String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8") @@ -489,263 +98,6 @@ class CatalogDbUtils { return vnfsList } - /** - * This method gets a single vf module from - * the catalog database using the vf module's - * model name. It returns that vf module as - * a JSONObject - * - * @param catalogDbEndpoint - * @param vfModuleModelName - * @return vfModule - */ - public JSONObject getVfModuleByVfModuleModelName(DelegateExecution execution, String vfModuleModelName) { - JSONObject vfModule = null - String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8") - try{ - msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1") - } - } - catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vfModule - } - - /** - * This method gets a single vf module from - * the catalog database using the vf module's - * model name. It returns that vf module as - * a JSONObject - * - * @param catalogDbEndpoint - * @param vfModuleModelName - * @param catalogUtilsVersion - * @return vfModules - */ - public JSONObject getVfModuleByVfModuleModelName(DelegateExecution execution, String vfModuleModelName, String catalogUtilsVersion) { - JSONObject vfModule = null - String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8") - try{ - msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1") - } - } - catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vfModule - } - - - public JSONArray getAllottedResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { - JSONArray vnfsList = null - String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllottedResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null - String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - vnfsList = responseJson.getJSONArray("serviceAllottedResources") - } - else { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllottedResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { - JSONArray vnfsList = null - String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllottedResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - vnfsList = responseJson.getJSONArray() - } - else { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getStackTrace()); - throw e - } - - return vnfsList - } - - public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - vnfsList = responseJson.getJSONArray("serviceAllottedResources") - } - else { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - - public JSONArray getAllottedResourcesByArModelCustomizationUuid(DelegateExecution execution, String arModelCustomizationUuid) { - JSONArray vnfsList = null - String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONArray getAllottedResourcesByArModelCustomizationUuid(DelegateExecution execution, String arModelCustomizationUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null - String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - JSONObject responseJson = new JSONObject(catalogDbResponse) - vnfsList = responseJson.getJSONArray("serviceAllottedResources") - } - else { - vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion) - } - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return vnfsList - } - - public JSONObject getServiceResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { - JSONObject resources = null - String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - - resources = parseServiceResourcesJson(catalogDbResponse, "v1") - } - - } - catch (Exception e) { - utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) - throw e - } - - return resources - } - public JSONObject getServiceResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { JSONObject resources = null String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") @@ -769,26 +121,6 @@ class CatalogDbUtils { return resources } - public JSONObject getServiceResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { - JSONObject resources = null - String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - - resources = parseServiceResourcesJson(catalogDbResponse, "v1") - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return resources - } - public String getServiceResourcesByServiceModelInvariantUuidString(DelegateExecution execution, String serviceModelInvariantUuid) { String resources = null String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") @@ -833,27 +165,6 @@ class CatalogDbUtils { return resources } - - public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { - JSONObject resources = null - String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - //TODO this is wrong - resources = parseServiceResourcesJson(catalogDbResponse) - } - - } - catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - throw e - } - - return resources - } - public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { JSONObject resources = null String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") @@ -878,8 +189,6 @@ class CatalogDbUtils { return resources } - - private JSONArray parseNetworksJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) { JSONArray modelInfos = null @@ -1004,58 +313,6 @@ class CatalogDbUtils { return modelInfos } - /** - * This method parses a Vf Module from the - * Vf Modules array - * - * @param catalogDbResponse - * @param arrayName - * @param catalogUtilsVersion - * @return vfModulelJson - */ - private JSONObject parseVfModuleJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) { - JSONObject vfModulelJson = new JSONObject() - msoLogger.debug("Started Parse Vf Module Json") - try { - JSONObject responseJson = new JSONObject(catalogDbResponse) - JSONArray vfModules = responseJson.getJSONArray(arrayName) - if(vfModules != null){ - JSONObject vfModuleInfo = new JSONObject() - for (int i = 0; i < vfModules.length(); i++) { - JSONObject vfModule = vfModules.getJSONObject(i) - JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion) - vfModulelJson.put("modelInfo", vfModuleModelInfo) - String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type") - vfModulelJson.put("vfModuleType", vfModuleType) - switch(catalogUtilsVersion) { - case "v1": - Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase") - if (isBase.intValue() == 1) { - vfModulelJson.put("isBase", "true") - } - else { - vfModulelJson.put("isBase", "false") - } - break - default: - boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase") - vfModulelJson.put("isBase", isBase) - break - } - String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label") - vfModulelJson.put("vfModuleLabel", vfModuleLabel) - Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount") - vfModulelJson.put("initialCount", initialCount.intValue()) - } - } - msoLogger.debug("Completed Parsing Vf Module: " + vfModulelJson.toString()) - }catch (Exception e){ - msoLogger.debug("Exception while parsing Vf Modules from Catalog DB Response: " + e.message) - } - - return vfModulelJson - } - private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) { JSONArray modelInfos = null @@ -1108,37 +365,9 @@ class CatalogDbUtils { return modelInfos } - //TODO this is wrong - private JSONObject parseServiceResourcesJson (String catalogDbResponse) { - JSONObject serviceResources = new JSONObject() - String catalogUtilsVersion = "v1" - - try { - // Create array of jsons - - JSONObject responseJson = new JSONObject(catalogDbResponse) - JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources") - JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "vnfResources", catalogUtilsVersion) - serviceResources.put("vnfs", vnfsArray) - JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "networkResourceCustomization", catalogUtilsVersion) - serviceResources.put("networks", networksArray) - JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "allottedResourceCustomization", catalogUtilsVersion) - serviceResources.put("allottedResources", allottedResourcesArray) - - String serviceResourcesString = serviceResources.toString() - msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString) - - } catch (Exception e) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); - } - - return serviceResources - } - private JSONObject parseServiceResourcesJson (String catalogDbResponse, String catalogUtilsVersion) { JSONObject serviceResources = new JSONObject() JSONObject serviceResourcesObject = new JSONObject() - String serviceResourcesString = "" try { // Create array of jsons @@ -1154,9 +383,7 @@ class CatalogDbUtils { JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "serviceAllottedResources", catalogUtilsVersion) serviceResources.put("serviceAllottedResources", allottedResourcesArray) serviceResourcesObject.put("serviceResources", serviceResources) - - serviceResourcesString = serviceResourcesObject.toString() - msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString) + msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesObject.toString()) } catch (Exception e) { msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy index f9ddd0d430..2f240fb70d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy @@ -287,14 +287,6 @@ class MsoUtils { return null } } - def getRelationshipVal(node, name){ - try{ - return node.'**'.find {it.'relationship-key'.text() == name}.'relationship-value'.text() - }catch(Exception e){ - return null - } - } - def log(logmode,logtxt,isDebugLogEnabled="false"){ if ("INFO"==logmode) { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy index 27d067dfc1..41db603cdf 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy @@ -26,7 +26,6 @@ import org.onap.aai.domain.yang.L3Network import org.onap.aai.domain.yang.Subnet import org.onap.aai.domain.yang.Subnets import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.logger.MsoLogger import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node @@ -44,8 +43,6 @@ import javax.xml.transform.stream.StreamResult * This groovy class supports the any Network processes that need the methods defined here. */ class NetworkUtils { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NetworkUtils.class); - public MsoUtils utils = new MsoUtils() private AbstractServiceTaskProcessor taskProcessor @@ -283,187 +280,6 @@ class NetworkUtils { } /** - * This method returns the string for Create Volume Request payload - * @param groupId the volume-group-id - * @param volumeName the volume-group-name - * @param vnfType the vnf-type - * @param tenantId the value of relationship-key 'tenant.tenant-id' - * @return String request payload - */ - def String CreateNetworkVolumeRequest(groupId, volumeName, vnfType, tenantId) { - - String requestPayload = - """<volume-group xmlns="http://org.onap.so/v6"> - <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id> - <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name> - <heat-stack-id></heat-stack-id> - <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - <orchestration-status>Pending</orchestration-status> - <relationship-list> - <relationship> - <related-to>tenant</related-to> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>${MsoUtils.xmlEscape(tenantId)}</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </volume-group>""" - - return requestPayload - } - - /** - * This method returns the string for Update Volume Request payload - * @param requeryAAIVolGrpNameResponse the response of query volume group name (in AAI) - * @param heatStackId the value of heat stack id - * @return String request payload - */ - def String updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId, namespace, modelCustomizationId) { - String requestPayload = "" - if (requeryAAIVolGrpNameResponse != null) { - def groupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id") - def volumeName = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-name") - def vnfType = utils.getNodeText(requeryAAIVolGrpNameResponse, "vnf-type") - def resourceVersion = utils.getNodeText(requeryAAIVolGrpNameResponse, "resource-version") - def relationshipList = "" - if (utils.nodeExists(requeryAAIVolGrpNameResponse, "relationship")) { - relationshipList = rebuildRelationship(requeryAAIVolGrpNameResponse) - } - - requestPayload = - """<volume-group xmlns="${namespace}"> - <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id> - <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name> - <heat-stack-id>${MsoUtils.xmlEscape(heatStackId)}</heat-stack-id> - <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - <orchestration-status>Active</orchestration-status> - <resource-version>${MsoUtils.xmlEscape(resourceVersion)}</resource-version> - <vf-module-model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</vf-module-model-customization-id> - ${relationshipList} - </volume-group>""" - } - - return requestPayload - } - - - /** - * This method returns the string for Update Volume Request payload - * @param requeryAAIVolGrpNameResponse the response of query volume group name (in AAI) - * @param heatStackId the value of heat stack id - * @return String request payload - */ - def String UpdateNetworkVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId) { - String requestPayload = "" - if (requeryAAIVolGrpNameResponse != null) { - def groupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id") - def volumeName = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-name") - def vnfType = utils.getNodeText(requeryAAIVolGrpNameResponse, "vnf-type") - def resourceVersion = utils.getNodeText(requeryAAIVolGrpNameResponse, "resource-version") - def relationshipList = "" - if (utils.nodeExists(requeryAAIVolGrpNameResponse, "relationship")) { - relationshipList = rebuildRelationship(requeryAAIVolGrpNameResponse) - } - - requestPayload = - """<volume-group xmlns="http://org.onap.so/v6"> - <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id> - <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name> - <heat-stack-id>${MsoUtils.xmlEscape(heatStackId)}</heat-stack-id> - <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - <orchestration-status>Active</orchestration-status> - <resource-version>${MsoUtils.xmlEscape(resourceVersion)}</resource-version> - ${relationshipList} - </volume-group>""" - } - - return requestPayload - } - - /** - * This method returns the string for Create Contrail Network payload - * @param requeryIdAAIResponse the response from AAI query by id - * @param createNetworkResponse the response of create network - * @return String contrailNetworkCreatedUpdate - */ - def ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) { - - String contrailNetworkCreatedUpdate = "" - if(requeryIdAAIResponse!=null && createNetworkResponse!=null) { - - def l3Network = utils.getNodeXml(requeryIdAAIResponse, "l3-network", false).replace("tag0:","").replace(":tag0","") - def createNetworkContrailResponse = "" - if (utils.nodeExists(createNetworkResponse, 'createNetworkResponse')) { - createNetworkContrailResponse = utils.getNodeXml(createNetworkResponse, "createNetworkResponse", false).replace("tag0:","").replace(":tag0","") - } else { - createNetworkContrailResponse = utils.getNodeXml(createNetworkResponse, "updateNetworkContrailResponse", false).replace("tag0:","").replace(":tag0","") - } - - // rebuild network - def networkList = ["network-id", "network-name", "network-type", "network-role", "network-technology", "neutron-network-id", "is-bound-to-vpn", "service-id", "network-role-instance", "resource-version", "resource-model-uuid", "orchestration-status", "heat-stack-id", "mso-catalog-key", "contrail-network-fqdn", - "physical-network-name", "is-provider-network", "is-shared-network", "is-external-network"] - String rebuildNetworkElements = buildNetworkElements(l3Network, createNetworkContrailResponse, networkList) - - // rebuild 'subnets' - def rebuildSubnetList = "" - if (utils.nodeExists(requeryIdAAIResponse, 'subnet')) { - rebuildSubnetList = buildSubnets(requeryIdAAIResponse, createNetworkResponse) - } - - // rebuild 'segmentation-assignments' - def rebuildSegmentationAssignments = "" - if (utils.nodeExists(requeryIdAAIResponse, 'segmentation-assignments')) { - List elementList = ["segmentation-id", "resource-version"] - if (utils.nodeExists(requeryIdAAIResponse, 'segmentation-assignment')) { // new tag - rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "segmentation-assignments", "segmentation-assignment", elementList) - } else { - rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "", "segmentation-assignments", elementList) - } - } - - // rebuild 'ctag-assignments' / rebuildCtagAssignments - def rebuildCtagAssignmentsList = "" - if (utils.nodeExists(requeryIdAAIResponse, 'ctag-assignment')) { - rebuildCtagAssignmentsList = rebuildCtagAssignments(requeryIdAAIResponse) - } - - // rebuild 'relationship' - def relationshipList = "" - if (utils.nodeExists(requeryIdAAIResponse, 'relationship-list')) { - String rootRelationshipData = getFirstNodeXml(requeryIdAAIResponse, "relationship-list").drop(38).trim().replace("tag0:","").replace(":tag0","") - if (utils.nodeExists(rootRelationshipData, 'relationship')) { - relationshipList = rebuildRelationship(rootRelationshipData) - } - } - - //Check for optional contrail network fqdn within CreateNetworkResponse - String contrailNetworkFQDN - if(utils.nodeExists(createNetworkResponse, "contrail-network-fqdn")){ - contrailNetworkFQDN = utils.getNodeXml(createNetworkResponse, "contrail-network-fqdn") - contrailNetworkFQDN = utils.removeXmlNamespaces(contrailNetworkFQDN) - contrailNetworkFQDN = utils.removeXmlPreamble(contrailNetworkFQDN) - }else{ - contrailNetworkFQDN = "" - } - - contrailNetworkCreatedUpdate = - """<l3-network xmlns="${schemaVersion}"> - ${rebuildNetworkElements} - ${rebuildSubnetList} - ${rebuildSegmentationAssignments} - ${rebuildCtagAssignmentsList} - ${relationshipList} - ${contrailNetworkFQDN} - </l3-network>""".trim() - - } - return contrailNetworkCreatedUpdate - } - - - - /** * This method returns the value for the name paramName. * Ex: <network-params> * <param name="shared">1</param> @@ -570,56 +386,6 @@ class NetworkUtils { } /** - * This method returns the uri value for the vpn bindings. - * Return the a list of value of vpn binding in the <related-link> string. - * Ex. - * <relationship-list> - * <relationship> - * <related-to>vpn-binding</related-to> - * <related-link>https://aai-app-e2e.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> - * <relationship-data> - * <relationship-key>vpn-binding.vpn-id</relationship-key> - * <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value> - * </relationship-data> - * </relationship> - * <relationship> - * <related-to>vpn-binding</related-to> - * <related-link>https://aai-ext1.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/</related-link> - * <relationship-data> - * <relationship-key>vpn-binding.vpn-id</relationship-key> - * <relationship-value>24a4b507-853a-4a38-99aa-05fcc54be24d</relationship-value> - * </relationship-data> - * <related-to-property> - * <property-key>vpn-binding.vpn-name</property-key> - * <property-value>oam_protected_net_6_MTN5_msotest1</property-value> - * </related-to-property> - * </relationship> - * @param xmlInput the XML document - * @return a list of vpn binding values - * ex: ['aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', 'aai/v6/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/'] - * - **/ - def getVnfBindingObject(xmlInput) { - //def rtn = null - List rtn = [] - if (xmlInput!=null) { - def relationshipList = getListWithElements(xmlInput, 'relationship') - def relationshipListSize = relationshipList.size() - if (relationshipListSize > 0) { - for (i in 0..relationshipListSize-1) { - def relationshipXml = XmlUtil.serialize(relationshipList[i]) - if (utils.getNodeText(relationshipXml, 'related-to') == "vpn-binding") { - def relatedLink = utils.getNodeText(relationshipXml, 'related-link') - if (relatedLink != null || relatedLink != "") { - rtn.add(relatedLink.substring(relatedLink.indexOf("/aai/"), relatedLink.length())) - } - } - } - } - } - return rtn - } - /** * similar to VNF bindings method * @param xmlInput the XML document * @return a list of network policy values @@ -845,40 +611,6 @@ class NetworkUtils { return xmlNetwork } - def buildSubnets(requeryIdAAIResponse, createNetworkResponse) { - def rebuildingSubnets = "" - if (requeryIdAAIResponse != null && utils.nodeExists(requeryIdAAIResponse, 'subnets')) { - def subnetIdMapValue = "" - def subnetsGroup = utils.getNodeXml(requeryIdAAIResponse, "subnets", false) - def subnetsData = new XmlSlurper().parseText(subnetsGroup) - rebuildingSubnets += "<subnets>" - try { - def subnets = subnetsData.'**'.findAll {it.name() == "subnet"} - def subnetsSize = subnets.size() - for (i in 0..subnetsSize-1) { - def subnet = subnets[i] - def subnetXml = XmlUtil.serialize(subnet) - def orchestrationStatus = utils.getNodeText(subnetXml, "orchestration-status") - if (orchestrationStatus == "PendingDelete" || orchestrationStatus == "pending-delete") { - // skip, do not include in processing, remove!!! - } else { - def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "subnet-role", "resource-version", "subnet-name", "ip-assignment-direction", "host-routes"] - rebuildingSubnets += buildSubNetworkElements(subnetXml, createNetworkResponse, subnetList, "subnet") - } - } - if (utils.nodeExists(subnetsData, 'relationship')) { - rebuildingSubnets = rebuildRelationship(requeryIdAAIResponse) - } - - } catch (Exception ex) { - // error - } finally { - rebuildingSubnets += "</subnets>" - } - } - return rebuildingSubnets - } - def buildSubnets(L3Network network) { def rebuildingSubnets = "" Subnets subnets = network.getSubnets() @@ -1056,74 +788,6 @@ class NetworkUtils { } - // rebuild ctag-assignments - def rebuildCtagAssignments(xmlInput) { - def rebuildingCtagAssignments = "" - if (xmlInput!=null) { - def ctagAssignmentsData = new XmlSlurper().parseText(xmlInput) - rebuildingCtagAssignments += "<ctag-assignments>" - def ctagAssignments = ctagAssignmentsData.'**'.findAll {it.name() == "ctag-assignment"} - def ctagAssignmentsSize = ctagAssignments.size() - for (i in 0..ctagAssignmentsSize-1) { - def ctagAssignment = ctagAssignments[i] - def ctagAssignmentXml = XmlUtil.serialize(ctagAssignment) - rebuildingCtagAssignments += "<ctag-assignment>" - List elementList = ["vlan-id-inner", "resource-version"] - rebuildingCtagAssignments += buildXMLElements(ctagAssignmentXml, "" , "", elementList) - if (utils.nodeExists(ctagAssignmentXml, 'relationship')) { - rebuildingCtagAssignments += rebuildRelationship(ctagAssignmentXml) - } - rebuildingCtagAssignments += "</ctag-assignment>" - } - rebuildingCtagAssignments += "</ctag-assignments>" - } - return rebuildingCtagAssignments - } - - // rebuild 'relationship-list' - def rebuildRelationship(xmlInput) { - def rebuildingSubnets = "" - if (xmlInput!=null) { - def subnetsData = new XmlSlurper().parseText(xmlInput) - rebuildingSubnets += "<relationship-list>" - def relationships = subnetsData.'**'.findAll {it.name() == "relationship"} - def relationshipsSize = relationships.size() - for (i in 0..relationshipsSize-1) { - def relationship = relationships[i] - def relationshipXml = XmlUtil.serialize(relationship) - rebuildingSubnets += "<relationship>" - def relationshipList = ["related-to", "related-link"] - rebuildingSubnets += buildSubNetworkElements(relationshipXml, "", relationshipList, "") - if (utils.nodeExists(relationshipXml, 'relationship-data')) { - def relationshipDataXmlData = new XmlSlurper().parseText(relationshipXml) - def relationshipsData = relationshipDataXmlData.'**'.findAll {it.name() == "relationship-data"} - def relationshipsDataSize = relationshipsData.size() - for (j in 0..relationshipsDataSize-1) { - def relationshipData = relationshipsData[j] - def relationshipDataXml = XmlUtil.serialize(relationshipData) - def relationshipDataList = ["relationship-key", "relationship-value"] - rebuildingSubnets += buildXMLElements(relationshipDataXml, "", "relationship-data", relationshipDataList) - } - } - if (utils.nodeExists(relationshipXml, 'related-to-property')) { - def relationshipDataXmlData = new XmlSlurper().parseText(relationshipXml) - def relationshipsData = relationshipDataXmlData.'**'.findAll {it.name() == "related-to-property"} - def relationshipsDataSize = relationshipsData.size() - for (j in 0..relationshipsDataSize-1) { - def relationshipData = relationshipsData[j] - def relationshipDataXml = XmlUtil.serialize(relationshipData) - def relationshipDataList = ["property-key", "property-value"] - rebuildingSubnets += buildXMLElements(relationshipDataXml, "", "related-to-property", relationshipDataList) - } - } - - rebuildingSubnets += "</relationship>" - } - rebuildingSubnets += "</relationship-list>" - } - return rebuildingSubnets - } - def buildVlans(queryIdResponse) { def rebuildingSubnets = "<vlans>" def subnetsData = new XmlSlurper().parseText(queryIdResponse) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy index 6691a82352..014dfb40c5 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -223,74 +223,6 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { } } - - /** - * Check the Volume Group ID from the incoming update request against the Volume Group ID from the - * given VF Module. If they are equal or if they are both 'null', then that is acceptable and 'null' - * is returned. Otherwise a message describing how the values are unacceptable/incompatible is returned. - * - * @param origRequest Incoming update request with VF Module elements to be updated. - * @param vfModuleNode VF Module (as a Node) retrieved from AAI. - * @param isDebugLogEnabled Is DEBUG log enabled? - * @return 'null' if the Volume Group IDs are acceptable. Otherwise return a message describing how the - * values are unacceptable/incompatible. - */ - private String checkVolumeGroupId(String origRequest, Node vfModuleNode, String isDebugLogEnabled) { - def requestVolumeGroupId = utils.getNodeText(origRequest, 'volume-group-id') - def currVolumeGroupId = getCurrVolumeGroupId(vfModuleNode) - - msoLogger.debug('Check volume-group-id: volume-group-id in original request is \'' + requestVolumeGroupId + '\', volume-group-id from VF Module is \'' + currVolumeGroupId + '\'') - - def result = null - - if (requestVolumeGroupId == null) { - if (currVolumeGroupId == null) { - // This is OK - } else { - result = 'Cannot detach a volume group from an existing VF Module' - } - } else { - if (currVolumeGroupId == null) { - result = 'Cannot add a volume gruop to an existing VF Module' - } else { - if (!requestVolumeGroupId.equals(currVolumeGroupId)) { - result = 'Cannot change the volume group on an existing VF Module' - } - } - } - - return result - } - - /** - * Find and return the value of the Volume Group ID for the specified VF Module. If - * the value of the Volume Group ID cannot be found for any reason, 'null' is returned. - * - * @param vfModuleNode VF Module (as a Node) retrieved from AAI. - * @return the value of the Volume Group ID for the specified VF Module. If the - * value of the Volume Group ID cannot be found for any reason, 'null' is returned. - */ - private String getCurrVolumeGroupId(Node vfModuleNode) { - def Node relationshipList = utils.getChildNode(vfModuleNode, 'relationship-list') - if (relationshipList == null) { - return null - } - def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') - for (Node relationshipNode in relationships) { - def String relatedTo = utils.getChildNodeText(relationshipNode, 'related-to') - if ((relatedTo != null) && relatedTo.equals('volume-group')) { - def NodeList relationshipDataList = utils.getIdenticalChildren(relationshipNode, 'relationship-data') - for (Node relationshipDataNode in relationshipDataList) { - def String relationshipKey = utils.getChildNodeText(relationshipDataNode, 'relationship-key') - if ((relationshipKey != null) && relationshipKey.equals('volume-group.volume-group-id')) { - return utils.getChildNodeText(relationshipDataNode, 'relationship-value') - } - } - } - } - return null - } - /** * Generates a WorkflowException if the AAI query returns a response code other than 200. * diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy index fec140da33..c1cd42e893 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy @@ -20,16 +20,9 @@ package org.onap.so.bpmn.common.scripts; -import java.io.ObjectInputStream.BlockDataInputStream - -import java.io.ObjectInputStream.BlockDataInputStream - -//import groovy.util.Node; - import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory -import org.apache.commons.lang3.* import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node @@ -38,9 +31,6 @@ import org.xml.sax.InputSource import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger - - - public abstract class VfModuleBase extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VfModuleBase.class); @@ -195,39 +185,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } return entries } - - /** - * Extract the Tenant Id from the Volume Group information returned by AAI. - * - * @param volumeGroupXml Volume Group XML returned by AAI. - * @return the Tenant Id extracted from the Volume Group information. 'null' is returned if - * the Tenant Id is missing or could not otherwise be extracted. - */ - protected String getTenantIdFromVolumeGroup(String volumeGroupXml) { - def groovy.util.Node volumeGroupNode = xmlParser.parseText(volumeGroupXml) - def groovy.util.Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list') - if (relationshipList != null) { - def groovy.util.NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') - for (groovy.util.Node relationship in relationships) { - def groovy.util.Node relatedTo = utils.getChildNode(relationship, 'related-to') - if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) { - def groovy.util.NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data') - for (groovy.util.Node relationshipData in relationshipDataList) { - def groovy.util.Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key') - if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) { - def groovy.util.Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value') - if (relationshipValue != null) { - return relationshipValue.text() - } - } - } - } - } - } - return null - } - - + /* * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response * and puts them into the format expected by VNF adapter. |