2022-03-17 18:22:23 +01:00
|
|
|
package org.gcube.application.cms.notifications;
|
|
|
|
|
2024-03-21 15:53:54 +01:00
|
|
|
import java.io.IOException;
|
2024-01-31 18:09:38 +01:00
|
|
|
import java.util.ArrayList;
|
2024-02-01 16:00:01 +01:00
|
|
|
import java.util.HashMap;
|
2024-01-31 18:09:38 +01:00
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2024-02-01 16:00:01 +01:00
|
|
|
import java.util.stream.Collectors;
|
2024-01-31 18:09:38 +01:00
|
|
|
|
|
|
|
import org.bson.Document;
|
|
|
|
import org.gcube.application.cms.implementations.utils.UserUtils;
|
|
|
|
import org.gcube.application.cms.notifications.config.SubscribeNotificationEvent;
|
2024-02-01 16:28:03 +01:00
|
|
|
import org.gcube.application.cms.notifications.manage.ManageDoActionNotification;
|
2024-03-21 15:53:54 +01:00
|
|
|
import org.gcube.application.cms.notifications.substitutor.NMessagesPlaceholdersSubstitutorUtil;
|
2024-01-31 18:09:38 +01:00
|
|
|
import org.gcube.application.cms.plugins.EventListenerPluginInterface;
|
|
|
|
import org.gcube.application.cms.plugins.events.EventListener;
|
|
|
|
import org.gcube.application.cms.plugins.events.EventManager;
|
|
|
|
import org.gcube.application.cms.plugins.events.EventManager.Event;
|
|
|
|
import org.gcube.application.cms.plugins.events.ItemObserved;
|
|
|
|
import org.gcube.application.cms.plugins.faults.InitializationException;
|
2024-04-15 16:39:35 +02:00
|
|
|
import org.gcube.application.cms.plugins.faults.InvalidProfileException;
|
2024-01-31 18:09:38 +01:00
|
|
|
import org.gcube.application.cms.plugins.faults.MaterializationException;
|
|
|
|
import org.gcube.application.cms.plugins.faults.ShutDownException;
|
2022-05-06 18:03:48 +02:00
|
|
|
import org.gcube.application.cms.plugins.implementations.AbstractPlugin;
|
2024-01-31 18:09:38 +01:00
|
|
|
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
|
|
|
import org.gcube.application.cms.plugins.reports.Report;
|
|
|
|
import org.gcube.application.cms.plugins.reports.Report.Status;
|
|
|
|
import org.gcube.application.cms.serialization.Serialization;
|
|
|
|
import org.gcube.application.geoportal.common.model.document.Project;
|
2022-05-06 18:03:48 +02:00
|
|
|
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
|
2024-01-31 18:09:38 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
2022-05-06 18:03:48 +02:00
|
|
|
|
2024-01-19 13:06:37 +01:00
|
|
|
import com.vdurmont.semver4j.Semver;
|
|
|
|
|
2024-01-31 18:09:38 +01:00
|
|
|
import lombok.Synchronized;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class NotificationsPlugin.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
* Jan 30, 2024
|
|
|
|
*/
|
|
|
|
@Slf4j
|
|
|
|
public class NotificationsPlugin extends AbstractPlugin implements EventListenerPluginInterface {
|
2022-05-06 18:03:48 +02:00
|
|
|
|
2024-01-31 18:09:38 +01:00
|
|
|
public static final String SUBSCRIBE_NOTIFICATIONS_CONFIG = "subscribeNotifications";
|
|
|
|
public static final String PLUGIN_ID = "Notifications-Plugin";
|
|
|
|
public static final String PLUGIN_TYPE = "EventListener";
|
|
|
|
|
2024-04-15 16:39:35 +02:00
|
|
|
private static final String CONFIG_ENABLED = "enabled";
|
|
|
|
private static final String CONFIG_LINK_TO_NOTIFICATIONS_MESSAGES = "link_to_notifications_messages";
|
|
|
|
|
2024-01-31 18:09:38 +01:00
|
|
|
public static final PluginDescriptor DESCRIPTOR = new PluginDescriptor(PLUGIN_ID, PLUGIN_TYPE);
|
2022-05-06 18:03:48 +02:00
|
|
|
|
2024-01-19 13:06:37 +01:00
|
|
|
static {
|
|
|
|
DESCRIPTOR.setVersion(new Semver("1.0.0"));
|
|
|
|
DESCRIPTOR.setDescription("Manage the notification from Geoportal engine");
|
|
|
|
}
|
2022-05-06 18:03:48 +02:00
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
// This is a map "<Context,<UCD_ID,NotificationEventsSubscribedConfig>"
|
|
|
|
protected Map<String, Map<String, NotificationEventsSubscribedConfig>> notificationEventsBindingMap = null;
|
|
|
|
|
2024-01-31 18:09:38 +01:00
|
|
|
/**
|
|
|
|
* Inits the.
|
|
|
|
*
|
|
|
|
* @return the initialization report
|
|
|
|
* @throws InitializationException the initialization exception
|
|
|
|
*/
|
2024-01-19 13:06:37 +01:00
|
|
|
@Override
|
2024-01-31 18:09:38 +01:00
|
|
|
public InitializationReport init() throws InitializationException {
|
|
|
|
log.debug("Called init");
|
|
|
|
InitializationReport report = null;
|
|
|
|
try {
|
|
|
|
// Creating all listeners
|
|
|
|
EventListener<ItemObserved<Project>> listenerCreated = new EventListener<ItemObserved<Project>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updated(ItemObserved<Project> observerd) {
|
2024-03-22 16:26:40 +01:00
|
|
|
log.info("listenerCreated fired on item: {} ", observerd);
|
2024-01-31 18:09:38 +01:00
|
|
|
|
|
|
|
boolean subscribed = checkIfSubscribedEvent(observerd);
|
|
|
|
|
|
|
|
if (subscribed) {
|
|
|
|
doAction(observerd);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EventListener<ItemObserved<Project>> listenerUpdated = new EventListener<ItemObserved<Project>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updated(ItemObserved<Project> observerd) {
|
2024-03-22 16:26:40 +01:00
|
|
|
log.info("listenerUpdated fired on item: {} ", observerd);
|
2024-01-31 18:09:38 +01:00
|
|
|
boolean subscribed = checkIfSubscribedEvent(observerd);
|
|
|
|
|
|
|
|
if (subscribed) {
|
|
|
|
doAction(observerd);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EventListener<ItemObserved<Project>> listenerDeleted = new EventListener<ItemObserved<Project>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updated(ItemObserved<Project> observerd) {
|
2024-03-22 16:26:40 +01:00
|
|
|
log.info("listenerDeleted fired on item: {} ", observerd);
|
2024-01-31 18:09:38 +01:00
|
|
|
boolean subscribed = checkIfSubscribedEvent(observerd);
|
|
|
|
|
|
|
|
if (subscribed) {
|
|
|
|
doAction(observerd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EventListener<ItemObserved<Project>> listenerLCStepPerformed = new EventListener<ItemObserved<Project>>() {
|
2022-05-06 18:03:48 +02:00
|
|
|
|
2024-01-31 18:09:38 +01:00
|
|
|
@Override
|
|
|
|
public void updated(ItemObserved<Project> observerd) {
|
2024-03-22 16:26:40 +01:00
|
|
|
log.info("listenerLCStepPerformed fired on item: {} ", observerd);
|
2024-01-31 18:09:38 +01:00
|
|
|
boolean subscribed = checkIfSubscribedEvent(observerd);
|
2022-05-06 18:03:48 +02:00
|
|
|
|
2024-01-31 18:09:38 +01:00
|
|
|
if (subscribed) {
|
|
|
|
doAction(observerd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Subscribing all events
|
|
|
|
EventManager eventMngInst = EventManager.getInstance();
|
|
|
|
eventMngInst.subscribe(Event.PROJECT_CREATED, listenerCreated);
|
|
|
|
eventMngInst.subscribe(Event.PROJECT_UPDATED, listenerUpdated);
|
|
|
|
eventMngInst.subscribe(Event.PROJECT_DELETED, listenerDeleted);
|
|
|
|
eventMngInst.subscribe(Event.LIFECYCLE_STEP_PERFORMED, listenerLCStepPerformed);
|
|
|
|
|
|
|
|
report = new InitializationReport(Status.OK, PLUGIN_ID + " init performed");
|
|
|
|
} catch (Exception e) {
|
|
|
|
InitializationException exc = new InitializationException("Unable to initialize " + DESCRIPTOR.getId(), e);
|
|
|
|
log.error("init error: {} ", exc);
|
|
|
|
throw exc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return report;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the descriptor.
|
|
|
|
*
|
|
|
|
* @return the descriptor
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public PluginDescriptor getDescriptor() {
|
2024-01-19 13:06:37 +01:00
|
|
|
return DESCRIPTOR;
|
|
|
|
}
|
2024-01-31 18:09:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Inits the in context.
|
|
|
|
*
|
|
|
|
* @return the initialization report
|
|
|
|
* @throws InitializationException the initialization exception
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Synchronized
|
|
|
|
public InitializationReport initInContext() throws InitializationException {
|
2024-04-10 15:20:53 +02:00
|
|
|
log.debug("Called initInContext");
|
2024-01-31 18:09:38 +01:00
|
|
|
InitializationReport report = new InitializationReport();
|
|
|
|
try {
|
|
|
|
String context = UserUtils.getCurrent().getContext();
|
|
|
|
if (getNotificationBindingMapPerContext() == null) {
|
|
|
|
log.info("Initializing in " + context);
|
2024-02-01 16:00:01 +01:00
|
|
|
notificationEventsBindingMap.put(context, new HashMap<String, NotificationEventsSubscribedConfig>());
|
2024-01-31 18:09:38 +01:00
|
|
|
}
|
|
|
|
report.setStatus(Report.Status.OK);
|
|
|
|
report.putMessage("Initialized " + DESCRIPTOR.getId() + " in the " + context);
|
|
|
|
} catch (Exception e) {
|
|
|
|
InitializationException exc = new InitializationException("Unable to initialize " + DESCRIPTOR.getId(), e);
|
|
|
|
log.error("initInContext error: {} ", exc);
|
|
|
|
throw exc;
|
|
|
|
}
|
|
|
|
return report;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if subscribed event.
|
|
|
|
*
|
|
|
|
* @param observerd the observerd
|
|
|
|
* @return true, if successful
|
|
|
|
*/
|
|
|
|
public boolean checkIfSubscribedEvent(ItemObserved<Project> observerd) {
|
|
|
|
log.info("Checking if {} is an subscribed event", observerd.getEvent());
|
|
|
|
try {
|
|
|
|
NotificationEventsSubscribedConfig eventsSub = readNotificationsSubscribedFromConfigurationInTheUCD(
|
|
|
|
observerd.getUseCaseDescriptor());
|
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
if (eventsSub != null) {
|
|
|
|
|
|
|
|
List<SubscribeNotificationEvent> listEvents = eventsSub.getListNotificationEventSubscribed();
|
|
|
|
log.info("List events is {}", listEvents);
|
2024-04-15 17:46:49 +02:00
|
|
|
|
|
|
|
if(listEvents==null) {
|
|
|
|
log.info("no event subscribed, returning false");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (listEvents.stream().anyMatch(sne -> sne.getEvent().equals(observerd.getEvent()))) {
|
2024-02-01 16:00:01 +01:00
|
|
|
log.info("the event {} is subscribed from config ", observerd.getEvent());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
log.info("the event {} is not subscribed from config ", observerd.getEvent());
|
|
|
|
return false;
|
2024-01-31 18:09:38 +01:00
|
|
|
}
|
|
|
|
log.info("the event {} is not subscribed from config ", observerd.getEvent());
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("Exception, Error on checking subscribed events", e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the notification binding map per context.
|
|
|
|
*
|
|
|
|
* @return the notification binding map per context
|
|
|
|
*/
|
2024-02-01 16:00:01 +01:00
|
|
|
protected Map<String, NotificationEventsSubscribedConfig> getNotificationBindingMapPerContext() {
|
2024-01-31 18:09:38 +01:00
|
|
|
String context = UserUtils.getCurrent().getContext();
|
|
|
|
log.debug("Getting {} from cache map for context {}", NotificationsPlugin.PLUGIN_ID, context);
|
2024-02-01 16:00:01 +01:00
|
|
|
if (notificationEventsBindingMap == null) {
|
|
|
|
notificationEventsBindingMap = new LinkedHashMap<String, Map<String, NotificationEventsSubscribedConfig>>();
|
|
|
|
}
|
2024-01-31 18:09:38 +01:00
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
// read notification events binding subscribed in the context
|
|
|
|
Map<String, NotificationEventsSubscribedConfig> map = notificationEventsBindingMap.get(context);
|
|
|
|
return map == null ? new LinkedHashMap<String, NotificationEventsSubscribedConfig>() : map;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the notification binding map per context.
|
|
|
|
*
|
|
|
|
* @param context the context
|
|
|
|
* @param ucd the ucd
|
|
|
|
* @param notification the notification
|
|
|
|
*/
|
|
|
|
private void setNotificationBindingMapPerContext(String context, UseCaseDescriptor ucd,
|
|
|
|
NotificationEventsSubscribedConfig notification) {
|
|
|
|
Map<String, NotificationEventsSubscribedConfig> mapNotificationConfig = notificationEventsBindingMap
|
|
|
|
.get(context);
|
|
|
|
if (mapNotificationConfig == null) {
|
|
|
|
mapNotificationConfig = new LinkedHashMap<String, NotificationEventsSubscribedConfig>();
|
|
|
|
}
|
|
|
|
|
|
|
|
mapNotificationConfig.put(ucd.getId(), notification);
|
|
|
|
notificationEventsBindingMap.put(context, mapNotificationConfig);
|
2024-01-31 18:09:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read notifications subscribed from configuration in the UCD.
|
|
|
|
*
|
|
|
|
* @param useCaseDescriptor the use case descriptor
|
|
|
|
* @return the notification events subscribed config
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
public NotificationEventsSubscribedConfig readNotificationsSubscribedFromConfigurationInTheUCD(
|
|
|
|
UseCaseDescriptor useCaseDescriptor) throws Exception {
|
|
|
|
|
|
|
|
log.debug("Reading subscribed events from UCD");
|
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
NotificationEventsSubscribedConfig notificationMapPerContext = null;
|
2024-01-31 18:09:38 +01:00
|
|
|
|
|
|
|
if (useCaseDescriptor == null)
|
|
|
|
throw new Exception("Error reading UCD null found");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String context = UserUtils.getCurrent().getContext();
|
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
Map<String, NotificationEventsSubscribedConfig> mapPerContext = getNotificationBindingMapPerContext();
|
2024-01-31 18:09:38 +01:00
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
notificationMapPerContext = mapPerContext.get(useCaseDescriptor.getId());
|
|
|
|
|
|
|
|
if (notificationMapPerContext == null) {
|
|
|
|
notificationMapPerContext = new NotificationEventsSubscribedConfig();
|
|
|
|
setNotificationBindingMapPerContext(context, useCaseDescriptor, notificationMapPerContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<SubscribeNotificationEvent> listNotificationEventsSubscribedPerUCD = notificationMapPerContext
|
|
|
|
.getListNotificationEventSubscribed();
|
|
|
|
|
|
|
|
if (listNotificationEventsSubscribedPerUCD == null) {
|
2024-02-01 12:22:34 +01:00
|
|
|
listNotificationEventsSubscribedPerUCD = new ArrayList<SubscribeNotificationEvent>();
|
2024-01-31 18:09:38 +01:00
|
|
|
Document profileConfiguration = getConfigurationFromProfile(useCaseDescriptor).getConfiguration();
|
|
|
|
log.debug("UseCaseDescriptor Configuration is {} ", profileConfiguration);
|
|
|
|
// JSONPathWrapper schemaNavigator = new
|
|
|
|
// JSONPathWrapper(useCaseDescriptor.getSchema().toJson());
|
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
if (profileConfiguration != null) {
|
|
|
|
for (Object fsConfigObj : profileConfiguration.get(SUBSCRIBE_NOTIFICATIONS_CONFIG, List.class)) {
|
2024-04-17 16:08:35 +02:00
|
|
|
log.debug("Managing {}", fsConfigObj);
|
2024-02-01 16:00:01 +01:00
|
|
|
SubscribeNotificationEvent fsConfig = Serialization.convert(fsConfigObj,
|
|
|
|
SubscribeNotificationEvent.class);
|
|
|
|
log.debug("Converted config {}", fsConfig);
|
|
|
|
try {
|
|
|
|
Event theEventSubsribed = Serialization.convert(fsConfig.getEvent(), Event.class);
|
|
|
|
if (theEventSubsribed == null)
|
|
|
|
throw new MaterializationException(
|
|
|
|
"Invalid Field Definition path in configuration [NO MATCH] : "
|
|
|
|
+ theEventSubsribed);
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("MaterializationException: ", e);
|
|
|
|
throw new MaterializationException(
|
|
|
|
"Invalid Event Definition path in configuration [NO MATCH Event] : "
|
|
|
|
+ Event.values());
|
|
|
|
}
|
|
|
|
|
2024-02-01 12:22:34 +01:00
|
|
|
listNotificationEventsSubscribedPerUCD.add(fsConfig);
|
|
|
|
}
|
2024-01-31 18:09:38 +01:00
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
notificationMapPerContext.setUcd(useCaseDescriptor);
|
|
|
|
notificationMapPerContext
|
|
|
|
.setListNotificationEventSubscribed(listNotificationEventsSubscribedPerUCD);
|
2024-04-15 16:39:35 +02:00
|
|
|
String linkToMessages = profileConfiguration.get(CONFIG_LINK_TO_NOTIFICATIONS_MESSAGES,
|
|
|
|
String.class);
|
|
|
|
Boolean enabledNotifications = profileConfiguration.get(CONFIG_ENABLED, Boolean.class);
|
2024-03-21 15:53:54 +01:00
|
|
|
notificationMapPerContext.setLinkToNotificationsMessages(linkToMessages);
|
2024-03-26 10:28:21 +01:00
|
|
|
notificationMapPerContext.setEnabled(enabledNotifications);
|
2024-02-01 16:00:01 +01:00
|
|
|
}
|
|
|
|
setNotificationBindingMapPerContext(context, useCaseDescriptor, notificationMapPerContext);
|
2024-01-31 18:09:38 +01:00
|
|
|
|
2024-02-01 12:22:34 +01:00
|
|
|
log.info("Events subscribed read from config {} ", notificationMapPerContext);
|
2024-01-31 18:09:38 +01:00
|
|
|
|
|
|
|
}
|
2024-04-15 16:39:35 +02:00
|
|
|
} catch (InvalidProfileException e) {
|
2024-04-15 17:01:56 +02:00
|
|
|
log.warn("Unable to read configuration for {} in the UCD {}", NotificationsPlugin.PLUGIN_ID,
|
2024-04-15 16:39:35 +02:00
|
|
|
useCaseDescriptor.getId());
|
2024-01-31 18:09:38 +01:00
|
|
|
} catch (Exception e) {
|
2024-02-01 16:00:01 +01:00
|
|
|
log.error("Unable to read configuration for " + NotificationsPlugin.PLUGIN_ID, e);
|
2024-01-31 18:09:38 +01:00
|
|
|
} catch (Throwable t) {
|
|
|
|
log.error("Exception, Unable to read configuration ", t);
|
|
|
|
}
|
|
|
|
|
2024-02-01 12:22:34 +01:00
|
|
|
return notificationMapPerContext;
|
2024-01-31 18:09:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shutdown.
|
|
|
|
*
|
|
|
|
* @throws ShutDownException the shut down exception
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void shutdown() throws ShutDownException {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do action.
|
|
|
|
*
|
|
|
|
* @param itemObserved the item observed
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void doAction(ItemObserved<Project> itemObserved) {
|
2024-02-01 16:28:03 +01:00
|
|
|
log.debug("doAction called...");
|
2024-03-26 10:28:21 +01:00
|
|
|
|
2024-02-01 16:28:03 +01:00
|
|
|
boolean isSubscribedEvent = checkIfSubscribedEvent(itemObserved);
|
2024-02-01 16:00:01 +01:00
|
|
|
|
2024-02-01 16:28:03 +01:00
|
|
|
log.info("Is the event {} subscribed in notification plugin configured in the UCD: {} ",
|
|
|
|
itemObserved.getEvent(), isSubscribedEvent);
|
2024-02-01 16:00:01 +01:00
|
|
|
|
2024-02-01 16:28:03 +01:00
|
|
|
if (isSubscribedEvent) {
|
|
|
|
|
|
|
|
// Map (UCD_ID, Notification)
|
2024-02-01 16:00:01 +01:00
|
|
|
Map<String, NotificationEventsSubscribedConfig> notificationMapPerContext = getNotificationBindingMapPerContext();
|
2024-02-01 16:28:03 +01:00
|
|
|
|
2024-02-01 16:00:01 +01:00
|
|
|
NotificationEventsSubscribedConfig subscribedConfig = notificationMapPerContext
|
|
|
|
.get(itemObserved.getUCD_Id());
|
|
|
|
|
2024-03-26 10:28:21 +01:00
|
|
|
boolean subscribeNotificationsEnabled = subscribedConfig.isEnabled();
|
2024-02-01 16:00:01 +01:00
|
|
|
|
2024-03-26 10:28:21 +01:00
|
|
|
log.info("subscribeNotifications enabled: {}", subscribeNotificationsEnabled);
|
2024-02-01 16:00:01 +01:00
|
|
|
|
2024-03-26 10:28:21 +01:00
|
|
|
if (subscribeNotificationsEnabled) {
|
|
|
|
|
|
|
|
String linkToFileWithMessages = subscribedConfig.getLinkToNotificationsMessages();
|
|
|
|
List<SubscribeNotificationEvent> list = subscribedConfig.getListNotificationEventSubscribed();
|
|
|
|
|
|
|
|
// Filtering list of SubscribeNotificationEvent for itemObserved Event
|
|
|
|
List<SubscribeNotificationEvent> filterList = list.stream()
|
|
|
|
.filter(sne -> sne.getEvent().equals(itemObserved.getEvent())).collect(Collectors.toList());
|
2024-02-01 16:00:01 +01:00
|
|
|
|
2024-03-26 10:28:21 +01:00
|
|
|
log.debug(linkToFileWithMessages);
|
|
|
|
NMessagesPlaceholdersSubstitutorUtil nMPlaceholdersSUtil = null;
|
|
|
|
try {
|
|
|
|
nMPlaceholdersSUtil = new NMessagesPlaceholdersSubstitutorUtil(linkToFileWithMessages);
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.error("Error instancing the {}. Please check the URL {}. Returning!!",
|
|
|
|
NMessagesPlaceholdersSubstitutorUtil.class.getSimpleName(), linkToFileWithMessages);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ManageDoActionNotification mdoact = new ManageDoActionNotification(itemObserved, nMPlaceholdersSUtil,
|
|
|
|
filterList);
|
|
|
|
mdoact.manage();
|
|
|
|
|
|
|
|
}
|
2024-02-01 16:00:01 +01:00
|
|
|
}
|
2024-01-31 18:09:38 +01:00
|
|
|
|
|
|
|
}
|
2022-03-17 18:22:23 +01:00
|
|
|
}
|