HSAdmin Backend Domains, E-Mail, Datenbanken
Michael Hierweck
2017-09-17 5ce044e645d6ffeec8e97c7b82f27f2dc03f5140
Logging.
1 files modified
10 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java 10 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java
@@ -1,6 +1,8 @@
package de.hsadmin.mods.email;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.Query;
@@ -16,6 +18,7 @@
public class EMailAddressProcessorFactory implements EntityProcessorFactory {
    public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) {
        Logger logger = Logger.getLogger(EMailAddressProcessorFactory.class.getName());
        CompoundProcessor cp = new CompoundProcessor();
        EMailAddress email = (EMailAddress) entity;
        if (emailAddressCount(em, email) > 0) {
@@ -23,9 +26,11 @@
            cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual || true",
                    email.getFullDomain() + " -\n" +
                    "." + email.getFullDomain() + " -\n"));
            logger.log(Level.INFO, "Queue: virtual => create domain record");
        }
        cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual || true",
                email.getEMailAddress() + " " + email.getTarget() + "\n"));
        logger.log(Level.INFO, "Queue: virtual => create email address record");
        WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
        Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.mail").split(",")) {
@@ -33,6 +38,7 @@
                    new ShellProcessor("postmap -r -i /etc/postfix-mailin/relayrecipients || true",
                            email.getEMailAddress() + " anything\n"),
                    "Add to relayrecipients");
            logger.log(Level.INFO, "Queue: relayrecipients => create email address record for " + queueName);
        }
        return waitingTasksProcessor;
    }
@@ -44,6 +50,7 @@
    }
    public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
        Logger logger = Logger.getLogger(EMailAddressProcessorFactory.class.getName());
        CompoundProcessor cp = new CompoundProcessor();
        EMailAddress email = (EMailAddress) entity;
        if (emailAddressCount(em, email) == 0) {
@@ -51,9 +58,11 @@
            cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/virtual || true",
                    email.getFullDomain() + "\n" +
                    "." + email.getFullDomain() + "\n"));
                    logger.log(Level.INFO, "Queue: virtual => remove domain record");
        }
        cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/virtual || true", 
                email.getEMailAddress() + "\n"));
        logger.log(Level.INFO, "Queue: virtual => remove email address record");
        Config config = Config.getInstance();
        WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
        for (String queueName : config.getProperty("queues.mail").split(",")) {
@@ -61,6 +70,7 @@
                    new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients || true", 
                            email.getEMailAddress() + "\n"),
                    "Remove from relayrecipients");
            logger.log(Level.INFO, "Queue: relayrecipients => remove email address record for " + queueName);
        }
        return waitingTasksProcessor;
    }