From 6bb368fb37325070f138175d630fc4322ca491bc Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 23 Mar 2011 15:49:58 +0000 Subject: [PATCH] Paket und Admin-User in HSDB anlegen --- .../src/de/hsadmin/mods/pac/PacModuleImpl.java | 17 +++++++++++++++++ hsarback/src/de/hsadmin/mods/user/UnixUser.java | 4 +++- hsarback/test/de/hsadmin/remote/PacTest.java | 3 +-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java index dcccd0c..ddd73df 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java @@ -11,7 +11,9 @@ import javax.persistence.Query; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.HSAdminException; +import de.hsadmin.mods.cust.Contact; import de.hsadmin.mods.cust.Customer; +import de.hsadmin.mods.user.UnixUser; public class PacModuleImpl extends AbstractModuleImpl { @@ -77,6 +79,21 @@ public class PacModuleImpl extends AbstractModuleImpl { pacComponents.add(pacComponent); } pac.setPacComponents(pacComponents); + Set users = new HashSet(); + pac.setUnixUser(users); + UnixUser admin = new UnixUser(); + Contact contact = customer.getContractualContact(); + admin.setComment(contact.getFirstName() + " " + contact.getLastName()); + admin.setHomedir("/home/pacs/" + pac.getName()); + admin.setName(pac.getName()); + admin.setShell("/bin/bash"); + admin.setQuotaSoftlimit(0); + admin.setQuotaHardlimit(0); + admin.setPac(pac); + long nUID = 20000; + Long maxUid = (Long) em.createQuery("SELECT MAX(u.userId) FROM UnixUsers u").getSingleResult(); + if (maxUid >= nUID) nUID = maxUid + 1; + admin.setUserId(nUID); return super.add(newEntity); } diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUser.java b/hsarback/src/de/hsadmin/mods/user/UnixUser.java index 12763b8..57594db 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUser.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUser.java @@ -156,7 +156,9 @@ public class UnixUser extends de.hsadmin.core.model.AbstractEntity implements Se public void setPac(Pac pac) { this.pac = pac; - pac.getUnixUser().add(this); + if (pac.getUnixUser() != null) { + pac.getUnixUser().add(this); + } } public String getComment() { diff --git a/hsarback/test/de/hsadmin/remote/PacTest.java b/hsarback/test/de/hsadmin/remote/PacTest.java index 793c70d..3918277 100644 --- a/hsarback/test/de/hsadmin/remote/PacTest.java +++ b/hsarback/test/de/hsadmin/remote/PacTest.java @@ -75,11 +75,10 @@ public class PacTest { assertNotNull(execute); fail("exception expected"); } catch (XmlRpcException e) { -// System.out.println(e.getMessage()); + } } - @Test public void testCreate() { int count = getPacsCount();