use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.
the class MailTemplatesCT method create_shouldThrowConflictException_WhenThereIsAlreadyAMailTemplateWithSameLocaleAndName.
@Test
public void create_shouldThrowConflictException_WhenThereIsAlreadyAMailTemplateWithSameLocaleAndName() {
MailTemplate mailTemplate = new MailTemplate("Newsletter1", "fr_FR", "test content", "Test Subject");
try {
service.create(mailTemplate);
fail("Should have thrown exception");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.CONFLICT);
}
}
use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.
the class DefaultPaymentTransactionEngine method sendOrderConfirmationMail.
protected void sendOrderConfirmationMail(Order order) {
User user = order.getUser();
MailTemplate mailTemplate = mailTemplateFinder.findByNameAndLocale(orderValidated.name(), user.getPreferredLocale());
if (mailTemplate == null) {
LOG.warn("orderValidated e-mail template does not exist. Configure this missing template to allow user e-mail notification");
return;
}
try {
Template mailContentTpl = new Template(orderValidated.name(), mailTemplate.getContent(), new Configuration(Configuration.VERSION_2_3_21));
final StringWriter mailBody = new StringWriter();
mailContentTpl.process(order, mailBody);
mailer.sendMail(mailTemplate.getSubject(), user.getLogin(), mailBody.toString());
} catch (Exception e) {
LOG.error("Unable to send mail " + orderValidated + " to user " + user.getLogin(), e);
}
}
use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.
the class MailTemplates method create.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed(ADMIN)
public MailTemplate create(MailTemplate mailTemplate) {
MailTemplate existingTpl = mailTemplateFinder.findByNameAndLocale(mailTemplate.getName(), mailTemplate.getLocale());
if (existingTpl != null) {
throw new WebApplicationException(Response.Status.CONFLICT);
}
entityManager.persist(mailTemplate);
return mailTemplate;
}
use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.
the class MailTemplateFinder method findAll.
public List<MailTemplate> findAll(Integer offset, Integer limit, String orderBy, Boolean isDesc) {
JPAQuery<MailTemplate> query = new JPAQueryFactory(entityManager).selectFrom(mailTemplate);
if (offset != null)
query.offset(offset);
if (limit != null)
query.limit(limit);
sortBy(orderBy, isDesc, query);
return query.fetch();
}
Aggregations