summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-04-19 12:40:01 +0300
committerRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-04-20 12:58:55 +0300
commit24bf350947acb7fcb62878932d520387bc922a96 (patch)
tree447c8ad367db6769c5e6bd66f85fcf059524999b /cps-service/src/main/java/org
parent3da52076907385c8a42b817f7aceb65e0dcb7cdd (diff)
Create child data node (part 1): CPS service + REST
Issue-ID: CPS-337 Change-Id: I9c5c62d144b5301ac80e2b82a5cc66a980dad011 Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-service/src/main/java/org')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsDataService.java16
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java7
2 files changed, 23 insertions, 0 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 54d9258918..8552c6c0d8 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
@@ -22,6 +22,8 @@ package org.onap.cps.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.onap.cps.spi.FetchDescendantsOption;
+import org.onap.cps.spi.exceptions.AlreadyDefinedException;
+import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
import org.onap.cps.spi.exceptions.DataValidationException;
import org.onap.cps.spi.model.DataNode;
@@ -41,6 +43,20 @@ public interface CpsDataService {
void saveData(@NonNull String dataspaceName, @NonNull String anchorName, @NonNull String jsonData);
/**
+ * Persists child data fragment under existing data node for the given anchor and dataspace.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @param parentNodeXpath parent node xpath
+ * @param jsonData json data
+ * @throws DataValidationException when json data is invalid
+ * @throws DataNodeNotFoundException when parent node cannot be found by parent node xpath
+ * @throws AlreadyDefinedException when child data node with same xpath already exists
+ */
+ void saveData(@NonNull String dataspaceName, @NonNull String anchorName, @NonNull String parentNodeXpath,
+ @NonNull String jsonData);
+
+ /**
* Retrieves datanode by XPath for given dataspace and anchor.
*
* @param dataspaceName dataspace name
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 6f7d6439b6..cc290bf29d 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
@@ -59,6 +59,13 @@ public class CpsDataServiceImpl implements CpsDataService {
}
@Override
+ public void saveData(final String dataspaceName, final String anchorName, final String parentNodeXpath,
+ final String jsonData) {
+ final DataNode dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData);
+ cpsDataPersistenceService.addChildDataNode(dataspaceName, anchorName, parentNodeXpath, dataNode);
+ }
+
+ @Override
public DataNode getDataNode(final String dataspaceName, final String anchorName, final String xpath,
final FetchDescendantsOption fetchDescendantsOption) {
return cpsDataPersistenceService.getDataNode(dataspaceName, anchorName, xpath, fetchDescendantsOption);