summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org/onap
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-02-14 10:56:35 +0000
committerRenu Kumari <renu.kumari@bell.ca>2022-02-17 17:19:09 +0000
commitebfa4077b2e462237301e93566fed6ef2f56674c (patch)
treeee235c331884988bd34d008cc9c7f15729b1c615 /cps-service/src/main/java/org/onap
parenta15c0e5b58f16c3ab4a7c7610ac8c4a191e5e051 (diff)
Align JSON DataNode for Get and Post/Put API in CPS
Issue-ID: CPS-865 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: I60b1f9c94e79bdd66d60fe6a68f5fc4adc718d35
Diffstat (limited to 'cps-service/src/main/java/org/onap')
-rw-r--r--cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java13
2 files changed, 13 insertions, 2 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java b/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java
index e7b639d48e..1013c13b76 100644
--- a/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java
+++ b/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java
@@ -89,7 +89,7 @@ public class CpsDataUpdatedEventFactory {
private Data createData(final DataNode dataNode) {
final var data = new Data();
- DataMapUtils.toDataMap(dataNode).forEach(data::setAdditionalProperty);
+ DataMapUtils.toDataMapWithIdentifier(dataNode).forEach(data::setAdditionalProperty);
return data;
}
diff --git a/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java b/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
index 71a95f1ca0..42719d9b3c 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
@@ -37,12 +37,23 @@ import org.onap.cps.spi.model.DataNode;
public class DataMapUtils {
/**
+ * Converts DataNode structure into a map including the root node identifier for a JSON response.
+ *
+ * @param dataNode data node object
+ * @return a map representing same data with the root node identifier
+ */
+ public static Map<String, Object> toDataMapWithIdentifier(final DataNode dataNode) {
+ return ImmutableMap.<String, Object>builder()
+ .put(getNodeIdentifier(dataNode.getXpath()), toDataMap(dataNode))
+ .build();
+ }
+
+ /**
* Converts DataNode structure into a map for a JSON response.
*
* @param dataNode data node object
* @return a map representing same data
*/
-
public static Map<String, Object> toDataMap(final DataNode dataNode) {
return ImmutableMap.<String, Object>builder()
.putAll(dataNode.getLeaves())