Logging.
This commit is contained in:
parent
0cb44ebcc9
commit
5ce044e645
@ -1,6 +1,8 @@
|
|||||||
package de.hsadmin.mods.email;
|
package de.hsadmin.mods.email;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
@ -16,6 +18,7 @@ import de.hsadmin.core.util.Config;
|
|||||||
public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
||||||
|
|
||||||
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) {
|
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) {
|
||||||
|
Logger logger = Logger.getLogger(EMailAddressProcessorFactory.class.getName());
|
||||||
CompoundProcessor cp = new CompoundProcessor();
|
CompoundProcessor cp = new CompoundProcessor();
|
||||||
EMailAddress email = (EMailAddress) entity;
|
EMailAddress email = (EMailAddress) entity;
|
||||||
if (emailAddressCount(em, email) > 0) {
|
if (emailAddressCount(em, email) > 0) {
|
||||||
@ -23,9 +26,11 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual || true",
|
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual || true",
|
||||||
email.getFullDomain() + " -\n" +
|
email.getFullDomain() + " -\n" +
|
||||||
"." + 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",
|
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual || true",
|
||||||
email.getEMailAddress() + " " + email.getTarget() + "\n"));
|
email.getEMailAddress() + " " + email.getTarget() + "\n"));
|
||||||
|
logger.log(Level.INFO, "Queue: virtual => create email address record");
|
||||||
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
||||||
Config config = Config.getInstance();
|
Config config = Config.getInstance();
|
||||||
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
||||||
@ -33,6 +38,7 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relayrecipients || true",
|
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relayrecipients || true",
|
||||||
email.getEMailAddress() + " anything\n"),
|
email.getEMailAddress() + " anything\n"),
|
||||||
"Add to relayrecipients");
|
"Add to relayrecipients");
|
||||||
|
logger.log(Level.INFO, "Queue: relayrecipients => create email address record for " + queueName);
|
||||||
}
|
}
|
||||||
return waitingTasksProcessor;
|
return waitingTasksProcessor;
|
||||||
}
|
}
|
||||||
@ -44,6 +50,7 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
|
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
|
||||||
|
Logger logger = Logger.getLogger(EMailAddressProcessorFactory.class.getName());
|
||||||
CompoundProcessor cp = new CompoundProcessor();
|
CompoundProcessor cp = new CompoundProcessor();
|
||||||
EMailAddress email = (EMailAddress) entity;
|
EMailAddress email = (EMailAddress) entity;
|
||||||
if (emailAddressCount(em, email) == 0) {
|
if (emailAddressCount(em, email) == 0) {
|
||||||
@ -51,9 +58,11 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/virtual || true",
|
cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/virtual || true",
|
||||||
email.getFullDomain() + "\n" +
|
email.getFullDomain() + "\n" +
|
||||||
"." + 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",
|
cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/virtual || true",
|
||||||
email.getEMailAddress() + "\n"));
|
email.getEMailAddress() + "\n"));
|
||||||
|
logger.log(Level.INFO, "Queue: virtual => remove email address record");
|
||||||
Config config = Config.getInstance();
|
Config config = Config.getInstance();
|
||||||
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
||||||
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
||||||
@ -61,6 +70,7 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients || true",
|
new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients || true",
|
||||||
email.getEMailAddress() + "\n"),
|
email.getEMailAddress() + "\n"),
|
||||||
"Remove from relayrecipients");
|
"Remove from relayrecipients");
|
||||||
|
logger.log(Level.INFO, "Queue: relayrecipients => remove email address record for " + queueName);
|
||||||
}
|
}
|
||||||
return waitingTasksProcessor;
|
return waitingTasksProcessor;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user