Paket und Admin-User in HSDB anlegen

This commit is contained in:
Peter Hormanns 2011-03-23 15:49:58 +00:00
parent 39c0c3b8c2
commit 6bb368fb37
3 changed files with 21 additions and 3 deletions

View File

@ -11,7 +11,9 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.mods.cust.Contact;
import de.hsadmin.mods.cust.Customer; import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.user.UnixUser;
public class PacModuleImpl extends AbstractModuleImpl { public class PacModuleImpl extends AbstractModuleImpl {
@ -77,6 +79,21 @@ public class PacModuleImpl extends AbstractModuleImpl {
pacComponents.add(pacComponent); pacComponents.add(pacComponent);
} }
pac.setPacComponents(pacComponents); pac.setPacComponents(pacComponents);
Set<UnixUser> users = new HashSet<UnixUser>();
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); return super.add(newEntity);
} }

View File

@ -156,7 +156,9 @@ public class UnixUser extends de.hsadmin.core.model.AbstractEntity implements Se
public void setPac(Pac pac) { public void setPac(Pac pac) {
this.pac = pac; this.pac = pac;
pac.getUnixUser().add(this); if (pac.getUnixUser() != null) {
pac.getUnixUser().add(this);
}
} }
public String getComment() { public String getComment() {

View File

@ -75,11 +75,10 @@ public class PacTest {
assertNotNull(execute); assertNotNull(execute);
fail("exception expected"); fail("exception expected");
} catch (XmlRpcException e) { } catch (XmlRpcException e) {
// System.out.println(e.getMessage());
} }
} }
@Test @Test
public void testCreate() { public void testCreate() {
int count = getPacsCount(); int count = getPacsCount();