From bb030cb7803d3d08f86de5eb1c6be5ad32f5fbf6 Mon Sep 17 00:00:00 2001 From: "puthuparambil.aditya" Date: Tue, 1 Mar 2022 11:51:20 +0000 Subject: Bug fix for delete data node not working for root node Fixing event for deletion of container node Fixing event for deletion of root node when '' is passed as xpath Issue-ID: CPS-895 Signed-off-by: puthuparambil.aditya Change-Id: I0676aec29e7b7e12bef2300219207ddc22414daa --- .../java/org/onap/cps/notification/NotificationService.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'cps-service/src/main') diff --git a/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java b/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java index 5ad59df2a..5e26a2204 100644 --- a/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java +++ b/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java @@ -37,8 +37,6 @@ import org.springframework.stereotype.Service; @Slf4j public class NotificationService { - private static final String ROOT_NODE_XPATH = "/"; - private NotificationProperties notificationProperties; private NotificationPublisher notificationPublisher; private CpsDataUpdatedEventFactory cpsDataUpdatedEventFactory; @@ -120,7 +118,15 @@ public class NotificationService { } private Operation getRootNodeOperation(final String xpath, final Operation operation) { - return ROOT_NODE_XPATH.equals(xpath) ? operation : Operation.UPDATE; + return isRootXpath(xpath) || isRootContainerNodeXpath(xpath) ? operation : Operation.UPDATE; + } + + private static boolean isRootXpath(final String xpath) { + return "/".equals(xpath) || "".equals(xpath); + } + + private static boolean isRootContainerNodeXpath(final String xpath) { + return 0 == xpath.lastIndexOf('/'); } } -- cgit 1.2.3-korg