From 96675a06eb060348b36c20269ec151d4ec2e754d Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Fri, 21 Sep 2012 16:48:49 +0200
Subject: [PATCH] fix problem detached domainoption

---
 hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java
index b45ddc6..0b82220 100644
--- a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java
+++ b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java
@@ -91,10 +91,6 @@
 			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 @@
 		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()) {

--
Gitblit v1.9.0-SNAPSHOT