aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2021-01-05 19:22:26 +0000
committerGerrit Code Review <gerrit@onap.org>2021-01-05 19:22:26 +0000
commit88f5917edae8c50ddfbe9b0538c2e33502bf50a3 (patch)
treebaabed103156da11ca693b6e434706dbc180b4a0 /mso-catalog-db/src/main/java
parentef992713f2ab47facf2eea820cbcfad0a9bcbd4b (diff)
parent8bc7057f9b23555ba78c9f656743c57fa3d62a64 (diff)
Merge "Use the timeout from the heat templates for"
Diffstat (limited to 'mso-catalog-db/src/main/java')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java23
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java3
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);