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) {
Assert.notNull(message);
Assert.notNull(emails);
//
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);
//
producerTemplate.sendBody("direct:emails", emailLog);
//
return emailLog;
}
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(IdmNotificationDto notification) {
Assert.notNull(notification, "Notification is required!");
//
LOG.info("Adding email notification to queue [{}]", notification);
IdmEmailLogDto log = createLog(notification);
// send notification to routing, generate new message
producerTemplate.sendBody("direct:emails", log);
return log;
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmEmailLogDto in project CzechIdMng by bcvsolutions.
the class CustomMailActivityBehavior method execute.
/**
* Sending email through {@link EmailNotificationSender}.
*/
@Override
public void execute(DelegateExecution execution) {
LOG.trace("Sending email from workflow execution [{}]", execution.getId());
IdmEmailLogDto emailLog = new IdmEmailLogDto();
// recipients
String[] tos = splitAndTrim(getStringFromField(to, execution));
if (!ObjectUtils.isEmpty(tos)) {
emailLog.setRecipients(Arrays.stream(tos).map(identityOrAddress -> {
return prepareRecipient(identityOrAddress);
}).collect(Collectors.toList()));
}
// sender
emailLog.setIdentitySender(getIdentity(getStringFromField(from, execution)).getId());
// message
emailLog.setMessage(new IdmMessageDto.Builder().setSubject(getStringFromField(subject, execution)).setTextMessage(getStringFromField(text, execution)).setHtmlMessage(getStringFromField(html, execution)).build());
IdmNotificationDto result = emailService.send(emailLog);
LOG.trace("Email from workflow execution [{}] was sent with result [{}]", execution.getId(), result == null ? false : true);
leave(execution);
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmEmailLogDto in project CzechIdMng by bcvsolutions.
the class CustomMailActivityBehavior method execute.
/**
* Sending emails through {@link EmailNotificationSender}
*/
@Override
public void execute(ActivityExecution execution) {
log.trace("Sending email from workflow execution [{}]", execution.getId());
IdmEmailLogDto emailLog = new IdmEmailLogDto();
// recipients
String[] tos = splitAndTrim(getStringFromField(to, execution));
if (!ObjectUtils.isEmpty(tos)) {
emailLog.setRecipients(Arrays.stream(tos).map(identityOrAddress -> {
return prepareRecipient(identityOrAddress);
}).collect(Collectors.toList()));
}
// sender
emailLog.setIdentitySender(getIdentity(getStringFromField(from, execution)).getId());
// message
emailLog.setMessage(new IdmMessageDto.Builder().setSubject(getStringFromField(subject, execution)).setTextMessage(getStringFromField(text, execution)).setHtmlMessage(getStringFromField(html, execution)).build());
IdmNotificationDto result = emailService.send(emailLog);
log.trace("Email from workflow execution [{}] was sent with result [{}]", execution.getId(), result == null ? false : true);
leave(execution);
}
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, DateTime 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);
}
Aggregations