Initial Findings
It is found that the current Patch operation in CPS core can only update value of one data tree at a time. So if there are multiple data trees under an anchor and a Patch is performed on all the data trees using root node xPath "/" then only the first data tree gets updated and the remaining data trees remain as it is,
Based on the above outcome, another test to update individual data trees was preformed, and it was found that when a specific data tree is being updated using its specific xPath none of the data trees get updated and a 400 BAD REQUEST is received.
Decisions
To be added
JSON Data Stored in CPS DB using POST operation
The following JSON data was first stored in CPS DB, then to test the GET operation:
{ "first-container": { "a-leaf": "a-Value" }, "last-container": { "x-leaf": "x-value" } }
Analysis of Patch operation (Update node leaves)
Currently after multiple data trees are stored in CPS DB. On performing the Patch operation on the same data, with xpath set as root "/", the first data tree is only updated by the Patch operation. To test this following scenarios were performed:
Updating all data trees under an anchor with root node xPath "/"
CURL request to update all data trees
curl --location --request PATCH 'http://localhost:8080/cps/api/v2/dataspaces/testDataspace/anchors/multipleDataTree/nodes?xpath=%2F&observed-timestamp=2021-03-21T00%3A10%3A34.030-0100' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node056putyccbmdr1ij6x17mynl312.node0' \ --data '{ "first-container": { "a-leaf": "a-updated-value" }, "last-container": { "x-leaf": "x-updated-value" } }'
Response: 200 OK
On performing Get operation we get the following JSON data[ { "multiple-data-tree:last-container": { "x-leaf": "x-value" } }, { "multiple-data-tree:first-container": { "a-leaf": "a-updated-value" } } ]
- Updating the first data tree
CURL request to update first data treecurl --location --request PATCH 'http://localhost:8080/cps/api/v2/dataspaces/testDataspace/anchors/multipleDataTree/nodes?xpath=%2Ffirst-container&observed-timestamp=2021-03-21T00%3A10%3A34.030-0100' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node02yp851tkv9yvzexd1irvkyqc0.node0' \ --data '{ "first-container": { "a-leaf": "a-updated-value" } }'
Response
{ "status": "400 BAD_REQUEST", "message": "Failed to parse json data. Unsupported xpath or json data:{\"first-container\":{\"a-leaf\":\"a-updated-value\"}}", "details": "Schema node with name first-container was not found under (org:onap:ccsdk:multiDataTree?revision=2020-09-15)first-container." }
Updating the second data tree
CURL request to update second data treecurl --location --request PATCH 'http://localhost:8080/cps/api/v2/dataspaces/testDataspace/anchors/multipleDataTree/nodes?xpath=%2Flast-container&observed-timestamp=2021-03-21T00%3A10%3A34.030-0100' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node02yp851tkv9yvzexd1irvkyqc0.node0' \ --data '{ "last-container": { "x-leaf": "x-updated-value" } }'
Response
{ "status": "400 BAD_REQUEST", "message": "Failed to parse json data. Unsupported xpath or json data:{\"last-container\":{\"x-leaf\":\"x-updated-value\"}}", "details": "Schema node with name last-container was not found under (org:onap:ccsdk:multiDataTree?revision=2020-09-15)last-container." }