diff options
author | puthuparambil.aditya <aditya.puthuparambil@bell.ca> | 2022-03-01 11:51:20 +0000 |
---|---|---|
committer | puthuparambil.aditya <aditya.puthuparambil@bell.ca> | 2022-03-03 14:10:15 +0000 |
commit | bb030cb7803d3d08f86de5eb1c6be5ad32f5fbf6 (patch) | |
tree | f92d4946fd63f4ddf6d5954894abe56a2bf24e01 /cps-service/src/main | |
parent | 304b9f319cddad71a77f6bbffb8c18f63b7f5ee2 (diff) |
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 <aditya.puthuparambil@bell.ca>
Change-Id: I0676aec29e7b7e12bef2300219207ddc22414daa
Diffstat (limited to 'cps-service/src/main')
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/notification/NotificationService.java | 12 |
1 files changed, 9 insertions, 3 deletions
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 5ad59df2aa..5e26a22045 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('/'); } } |