You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Initial Findings

It was found that the V1 of Get Data Node API would always return the first data node under an anchor. So if there are multiple data nodes stored under an anchor, when the Get operation was performed to retrieve all data nodes(by setting the xPath as root node xPath"/"), then only the first data node in the stack would be returned.

Also when the get operation is performed to retrieve individual parent data nodes under an anchor, the data nodes are retrieved successfully. Hence proving that even when multiple data nodes exist under an anchor, only one of them can be retrieved at a time and when trying to retrieve all of them by using root node xPath the operation only returns the first data node.

Decisions

After team discussion based on the findings mentioned below, it was decided to release V2 of Get Data Node API, where in the response body was to be updated to be a JSON array. And within this array individual data trees would be returned.

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 Get a Node API 

Currently after multiple data trees are stored in CPS DB. On performing the GET operation on the same data, with xpath set as root "/", the first data tree is returned by the Get Data Node API. This data tree is returned in form of a JSON Object as follows:

CURL Request:

curl --location 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/node?xpath=%2F' \
--header 'Accept: application/json' \
--header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE='

Response:

Current JSON response body
{
        "multiple-data-tree:first-container": {
            "a-leaf": "a-Value"
        }
}

Expected Outcome

After the GET API is updated, we want all the data trees to be returned when the xpath is set to root "/" and when a specific xpath is provided we want the functionality to remain as is.

Based on the existing GET request there are two possible responses we can get here:

  1. Data returned as a JSON array, with the array containing individual data trees (This approach was finalized to be implemented in V2 of get API)

    Get all the data trees in a JSON Array
    //JSON Array
    [
      {
        "multiple-data-tree:first-container": {	 //Data Tree 1
          "a-leaf": "a-Value"
        }
      },
      {
        "multiple-data-tree:last-container": {		//Data Tree 2
          "x-leaf": "x-value"
        }
      }
    ]
  2. Data Returned as a JSON object, with all data trees in a single object

    Get all the data trees as JSON Objects
    {
      "multiple-data-tree:first-container": {
        "a-leaf": "a-Value"
      },
      "multiple-data-tree:last-container": {
        "x-leaf": "x-value"
      }
    }
  • No labels