From 66fa621f5766296454c33b4e8bc8d3d24ddb9e6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 18 May 2016 14:45:53 +0200 Subject: [PATCH] Continued a bit: - moved templates to src folder as this is required for the loader - baseUrl cannot be generated from an EJB as it doesn't have "access" on faces context ... --- .../mailer/model/delivery/AddressbookMailer.java | 12 ++++-------- {templates => src/templates}/de/registration.vm | 0 .../templates}/de/resend_confirmation_link.vm | 0 3 files changed, 4 insertions(+), 8 deletions(-) rename {templates => src/templates}/de/registration.vm (100%) rename {templates => src/templates}/de/resend_confirmation_link.vm (100%) diff --git a/src/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailer.java b/src/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailer.java index 98a8a06..772d855 100644 --- a/src/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailer.java +++ b/src/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailer.java @@ -23,7 +23,6 @@ import javax.mail.MessagingException; import javax.mail.Session; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; -import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jmailee.model.delivery.BaseMailer; import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery; @@ -72,20 +71,17 @@ public class AddressbookMailer extends BaseMailer implements DeliverableAddressb } else if (emailWrapper.getLocale() == null) { // Throw NPE again throw new NullPointerException("emailWrapper.locale is null"); //NOI18N + } else if (!emailWrapper.getTemplateVariables().containsKey("baseUrl")) { //NOI18N + // Not set + throw new IllegalArgumentException("emailWrapper.templateVariables.baseUrl is not set"); //NOI18N } // All required data is set, load template - Template template = this.getTemplateEngine().getTemplate(String.format("./templates/%s/%s.vm", emailWrapper.getLocale().getLanguage().toLowerCase(), emailWrapper.getTemplateName())); //NOI18N + Template template = this.getTemplateEngine().getTemplate(String.format("templates/%s/%s.vm", emailWrapper.getLocale().getLanguage().toLowerCase(), emailWrapper.getTemplateName())); //NOI18N // Init context VelocityContext context = new VelocityContext(); - // Get base URL from JSF - String baseUrl = FacesUtils.generateBaseUrl(); - - // ... and set it (for all templates the same) - context.put("baseUrl", baseUrl); //NOI18N - // Are some variables set? if ((emailWrapper.getTemplateVariables() != null) && (!emailWrapper.getTemplateVariables().isEmpty())) { // Add all variables diff --git a/templates/de/registration.vm b/src/templates/de/registration.vm similarity index 100% rename from templates/de/registration.vm rename to src/templates/de/registration.vm diff --git a/templates/de/resend_confirmation_link.vm b/src/templates/de/resend_confirmation_link.vm similarity index 100% rename from templates/de/resend_confirmation_link.vm rename to src/templates/de/resend_confirmation_link.vm -- 2.39.5