]> git.mxchange.org Git - jmailer-ee.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 19 Oct 2022 12:02:31 +0000 (14:02 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 19 Oct 2022 12:03:10 +0000 (14:03 +0200)
- added checks on each parameter
- made some (local) variables final

src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java
src/org/mxchange/jmailee/model/delivery/wrapper/EmailDeliveryWrapper.java

index f859ba8f05a2e2e7ec383e3be2224716eec23ad9..7d16adb84202f3f9eb551c3ce267d9fa4d4531db 100644 (file)
@@ -133,10 +133,10 @@ public abstract class BaseMailerBean extends BaseEnterpriseBean implements Deliv
                }
 
                // Parse from address
-               Address senderAddress = new InternetAddress(this.properties.getProperty("mailer.from"));
+               final Address senderAddress = new InternetAddress(this.properties.getProperty("mailer.from"));
 
                // Get MIME message instance
-               MimeMessage message = new MimeMessage(mailSession);
+               final MimeMessage message = new MimeMessage(mailSession);
 
                // Set subject, recipients and body
                message.setFrom(senderAddress);
index 304d5fc99ad647b7a1b652d1d599587f7ca91931..479dbe0de3cf411b802d966a557fd418618ac486 100644 (file)
@@ -67,6 +67,33 @@ public class EmailDeliveryWrapper implements WrapableEmailDelivery {
         * @param locale            Recipient's locale
         */
        public EmailDeliveryWrapper (final Address recipientAddress, final String subjectLine, final String templateName, final Properties templateVariables, final Locale locale) {
+               // Are all parameter set?
+               if (null == recipientAddress) {
+                       // Throw NPE
+                       throw new NullPointerException("recipientAddress is null"); //NOI18N
+               } else if (null == subjectLine) {
+                       // Throw it again
+                       throw new NullPointerException("subjectLine is null"); //NOI18N
+               } else if (subjectLine.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("subjectLine is empty"); //NOI18N
+               } else if (null == templateName) {
+                       // Throw NPE
+                       throw new NullPointerException("templateName is null"); //NOI18N
+               } else if (templateName.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("templateName is empty"); //NOI18N
+               } else if (null == templateVariables) {
+                       // Throw NPE
+                       throw new NullPointerException("templateVariables is null"); //NOI18N
+               } else if (templateVariables.isEmpty()) {
+                       // At least one parameter should be there
+                       throw new IllegalArgumentException("templatesVariables should have at least one parameter set."); //NOI18N
+               } else if (null == locale) {
+                       // Throw NPE
+                       throw new NullPointerException("locale is null"); //NOI18N
+               }
+
                // Set all fields
                this.recipientAddress = recipientAddress;
                this.subjectLine = subjectLine;