From 8c7363cb148e9771c5045e806b386024da71e75b Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Wed, 27 Jul 2011 18:45:47 +0200
Subject: [PATCH] delete pac domains

---
 hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
index ea46170..48955de 100644
--- a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
+++ b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
@@ -119,6 +119,7 @@
 	public void delete(AbstractEntity existingEntity) throws HSAdminException {
 		EntityManager em = getTransaction().getEntityManager();
 		Pac pac = (Pac) existingEntity;
+		String pacName = pac.getName();
 		Date dateCancelled = pac.getCancelled();
 		if (dateCancelled == null || dateCancelled.getTime() > System.currentTimeMillis()) {
 			throw new AuthorisationException(getLoginUser(), "delete", existingEntity);
@@ -126,7 +127,7 @@
 		GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
 		
 		Query qDoms = em.createQuery("SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac");
-		qDoms.setParameter("pac", pac.getName());
+		qDoms.setParameter("pac", pacName);
 		List<?> domsList = qDoms.getResultList();
 		for (Object o : domsList) {
 			if (o instanceof Domain) {
@@ -134,9 +135,8 @@
 			}
 		}
 		
-		UnixUser admin = pac.owningUser(em);
 		for (UnixUser user : pac.getUnixUser()) {
-			if (admin.getId() != user.getId()) {
+			if (!pacName.equals(user.getName())) {
 				helperModule.delete(user);
 			}
 		}

--
Gitblit v1.9.1