fix problem detached domainoption

This commit is contained in:
Peter Hormanns 2012-09-21 16:48:49 +02:00
parent a5527411d8
commit 96675a06eb

View File

@ -91,10 +91,6 @@ public class DomainModuleImpl extends AbstractModuleImpl {
throw new HSAdminException("domain admin required");
}
// Standard domainoptions setzen. TODO: Alle defaults über eigene Klasse aus der Datenbank holen.
HashSet<DomainOption> domainOptions = new HashSet<DomainOption>();
DomainOption domainOption = new DomainOption();
domainOption.setName("greylisting");
domainOptions.add(domainOption);
EntityManager em = getTransaction().getEntityManager();
UnixUser loginUser = getTransaction().getLoginUser();
if (!loginUser.hasHostmasterRole()) {
@ -130,14 +126,13 @@ public class DomainModuleImpl extends AbstractModuleImpl {
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());
}
HashSet<DomainOption> domainOptions = new HashSet<DomainOption>();
q.setParameter("optName", "greylisting");
List<?> list = q.getResultList();
if (list.size() != 1) {
throw new HSAdminException("invalid domain option: " + "greylisting");
} else {
domainOptions.add((DomainOption) list.get(0));
}
dom.setDomainoptions(domainOptions);
if (dom.isPacDomain()) {