subdomains to pacdomain are not allowed

This commit is contained in:
Peter Hormanns 2012-01-04 15:12:47 +00:00
parent 9188fd5e42
commit 4d31afc018

View File

@ -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);
}