/*
- * 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
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;
/**
* Configuration file
*/
- private final String configFile = "org.mxchange.jmailer.config"; //NOI18N//NOI18N
+ private final String configFile = "org.mxchange.jmailer.config"; //NOI18N
/**
* Email session
/**
* Default constructor
- * <p>
*/
public AddressbookMailerSingletonBean () {
+ // Invoke super constructor
+ super();
}
/**
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
}
// Init Properties
- Properties properties = new Properties();
+ final Properties properties = new Properties();
// Is the bundle not empty?
if (!bundle.keySet().isEmpty()) {
}
// 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