diff options
author | DylanB95EST <dylan.byrne@est.tech> | 2021-08-18 17:12:25 +0100 |
---|---|---|
committer | Dylan Byrne <dylan.byrne@est.tech> | 2021-08-24 11:22:53 +0000 |
commit | 31facc867f1a5dcfe78295b15dc3ddc1c9d15896 (patch) | |
tree | e5f27cb7958de1d44d16e2f3ec2328ae441be2f0 /cps-service/src/main/java | |
parent | dc5ed75c841da857611713bceed8bf9988204d3d (diff) |
Update CmHandle in DMI-Registry for a DMI-Plugin Instance in NCMP as part of dmi registration.
Updating existing CM-Handles created previously as part of CPS-442
Note - Can only update cm handles and properties which already exist.
Issue-ID: CPS-443
Change-Id: Ib05a4e01336ca463578b45917dcdfe715b6bad07
Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Diffstat (limited to 'cps-service/src/main/java')
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/api/CpsDataService.java | 13 | ||||
-rwxr-xr-x | cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java | 25 |
2 files changed, 38 insertions, 0 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java index 6036f92225..2583e9905b 100644 --- a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java +++ b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java @@ -118,4 +118,17 @@ public interface CpsDataService { * @param listNodeXpath list node xpath */ void deleteListNodeData(@NonNull String dataspaceName, @NonNull String anchorName, @NonNull String listNodeXpath); + + /** + * Updates leaves of DataNode for given dataspace and anchor using xpath, + * along with the leaves of each Child Data Node which already exists. + * This method will throw an exception if data node update or any descendant update does not exist. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @param parentNodeXpath xpath + * @param dataNodeUpdatesAsJson json data representing data node updates + */ + void updateNodeLeavesAndExistingDescendantLeaves(String dataspaceName, String anchorName, String parentNodeXpath, + String dataNodeUpdatesAsJson); } diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index 5e6e1a2687..b45645bc42 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -98,6 +98,18 @@ public class CpsDataServiceImpl implements CpsDataService { } @Override + public void updateNodeLeavesAndExistingDescendantLeaves(final String dataspaceName, final String anchorName, + final String parentNodeXpath, + final String dataNodeUpdatesAsJson) { + final Collection<DataNode> dataNodeUpdates = + buildDataNodeCollectionFromJson(dataspaceName, anchorName, parentNodeXpath, dataNodeUpdatesAsJson); + for (final DataNode dataNodeUpdate : dataNodeUpdates) { + processDataNodeUpdate(dataspaceName, anchorName, dataNodeUpdate); + } + notificationService.processDataUpdatedEvent(dataspaceName, anchorName); + } + + @Override public void replaceNodeTree(final String dataspaceName, final String anchorName, final String parentNodeXpath, final String jsonData) { final var dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData); @@ -160,4 +172,17 @@ public class CpsDataServiceImpl implements CpsDataService { private SchemaContext getSchemaContext(final String dataspaceName, final String schemaSetName) { return yangTextSchemaSourceSetCache.get(dataspaceName, schemaSetName).getSchemaContext(); } + + private void processDataNodeUpdate(final String dataspaceName, final String anchorName, + final DataNode dataNodeUpdate) { + if (dataNodeUpdate == null) { + return; + } + cpsDataPersistenceService.updateDataLeaves(dataspaceName, anchorName, dataNodeUpdate.getXpath(), + dataNodeUpdate.getLeaves()); + final Collection<DataNode> childDataNodeUpdates = dataNodeUpdate.getChildDataNodes(); + for (final DataNode childDataNodeUpdate : childDataNodeUpdates) { + processDataNodeUpdate(dataspaceName, anchorName, childDataNodeUpdate); + } + } } |