From: danielhanrahan Date: Thu, 21 Nov 2024 09:44:15 +0000 (+0000) Subject: [BUG] Fix for module endpoints using alternate ID X-Git-Tag: 3.5.5~18 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F139510%2F1;p=cps.git [BUG] Fix for module endpoints using alternate ID The endpoints for fetching modules and module definitions previously returned empty result if a CM handle was not found or not ready. Recent changes for alternate ID have changed the behaviour so it returns an error instead. This restores original behaviour by swallowing the exception. Change-Id: I63091d04d171e6f4ac6ad1c44b359b9a0c4b8f65 Issue-ID: CPS-2509 Signed-off-by: danielhanrahan --- diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java index f0547d3d24..ec440f4905 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java @@ -27,8 +27,10 @@ package org.onap.cps.ncmp.api.inventory; import static org.onap.cps.ncmp.impl.inventory.CmHandleQueryParametersValidator.validateCmHandleQueryParameters; import java.util.Collection; +import java.util.Collections; import java.util.Map; import lombok.RequiredArgsConstructor; +import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException; import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryApiParameters; import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters; import org.onap.cps.ncmp.api.inventory.models.CompositeState; @@ -111,8 +113,12 @@ public class NetworkCmProxyInventoryFacade { * @return a collection of modules names and revisions */ public Collection getYangResourcesModuleReferences(final String cmHandleReference) { - final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference); - return inventoryPersistence.getYangResourcesModuleReferences(cmHandleId); + try { + final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference); + return inventoryPersistence.getYangResourcesModuleReferences(cmHandleId); + } catch (final CmHandleNotFoundException cmHandleNotFoundException) { + return Collections.emptyList(); + } } /** @@ -122,8 +128,12 @@ public class NetworkCmProxyInventoryFacade { * @return a collection of module definition (moduleName, revision and yang resource content) */ public Collection getModuleDefinitionsByCmHandleReference(final String cmHandleReference) { - final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference); - return inventoryPersistence.getModuleDefinitionsByCmHandleId(cmHandleId); + try { + final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference); + return inventoryPersistence.getModuleDefinitionsByCmHandleId(cmHandleId); + } catch (final CmHandleNotFoundException cmHandleNotFoundException) { + return Collections.emptyList(); + } } /** @@ -137,8 +147,12 @@ public class NetworkCmProxyInventoryFacade { public Collection getModuleDefinitionsByCmHandleAndModule(final String cmHandleReference, final String moduleName, final String moduleRevision) { - final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference); - return inventoryPersistence.getModuleDefinitionsByCmHandleAndModule(cmHandleId, moduleName, moduleRevision); + try { + final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference); + return inventoryPersistence.getModuleDefinitionsByCmHandleAndModule(cmHandleId, moduleName, moduleRevision); + } catch (final CmHandleNotFoundException cmHandleNotFoundException) { + return Collections.emptyList(); + } } /** @@ -227,4 +241,4 @@ public class NetworkCmProxyInventoryFacade { .getEffectiveTrustLevel(ncmpServiceCmHandle.getCmHandleId())); } -} \ No newline at end of file +}