Search in sources :

Example 6 with IdmNotificationRecipientDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto 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)

Example 7 with IdmNotificationRecipientDto

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

the class DefaultNotificationManager method createLog.

/**
 * Persists new notification record from given notification.
 * Input notification type is leaved unchanged - is needed for another processing (routing).
 *
 * @param notification
 * @return
 */
private IdmNotificationLogDto createLog(IdmNotificationDto notification) {
    Assert.notNull(notification);
    Assert.notNull(notification.getMessage());
    // IdmNotificationLog
    if (notification instanceof IdmNotificationLogDto) {
        notification.setSent(new DateTime());
        IdmNotificationLogDto notificationLog = notificationLogService.save((IdmNotificationLogDto) notification);
        // set previous type - is needed for choose correct notification sender
        notificationLog.setType(notification.getType());
        return notificationLog;
    }
    // we need to clone notification
    IdmNotificationLogDto notificationLog = new IdmNotificationLogDto();
    notificationLog.setType(notification.getType());
    notificationLog.setSent(new DateTime());
    // clone message
    notificationLog.setMessage(cloneMessage(notification));
    // clone recipients
    for (IdmNotificationRecipientDto recipient : notification.getRecipients()) {
        notificationLog.getRecipients().add(cloneRecipient(notificationLog, recipient, recipient.getRealRecipient()));
    }
    notificationLog.setIdentitySender(notification.getIdentitySender());
    notificationLog = notificationLogService.save(notificationLog);
    // set previous type - is needed for choose correct notification sender
    notificationLog.setType(notification.getType());
    return notificationLog;
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) DateTime(org.joda.time.DateTime)

Aggregations

IdmNotificationRecipientDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto)7 Transactional (org.springframework.transaction.annotation.Transactional)3 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)2 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)2 DateTime (org.joda.time.DateTime)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 Lists (com.google.common.collect.Lists)1 InitTestData (eu.bcvsolutions.idm.InitTestData)1 BaseDtoController (eu.bcvsolutions.idm.core.api.rest.BaseDtoController)1 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)1 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)1 FlashMessage (eu.bcvsolutions.idm.core.notification.api.dto.FlashMessage)1 IdmConsoleLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmConsoleLogDto)1 IdmEmailLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmEmailLogDto)1 IdmNotificationDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto)1 IdmWebsocketLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmWebsocketLogDto)1 IdmJwtAuthentication (eu.bcvsolutions.idm.core.security.api.domain.IdmJwtAuthentication)1 IdmAuthorityUtils (eu.bcvsolutions.idm.core.security.api.utils.IdmAuthorityUtils)1