From aa859daa7e210a286aae0e496fa09b4d9c133b86 Mon Sep 17 00:00:00 2001 From: Enbo Wang Date: Mon, 26 Oct 2020 21:34:42 +0800 Subject: Fix issue of writing NSSI to AAI for ExternalNssmfManager Issue-ID: SO-3341 Signed-off-by: Enbo Wang Change-Id: I242b48bee5420bc2a346240baa6056e31acb006c --- .../so/adapters/nssmf/extclients/aai/AaiServiceProvider.java | 1 + .../nssmf/extclients/aai/AaiServiceProviderImpl.java | 12 ++++++++++++ .../so/adapters/nssmf/manager/impl/ExternalNssmfManager.java | 6 +++++- .../nssmf/manager/impl/external/ExternalAnNssmfManager.java | 2 ++ .../main/java/org/onap/so/adapters/nssmf/util/RestUtil.java | 5 +++++ 5 files changed, 25 insertions(+), 1 deletion(-) (limited to 'adapters/mso-nssmf-adapter/src/main') diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java index 665b111e03..dacab3b168 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java @@ -33,4 +33,5 @@ public interface AaiServiceProvider { void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, String serviceInstanceId); + ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId); } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java index b972517338..7cdeac4507 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java @@ -75,4 +75,16 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); aaiClientProvider.getAaiClient().create(uri, nssiInstance); } + + @Override + public ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, + String serviceInstanceId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); + + return aaiClientProvider.getAaiClient().get(ServiceInstance.class, uri).orElseGet(() -> { + logger.debug("ServiceInstance " + serviceInstanceId + " not found in AAI"); + return null; + }); + } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index fc23ca9feb..7a5b6a4926 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -63,7 +63,11 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { protected void afterQueryJobStatus(ResourceOperationStatus status) { if (Integer.parseInt(status.getProgress()) == 100) { - ServiceInstance nssiInstance = new ServiceInstance(); + ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo); + if (nssiInstance == null) { + nssiInstance = new ServiceInstance(); + } + nssiInstance.setServiceInstanceId(serviceInfo.getNssiId()); nssiInstance.setServiceInstanceName(serviceInfo.getNssiName()); nssiInstance.setServiceType(serviceInfo.getSST()); diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java index 491da0aab4..eb2dba0f44 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -128,6 +128,8 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { updateRequestDbJobStatus(responseDescriptor, status, restResponse); + status.setProgress(Integer.toString(responseDescriptor.getProgress())); + return restResponse; } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java index 0c5999b20e..a4a79bf2cd 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java @@ -77,6 +77,11 @@ public class RestUtil { serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); } + public ServiceInstance getServiceInstance(ServiceInfo serviceInfo) { + return aaiSvcProv.invokeGetServiceInstance(serviceInfo.getGlobalSubscriberId(), + serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); + } + public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException { EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList(); if (sdncList != null && sdncList.getEsrThirdpartySdnc() != null) { -- cgit 1.2.3-korg