Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It is to be noted here that the methods used for GET operation are not limited to Get a Node API and are reused in other API's as well. All the APIS discussed below internally call the getFragmentWithoutDescendantsByXpath()to retrieve the data trees. This epic covers the impact on all the API's due to the above mentioned changes in CPS core.

A common task across the API's is to maintain backwards compatibility as well.

...

OperationAPIIssuesPossible Solution
GETGet a Node
  • should return all the data trees when xpath is set to root(/)
  • currently returns only the first data tree
  • modify the existing code for Get a Node API so it returns a List of fragment entities
  • this impacts other API's as well which make use of the Get operation
  • a separate API can be developed to return all the data trees, similar to Get all anchors and Get one anchor API in CPS
PUT
  • Replace a node with descendants

  • Replace list content


  • currently when the replace action is performed with xpath set to root, it will first perform a get operation internally to retrieve the first data tree and then execute the replace operation
  • but with support for multiple data trees under root
  • when the API is called with xpath set to "/", it will return first get all the data trees
  • once all the data trees are returned the PUT operation will be performed
    • if xpath is set to "/" and the number of data trees on which the replace operation is being performed is less than the total number of data trees the operation of retrieving all the data trees is does not seems to be feasible
  • when xpath is set to "/" the replace operation can return an error message
  • the user can specify the data tree for which Replace operation is to be performed,
  • but the drawback of this approach is if the number of data trees on which replace operation is to be performed is significantly bighigh
DELETEDelete a datanode


  • when delete operation is performed with xpath set to root all the data trees must be deleted
PATCHUpdate node leaves
  • when the API is called and xpath is set to "/", a first the get operation is executed internally to retrieve all the data trees first
  • once all the data trees are returned in a List the API proceeds to perform the Patch operation
    • if xpath is set to "/" and the number of data trees on which the patch operation is being performed is less than the total number of data trees the operation of retrieving all the data trees is not feasible
  • when xpath is set to "/" the patch operation can return an error message
  • the user can specify the data tree for which patch operation is to be performed, but the drawback of this approach is, when the number of data trees on which patch operation is to be performed is significantly big
PUT
POSTAdd list element to existing listReplace list content
  • when the API is called with and xpath is set to "/", it will return first the get operation is executed internally to retrieve all the data trees
  • once all the data trees are returned the PUT operation will be performedin a List the API proceeds to perform the Post operation
    • if xpath is set to / and the number of data trees on which the replace operation is being performed is less than the total number of data trees the operation of retrieving all the data trees is does not feasible
  • this operation is to be performed on a list in an existing data tree. hence the possibility of multiple lists in multiple trees bring updated at same time is to be taken into consideration
    • seems feasible with xpath set to root, given the scenario where new list element is getting added to few of the data trees
  • with xpath set to root, the API should when xpath is set to "/" the replace operation can return an error message
  • the user can specify the data tree for which Replace operation is to be performed, but the drawback of this approach is if the number of data trees on which replace operation is to be performed is significantly bigPOST operation can be performed on particular data trees by specifying their respective xpaths.

The existing GET operation

Code Block
//Returns single fragment entity
default FragmentEntity findFirstRootByDataspaceAndAnchor(@NonNull DataspaceEntity dataspaceEntity,
                                                             @NonNull AnchorEntity anchorEntity) {
        return findRootsByDataspaceAndAnchor(dataspaceEntity.getId(), anchorEntity.getId()).stream().findFirst()
            .orElseThrow(() -> new DataNodeNotFoundException(dataspaceEntity.getName(), anchorEntity.getName()));


The updated GET operation is as follows to retrieve all the data trees under root

Code Block
//Now returns a List of Fragment entities
default List<FragmentEntity> findFirstRootByDataspaceAndAnchor(@NonNull DataspaceEntity dataspaceEntity,
                                                                   @NonNull AnchorEntity anchorEntity) {
        final List<FragmentEntity> fragmentEntities = new ArrayList<>(findRootsByDataspaceAndAnchor(dataspaceEntity.getId(), anchorEntity.getId()));
        if (! fragmentEntities.isEmpty()){
            return  fragmentEntities;
        } else{
            throw new DataNodeNotFoundException(dataspaceEntity.getName(), anchorEntity.getName());
        }
    }

...