create email addresses by generic module

This commit is contained in:
Peter Hormanns 2017-10-04 17:07:41 +02:00
parent 9dd25448d8
commit 66e570cfb2
2 changed files with 36 additions and 24 deletions

View File

@ -185,16 +185,27 @@ public class DomainModuleImpl extends AbstractModuleImpl {
if (dom.getValidsubdomainnames() == null) { if (dom.getValidsubdomainnames() == null) {
dom.setValidsubdomainnames("www"); 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()) { if (dom.isPacDomain()) {
em.persist(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getName().substring(6) + "@hostsharing.net")); helperModule.add(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")); helperModule.add(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(dom.getUser().getPac().getName(), "", dom, dom.getUser().getPac().getName() + "@hostsharing.net"));
} else { } else {
em.persist(new EMailAddress("abuse", "", dom, admin.getName())); helperModule.add(new EMailAddress("abuse", "", dom, admin.getName()));
em.persist(new EMailAddress("postmaster", "", dom, admin.getName())); helperModule.add(new EMailAddress("postmaster", "", dom, admin.getName()));
em.persist(new EMailAddress("webmaster", "", dom, admin.getName())); helperModule.add(new EMailAddress("webmaster", "", dom, admin.getName()));
} }
return super.add(dom); return newDomain;
} }
@Override @Override

View File

@ -41,8 +41,9 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
Pac pac = domUser.getPac(); Pac pac = domUser.getPac();
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor( WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(
new CompoundProcessor( new CompoundProcessor(
createHiveDNSSetupProcessor(em, dom), createHiveDNSSetupProcessor(em, dom)
createHiveEMailSetupProcessor(em, dom) // ,
// createHiveEMailSetupProcessor(em, dom)
) )
); );
Config config = Config.getInstance(); Config config = Config.getInstance();
@ -136,21 +137,21 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
" && invoke-rc.d bind9 reload"); " && invoke-rc.d bind9 reload");
} }
private CompoundProcessor createHiveEMailSetupProcessor(EntityManager em, Domain dom) { // private CompoundProcessor createHiveEMailSetupProcessor(EntityManager em, Domain dom) {
LOG.info("createHiveEMailSetupProcessor( " + dom.getName() + " )"); // LOG.info("createHiveEMailSetupProcessor( " + dom.getName() + " )");
final EMailAddressProcessorFactory eMailAddressProcessorFactory = new EMailAddressProcessorFactory(); // final EMailAddressProcessorFactory eMailAddressProcessorFactory = new EMailAddressProcessorFactory();
final CompoundProcessor emailAdrProcessor = new CompoundProcessor(); // final CompoundProcessor emailAdrProcessor = new CompoundProcessor();
final Query query = em.createQuery( // final Query query = em.createQuery(
"SELECT adr FROM EMailAddresses adr WHERE adr.domain.name = :domname"); // "SELECT adr FROM EMailAddresses adr WHERE adr.domain.name = :domname");
query.setParameter("domname", dom.getName()); // query.setParameter("domname", dom.getName());
final List<?> resultList = query.getResultList(); // final List<?> resultList = query.getResultList();
for (final Object obj : resultList) { // for (final Object obj : resultList) {
final EMailAddress eMailAddress = (EMailAddress) obj; // final EMailAddress eMailAddress = (EMailAddress) obj;
LOG.info("EMail: " + eMailAddress.getEMailAddress()); // LOG.info("EMail: " + eMailAddress.getEMailAddress());
emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress)); // emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress));
} // }
return emailAdrProcessor; // return emailAdrProcessor;
} // }
private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException { private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
final String inetAddr = pac.getCurINetAddr().getInetAddr(); final String inetAddr = pac.getCurINetAddr().getInetAddr();