summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2024-11-21 09:44:15 +0000
committerdanielhanrahan <daniel.hanrahan@est.tech>2024-11-21 10:39:00 +0000
commit810865ac3c11094edbb177a4c2a00702964db001 (patch)
tree52a734522ff16acfc492ecde034a4904eac70fe6
parent9060818e7974ca09a06b715533161876b94fde84 (diff)
[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 <daniel.hanrahan@est.tech>
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java28
1 files changed, 21 insertions, 7 deletions
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<ModuleReference> 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<ModuleDefinition> 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<ModuleDefinition> 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
+}