diff options
author | Priyank Maheshwari <priyank.maheshwari@est.tech> | 2024-11-29 10:28:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-11-29 10:28:06 +0000 |
commit | a27a62c1ca4f87d126cb5e40cc797aed9aa590db (patch) | |
tree | 3fdcba0ecc089065040ed54db84d12b9586dcfef /cps-rest/src/main/java | |
parent | b97d522cb3d08b596241aea88aafe3bd08b4ef77 (diff) | |
parent | dfcc95236daf7d45687fa42446a7d236ac12637e (diff) |
Merge "XML content support on Replace list content"
Diffstat (limited to 'cps-rest/src/main/java')
-rwxr-xr-x | cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java | 10 | ||||
-rw-r--r-- | cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java | 2 |
2 files changed, 7 insertions, 5 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 dda88e019c..3efb6b421c 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 @@ -173,9 +173,11 @@ public class DataRestController implements CpsDataApi { @Override public ResponseEntity<Object> replaceListContent(final String apiVersion, final String dataspaceName, final String anchorName, final String parentNodeXpath, - final Object jsonData, final String observedTimestamp) { + final String nodeData, final String observedTimestamp, + final String contentTypeInHeader) { + final ContentType contentType = ContentType.fromString(contentTypeInHeader); cpsDataService.replaceListContent(dataspaceName, anchorName, parentNodeXpath, - jsonObjectMapper.asJsonString(jsonData), toOffsetDateTime(observedTimestamp)); + nodeData, toOffsetDateTime(observedTimestamp), contentType); return new ResponseEntity<>(HttpStatus.OK); } @@ -225,10 +227,10 @@ public class DataRestController implements CpsDataApi { return new ResponseEntity<>(jsonObjectMapper.asJsonString(deltaBetweenAnchors), HttpStatus.OK); } - ResponseEntity<Object> buildResponseEntity(final List<Map<String, Object>> dataMaps, + private ResponseEntity<Object> buildResponseEntity(final List<Map<String, Object>> dataMaps, final ContentType contentType) { final String responseData; - if (contentType == ContentType.XML) { + if (ContentType.XML.equals(contentType)) { responseData = XmlFileUtils.convertDataMapsToXml(dataMaps); } else { responseData = jsonObjectMapper.asJsonString(dataMaps); diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java index 55a1886ce7..ec71c30a75 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java @@ -151,7 +151,7 @@ public class QueryRestController implements CpsQueryApi { private ResponseEntity<Object> buildResponseEntity(final List<Map<String, Object>> dataNodesAsListOfMaps, final ContentType contentType) { final String responseData; - if (contentType == ContentType.XML) { + if (ContentType.XML.equals(contentType)) { responseData = XmlFileUtils.convertDataMapsToXml(dataNodesAsListOfMaps); } else { responseData = jsonObjectMapper.asJsonString(dataNodesAsListOfMaps); |