From: Roland Häder Date: Sat, 8 Jul 2017 17:20:03 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=179e7cccf3ff808febfa62bd7b1d363b64e5a33c;p=addressbook-mailer-lib.git Please cherry-pick: - initialized new project 'addressbook-mailer-lib' from 'addressbook-mailer' project - no longer then need velocity around + templates - the mailer class has been converted to a singleton EJB in addressbook-mailer-ejb Signed-off-by: Roland Häder --- diff --git a/build.xml b/build.xml index cb06e4e..9a2ce7c 100644 --- a/build.xml +++ b/build.xml @@ -7,8 +7,8 @@ - - Builds, tests, and runs the project addressbook-mailer. + + Builds, tests, and runs the project addressbook-mailer-lib. - + @@ -474,7 +474,7 @@ is divided into following sections: - + @@ -625,7 +625,7 @@ is divided into following sections: - + @@ -917,7 +917,7 @@ is divided into following sections: - + @@ -1402,7 +1402,7 @@ is divided into following sections: - + diff --git a/nbproject/project.properties b/nbproject/project.properties index 3705b37..e845745 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=true annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=addressbook-mailer +application.title=addressbook-mailer-lib application.vendor=Roland H\u00e4der auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml build.classes.dir=${build.dir}/classes @@ -26,27 +26,21 @@ debug.test.classpath=\ dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist -dist.jar=${dist.dir}/addressbook-mailer.jar +dist.jar=${dist.dir}/addressbook-mailer-lib.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= -file.reference.jcontacts-core.jar=lib/jcontacts-core.jar file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar file.reference.jcoreee.jar=lib/jcoreee.jar file.reference.jmailer-ee.jar=lib/jmailer-ee.jar -file.reference.juser-core.jar=lib/juser-core.jar -file.reference.velocity-1.7.jar=lib/velocity-1.7.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=false jar.index=${jnlp.enabled} javac.classpath=\ ${file.reference.jcoreee.jar}:\ - ${file.reference.juser-core.jar}:\ - ${file.reference.jcontacts-core.jar}:\ ${file.reference.jcore-logger-lib.jar}:\ ${file.reference.jmailer-ee.jar}:\ - ${file.reference.velocity-1.7.jar}:\ ${libs.javaee-api-7.0.classpath} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation @@ -68,7 +62,6 @@ javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=true -javadoc.reference.velocity-1.7.jar=http://velocity.apache.org/engine/devel/apidocs/ javadoc.splitindex=true javadoc.use=true javadoc.version=true @@ -105,10 +98,8 @@ run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 -source.reference.jcontacts-core.jar=../jcontacts-core/src/ source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/ source.reference.jcoreee.jar=../jcoreee/src/ source.reference.jmailer-ee.jar=../jmailer-ee/src/ -source.reference.juser-core.jar=../juser-core/src/ src.dir=src test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index b335db3..bbb5d97 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -3,7 +3,7 @@ org.netbeans.modules.java.j2seproject - addressbook-mailer + addressbook-mailer-lib diff --git a/src/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailer.java b/src/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailer.java deleted file mode 100644 index fb23ddf..0000000 --- a/src/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailer.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.addressbook.mailer.model.delivery; - -import java.text.MessageFormat; -import java.util.Map; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.mxchange.jmailee.model.delivery.BaseMailer; -import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery; - -/** - * A mailer for JJobs project - *

