From c3928f8614d007384969f7f24a7ef31c73647992 Mon Sep 17 00:00:00 2001 From: sourabh_sourabh Date: Wed, 25 Jan 2023 17:13:38 +0000 Subject: NCMP De-Register response payload and status is invalid -Refactored "DELETING" and "DELETED" update state to avoid wrong response code. Issue-ID: CPS-1463 Signed-off-by: sourabh_sourabh Change-Id: I639ba94986c4ffe48d2d42f14f6a6b4e2bd2713e Signed-off-by: sourabh_sourabh --- .../ncmp/api/impl/NetworkCmProxyDataServiceImpl.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'cps-ncmp-service/src') diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index 5aad404e61..8b80a0341a 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -325,8 +325,10 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService final List tobeRemovedCmHandles) { final List cmHandleRegistrationResponses = new ArrayList<>(tobeRemovedCmHandles.size()); - - setState(tobeRemovedCmHandles, CmHandleState.DELETING); + final List yangModelCmHandles = + tobeRemovedCmHandles.stream().map(inventoryPersistence::getYangModelCmHandle) + .collect(Collectors.toList()); + updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETING); for (final String cmHandleId : tobeRemovedCmHandles) { try { @@ -350,18 +352,15 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } } - setState(tobeRemovedCmHandles, CmHandleState.DELETED); - + updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETED); return cmHandleRegistrationResponses; } - private void setState(final List tobeRemovedCmHandles, final CmHandleState cmHandleState) { + private void updateCmHandleStateBatch(final List yangModelCmHandles, + final CmHandleState cmHandleState) { final Map cmHandleIdsToBeRemoved = new HashMap<>(); - for (final String cmHandleId : tobeRemovedCmHandles) { - cmHandleIdsToBeRemoved.put( - inventoryPersistence.getYangModelCmHandle(cmHandleId), - cmHandleState); - } + yangModelCmHandles.stream().forEach(yangModelCmHandle -> + cmHandleIdsToBeRemoved.put(yangModelCmHandle, cmHandleState)); lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleIdsToBeRemoved); } -- cgit 1.2.3-korg