From 24c72db6b3674bde16eb5a7313d71f507a880de9 Mon Sep 17 00:00:00 2001 From: Ruslan Kashapov Date: Tue, 9 Feb 2021 17:25:18 +0200 Subject: Data fragment update by xpath #3 - rest and service layers Issue-ID: CPS-58 Change-Id: Ie224da95b07748b63648226df6484cebae91cdec Signed-off-by: Ruslan Kashapov --- .../onap/cps/rest/controller/DataRestController.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'cps-rest/src/main/java') diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java index c39a9696e3..8366f06b38 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java @@ -54,15 +54,29 @@ public class DataRestController implements CpsDataApi { @Override public ResponseEntity getNodeByDataspaceAndAnchor(final String dataspaceName, final String anchorName, - final String cpsPath, final Boolean includeDescendants) { - if ("/".equals(cpsPath)) { + final String xpath, final Boolean includeDescendants) { + if ("/".equals(xpath)) { // TODO: extracting data by anchor only (root data node and below) return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } final FetchDescendantsOption fetchDescendantsOption = Boolean.TRUE.equals(includeDescendants) ? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS : FetchDescendantsOption.OMIT_DESCENDANTS; final DataNode dataNode = - cpsDataService.getDataNode(dataspaceName, anchorName, cpsPath, fetchDescendantsOption); + cpsDataService.getDataNode(dataspaceName, anchorName, xpath, fetchDescendantsOption); return new ResponseEntity<>(DataMapUtils.toDataMap(dataNode), HttpStatus.OK); } + + @Override + public ResponseEntity updateNodeLeaves(final String jsonData, final String dataspaceName, + final String anchorName, final String parentNodeXpath) { + cpsDataService.updateNodeLeaves(dataspaceName, anchorName, parentNodeXpath, jsonData); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Override + public ResponseEntity replaceNode(final String jsonData, final String dataspaceName, + final String anchorName, final String parentNodeXpath) { + cpsDataService.replaceNodeTree(dataspaceName, anchorName, parentNodeXpath, jsonData); + return new ResponseEntity<>(HttpStatus.OK); + } } -- cgit 1.2.3-korg