diff options
Diffstat (limited to 'cps-service/src/main')
3 files changed, 39 insertions, 8 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java index 6332f09109..174d71f64d 100644 --- a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java +++ b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2022 Nordix Foundation + * Copyright (C) 2020-2023 Nordix Foundation * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2021-2022 Bell Canada * Modifications Copyright (C) 2022 Deutsche Telekom AG @@ -199,19 +199,30 @@ public interface CpsDataService { /** * Deletes data node for given anchor and dataspace. * - * @param dataspaceName dataspace name - * @param anchorName anchor name - * @param dataNodeXpath data node xpath + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @param dataNodeXpath data node xpath * @param observedTimestamp observed timestamp */ void deleteDataNode(String dataspaceName, String anchorName, String dataNodeXpath, OffsetDateTime observedTimestamp); /** + * Deletes multiple data nodes for given anchor and dataspace. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @param dataNodeXpaths data node xpaths + * @param observedTimestamp observed timestamp + */ + void deleteDataNodes(String dataspaceName, String anchorName, Collection<String> dataNodeXpaths, + OffsetDateTime observedTimestamp); + + /** * Deletes all data nodes for a given anchor in a dataspace. * * @param dataspaceName dataspace name - * @param anchorName anchor name + * @param anchorName anchor name * @param observedTimestamp observed timestamp */ void deleteDataNodes(String dataspaceName, String anchorName, OffsetDateTime observedTimestamp); diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index 53fab2916f..06a0845385 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -264,7 +264,18 @@ public class CpsDataServiceImpl implements CpsDataService { @Timed(value = "cps.data.service.datanode.batch.delete", description = "Time taken to delete a batch of datanodes") public void deleteDataNodes(final String dataspaceName, final String anchorName, - final OffsetDateTime observedTimestamp) { + final Collection<String> dataNodeXpaths, final OffsetDateTime observedTimestamp) { + cpsValidator.validateNameCharacters(dataspaceName, anchorName); + cpsDataPersistenceService.deleteDataNodes(dataspaceName, anchorName, dataNodeXpaths); + dataNodeXpaths.forEach(dataNodeXpath -> + processDataUpdatedEventAsync(dataspaceName, anchorName, dataNodeXpath, DELETE, observedTimestamp)); + } + + @Override + @Timed(value = "cps.data.service.datanode.all.delete", + description = "Time taken to delete all datanodes") + public void deleteDataNodes(final String dataspaceName, final String anchorName, + final OffsetDateTime observedTimestamp) { cpsValidator.validateNameCharacters(dataspaceName, anchorName); processDataUpdatedEventAsync(dataspaceName, anchorName, ROOT_NODE_XPATH, DELETE, observedTimestamp); cpsDataPersistenceService.deleteDataNodes(dataspaceName, anchorName); diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java index 0989ccae2d..3e0b4475e8 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2022 Nordix Foundation. + * Copyright (C) 2020-2023 Nordix Foundation. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022 Bell Canada * Modifications Copyright (C) 2022 TechMahindra Ltd. @@ -174,6 +174,15 @@ public interface CpsDataPersistenceService { void deleteDataNode(String dataspaceName, String anchorName, String targetXpath); /** + * Deletes multiple dataNode, yang container or yang list or yang list element. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @param targetXpaths xpaths of nodes to delete + */ + void deleteDataNodes(String dataspaceName, String anchorName, Collection<String> targetXpaths); + + /** * Deletes all dataNodes in a given anchor. * * @param dataspaceName dataspace name @@ -182,7 +191,7 @@ public interface CpsDataPersistenceService { void deleteDataNodes(String dataspaceName, String anchorName); /** - * Deletes existing a single list element or the whole list. + * Deletes a single existing list element or the whole list. * * @param dataspaceName dataspace name * @param anchorName anchor name |