This Spike describes the implementation and changes necessary in order to support a list element as a top-level data node.
Implementation Proposal
We will be augmenting the existing CPS-Core endpoint /v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes?xpath=/
REST Layer
- DataRestController.java
- Add a check in addListElements to see if the parent xpath is a root path ("/"). If root node, create passed list element as top node. Else add passed list element to parent xpath node.
- DataRestControllerSpec.groovy
- Add test for scenario above
Service Layer
- CpsDataService.java
- Overload saveListElements method with implementation for no parentNodeXpath
- CpsDataServiceImpl.java
- Overload saveListElements method with implementation for no parentNodeXpath
- buildDataNodes and call new method storeListElements in Persistence Layer
Persistence Layer
- CpsDataPersistenceService.java
- new method storeListElements
- CpsDataPersistenceServiceImpl.java
- new method storeListElements, converts datanodes to fragment repository and saves it.
Issues:
Get Datanode only gets the first node of the list element at the top level. Possible solutions:
- Refactor endpoint get node to get node(s) and have it search for parallel nodes.
- Create new endpoint (get root node / get list elements)
- Refactor endpoint so that it functions differently when root xpath is given
Delete Datanode only deletes one node of the list element at the top level
- Refactor to delete all nodes when passed root xpath /
Confirm that we do not want to allow an empty list element as the top level element (would not be a node)