From 9910aeb9e098e1b29252eb354f5a909503cc0662 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 21 Jan 2013 13:33:19 +0100 Subject: [PATCH] on domain add use default domainoptions only if no optins are given --- .../de/hsadmin/mods/dom/DomainModuleImpl.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java index 01511e1..245a1b3 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -135,20 +135,22 @@ public class DomainModuleImpl extends AbstractModuleImpl { dom.setUser((UnixUser) adminQuery.getSingleResult()); needsWriteAccessOn(newEntity, "add"); em.persist(dom); - HashSet domainOptions = new HashSet(); - for (String domOpt : DEFAULT_DOMOPTS) { - Query q = em.createQuery("SELECT opt FROM " + - DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() + - " opt WHERE opt.name=:optName"); - q.setParameter("optName", domOpt); - List list = q.getResultList(); - if (list.size() == 1) { - domainOptions.add((DomainOption) list.get(0)); - } else { - throw new HSAdminException("invalid domain option: " + domOpt); + if (dom.getDomainoptions() == null) { // set default-domainoptions + HashSet domainOptions = new HashSet(); + for (String domOpt : DEFAULT_DOMOPTS) { + Query q = em.createQuery("SELECT opt FROM " + + DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() + + " opt WHERE opt.name=:optName"); + q.setParameter("optName", domOpt); + List list = q.getResultList(); + if (list.size() == 1) { + domainOptions.add((DomainOption) list.get(0)); + } else { + throw new HSAdminException("invalid domain option: " + domOpt); + } } + dom.setDomainoptions(domainOptions); } - 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"));