Currently within CPS it is possible to delete child list-nodes on a given anchor and xpath, or deleting the anchor which subsequently deletes all related list-nodes under that anchor.

There is no functionality right now to delete the data-node at the highest level, and subsequently the list-nodes for this data-node.

CPS should provide the functionality to delete data-nodes as part available within the CPS-REST API, and the NCMP-REST API.

Implementation Proposal

Implement an endpoint which provides functionality to support data-node removal using the data-node xpath.

REST layer

  • URI
    • (CPS-Core) DELETE dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes

REST layer (DataRestController.java)

  • Implement method to delete data-nodes with anchor, dataspace and xpath as string parameters.
  • Call cpsDataService.
  • return 204.

REST layer (cpsData.yml)

  • Add delete operation to endpoint functionality within CPS-Core

REST layer (DataRestControllerSpec.groovy)

  • Ensure appropriate response in tests on invocation.

Service layer (CPSDataService.java)

  • Create new abstract method deleteDataNode.

Service layer (CpsDataServiceImpl.java)

  • validate xpath of the data-node.
  • call cpsDataPersistence.deleteDataNodes(rename method)
  • notificationService.processDataUpdatedEvent(dataspaceName, anchorName)

Service layer (CPSDataServiceImplSpec.groovy)

  • delete data-node under xpath.

Persistence layer (CpsDataPeristenceService.java)

  • Create new abstract method, deleteDataNodes()

Persistence layer(CpsDataPersistenceServiceImpl.java)

  • Use method getFragmentByXpath() to the get the parentEntity of the data-node.
  • Check if it is a data-node or a list-node to be deleted.
  • If it is a data-node call removeDataNode().
  • If it is a list-node call deleteListDataNodes(). (See CPS-361 - Getting issue details... STATUS )

Persistence layer (CpsDataPersistenceServiceSpec.groovy)

  • Verify data-node is deleted successfully.
  • Verify list-node is deleted successfully 
  • Error thrown when the xpath does not exist.
  • Error is thrown if data node or list node don't exist.

CPS-313 - Getting issue details... STATUS


Issues & Decisions

#

Issue

Notes

Decision

1Empty AnchorsIf top level data-node is removed, it could potentially leave an empty anchor.Check with stakeholders (Peter and Kieran)
  • No labels