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

Compare with Current View Page History

« Previous Version 19 Next »

Overview

In CPS-341 the POST operation to create a new data node was updated to bring support for a multiple data trees under a single anchor (or a single root "/" node). In order to achieve this, the JSON data containing multiple data trees are parsed into a Collection of data nodes.

This collection of data nodes is then converted to a List of Fragment Entities which is stored into the database.

From the above description it is clear that when a GET operation will be performed on an anchor containing multiple data trees to retrieve one or all data trees, it will be returned as a List of Fragment Entities as opposed to a single Fragment Entity being returned earlier.

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.

References

Open Issues and Decisions

#APIIssue/DescriptionDecisionsFinal Outcome
1

Get operation should return all the data trees under the root when xpath is set to "/"

after discussion with Toine Siebelink it was decided to give priority to the GET operation first, before heading for other API's. A discussion with the architects is to be scheduled to discuss upon the following points:

  • should a separate end point be created which returns all the data trees under the root node
  • impact of ongoing versioning issue with CPS on the above point and backwards compatibility

after discussion with the architects it was decided to have a v2 of the GET API and the v2 will return all the data nodes in an array


2Response body of GET APIshould GET Data Node return a JSON array or JSON object in response for multiple data trees

as discussed in weekly meeting, it was decided that v2 of the GET API will return JSON Array and v1 will remain as is (that is returns single data node as JSON Object)


3Impact on NCMP DMI pluginimpact analysis of Get Data Node returning multiple data trees on NCMP DMI plugin

4CPS Core API's under this linkThe remaining CPS core API's might require modification with respect to decisions made for the GET operation. Based upon the decisions for the above Issue this table will be updated from time to time.

in the meeting it was decided to focus on GET operation first as the work on remaining API's seemed different from the one for the GET API. Also it was decided to first have a discussion with the architects regarding the GET API and then have a separate discussion for the remaining API;s.


List of impacted API's

OperationAPIIssuesPossible Solution

GET

Get 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 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 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 if the number of data trees on which replace operation is to be performed is significantly high
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 "/", first the get operation is executed internally to retrieve all the data trees
  • 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
POSTAdd list element to existing list
  • when the API is called and xpath is set to "/", first the get operation is executed internally to retrieve all the data trees
  • once all the data trees are returned in a List the API proceeds to perform the Post operation
    • retrieving all the data trees does not 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 return an error message
  • the POST operation can be performed on particular data trees by specifying their respective xpaths.

The existing GET operation

//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()));


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 CPS-Core Get Data Node API. This data tree is returned in form of a JSON Object as follows:

{
        "multiple-data-tree:first-container": {
            "a-leaf": "a-Value"
        }
}

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. Now, when the xpath is set as root, CPS should return all the data trees. Now there are two possible responses we can get here:

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

Impact on CPS-NCMP_DMI plugin

The CPS NCMP DMI plugin internally calls the getDataNode method in order to fetch the configuration data for NCMP-DMI plugin, As of now it expects only a single DataNode to be returned by the getDataNode method and with the updated GET API we are now getting a collection of one or more data nodes from the getDtaNode method.

A couple of things to be checked here are:

  • Will there be any Impact of multiple data nodes on the functionality of NCMP plugin
  • Appropriate approach to bring in support for multiple data nodes into NCMP

The error was noticed in the following files, where the getDataNode method is being called internally:

Java file
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java

Corresponding test cases
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy
  • No labels