From 8bc7057f9b23555ba78c9f656743c57fa3d62a64 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory" Date: Thu, 19 Nov 2020 18:10:56 -0500 Subject: Use the timeout from the heat templates for Use the timeout from the heat templates for polling Removed unused imports and code from base Added to get timeout from the rest client Fixed unit test for polling to account for changes Issue-ID: SO-3397 Signed-off-by: Benjamin, Max (mb388a) Change-Id: If633f4f49d88eb797020b7d72c6edd0fbee0926c --- .../onap/so/db/catalog/client/CatalogDbClient.java | 23 ++++++++++++++++++++++ .../data/repository/NetworkResourceRepository.java | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'mso-catalog-db/src/main/java/org') diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index ef90dd6984..91cfb00911 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -47,6 +47,7 @@ import org.onap.so.db.catalog.beans.HomingInstance; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkRecipe; +import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -98,6 +99,7 @@ public class CatalogDbClient { private static final String RAINY_DAY_HANDLER_MACRO = "/rainy_day_handler_macro"; private static final String NORTHBOUND_REQUEST_REF_LOOKUP = "/northbound_request_ref_lookup"; private static final String NETWORK_RESOURCE_CUSTOMIZATION = "/networkResourceCustomization"; + private static final String NETWORK_RESOURCE = "/networkResource"; private static final String COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION = "/collectionResourceInstanceGroupCustomization"; private static final String VNFC_INSTANCE_GROUP_CUSTOMIZATION = "/vnfcInstanceGroupCustomization"; @@ -223,6 +225,7 @@ public class CatalogDbClient { private String vnfResourceURI; private String networkCollectionResourceCustomizationURI; private String networkResourceCustomizationURI; + private String networkResourceURI; private String collectionNetworkResourceCustomizationURI; private String instanceGroupURI; private String cloudifyManagerURI; @@ -375,6 +378,7 @@ public class CatalogDbClient { networkCollectionResourceCustomizationURI = endpoint + NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; networkResourceCustomizationURI = endpoint + NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; + networkResourceURI = endpoint + NETWORK_RESOURCE + SEARCH; collectionNetworkResourceCustomizationURI = endpoint + COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR; @@ -607,6 +611,25 @@ public class CatalogDbClient { return networkResourceCustomization; } + public NetworkResource getNetworkResourceByModelName(String networkType) { + if (Strings.isNullOrEmpty(networkType)) { + throw new EntityNotFoundException("networkType passed as Null or Empty String"); + } + try { + HttpEntity entity = getHttpEntity(); + return restTemplate.exchange( + UriBuilder.fromUri(networkResourceURI + "/findFirstByModelNameOrderByModelVersionDesc") + .queryParam("modelName", networkType).build(), + HttpMethod.GET, entity, NetworkResource.class).getBody(); + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException("Unable to find NetworkResource By networkType " + networkType); + } + throw e; + } + } + + public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) { BuildingBlockDetail buildingBlockDetail = diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java index 42d107c1ff..30f3df7110 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java @@ -23,6 +23,7 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.NetworkResource; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; @@ -38,7 +39,7 @@ public interface NetworkResourceRepository extends JpaRepository