]> git.mxchange.org Git - addressbook-mailer-ejb.git/blobdiff - src/java/org/mxchange/addressbook/mailer/model/delivery/AddressbookMailerSingletonBean.java
Updated copyright year
[addressbook-mailer-ejb.git] / src / java / org / mxchange / addressbook / mailer / model / delivery / AddressbookMailerSingletonBean.java
index 38afa9cda777a13430e7dfca955477139fc39b14..0c2dd4ba3ef529a8f425e7bd67d5bf8bd79c430a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 - 2020 Free Software Foundation
+ * Copyright (C) 2016 - 2024 Free Software Foundation
  *
  * 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
@@ -27,6 +27,7 @@ import javax.mail.MessagingException;
 import javax.mail.Session;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.context.Context;
 import org.mxchange.jmailee.model.delivery.BaseMailerBean;
 import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
 
@@ -46,7 +47,7 @@ public class AddressbookMailerSingletonBean extends BaseMailerBean implements De
        /**
         * Configuration file
         */
-       private final String configFile = "org.mxchange.jmailer.config"; //NOI18N//NOI18N
+       private final String configFile = "org.mxchange.jmailer.config"; //NOI18N
 
        /**
         * Email session
@@ -56,9 +57,10 @@ public class AddressbookMailerSingletonBean extends BaseMailerBean implements De
 
        /**
         * Default constructor
-        * <p>
         */
        public AddressbookMailerSingletonBean () {
+               // Invoke super constructor
+               super();
        }
 
        /**
@@ -70,7 +72,7 @@ public class AddressbookMailerSingletonBean extends BaseMailerBean implements De
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.init: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Try to load bundle
-               ResourceBundle bundle = ResourceBundle.getBundle(this.configFile);
+               final ResourceBundle bundle = ResourceBundle.getBundle(this.configFile);
 
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.init: bundle={1}", this.getClass().getSimpleName(), bundle)); //NOI18N
@@ -82,7 +84,7 @@ public class AddressbookMailerSingletonBean extends BaseMailerBean implements De
                }
 
                // Init Properties
-               Properties properties = new Properties();
+               final Properties properties = new Properties();
 
                // Is the bundle not empty?
                if (!bundle.keySet().isEmpty()) {
@@ -136,23 +138,26 @@ public class AddressbookMailerSingletonBean extends BaseMailerBean implements De
                }
 
                // 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
+               final Template template = this.getTemplateEngine().getTemplate(String.format("templates/%s/%s.vm", emailWrapper.getLocale().getLanguage().toLowerCase(), emailWrapper.getTemplateName())); //NOI18N
 
                // Init context
-               VelocityContext context = new VelocityContext();
+               final Context context = new VelocityContext();
 
                // Are some variables set?
                if ((emailWrapper.getTemplateVariables() != null) && (!emailWrapper.getTemplateVariables().isEmpty())) {
                        // Add all variables
-                       for (Map.Entry<Object, Object> entry : emailWrapper.getTemplateVariables().entrySet()) {
+                       for (final Map.Entry<Object, Object> entry : emailWrapper.getTemplateVariables().entrySet()) {
                                // Get key/value
-                               String key = (String) entry.getKey();
-                               String value = (String) entry.getValue();
+                               final String key = (String) entry.getKey();
+                               final String value = (String) entry.getValue();
 
                                // Both should not be empty
                                if (null == key) {
                                        // Throw NPE
                                        throw new NullPointerException("key is null"); //NOI18N
+                               } else if (key.isEmpty()) {
+                                       // Throw IAE
+                                       throw new NullPointerException("key is empty"); //NOI18N
                                } else if (null == value) {
                                        // Throw NPE again
                                        throw new NullPointerException(MessageFormat.format("value for key={0} is null", key)); //NOI18N