- * @author Roland Häder - */ -public class AddressbookMailer extends BaseMailer implements DeliverableAddressbookEmail { - - /** - * Serial number - */ - private static final long serialVersionUID = 17_857_816_596_030_918L; - - /** - * Email session - */ - private final Session mailSession; - - /** - * Default constructor - *

- * @throws javax.naming.NamingException If the JNDI name is not found - */ - public AddressbookMailer () throws NamingException { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.mailSession = (Session) context.lookup("java:comp/env/mail/addressbookSmtpSession"); //NOI18N - } - - @Override - public void sendDeliverableMail (final WrapableEmailDelivery emailWrapper) throws MessagingException { - // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendDeliverableMail: emailWrapper={0} - CALLED!", emailWrapper)); //NOI18N - - // The parameter must be valid - if (null == emailWrapper) { - // Throw NPE - throw new NullPointerException("emailWrapper is null"); //NOI18N - } else if (emailWrapper.getRecipientAddress() == null) { - // Throw NPE again - throw new NullPointerException("emailWrapper.recipientAddress is null"); //NOI18N - } else if (emailWrapper.getSubjectLine() == null) { - // ... and again - throw new NullPointerException("emailWrapper.subjectLine is null"); //NOI18N - } else if (emailWrapper.getSubjectLine().isEmpty()) { - // Is empty - throw new IllegalArgumentException("emailWrapper.subjectLine is empty"); //NOI18N - } else if (emailWrapper.getTemplateName() == null) { - // ... and again - throw new NullPointerException("emailWrapper.templateName is null"); //NOI18N - } else if (emailWrapper.getTemplateName().isEmpty()) { - // Is empty - throw new IllegalArgumentException("emailWrapper.templateName is empty"); //NOI18N - } 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 - - // Init context - VelocityContext context = new VelocityContext(); - - // Are some variables set? - if ((emailWrapper.getTemplateVariables() != null) && (!emailWrapper.getTemplateVariables().isEmpty())) { - // Add all variables - for (Map.Entry entry : emailWrapper.getTemplateVariables().entrySet()) { - // Get key/value - String key = (String) entry.getKey(); - String value = (String) entry.getValue(); - - // Both should not be empty - if (null == key) { - // Throw NPE - throw new NullPointerException("key is null"); //NOI18N - } else if (null == value) { - // Throw NPE again - throw new NullPointerException(MessageFormat.format("value for key={0} is null", key)); //NOI18N - } - - // Set it - context.put(key, value); - } - } - - // Send the email - this.sendMailTemplate(template, context, emailWrapper, this.mailSession); - - // Trace message - this.getLoggerBeanLocal().logTrace("sendDeliverableMail: EXIT!"); //NOI18N - } - -} diff --git a/src/org/mxchange/addressbook/mailer/model/delivery/DeliverableAddressbookEmail.java b/src/org/mxchange/addressbook/mailer/model/delivery/DeliverableAddressbookEmail.java deleted file mode 100644 index 03057e8..0000000 --- a/src/org/mxchange/addressbook/mailer/model/delivery/DeliverableAddressbookEmail.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.addressbook.mailer.model.delivery; - -import javax.mail.MessagingException; -import org.mxchange.jmailee.model.delivery.DeliverableEmail; -import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery; - -/** - * An interface for deliverable emails by JJobs project. - *

- * @author Roland Häder - */ -public interface DeliverableAddressbookEmail extends DeliverableEmail { - - /** - * Sends given deliverable mail instance. This must have set a template - * name, a recipient address and a subject line set. - *

- * @param emailWrapper Deliverable mail wrapper - * @throws MessagingException If something bad happened - */ - void sendDeliverableMail (final WrapableEmailDelivery emailWrapper) throws MessagingException; - -} diff --git a/src/org/mxchange/addressbook/mailer/model/delivery/DeliverableAddressbookEmailLocal.java b/src/org/mxchange/addressbook/mailer/model/delivery/DeliverableAddressbookEmailLocal.java new file mode 100644 index 0000000..f467a1c --- /dev/null +++ b/src/org/mxchange/addressbook/mailer/model/delivery/DeliverableAddressbookEmailLocal.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.mailer.model.delivery; + +import javax.ejb.Local; +import org.mxchange.jmailee.model.delivery.DeliverableEmailLocal; + +/** + * An interface for deliverable emails by JJobs project. + *

+ * @author Roland Häder + */ +@Local +public interface DeliverableAddressbookEmailLocal extends DeliverableEmailLocal { + +} diff --git a/src/templates/de/account_confirmed.vm b/src/templates/de/account_confirmed.vm deleted file mode 100644 index f56ac6c..0000000 --- a/src/templates/de/account_confirmed.vm +++ /dev/null @@ -1,10 +0,0 @@ -Hallo $contactPersonalTitle $contactFirstName $contactFamilyName, - -Sie hatten soeben ($userUpdated) Ihren Account bestätigt. Vielen Dank. - -Sie können sich mit Ihrem Benutzernamen $userName und Ihrem vergebenen Passwort im Mitgliedsbereich einloggen. - -Mit freundlichen Grüßen - -Kontaktmöglichkeit und Impressum: -$baseUrl/imprint.xhtml diff --git a/src/templates/de/registration.vm b/src/templates/de/registration.vm deleted file mode 100644 index c0e5baa..0000000 --- a/src/templates/de/registration.vm +++ /dev/null @@ -1,53 +0,0 @@ -Hallo $contactPersonalTitle $contactFirstName $contactFamilyName, - -Sie hatten sich eben ($userCreated) bei uns angemeldet. Sollten Sie dies nicht gewesen sein, so melden Sie sich bitter per Kontaktformular bei uns. - -Hier sind Ihre Daten: ---------------------- -Benuzter-Id: -$userId ---------------------- -Benutzername: -$userName ---------------------- -Anrede: -$contactPersonalTitle ---------------------- -Titel: -$contactTitle ---------------------- -Vorname: -$contactFirstName ---------------------- -Nachname: -$contactFamilyName ---------------------- -Straße + Hausnummer: -$contactStreet $contactHouseNumber ---------------------- -PLZ, Wohnort: -$contactZipCode $contactCity ---------------------- -Geburtsdatum: -$contactBirthday ---------------------- -Email-Adresse: -$contactEmailAddress ---------------------- - -Wenn Sie sich anmelden möchten, so müssen Sie Ihren Account bestätigen. Bitte klicken Sie oder kopieren Sie den unten stehenden Link in Ihren Browser: - -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/user_confirm_account.xhtml?confirmKey=$userConfirmKey -- - - - - - - - - - - - - - - - - - - - - - -Falls der Link nicht funktioniert, rufen Sie bitte folgenden auf und lassen sich einen neuen Link zuschicken: - -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/resend_link.xhtml -- - - - - - - - - - - - - - - - - - - - - - -Mit freundlichen Grüßen - -Kontaktmöglichkeit und Impressum: -$baseUrl/imprint.xhtml diff --git a/src/templates/de/resend_confirmation_link.vm b/src/templates/de/resend_confirmation_link.vm deleted file mode 100644 index 6782f02..0000000 --- a/src/templates/de/resend_confirmation_link.vm +++ /dev/null @@ -1,21 +0,0 @@ -Hallo $contactPersonalTitle $contactFirstName $contactFamilyName, - -Sie hatten soeben ($userUpdated) einen neuen Bestätigungslink angefordert. Die Anmeldung war $userCreated . - -Hier ist der neue Link: -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/user_confirm_account.xhtml?confirmKey=$userConfirmKey -- - - - - - - - - - - - - - - - - - - - - - -Falls der Link nicht funktioniert, rufen Sie bitte folgenden auf und lassen sich einen neuen Link zuschicken: - -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/resend_link.xhtml -- - - - - - - - - - - - - - - - - - - - - - -Sollten Sie dies bereits getan haben und nicht weiterkommen, so melden Sie sich bitte bei uns. - -Mit freundlichen Grüßen - -Kontaktmöglichkeit und Impressum: -$baseUrl/imprint.xhtml diff --git a/src/templates/de/user_password_change.vm b/src/templates/de/user_password_change.vm deleted file mode 100644 index 1757a45..0000000 --- a/src/templates/de/user_password_change.vm +++ /dev/null @@ -1,13 +0,0 @@ -Hallo $contactPersonalTitle $contactFirstName $contactFamilyName, - -Sie haben soeben Ihr Zugangspasswort geändert. Das alte Passwort ist somit nicht mehr gültig. Aus Sicherheitsgründen kann Ihr neuesd Passwort hier nicht mit gesendet werden. - ------------------------------------ -Ihr Benutzername: $userName -Benutzer-Id: $userId ------------------------------------ - -Mit freundlichen Grüßen - -Kontaktmöglichkeit und Impressum: -$baseUrl/imprint.xhtml diff --git a/src/templates/en/user_account_confirmed.vm b/src/templates/en/user_account_confirmed.vm deleted file mode 100644 index b19185f..0000000 --- a/src/templates/en/user_account_confirmed.vm +++ /dev/null @@ -1,10 +0,0 @@ -Hello $contactPersonalTitle $contactFirstName $contactFamilyName, - -You have just ($userUpdated) confirmed your account. Thank you. - -You can now login with your username $userName and password into the member area. - -Best regards - -Contact us: -$baseUrl/imprint.xhtml diff --git a/src/templates/en/user_password_change.vm b/src/templates/en/user_password_change.vm deleted file mode 100644 index 07c1ec2..0000000 --- a/src/templates/en/user_password_change.vm +++ /dev/null @@ -1,13 +0,0 @@ -Hello $contactPersonalTitle $contactFirstName $contactFamilyName, - -You have just changed your password. Your old password is no longer valid. For security reasons your new password is not included in this email. - ------------------------------------ -Your user name: $userName -User id: $userId ------------------------------------ - -Best regards - -Contact us: -$baseUrl/imprint.xhtml diff --git a/src/templates/en/user_registration.vm b/src/templates/en/user_registration.vm deleted file mode 100644 index f38cffe..0000000 --- a/src/templates/en/user_registration.vm +++ /dev/null @@ -1,53 +0,0 @@ -Hello $contactPersonalTitle $contactFirstName $contactFamilyName, - -You have just ($userCreated) registered. If this wasn't you, please contact us immediately. - -Here is your data: ---------------------- -User id: -$userId ---------------------- -User name: -$userName ---------------------- -Personal title: -$contactPersonalTitle ---------------------- -Academical title: -$contactTitle ---------------------- -First name: -$contactFirstName ---------------------- -Family name: -$contactFamilyName ---------------------- -Street + house number: -$contactStreet $contactHouseNumber ---------------------- -ZIP code + city: -$contactZipCode $contactCity ---------------------- -Date of birth: -$contactBirthday ---------------------- -Email address: -$contactEmailAddress ---------------------- - -If you want to register, you have confirm your account. Please click on following link or copy it into your browser: - -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/user_confirm_account.xhtml?confirmKey=$userConfirmKey -- - - - - - - - - - - - - - - - - - - - - - -If the above link is not working, please visit following link and send out a new link: - -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/resend_link.xhtml -- - - - - - - - - - - - - - - - - - - - - - -Best regards - -Contact us: -$baseUrl/imprint.xhtml diff --git a/src/templates/en/user_resend_confirmation_link.vm b/src/templates/en/user_resend_confirmation_link.vm deleted file mode 100644 index fcc12ec..0000000 --- a/src/templates/en/user_resend_confirmation_link.vm +++ /dev/null @@ -1,21 +0,0 @@ -Hello $contactPersonalTitle $contactFirstName $contactFamilyName, - -you have just ($userUpdated) requested a new confirmation link. Your registration happened on $userCreated . - -Here is your new link: -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/user_confirm_account.xhtml?confirmKey=$userConfirmKey -- - - - - - - - - - - - - - - - - - - - - - -If the link is not working, please visit following link and send a new link to this email address.: - -- - - - - - - - - - - - - - - - - - - - - -$baseUrl/guest/user/resend_link.xhtml -- - - - - - - - - - - - - - - - - - - - - - -If you have already tried this and you are stuck here, please contact us. - -Best regards - -Contact us: -$baseUrl/imprint.xhtml