| 1 | package de.aikiit.mailversendala; | |
| 2 | ||
| 3 | import lombok.Getter; | |
| 4 | import org.apache.logging.log4j.LogManager; | |
| 5 | import org.apache.logging.log4j.Logger; | |
| 6 | import org.apache.tamaya.Configuration; | |
| 7 | ||
| 8 | ||
| 9 | /** | |
| 10 | * Encapsulates the configuration of this application. | |
| 11 | */ | |
| 12 | @Getter | |
| 13 | public class MailConfig { | |
| 14 | ||
| 15 | private static final Logger LOG = | |
| 16 | LogManager.getLogger(MailConfig.class); | |
| 17 | ||
| 18 | private final String host; | |
| 19 | private final int port; | |
| 20 | private final String username; | |
| 21 | private final String password; | |
| 22 | private final String to; | |
| 23 | private final String from; | |
| 24 | private final String subject; | |
| 25 | private final String csvPath; | |
| 26 | private final String templatePath; | |
| 27 | private final boolean isDemoMode; | |
| 28 | ||
| 29 | /** | |
| 30 | * Read from Tamaya configuration or fallback to dummy default values. | |
| 31 | */ | |
| 32 | public MailConfig() { | |
| 33 | LOG.debug("Reading Tamaya configuration ..."); | |
| 34 | final Configuration configuration = Configuration.current(); | |
| 35 | ||
| 36 | this.host = configuration.getOrDefault("host", "smtp.example.com"); | |
| 37 | this.port = Integer.parseInt(configuration.getOrDefault("port", "465")); | |
| 38 | this.username = configuration.getOrDefault("username", "user@example.com"); | |
| 39 | this.password = configuration.getOrDefault("password", "chooseMeWisely"); | |
| 40 | this.to = configuration.getOrDefault("to", "xmas@man.com"); | |
| 41 | this.from = configuration.getOrDefault("from", "santa@cruz.com"); | |
| 42 | this.subject = configuration.getOrDefault("subject", "Do adapt your configuration - will not work"); | |
| 43 | this.csvPath = configuration.getOrDefault("csvpath", "mailversendala-example.csv"); | |
| 44 | this.isDemoMode = Boolean.parseBoolean(configuration.getOrDefault("demomode", "true")); | |
| 45 | this.templatePath = configuration.getOrDefault("templatepath", "template"); | |
| 46 | LOG.debug("Configuration: DONE."); | |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * If in demo mode <strong>NO</strong> mails should be sent out! | |
| 51 | * | |
| 52 | * @return {@code true} if in demo mode, thus no mails will be sent by default. | |
| 53 | */ | |
| 54 | public boolean sendOutMails() { | |
| 55 |
2
1. sendOutMails : negated conditional → KILLED 2. sendOutMails : replaced boolean return with true for de/aikiit/mailversendala/MailConfig::sendOutMails → KILLED |
return !isDemoMode; |
| 56 | } | |
| 57 | ||
| 58 | } | |
Mutations | ||
| 55 |
1.1 2.2 |