From 8661255afca19d7ef0750288c1a905e0bf89599a Mon Sep 17 00:00:00 2001 From: aosull01 Date: Fri, 1 Feb 2019 17:33:45 +0000 Subject: node query for service instance query Change-Id: I7147f76b65a02e61f804ff5fd1304e47a983e092 Issue-ID: EXTAPI-194 Signed-off-by: aosull01 --- src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java | 14 +++++++------- .../org/onap/nbi/apis/serviceinventory/AaiClient.java | 12 +++++++++++- .../apis/serviceinventory/ServiceInventoryService.java | 15 ++------------- 3 files changed, 20 insertions(+), 21 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java b/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java index 2414c68..212242b 100644 --- a/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java +++ b/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java @@ -30,16 +30,16 @@ public final class OnapComponentsUrlPaths { // AAI public static final String AAI_GET_TENANTS_PATH = - "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/$onap.cloudOwner/$onap.lcpCloudRegionId/tenants"; - public static final String AAI_GET_CUSTOMER_PATH = "/aai/v11/business/customers/customer/"; + "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/$onap.cloudOwner/$onap.lcpCloudRegionId/tenants"; + public static final String AAI_GET_CUSTOMER_PATH = "/aai/v14/business/customers/customer/"; public static final String AAI_GET_SERVICES_FOR_CUSTOMER_PATH = - "/aai/v11/business/customers/customer/$customerId/service-subscriptions"; + "/aai/v14/business/customers/customer/$customerId/service-subscriptions"; public static final String AAI_PUT_SERVICE_FOR_CUSTOMER_PATH = - "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/"; - public static final String AAI_GET_SERVICE_FOR_CUSTOMER_PATH = - "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/service-instance/$serviceId"; + "/aai/v14/business/customers/customer/$customerId/service-subscriptions/service-subscription/"; + public static final String AAI_GET_SERVICE = + "/aai/v14/nodes/service-instances/service-instance/$serviceId"; public static final String AAI_GET_SERVICE_INSTANCES_PATH = - "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/"; + "/aai/v14/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/"; // MSO public static final String MSO_CREATE_SERVICE_INSTANCE_PATH = "/onap/so/infra/serviceInstantiation/v7/serviceInstances/"; diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java index 391cf41..ebb5144 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java @@ -57,7 +57,7 @@ public class AaiClient extends BaseClient { @PostConstruct private void setUpAndlogAAIUrl() { - aaiServiceUrl= new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_FOR_CUSTOMER_PATH).toString(); + aaiServiceUrl= new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE).toString(); aaiServicesUrl= new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH).toString(); aaiServicesInstancesUrl= new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_INSTANCES_PATH).toString(); @@ -94,7 +94,17 @@ public class AaiClient extends BaseClient { } return null; } + + public Map getService(String serviceId) { + String callUrlFormated = aaiServiceUrl.replace("$serviceId", serviceId); + + ResponseEntity response = callApiGet(callUrlFormated, buildRequestHeaderForAAI()); + if (response != null && response.getStatusCode().equals(HttpStatus.OK)) { + return (LinkedHashMap) response.getBody(); + } + return null; + } public Map getVNF(String relatedLink) { diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java index 1564e9c..57bb0f9 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java @@ -48,24 +48,13 @@ public class ServiceInventoryService { public Map get(String serviceId, MultiValueMap params) { - String clientId = params.getFirst("relatedParty.id"); - String serviceSpecId = params.getFirst("serviceSpecification.id"); - String serviceSpecName = params.getFirst("serviceSpecification.name"); - - if (StringUtils.isEmpty(serviceSpecId) && StringUtils.isEmpty(serviceSpecName)) { - throw new BackendFunctionalException(HttpStatus.NOT_FOUND, - "serviceSpecName or serviceSpecId must be provided","serviceSpecName or serviceSpecId must be provided"); - } - - String customerId = getCustomerId(clientId); - String serviceName = getServiceName(serviceSpecName, serviceSpecId); - Map serviceResponse = aaiClient.getCatalogService(customerId, serviceName, serviceId); + + Map serviceResponse = aaiClient.getService(serviceId); if (serviceResponse != null) { addVnfsToResponse(serviceResponse); LinkedHashMap serviceInventoryResponse = (LinkedHashMap) getServiceInventoryJsonTransformer.transform(serviceResponse); - addRelatedPartyId(customerId, serviceInventoryResponse); return serviceInventoryResponse; } else { throw new BackendFunctionalException(HttpStatus.NOT_FOUND, "no catalog service found","no catalog service found"); -- cgit 1.2.3-korg