Search in sources :

Example 11 with IdmEmailLogDto

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

the class DefaultEmailNotificationSender method send.

@Override
@Transactional
public IdmEmailLogDto send(IdmMessageDto message, String[] emails, List<IdmAttachmentDto> attachments) {
    Assert.notNull(message, "Message is required.");
    Assert.notNull(emails, "Emails are required.");
    // 
    IdmEmailLogDto emailLog = new IdmEmailLogDto();
    // there is no parent
    // build message, without password
    emailLog.setMessage(notificationTemplateService.buildMessage(message, false));
    // 
    for (String email : emails) {
        // fill email to recipientDto
        emailLog.getRecipients().add(new IdmNotificationRecipientDto(email));
    }
    emailLog = this.emailLogService.save(emailLog);
    // save notification attachments
    emailLog.setAttachments(saveNotificationAttachments(emailLog, attachments));
    // 
    producerTemplate.sendBody("direct:emails", emailLog);
    // 
    return emailLog;
}
Also used : IdmEmailLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmEmailLogDto) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with IdmEmailLogDto

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

the class DefaultIdmEmailLogService method setEmailSent.

/**
 * Persists sent date to given emailLogId
 *
 * @param emailLogId
 * @param sent
 */
@Override
@Transactional
public void setEmailSent(UUID emailLogId, ZonedDateTime sent) {
    IdmEmailLogDto emailLog = get(emailLogId);
    Assert.notNull(emailLog, MessageFormat.format("Email log [id:{0}] does not exist", emailLogId));
    // 
    LOG.debug("Persist sent date [{}] to emailLogId [{}]", sent, emailLogId);
    emailLog.setSent(sent);
    save(emailLog);
}
Also used : IdmEmailLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmEmailLogDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with IdmEmailLogDto

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

the class DefaultIdmEmailLogService method setEmailSentLog.

/**
 * Persists sent log to given emailLog
 *
 * @param emailLogId
 * @param sentLog
 */
@Override
@Transactional
public void setEmailSentLog(UUID emailLogId, String sentLog) {
    IdmEmailLogDto emailLog = get(emailLogId);
    Assert.notNull(emailLog, MessageFormat.format("Email log [id:{0}] does not exist", emailLogId));
    // 
    LOG.debug("Persist sent log [{}] to emailLogId [{}]", sentLog, emailLogId);
    emailLog.setSentLog(sentLog);
    save(emailLog);
}
Also used : IdmEmailLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmEmailLogDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmEmailLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmEmailLogDto)13 Transactional (org.springframework.transaction.annotation.Transactional)7 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)6 IdmNotificationRecipientDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto)6 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 IdmNotificationDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto)3 Test (org.junit.Test)3 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)2 NotificationState (eu.bcvsolutions.idm.core.notification.api.domain.NotificationState)2 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)2 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)2 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)2 ZonedDateTime (java.time.ZonedDateTime)2 List (java.util.List)2 Assert (org.junit.Assert)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Lists (com.google.common.collect.Lists)1