@Override public NotificationTO getNotificationTO(final Notification notification) { NotificationTO notificationTO = new NotificationTO(); notificationTO.setKey(notification.getKey()); notificationTO.setTemplate(notification.getTemplate().getKey()); notificationTO.getEvents().addAll(notification.getEvents()); notificationTO.setRecipientsFIQL(notification.getRecipientsFIQL()); notificationTO.getStaticRecipients().addAll(notification.getStaticRecipients()); notificationTO.setRecipientAttrName(notification.getRecipientAttrName()); notificationTO.setSelfAsRecipient(notification.isSelfAsRecipient()); notificationTO.setSender(notification.getSender()); notificationTO.setSubject(notification.getSubject()); notificationTO.setTraceLevel(notification.getTraceLevel()); notificationTO.setActive(notification.isActive()); notification.getAbouts().forEach(about -> { notificationTO.getAbouts().put(about.getAnyType().getKey(), about.get()); }); if (notification.getRecipientsProvider() != null) { notificationTO.setRecipientsProvider(notification.getRecipientsProvider().getKey()); } return notificationTO; }
@Override public boolean notificationsAvailable( final AuditElements.EventCategoryType type, final String category, final String subcategory, final String event) { final String successEvent = AuditLoggerName.buildEvent(type, category, subcategory, event, Result.SUCCESS); final String failureEvent = AuditLoggerName.buildEvent(type, category, subcategory, event, Result.FAILURE); return notificationDAO.findAll().stream(). anyMatch(notification -> notification.isActive() && (notification.getEvents().contains(successEvent) || notification.getEvents().contains(failureEvent))); }
@Override public void update(final Notification notification, final NotificationTO notificationTO) { notification.setRecipientsFIQL(notificationTO.getRecipientsFIQL()); notification.getStaticRecipients().clear(); notification.getStaticRecipients().addAll(notificationTO.getStaticRecipients()); notification.setRecipientAttrName(notificationTO.getRecipientAttrName()); notification.setSelfAsRecipient(notificationTO.isSelfAsRecipient()); notification.setSender(notificationTO.getSender()); notification.setSubject(notificationTO.getSubject()); notification.setTraceLevel(notificationTO.getTraceLevel()); notification.setActive(notificationTO.isActive()); notification.getEvents().clear(); notification.getEvents().addAll(notificationTO.getEvents()); notification.setTemplate(template); if (notification.getEvents().isEmpty()) { sce.getElements().add("events"); if (!notification.getStaticRecipients().isEmpty()) { notification.getStaticRecipients().forEach(mail -> { Matcher matcher = SyncopeConstants.EMAIL_PATTERN.matcher(mail); if (!matcher.matches()) { LOG.debug("Invalid AnyType {} specified, ignoring...", entry.getKey()); } else { AnyAbout about = notification.getAbout(anyType).orElse(null);
if (notification.getRecipientsFIQL() != null) { recipients.addAll(searchDAO.<User>search( SearchCondConverter.convert(notification.getRecipientsFIQL()), Collections.<OrderByClause>emptyList(), AnyTypeKind.USER)); if (notification.isSelfAsRecipient() && any instanceof User) { recipients.add((User) any); String email = getRecipientEmail(notification.getRecipientAttrName(), recipient); if (email == null) { LOG.warn("{} cannot be notified: {} not found", recipient, notification.getRecipientAttrName()); } else { recipientEmails.add(email); if (notification.getStaticRecipients() != null) { recipientEmails.addAll(notification.getStaticRecipients()); if (notification.getRecipientsProvider() != null) { try { RecipientsProvider recipientsProvider = ImplementationManager.build(notification.getRecipientsProvider()); recipientEmails.addAll(recipientsProvider.provideRecipients(notification)); } catch (Exception e) { LOG.error("While building {}", notification.getRecipientsProvider(), e); jexlVars.put("events", notification.getEvents()); task.setTraceLevel(notification.getTraceLevel()); task.getRecipients().addAll(recipientEmails);
for (Notification notification : notificationDAO.findAll()) { if (LOG.isDebugEnabled()) { notification.getAbouts().forEach(about -> { LOG.debug("Notification about {} defined: {}", about.getAnyType(), about.get()); }); if (notification.isActive()) { String currentEvent = AuditLoggerName.buildEvent(type, category, subcategory, event, condition); if (!notification.getEvents().contains(currentEvent)) { LOG.debug("No events found about {}", any); } else if (anyType == null || any == null || !notification.getAbout(anyType).isPresent() || searchDAO.matches( any, SearchCondConverter.convert(notification.getAbout(anyType).get().get()))) { LOG.debug("Notification {} is not active, task will not be created", notification.getKey());
queryParameters.add(notification.getKey());
NotificationTaskTO notificationTaskTO = (NotificationTaskTO) taskTO; notificationTaskTO.setNotification(notificationTask.getNotification().getKey()); notificationTaskTO.setAnyTypeKind(notificationTask.getAnyTypeKind()); notificationTaskTO.setEntityKey(notificationTask.getEntityKey());