diff options
author | Rudrangi Anupriya <ra00745022@techmahindra.com> | 2024-07-11 21:56:24 +0530 |
---|---|---|
committer | Rudrangi Anupriya <ra00745022@techmahindra.com> | 2024-07-16 11:00:11 +0000 |
commit | 760dd950e6f6fcb6f49c6f9d92a33f538adffd24 (patch) | |
tree | cccab533a2837a60e527ff1e75d6dbcd01197d6a /cps-service/src/main | |
parent | ac58e919008c4449b389d3681a6f8aa216cb5f8f (diff) |
XML content support on replace a node with descendants
Issue-ID: CPS-2282
Change-Id: Ibb7ffb65ccbb03703266712c6d5c2eade0e7ab4b
Signed-off-by: Rudrangi Anupriya <ra00745022@techmahindra.com>
Diffstat (limited to 'cps-service/src/main')
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/api/CpsDataService.java | 20 | ||||
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java | 19 |
2 files changed, 21 insertions, 18 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 f396b49e6b..cfa5f2de20 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 @@ -55,7 +55,7 @@ public interface CpsDataService { * @param anchorName anchor name * @param nodeData node data * @param observedTimestamp observedTimestamp - * @param contentType node data content type + * @param contentType JSON/XML content type */ void saveData(String dataspaceName, String anchorName, String nodeData, OffsetDateTime observedTimestamp, ContentType contentType); @@ -80,7 +80,7 @@ public interface CpsDataService { * @param parentNodeXpath parent node xpath * @param nodeData node data * @param observedTimestamp observedTimestamp - * @param contentType node data content type + * @param contentType JSON/XML content type * */ void saveData(String dataspaceName, String anchorName, String parentNodeXpath, String nodeData, @@ -134,7 +134,7 @@ public interface CpsDataService { * @param parentNodeXpath xpath to parent node * @param nodeData node data * @param observedTimestamp observedTimestamp - * @param contentType node data content type + * @param contentType JSON/XML content type */ void updateNodeLeaves(String dataspaceName, String anchorName, String parentNodeXpath, String nodeData, OffsetDateTime observedTimestamp, ContentType contentType); @@ -145,22 +145,24 @@ public interface CpsDataService { * @param dataspaceName dataspace name * @param anchorName anchor name * @param parentNodeXpath xpath to parent node - * @param jsonData json data + * @param nodeData node data * @param observedTimestamp observedTimestamp + * @param contentType JSON/XML content type */ - void updateDataNodeAndDescendants(String dataspaceName, String anchorName, String parentNodeXpath, String jsonData, - OffsetDateTime observedTimestamp); + void updateDataNodeAndDescendants(String dataspaceName, String anchorName, String parentNodeXpath, String nodeData, + OffsetDateTime observedTimestamp, ContentType contentType); /** * Replaces multiple existing data nodes' content including descendants in a batch operation. * * @param dataspaceName dataspace name * @param anchorName anchor name - * @param nodesJsonData map of xpath and node JSON data + * @param nodeDataPerXPath map of xpath and node JSON/XML data * @param observedTimestamp observedTimestamp + * @param contentType JSON/XML content type */ - void updateDataNodesAndDescendants(String dataspaceName, String anchorName, Map<String, String> nodesJsonData, - OffsetDateTime observedTimestamp); + void updateDataNodesAndDescendants(String dataspaceName, String anchorName, Map<String, String> nodeDataPerXPath, + OffsetDateTime observedTimestamp, ContentType contentType); /** * Replaces list content by removing all existing elements and inserting the given new elements as json 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 5a48428772..c65bc5e0e9 100644 --- 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 @@ -251,12 +251,12 @@ public class CpsDataServiceImpl implements CpsDataService { @Timed(value = "cps.data.service.datanode.descendants.update", description = "Time taken to update a data node and descendants") public void updateDataNodeAndDescendants(final String dataspaceName, final String anchorName, - final String parentNodeXpath, final String jsonData, - final OffsetDateTime observedTimestamp) { + final String parentNodeXpath, final String nodeData, + final OffsetDateTime observedTimestamp, final ContentType contentType) { cpsValidator.validateNameCharacters(dataspaceName, anchorName); final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); final Collection<DataNode> dataNodes = - buildDataNodesWithParentNodeXpath(anchor, parentNodeXpath, jsonData, ContentType.JSON); + buildDataNodesWithParentNodeXpath(anchor, parentNodeXpath, nodeData, contentType); cpsDataPersistenceService.updateDataNodesAndDescendants(dataspaceName, anchorName, dataNodes); sendDataUpdatedEvent(anchor, parentNodeXpath, Operation.UPDATE, observedTimestamp); } @@ -265,13 +265,13 @@ public class CpsDataServiceImpl implements CpsDataService { @Timed(value = "cps.data.service.datanode.descendants.batch.update", description = "Time taken to update a batch of data nodes and descendants") public void updateDataNodesAndDescendants(final String dataspaceName, final String anchorName, - final Map<String, String> nodesJsonData, - final OffsetDateTime observedTimestamp) { + final Map<String, String> nodeDataPerXPath, + final OffsetDateTime observedTimestamp, final ContentType contentType) { cpsValidator.validateNameCharacters(dataspaceName, anchorName); final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); - final Collection<DataNode> dataNodes = buildDataNodesWithParentNodeXpath(anchor, nodesJsonData); + final Collection<DataNode> dataNodes = buildDataNodesWithParentNodeXpath(anchor, nodeDataPerXPath, contentType); cpsDataPersistenceService.updateDataNodesAndDescendants(dataspaceName, anchorName, dataNodes); - nodesJsonData.keySet().forEach(nodeXpath -> + nodeDataPerXPath.keySet().forEach(nodeXpath -> sendDataUpdatedEvent(anchor, nodeXpath, Operation.UPDATE, observedTimestamp)); } @@ -408,11 +408,12 @@ public class CpsDataServiceImpl implements CpsDataService { } private Collection<DataNode> buildDataNodesWithParentNodeXpath(final Anchor anchor, - final Map<String, String> nodesJsonData) { + final Map<String, String> nodesJsonData, + final ContentType contentType) { final Collection<DataNode> dataNodes = new ArrayList<>(); for (final Map.Entry<String, String> nodeJsonData : nodesJsonData.entrySet()) { dataNodes.addAll(buildDataNodesWithParentNodeXpath(anchor, nodeJsonData.getKey(), - nodeJsonData.getValue(), ContentType.JSON)); + nodeJsonData.getValue(), contentType)); } return dataNodes; } |