diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java index e1e6df9..550e6d2 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -100,16 +100,16 @@ public class DomainModuleImpl extends AbstractModuleImpl { Query domainQuery = em.createQuery("SELECT d FROM Domains d WHERE d.name = :domainName"); String superior = dom.getName(); while (superior.contains(".")) { - superior = superior.substring(superior.indexOf('.') + 1); if (dom.isPacDomain()) { break; } + superior = superior.substring(superior.indexOf('.') + 1); domainQuery.setParameter("domainName", superior); List resultList = domainQuery.getResultList(); if (resultList.size() > 0) { Domain superDom = (Domain) resultList.get(0); if (superDom.isPacDomain()) { - throw new HSAdminException("subdomains to pacdomain " + superDom.getName() + " are not allowed"); + throw new HSAdminException("subdomains to pacdomain " + superDom.getName() + " is not allowed"); } if (loginUser.hasPacAdminRoleFor(superDom.getUser().getPac())) { break; // same pac @@ -131,13 +131,15 @@ public class DomainModuleImpl extends AbstractModuleImpl { adminQuery.setParameter("adminName", admin.getName()); dom.setUser((UnixUser) adminQuery.getSingleResult()); needsWriteAccessOn(newEntity, "add"); -// Entity addedEntity = super.add(dom); -// Domain addedDomain = (Domain) addedEntity; em.persist(dom); - String[] emailAddresses = new String[] { "abuse", "postmaster", "webmaster" }; - for (String emailLocalpart : emailAddresses) { - EMailAddress eMailAddress = new EMailAddress(emailLocalpart, "", dom, admin.getName()); - em.persist(eMailAddress); + if (dom.isPacDomain()) { + em.persist(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getContractualContact().getEmail())); + em.persist(new EMailAddress("admin", "", dom, admin.getName())); + em.persist(new EMailAddress(dom.getUser().getPac().getName(), "", dom, admin.getName())); + } 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())); } return super.add(dom); }