]> git.mxchange.org Git - jmailer-ee.git/commitdiff
If this is a generic method in a general mailer class, then *do always* check
authorRoland Häder <roland@mxchange.org>
Thu, 6 Jul 2017 21:14:10 +0000 (23:14 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 6 Jul 2017 21:21:53 +0000 (23:21 +0200)
all arguments deeply.

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jmailee/model/delivery/BaseMailer.java

index 2e677f7a625513aa37dcd77951571a5b902dc100..c9283f8911388f0cb5e34e418215fc8a22d5fb32 100644 (file)
@@ -136,10 +136,43 @@ public abstract class BaseMailer implements DeliverableEmail {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendMail: emailWrapper={0},body={1},mailSession={2} - CALLED!", emailWrapper, writer, mailSession)); //NOI18N
 
-               // Are the additional properties set?
+               // Are the additional properties and all parameter set?
                if (null == this.properties) {
                        // Nothing set
                        throw new NullPointerException("this.properties is null"); //NOI18N
+               } else if (null == emailWrapper) {
+                       // Throw NPE
+                       throw new NullPointerException("emailWrapper is null"); //NOI18N
+               } else if (emailWrapper.getLocale() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.locale is null"); //NOI18N
+               } else if (emailWrapper.getRecipient() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.recipient is null"); //NOI18N
+               } else if (emailWrapper.getTemplateName() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.templateName is null"); //NOI18N
+               } else if (emailWrapper.getTemplateName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("emailWrapper.templateName is empty"); //NOI18N
+               } else if (emailWrapper.getTemplateVariables() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("emailWrapper.templateVariables is null"); //NOI18N
+               } else if (emailWrapper.getTemplateVariables().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("emailWrapper.templateVariables is empty"); //NOI18N
+               } else if (!emailWrapper.getTemplateVariables().containsKey("baseUrl")) { //NOI18N
+                       // Not set
+                       throw new IllegalArgumentException("emailWrapper.templateVariables.baseUrl is not set"); //NOI18N
+               } else if (null == writer) {
+                       // Throw NPE
+                       throw new NullPointerException("writer is null"); //NOI18N
+               } else if (writer.toString().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("writer.string is empty"); //NOI18N
+               } else if (null == mailSession) {
+                       // Throw NPE
+                       throw new NullPointerException("mailSession is null"); //NOI18N
                }
 
                // Get MIME message instance
@@ -209,24 +242,30 @@ public abstract class BaseMailer implements DeliverableEmail {
                } else if (null == emailWrapper) {
                        // Throw NPE
                        throw new NullPointerException("emailWrapper is null"); //NOI18N
+               } else if (emailWrapper.getLocale() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.locale is null"); //NOI18N
                } else if (emailWrapper.getRecipient() == null) {
-                       // Throw NPE again
+                       // Throw it again
                        throw new NullPointerException("emailWrapper.recipient 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 it again
                        throw new NullPointerException("emailWrapper.templateName is null"); //NOI18N
                } else if (emailWrapper.getTemplateName().isEmpty()) {
-                       // Is empty
+                       // Throw IAE
                        throw new IllegalArgumentException("emailWrapper.templateName is empty"); //NOI18N
-               } else if (emailWrapper.getLocale() == null) {
+               } else if (emailWrapper.getTemplateVariables() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("emailWrapper.locale is null"); //NOI18N
+                       throw new NullPointerException("emailWrapper.templateVariables is null"); //NOI18N
+               } else if (emailWrapper.getTemplateVariables().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("emailWrapper.templateVariables is empty"); //NOI18N
+               } else if (!emailWrapper.getTemplateVariables().containsKey("baseUrl")) { //NOI18N
+                       // Not set
+                       throw new IllegalArgumentException("emailWrapper.templateVariables.baseUrl is not set"); //NOI18N
+               } else if (null == mailSession) {
+                       // Throw NPE
+                       throw new NullPointerException("mailSession is null"); //NOI18N
                }
 
                // Get writer instance