From f7873bd1a65592539a26e49ba84cd3c90cdca252 Mon Sep 17 00:00:00 2001
From: mpriyank <priyank.maheshwari@est.tech>
Date: Tue, 7 May 2024 15:33:19 +0100
Subject: Conditional cps change events

- introduced a parameter to control the cps core change event
  notifications. we should be able to disable these notifications
  without affecting other notification flows.
- fixed the LayeredArchitectureTest as we are accessing the Anchor model
  in the events package now.

Issue-ID: CPS-2213
Change-Id: Id875925bc14de1cc6e8fa3193c0df470e09fe43f
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
---
 .../main/java/org/onap/cps/events/CpsDataUpdateEventsService.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'cps-service/src/main/java')

diff --git a/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsService.java b/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsService.java
index d38432dfa9..1097834880 100644
--- a/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsService.java
+++ b/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsService.java
@@ -46,6 +46,9 @@ public class CpsDataUpdateEventsService {
     @Value("${app.cps.data-updated.topic:cps-data-updated-events}")
     private String topicName;
 
+    @Value("${app.cps.data-updated.change-event-notifications-enabled:true}")
+    private boolean cpsChangeEventNotificationsEnabled;
+
     @Value("${notification.enabled:false}")
     private boolean notificationsEnabled;
 
@@ -60,7 +63,7 @@ public class CpsDataUpdateEventsService {
     @Timed(value = "cps.dataupdate.events.publish", description = "Time taken to publish Data Update event")
     public void publishCpsDataUpdateEvent(final Anchor anchor, final String xpath,
                                           final Operation operation, final OffsetDateTime observedTimestamp) {
-        if (notificationsEnabled) {
+        if (notificationsEnabled && cpsChangeEventNotificationsEnabled) {
             final CpsDataUpdatedEvent cpsDataUpdatedEvent = createCpsDataUpdatedEvent(anchor,
                     observedTimestamp, xpath, operation);
             final String updateEventId = anchor.getDataspaceName() + ":" + anchor.getName();
@@ -70,7 +73,8 @@ public class CpsDataUpdateEventsService {
                             .extensions(extensions).build().asCloudEvent();
             eventsPublisher.publishCloudEvent(topicName, updateEventId, cpsDataUpdatedEventAsCloudEvent);
         } else {
-            log.debug("Notifications disabled.");
+            log.debug("State of Overall Notifications : {} and Cps Change Event Notifications : {}",
+                    notificationsEnabled, cpsChangeEventNotificationsEnabled);
         }
     }
 
-- 
cgit