Search in sources :

Example 1 with IdmConsoleLogDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmConsoleLogDto in project CzechIdMng by bcvsolutions.

the class DefaultConsoleNotificationSender method send.

@Override
@Transactional
public IdmConsoleLogDto send(IdmNotificationDto notification) {
    Assert.notNull(notification, "Notification is required!");
    // 
    LOG.info("Sending notification to console [{}]", notification);
    IdmConsoleLogDto log = createLog(notification);
    final String message = MessageFormat.format("Sending notification [{0}]", createLogForSend(notification, true));
    LOG.info(message);
    notification.setType(IdmConsoleLog.NOTIFICATION_TYPE);
    return log;
}
Also used : IdmConsoleLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmConsoleLogDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with IdmConsoleLogDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmConsoleLogDto in project CzechIdMng by bcvsolutions.

the class DefaultConsoleNotificationSender method createLogForSend.

/**
 * Create email log for send, this record is not persist.
 *
 * @param notification
 * @param showGuardedString
 * @return
 */
private IdmConsoleLogDto createLogForSend(IdmNotificationDto notification, boolean showGuardedString) {
    Assert.notNull(notification);
    Assert.notNull(notification.getMessage());
    // 
    IdmConsoleLogDto notificationLog = new IdmConsoleLogDto();
    notificationLog.setSent(new DateTime());
    notificationLog.setParent(notification.getId());
    // clone message
    notificationLog.setMessage(getMessage(notification, showGuardedString));
    // clone recipients - real recipient is console
    notification.getRecipients().forEach(recipient -> {
        notificationLog.getRecipients().add(new IdmNotificationRecipientDto(notificationLog.getId(), recipient.getIdentityRecipient(), IdmConsoleLog.NOTIFICATION_TYPE));
    });
    // clone from - resolve real email
    notificationLog.setIdentitySender(notification.getIdentitySender());
    return notificationLog;
}
Also used : IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) IdmConsoleLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmConsoleLogDto) DateTime(org.joda.time.DateTime)

Aggregations

IdmConsoleLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmConsoleLogDto)2 IdmNotificationRecipientDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto)1 DateTime (org.joda.time.DateTime)1 Transactional (org.springframework.transaction.annotation.Transactional)1