diff options
author | Boslet, Cory <cory.boslet@att.com> | 2020-11-19 18:10:56 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2021-01-05 10:38:41 -0500 |
commit | 8bc7057f9b23555ba78c9f656743c57fa3d62a64 (patch) | |
tree | c0ee0e9e8043c22d4a7d9778645b621b43603a4b /mso-catalog-db/src | |
parent | e036ebd43a0b58eda96b2546290bba2189bb3824 (diff) |
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) <mb388a@att.com>
Change-Id: If633f4f49d88eb797020b7d72c6edd0fbee0926c
Diffstat (limited to 'mso-catalog-db/src')
2 files changed, 25 insertions, 1 deletions
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<NetworkResource */ @Query(value = "SELECT * FROM network_resource WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true) - NetworkResource findFirstByModelNameOrderByModelVersionDesc(String modelName); + NetworkResource findFirstByModelNameOrderByModelVersionDesc(@Param("modelName") String modelName); NetworkResource findResourceByModelUUID(String modelUUID); |