HSAdmin Backend Domains, E-Mail, Datenbanken
Michael Hierweck
2012-09-21 e33737aaf638b7dc2328e748a5a5240db7a385f5
Refactoring deletion of email addresses as part of the domain deletion
process.
2 files modified
16 ■■■■ changed files
hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java 5 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 11 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java
@@ -11,6 +11,7 @@
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.GenericModuleImpl;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.mods.email.EMailAddress;
import de.hsadmin.mods.pac.Pac;
@@ -177,9 +178,9 @@
        Query query = em.createQuery("SELECT adr FROM " + EMailAddress.class.getAnnotation(javax.persistence.Entity.class).name() 
                + " adr WHERE adr.domain.name='" + dom.getName() + "'");
        List<?> resultList = query.getResultList();
        GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
        for (Object obj : resultList) {
            EMailAddress eMailAddress = (EMailAddress) obj;
            em.remove(eMailAddress);
            helperModule.delete((EMailAddress) obj);
        }
        super.delete(existingEntity);
    }
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -101,10 +101,7 @@
        Domain dom = (Domain) entity;
        String domName = dom.getName();
        WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(
                new CompoundProcessor(
                    createHiveEMailRemoveProcessor(domName),
                    createHiveDNSRemoveProcessor(domName)
                )
            );
        Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.dns").split(",")) {
@@ -156,14 +153,6 @@
            emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress));
        }
        return emailAdrProcessor;
    }
    private ShellProcessor createHiveEMailRemoveProcessor(String domName) {
        return new ShellProcessor(
            "postmap -d '" + domName + "' /etc/postfix-mailin/virtual && " +
            "for KEY in $(postmap -s /etc/postfix-mailin/virtual|grep '@" + domName + "\\s'|cut -f1); " +
                "do postmap -d $KEY /etc/postfix-mailin/virtual; done"
            );
    }
    private Processor createDNSServerSetupProcessor(String domName, String pacInetAddr) {