set domain admin before persisting domain
This commit is contained in:
parent
b44aab8d2d
commit
a5527411d8
@ -96,21 +96,6 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
||||
domainOption.setName("greylisting");
|
||||
domainOptions.add(domainOption);
|
||||
EntityManager em = getTransaction().getEntityManager();
|
||||
em.persist(dom);
|
||||
Query q = em.createQuery("SELECT opt FROM " +
|
||||
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
|
||||
" opt WHERE opt.name=:optName");
|
||||
for (DomainOption opt : domainOptions) {
|
||||
q.setParameter("optName", opt.getName());
|
||||
List<?> list = q.getResultList();
|
||||
if (list.size() != 1) {
|
||||
throw new HSAdminException("invalid domain option: " + opt.getName());
|
||||
} else {
|
||||
opt.setId(((DomainOption) list.get(0)).getId());
|
||||
}
|
||||
}
|
||||
dom.setDomainoptions(domainOptions);
|
||||
|
||||
UnixUser loginUser = getTransaction().getLoginUser();
|
||||
if (!loginUser.hasHostmasterRole()) {
|
||||
// search for domains superior to dom
|
||||
@ -137,12 +122,24 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Query adminQuery = em.createQuery("SELECT u FROM UnixUsers u WHERE u.name = :adminName");
|
||||
adminQuery.setParameter("adminName", admin.getName());
|
||||
dom.setUser((UnixUser) adminQuery.getSingleResult());
|
||||
needsWriteAccessOn(newEntity, "add");
|
||||
em.persist(dom);
|
||||
Query q = em.createQuery("SELECT opt FROM " +
|
||||
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
|
||||
" opt WHERE opt.name=:optName");
|
||||
for (DomainOption opt : domainOptions) {
|
||||
q.setParameter("optName", opt.getName());
|
||||
List<?> list = q.getResultList();
|
||||
if (list.size() != 1) {
|
||||
throw new HSAdminException("invalid domain option: " + opt.getName());
|
||||
} else {
|
||||
opt.setId(((DomainOption) list.get(0)).getId());
|
||||
}
|
||||
}
|
||||
dom.setDomainoptions(domainOptions);
|
||||
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"));
|
||||
|
Loading…
Reference in New Issue
Block a user