From 3cc04662bab710d7f5e7738de18a0c11aecfc4d1 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Thu, 24 Mar 2011 18:18:30 +0100
Subject: [PATCH] Fixes

---
 hsarback/src/de/hsadmin/mods/email/EMailAlias.java             |   19 +++++++------------
 hsarback/src/de/hsadmin/mods/email/EMailAddress.java           |    2 +-
 hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java |    4 ++--
 3 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddress.java b/hsarback/src/de/hsadmin/mods/email/EMailAddress.java
index 0ecd6d1..693cba6 100644
--- a/hsarback/src/de/hsadmin/mods/email/EMailAddress.java
+++ b/hsarback/src/de/hsadmin/mods/email/EMailAddress.java
@@ -55,7 +55,7 @@
 	@JoinColumn(name = "domain_id", columnDefinition = "integer", updatable = false)
 	private Domain domain;
 	
-	@FieldValidation("[a-zA-Z0-9\\_\\-\\.\\|\\\"\\/\\@\\,\\+]*")
+	@FieldValidation("[a-zA-Z0-9\\_\\-\\.\\|\\\"\\/\\@\\,\\+\\ ]*")
 	@Column(name = "target", nullable= false)
 	private String target;
 
diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java
index de23749..976e277 100644
--- a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java
+++ b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java
@@ -49,8 +49,8 @@
 		EMailAddress detachedAddr = (EMailAddress) existingEntity;
 		EntityManager em = getTransaction().getEntityManager();
 		EMailAddress attachedAddr = em.find(EMailAddress.class, detachedAddr.getId());
-		Domain domain = detachedAddr.getDomain();
-		if (domain != null && domain.getId() != attachedAddr.getDomain().getId()) {
+		String domain = detachedAddr.getDomain().getName();
+		if (domain != null && !domain.equals(attachedAddr.getDomain().getName())) {
 			detachedAddr.setDomain(attachedAddr.getDomain());
 			throw new AuthorisationException(getLoginUser(), "update", detachedAddr, "domain");
 		}
diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAlias.java b/hsarback/src/de/hsadmin/mods/email/EMailAlias.java
index 0d3cb71..21cfecb 100644
--- a/hsarback/src/de/hsadmin/mods/email/EMailAlias.java
+++ b/hsarback/src/de/hsadmin/mods/email/EMailAlias.java
@@ -5,6 +5,7 @@
 import java.io.Serializable;
 
 import javax.persistence.Column;
+import javax.persistence.Entity;
 import javax.persistence.EntityManager;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
@@ -76,23 +77,17 @@
 			String pacName = name.substring(0, 5);
 			try {
 				// get the entities name (query part from FROM to WHERE)
-				javax.persistence.Entity entityAnnot = Pac.class
-						.getAnnotation(javax.persistence.Entity.class);
-				String queryString = "FROM " + entityAnnot.name() + " WHERE "
-						+ Pac.createQueryFromStringKey(pacName);
+				Entity entityAnnot = Pac.class.getAnnotation(Entity.class);
+				String queryString = "SELECT obj FROM " + entityAnnot.name() + " obj WHERE " + Pac.createQueryFromStringKey(pacName);
 
 				// set parameters
 				Query query = em.createQuery(queryString);
-				AbstractModuleImpl.setQueryParameter(query, queryString,
-						"loginUser", loginUser);
-				AbstractModuleImpl.setQueryParameter(query, queryString,
-						"loginUserName", loginUser.getName());
-				AbstractModuleImpl.setQueryParameter(query, queryString,
-						"loginUserPac", loginUser.getPac());
+				AbstractModuleImpl.setQueryParameter(query, queryString, "loginUser", loginUser);
+				AbstractModuleImpl.setQueryParameter(query, queryString, "loginUserName", loginUser.getName());
+				AbstractModuleImpl.setQueryParameter(query, queryString, "loginUserPac", loginUser.getPac());
 				pac = (Pac) query.getSingleResult();
 			} catch (NoResultException exc) {
-				throw new SecurityException("packet '" + pacName
-						+ "' not found or access denied");
+				throw new SecurityException("packet '" + pacName + "' not found or access denied");
 			}
 		}
 	}

--
Gitblit v1.9.1