Refactoring deletion of email addresses as part of the domain deletion
process.
This commit is contained in:
parent
9f568eef06
commit
e33737aaf6
@ -11,6 +11,7 @@ import javax.persistence.Query;
|
||||
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 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
||||
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);
|
||||
}
|
||||
|
@ -101,10 +101,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
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(",")) {
|
||||
@ -158,14 +155,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
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) {
|
||||
Processor seczonesFileProcessor;
|
||||
seczonesFileProcessor =
|
||||
|
Loading…
Reference in New Issue
Block a user