aboutsummaryrefslogtreecommitdiffstats
path: root/cps-rest/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'cps-rest/src/main')
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java25
1 files changed, 25 insertions, 0 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 310171b309..f579c82d25 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
@@ -24,12 +24,15 @@
package org.onap.cps.rest.controller;
+import static org.onap.cps.rest.utils.MultipartFileUtil.extractYangResourcesMap;
+
import io.micrometer.core.annotation.Timed;
import jakarta.validation.ValidationException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
@@ -49,6 +52,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("${rest.api.cps-base-path}")
@@ -172,6 +176,27 @@ public class DataRestController implements CpsDataApi {
}
@Override
+ public ResponseEntity<Object> getDeltaByDataspaceAnchorAndPayload(final String dataspaceName,
+ final String sourceAnchorName,
+ final Object jsonPayload,
+ final String xpath,
+ final MultipartFile multipartFile) {
+ final FetchDescendantsOption fetchDescendantsOption = FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS;
+
+ final Map<String, String> yangResourceMap;
+ if (multipartFile == null) {
+ yangResourceMap = Collections.emptyMap();
+ } else {
+ yangResourceMap = extractYangResourcesMap(multipartFile);
+ }
+ final Collection<DeltaReport> deltaReports = Collections.unmodifiableList(
+ cpsDataService.getDeltaByDataspaceAnchorAndPayload(dataspaceName, sourceAnchorName,
+ xpath, yangResourceMap, jsonPayload.toString(), fetchDescendantsOption));
+
+ return new ResponseEntity<>(jsonObjectMapper.asJsonString(deltaReports), HttpStatus.OK);
+ }
+
+ @Override
@Timed(value = "cps.data.controller.get.delta",
description = "Time taken to get delta between anchors")
public ResponseEntity<Object> getDeltaByDataspaceAndAnchors(final String dataspaceName,