diff options
author | Daniel Hanrahan <daniel.hanrahan@est.tech> | 2024-11-21 15:45:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-11-21 15:45:39 +0000 |
commit | 225626a21199cbb8fbab976169785313b3aeceb7 (patch) | |
tree | 23297d6e8789b45d8b0aeee6cb50f1c0e1244479 /cps-ncmp-service/src/main | |
parent | 404a773d4ff365174ac61228eb882f8147b5c7d8 (diff) | |
parent | 1e34dc01f3319517d66387f2c443c989a0752f7f (diff) |
Merge "Prioritize cm handle ids over alternate ids in data operations"
Diffstat (limited to 'cps-ncmp-service/src/main')
3 files changed, 18 insertions, 7 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/data/models/CmResourceAddress.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/data/models/CmResourceAddress.java index 98a343b92e..24a9b21bf4 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/data/models/CmResourceAddress.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/data/models/CmResourceAddress.java @@ -20,7 +20,6 @@ package org.onap.cps.ncmp.api.data.models; -import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.onap.cps.ncmp.config.CpsApplicationContext; @@ -31,11 +30,11 @@ import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher; public class CmResourceAddress { private final String datastoreName; - @Getter(AccessLevel.NONE) private final String cmHandleReference; private final String resourceIdentifier; - public String getResolvedCmHandleId() { - return CpsApplicationContext.getCpsBean(AlternateIdMatcher.class).getCmHandleId(cmHandleReference); + public String resolveCmHandleReferenceToId() { + final AlternateIdMatcher alternateIdMatcher = CpsApplicationContext.getCpsBean(AlternateIdMatcher.class); + return alternateIdMatcher.getCmHandleId(cmHandleReference); } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java index c4bdc1cf1b..41348aea3f 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java @@ -52,6 +52,7 @@ import org.onap.cps.ncmp.impl.models.DmiRequestBody; import org.onap.cps.ncmp.impl.utils.http.RestServiceUrlTemplateBuilder; import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters; import org.onap.cps.spi.exceptions.CpsException; +import org.onap.cps.spi.exceptions.DataNodeNotFoundException; import org.onap.cps.utils.JsonObjectMapper; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -93,7 +94,7 @@ public class DmiDataOperations { final String topic, final String requestId, final String authorization) { - final YangModelCmHandle yangModelCmHandle = getYangModelCmHandle(cmResourceAddress.getResolvedCmHandleId()); + final YangModelCmHandle yangModelCmHandle = resolveYangModelCmHandleFromCmHandleReference(cmResourceAddress); final CmHandleState cmHandleState = yangModelCmHandle.getCompositeState().getCmHandleState(); validateIfCmHandleStateReady(yangModelCmHandle, cmHandleState); final String jsonRequestBody = getDmiRequestBody(READ, requestId, null, null, yangModelCmHandle); @@ -173,7 +174,8 @@ public class DmiDataOperations { final CmResourceAddress cmResourceAddress = new CmResourceAddress(PASSTHROUGH_RUNNING.getDatastoreName(), cmHandleId, resourceId); - final YangModelCmHandle yangModelCmHandle = getYangModelCmHandle(cmResourceAddress.getResolvedCmHandleId()); + final YangModelCmHandle yangModelCmHandle = + getYangModelCmHandle(cmResourceAddress.resolveCmHandleReferenceToId()); policyExecutor.checkPermission(yangModelCmHandle, operationType, authorization, resourceId, requestData); @@ -279,6 +281,16 @@ public class DmiDataOperations { }).subscribe(); } + private YangModelCmHandle resolveYangModelCmHandleFromCmHandleReference(final CmResourceAddress cmResourceAddress) { + String cmHandleId = cmResourceAddress.getCmHandleReference(); + try { + return getYangModelCmHandle(cmHandleId); + } catch (final DataNodeNotFoundException ignored) { + cmHandleId = cmResourceAddress.resolveCmHandleReferenceToId(); + return getYangModelCmHandle(cmHandleId); + } + } + private String createDmiDataOperationRequestAsJsonString( final List<DmiDataOperation> dmiDataOperationRequestBodies) { final DmiDataOperationRequest dmiDataOperationRequest = DmiDataOperationRequest.builder() diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NcmpCachedResourceRequestHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NcmpCachedResourceRequestHandler.java index 01022cc03e..c14b928677 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NcmpCachedResourceRequestHandler.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NcmpCachedResourceRequestHandler.java @@ -62,7 +62,7 @@ public class NcmpCachedResourceRequestHandler extends NcmpDatastoreRequestHandle final FetchDescendantsOption fetchDescendantsOption = getFetchDescendantsOption(includeDescendants); final DataNode dataNode = cpsDataService.getDataNodes(cmResourceAddress.getDatastoreName(), - cmResourceAddress.getResolvedCmHandleId(), + cmResourceAddress.resolveCmHandleReferenceToId(), cmResourceAddress.getResourceIdentifier(), fetchDescendantsOption).iterator().next(); return Mono.justOrEmpty(dataNode); |