diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2020-03-09 19:27:19 +0000 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2020-03-10 18:09:25 +0000 |
commit | 3d7980f7f2e8255d3ef7911b5ba6fca4b0ccb00f (patch) | |
tree | 930b7649a90a676121d5bcc6170830376efe7286 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org | |
parent | 8429f063a6c3c14605cad891be1a627b0ad54f0c (diff) |
Updating operationalState and usageState to list
Change-Id: I59c22c3a9484a12ebd7831ceb693d90a6d1f4e7e
Issue-ID: SO-2714
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org')
3 files changed, 61 insertions, 42 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java index 6d566c07ad..f32a9b0fa9 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java @@ -21,16 +21,16 @@ package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.NotificationTypesEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.UsageStateEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVersions; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; @@ -62,7 +62,7 @@ public class PkgmSubscriptionRequestConverter implements private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter getPkgmNotificationsFilter( - final SubscriptionsFilter sol003SubscriptionsFilter) { + final SubscriptionsFilter1 sol003SubscriptionsFilter) { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter etsiCatalogManagerFilters = new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter(); @@ -81,21 +81,40 @@ public class PkgmSubscriptionRequestConverter implements etsiCatalogManagerFilters .setOperationalState(getOperationalState(sol003SubscriptionsFilter.getOperationalState())); - etsiCatalogManagerFilters.setUsageState(null); + etsiCatalogManagerFilters.setUsageState(getUsageState(sol003SubscriptionsFilter.getUsageState())); return etsiCatalogManagerFilters; } - // TODO 'operationalState' in the Sol003 Swagger is type 'OperationalStateEnum'. The ETSI - // Catalog Manager Swagger - // 'operationalState' is type 'List<OperationalStateEnum>'. This method needs to be updated once - // swagger is updated. + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> getUsageState( + final List<UsageStateEnum> usageStates) { + if (usageStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> etsiCatalogUsageStates = + new ArrayList<>(); + usageStates.stream().forEach(state -> { + etsiCatalogUsageStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum + .fromValue(state.getValue())); + }); + return etsiCatalogUsageStates; + } + return Collections.emptyList(); + } + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState( - final OperationalStateEnum operationalState) { - if (operationalState != null) { - return Arrays.asList( - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum - .fromValue(operationalState.getValue())); + final List<OperationalStateEnum> operationalStates) { + if (operationalStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> etsiCatalogOperationalStates = + new ArrayList<>(); + operationalStates.forEach(state -> { + etsiCatalogOperationalStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum + .fromValue(state.getValue())); + }); + + return etsiCatalogOperationalStates; } return Collections.emptyList(); } @@ -165,12 +184,12 @@ public class PkgmSubscriptionRequestConverter implements final List<NotificationTypesEnum> notificationTypes) { if (notificationTypes != null && !notificationTypes.isEmpty()) { - final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogManagerNotificationTypes = + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogNotificationTypes = new ArrayList<>(); - notificationTypes.forEach(type -> etsiCatalogManagerNotificationTypes.add( + notificationTypes.forEach(type -> etsiCatalogNotificationTypes.add( org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum .fromValue(type.getValue()))); - return etsiCatalogManagerNotificationTypes; + return etsiCatalogNotificationTypes; } return Collections.emptyList(); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java index a4c52fd13d..a23eb6c3e3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java @@ -34,14 +34,14 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServic import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider; +import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -80,7 +80,7 @@ public class SubscriptionManager { this.msoKeyString = msoKeyString; } - public Optional<InlineResponse2002> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) + public Optional<InlineResponse201> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = @@ -97,14 +97,14 @@ public class SubscriptionManager { packageManagementCacheServiceProvider.addSubscription(subscriptionId, pkgmSubscriptionRequest); - final InlineResponse2002 response2002 = new InlineResponse2002(); - response2002.setId(subscriptionId); - response2002.setFilter(pkgmSubscriptionRequest.getFilter()); - response2002.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); - response2002.setLinks(new SubscriptionsLinks() + final InlineResponse201 response = new InlineResponse201(); + response.setId(subscriptionId); + response.setFilter(pkgmSubscriptionRequest.getFilter()); + response.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); + response.setLinks(new SubscriptionsLinks() .self(new VnfPackagesLinksSelf().href(getSubscriptionUri(subscriptionId).toString()))); - return Optional.of(response2002); + return Optional.of(response); } throw new InternalServerErrorException( "Received empty response from POST to ETSI Catalog Manager Subscription Endpoint."); @@ -114,7 +114,7 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscriptionId(pkgmSubscriptionRequest); } - public Optional<InlineResponse2002> getSubscription(final String subscriptionId) { + public Optional<InlineResponse201> getSubscription(final String subscriptionId) { logger.debug("Checking if subscrition with id: {} exists in ETSI Catalog Manager", subscriptionId); final Optional<NsdmSubscription> etsiCatalogSubscriptionOption = @@ -137,12 +137,12 @@ public class SubscriptionManager { return Optional.empty(); } - public List<InlineResponse2002> getSubscriptions() { + public List<InlineResponse201> getSubscriptions() { final Map<String, PkgmSubscriptionRequest> subscriptions = packageManagementCacheServiceProvider.getSubscriptions(); - final List<InlineResponse2002> response = new ArrayList<>(); + final List<InlineResponse201> response = new ArrayList<>(); subscriptions.forEach((key, value) -> { - final Optional<InlineResponse2002> optional = getSubscription(key); + final Optional<InlineResponse201> optional = getSubscription(key); if (optional.isPresent()) { response.add(optional.get()); } @@ -175,8 +175,8 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscription(subscriptionId); } - private InlineResponse2002 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { - return new InlineResponse2002().id(id).filter(subscription.getFilter()) + private InlineResponse201 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { + return new InlineResponse201().id(id).filter(subscription.getFilter()) .callbackUri(subscription.getCallbackUri()); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java index 6db3797f9b..515e317496 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Optional; import javax.ws.rs.core.MediaType; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.SubscriptionManager; import org.slf4j.Logger; @@ -92,15 +92,15 @@ public class Sol003PackageManagementSubscriptionController { } logger.debug("No duplicate Subscription exists, continuing with POST."); - final Optional<InlineResponse2002> optionalInlineResponse2002 = + final Optional<InlineResponse201> optionalInlineResponse = subscriptionManager.createSubscription(pkgmSubscriptionRequest); - if (optionalInlineResponse2002.isPresent()) { - InlineResponse2002 inlineResponse2002 = optionalInlineResponse2002.get(); - final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse2002.getId()); + if (optionalInlineResponse.isPresent()) { + InlineResponse201 inlineResponse = optionalInlineResponse.get(); + final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse.getId()); final HttpHeaders headers = createLocationHeader(subscriptionUri); logger.debug("Sending response with uri {} ", subscriptionUri); - return new ResponseEntity<>(inlineResponse2002, headers, HttpStatus.CREATED); + return new ResponseEntity<>(inlineResponse, headers, HttpStatus.CREATED); } final String errorMessage = "A null response was received during the postSubscriptionRequest call."; logger.error(errorMessage); @@ -113,9 +113,9 @@ public class Sol003PackageManagementSubscriptionController { * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK */ @GetMapping(value = "/subscriptions") - public ResponseEntity<List<InlineResponse2002>> getSubscriptions() { + public ResponseEntity<List<InlineResponse201>> getSubscriptions() { logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions."); - List<InlineResponse2002> subscriptionsList = subscriptionManager.getSubscriptions(); + List<InlineResponse201> subscriptionsList = subscriptionManager.getSubscriptions(); return new ResponseEntity<>(subscriptionsList, HttpStatus.OK); } @@ -128,7 +128,7 @@ public class Sol003PackageManagementSubscriptionController { @GetMapping(value = "/subscriptions/{subscriptionId}") public ResponseEntity<?> getSubscription(@PathVariable("subscriptionId") final String subscriptionId) { logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId); - final Optional<InlineResponse2002> optional = subscriptionManager.getSubscription(subscriptionId); + final Optional<InlineResponse201> optional = subscriptionManager.getSubscription(subscriptionId); if (optional.isPresent()) { logger.debug("Return subscription with id {} and body {}", subscriptionId, optional); return new ResponseEntity<>(optional.get(), HttpStatus.OK); |