From 66e570cfb22bd80c7deac274dee6b026971959d6 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 4 Oct 2017 17:07:41 +0200 Subject: [PATCH] create email addresses by generic module --- .../de/hsadmin/mods/dom/DomainModuleImpl.java | 25 +++++++++---- .../mods/dom/DomainProcessorFactory.java | 35 ++++++++++--------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java index 724694c..c934c54 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -185,16 +185,27 @@ public class DomainModuleImpl extends AbstractModuleImpl { if (dom.getValidsubdomainnames() == null) { dom.setValidsubdomainnames("www"); } +// if (dom.isPacDomain()) { +// em.persist(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getName().substring(6) + "@hostsharing.net")); +// em.persist(new EMailAddress("admin", "", dom, dom.getUser().getPac().getName() + "@hostsharing.net")); +// em.persist(new EMailAddress(dom.getUser().getPac().getName(), "", dom, dom.getUser().getPac().getName() + "@hostsharing.net")); +// } else { +// em.persist(new EMailAddress("abuse", "", dom, admin.getName())); +// em.persist(new EMailAddress("postmaster", "", dom, admin.getName())); +// em.persist(new EMailAddress("webmaster", "", dom, admin.getName())); +// } + final AbstractEntity newDomain = super.add(dom); + final GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction()); if (dom.isPacDomain()) { - em.persist(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getName().substring(6) + "@hostsharing.net")); - em.persist(new EMailAddress("admin", "", dom, dom.getUser().getPac().getName() + "@hostsharing.net")); - em.persist(new EMailAddress(dom.getUser().getPac().getName(), "", dom, dom.getUser().getPac().getName() + "@hostsharing.net")); + helperModule.add(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getName().substring(6) + "@hostsharing.net")); + helperModule.add(new EMailAddress("admin", "", dom, dom.getUser().getPac().getName() + "@hostsharing.net")); + helperModule.add(new EMailAddress(dom.getUser().getPac().getName(), "", dom, dom.getUser().getPac().getName() + "@hostsharing.net")); } else { - em.persist(new EMailAddress("abuse", "", dom, admin.getName())); - em.persist(new EMailAddress("postmaster", "", dom, admin.getName())); - em.persist(new EMailAddress("webmaster", "", dom, admin.getName())); + helperModule.add(new EMailAddress("abuse", "", dom, admin.getName())); + helperModule.add(new EMailAddress("postmaster", "", dom, admin.getName())); + helperModule.add(new EMailAddress("webmaster", "", dom, admin.getName())); } - return super.add(dom); + return newDomain; } @Override diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index 3880e0f..f62ca8c 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -41,8 +41,9 @@ public class DomainProcessorFactory implements EntityProcessorFactory { Pac pac = domUser.getPac(); WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor( new CompoundProcessor( - createHiveDNSSetupProcessor(em, dom), - createHiveEMailSetupProcessor(em, dom) + createHiveDNSSetupProcessor(em, dom) +// , +// createHiveEMailSetupProcessor(em, dom) ) ); Config config = Config.getInstance(); @@ -136,21 +137,21 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && invoke-rc.d bind9 reload"); } - private CompoundProcessor createHiveEMailSetupProcessor(EntityManager em, Domain dom) { - LOG.info("createHiveEMailSetupProcessor( " + dom.getName() + " )"); - final EMailAddressProcessorFactory eMailAddressProcessorFactory = new EMailAddressProcessorFactory(); - final CompoundProcessor emailAdrProcessor = new CompoundProcessor(); - final Query query = em.createQuery( - "SELECT adr FROM EMailAddresses adr WHERE adr.domain.name = :domname"); - query.setParameter("domname", dom.getName()); - final List resultList = query.getResultList(); - for (final Object obj : resultList) { - final EMailAddress eMailAddress = (EMailAddress) obj; - LOG.info("EMail: " + eMailAddress.getEMailAddress()); - emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress)); - } - return emailAdrProcessor; - } +// private CompoundProcessor createHiveEMailSetupProcessor(EntityManager em, Domain dom) { +// LOG.info("createHiveEMailSetupProcessor( " + dom.getName() + " )"); +// final EMailAddressProcessorFactory eMailAddressProcessorFactory = new EMailAddressProcessorFactory(); +// final CompoundProcessor emailAdrProcessor = new CompoundProcessor(); +// final Query query = em.createQuery( +// "SELECT adr FROM EMailAddresses adr WHERE adr.domain.name = :domname"); +// query.setParameter("domname", dom.getName()); +// final List resultList = query.getResultList(); +// for (final Object obj : resultList) { +// final EMailAddress eMailAddress = (EMailAddress) obj; +// LOG.info("EMail: " + eMailAddress.getEMailAddress()); +// emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress)); +// } +// return emailAdrProcessor; +// } private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException { final String inetAddr = pac.getCurINetAddr().getInetAddr();