aboutsummaryrefslogtreecommitdiffstats
path: root/cps-rest/src/main/java/org
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2024-10-09 09:37:42 +0000
committerGerrit Code Review <gerrit@onap.org>2024-10-09 09:37:42 +0000
commitfe5bbade7c7e1711b6d9ca626d8505d9828eda1b (patch)
tree4b30b61928ee90bf4a19f676ea337ad320b3ad8a /cps-rest/src/main/java/org
parent3f9f193353a381822beef41058a9baae7e98b3ee (diff)
parent07acbb4ddd713f74406b156cbcac2507f96f3b08 (diff)
Merge "Implementation of Data validation feature in Create a Node API"
Diffstat (limited to 'cps-rest/src/main/java/org')
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java19
1 files changed, 12 insertions, 7 deletions
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 f86073fb06..7390afcf98 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
@@ -74,16 +74,21 @@ public class DataRestController implements CpsDataApi {
final String dataspaceName, final String anchorName,
final String contentTypeInHeader,
final String nodeData, final String parentNodeXpath,
- final String observedTimestamp) {
+ final Boolean dryRunEnabled, final String observedTimestamp) {
final ContentType contentType = getContentTypeFromHeader(contentTypeInHeader);
- if (isRootXpath(parentNodeXpath)) {
- cpsDataService.saveData(dataspaceName, anchorName, nodeData,
- toOffsetDateTime(observedTimestamp), contentType);
+ if (Boolean.TRUE.equals(dryRunEnabled)) {
+ cpsDataService.validateData(dataspaceName, anchorName, parentNodeXpath, nodeData, contentType);
+ return ResponseEntity.ok().build();
} else {
- cpsDataService.saveData(dataspaceName, anchorName, parentNodeXpath,
- nodeData, toOffsetDateTime(observedTimestamp), contentType);
+ if (isRootXpath(parentNodeXpath)) {
+ cpsDataService.saveData(dataspaceName, anchorName, nodeData,
+ toOffsetDateTime(observedTimestamp), contentType);
+ } else {
+ cpsDataService.saveData(dataspaceName, anchorName, parentNodeXpath,
+ nodeData, toOffsetDateTime(observedTimestamp), contentType);
+ }
+ return ResponseEntity.status(HttpStatus.CREATED).build();
}
- return new ResponseEntity<>(HttpStatus.CREATED);
}
@Override