use of eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel in project CzechIdMng by bcvsolutions.
the class DefaultIdmNotificationConfigurationService method getSenders.
@Override
public List<NotificationSender<?>> getSenders(BaseNotification notification) {
Assert.notNull(notification, "Notification is required.");
Assert.notNull(notification.getMessage(), "Message is required.");
//
// default senders for unknown topics
NotificationLevel level = notification.getMessage().getLevel();
String topic = notification.getTopic();
if (StringUtils.isEmpty(notification.getTopic())) {
return getDefaultSenders();
}
// if configuration for given topic is found, but is disabled,
// then default senders are not used => noticication is disabled and not be sent.
boolean disabled = false;
//
List<NotificationSender<?>> senders = new ArrayList<>();
if (!IdmNotificationLog.NOTIFICATION_TYPE.equals(notification.getType())) {
// concrete sender - configuration was resolved before, check for disabled is not needed now
NotificationSender<?> sender = getSender(notification.getType());
if (sender != null) {
senders.add(sender);
}
} else {
// notification - find all senders by topic and level by configuration
// check configuration is enabled
List<IdmNotificationConfiguration> configs = repository.findAllByTopicAndWildcardLevel(topic, level);
//
for (IdmNotificationConfiguration config : configs) {
if (config.isDisabled()) {
disabled = true;
LOG.debug("Configuration for topic [{}], level [{}], type [{}] is disabled. " + "Notification will not be sent by this configuration", topic, level, config.getNotificationType());
} else {
NotificationSender<?> sender = getSender(config.getNotificationType());
if (sender != null) {
senders.add(sender);
}
}
}
}
//
if (senders.isEmpty()) {
if (disabled) {
LOG.info("All configurations for topic [{}], level [{}] are disabled. " + "Notification will not be sent.", topic, level);
} else {
// configuration not found - return default senders
return getDefaultSenders();
}
}
return senders;
}
Aggregations