summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main
diff options
context:
space:
mode:
authorPriyank Maheshwari <priyank.maheshwari@est.tech>2023-02-09 11:41:55 +0000
committerGerrit Code Review <gerrit@onap.org>2023-02-09 11:41:55 +0000
commita230fafadb6bf262abc6d77eae327a16181330e4 (patch)
tree7327e8c516d371ba059276df280b06fa45d67476 /cps-ncmp-service/src/main
parentef200d43e3d2dc2be292bd76a8963cbb711247e7 (diff)
parent95ccdb630575a34c0229c08b6fdabd3a2e57f5fc (diff)
Merge "Update CmHandleState on deregistration response"
Diffstat (limited to 'cps-ncmp-service/src/main')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java22
1 files changed, 15 insertions, 7 deletions
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 a5bd60605a..59b960af65 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
@@ -327,9 +327,10 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
final List<String> tobeRemovedCmHandles) {
final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses =
new ArrayList<>(tobeRemovedCmHandles.size());
- final List<YangModelCmHandle> yangModelCmHandles =
- tobeRemovedCmHandles.stream().map(inventoryPersistence::getYangModelCmHandle)
- .collect(Collectors.toList());
+ final Map<String, YangModelCmHandle> cmHandleIdToYangModelCmHandleMap = tobeRemovedCmHandles.stream()
+ .collect(Collectors.toMap(cmHandleId -> cmHandleId, inventoryPersistence::getYangModelCmHandle));
+
+ final Collection<YangModelCmHandle> yangModelCmHandles = cmHandleIdToYangModelCmHandleMap.values();
updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETING);
for (final List<String> tobeRemovedCmHandleBatch : Lists.partition(tobeRemovedCmHandles, DELETE_BATCH_SIZE)) {
@@ -348,7 +349,15 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
}
}
- updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETED);
+ final Collection<YangModelCmHandle> deletedYangModelCmHandles =
+ cmHandleRegistrationResponses.stream()
+ .filter(cmHandleRegistrationResponse ->
+ cmHandleRegistrationResponse.getStatus().equals(CmHandleRegistrationResponse.Status.SUCCESS))
+ .map(CmHandleRegistrationResponse::getCmHandle)
+ .map(cmHandleIdToYangModelCmHandleMap::get)
+ .collect(Collectors.toList());
+ updateCmHandleStateBatch(deletedYangModelCmHandles, CmHandleState.DELETED);
+
return cmHandleRegistrationResponses;
}
@@ -372,11 +381,10 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
}
}
- private void updateCmHandleStateBatch(final List<YangModelCmHandle> yangModelCmHandles,
+ private void updateCmHandleStateBatch(final Collection<YangModelCmHandle> yangModelCmHandles,
final CmHandleState cmHandleState) {
final Map<YangModelCmHandle, CmHandleState> cmHandleIdsToBeRemoved = new HashMap<>();
- yangModelCmHandles.stream().forEach(yangModelCmHandle ->
- cmHandleIdsToBeRemoved.put(yangModelCmHandle, cmHandleState));
+ yangModelCmHandles.forEach(yangModelCmHandle -> cmHandleIdsToBeRemoved.put(yangModelCmHandle, cmHandleState));
lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleIdsToBeRemoved);
}