HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2017-10-04 66e570cfb22bd80c7deac274dee6b026971959d6
create email addresses by generic module
2 files modified
60 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java 25 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 35 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java
@@ -185,16 +185,27 @@
        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
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -41,8 +41,9 @@
        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 @@
            " && 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();