Rollen-spezifische Module

This commit is contained in:
Peter Hormanns 2011-03-31 19:24:02 +00:00
parent 8ef722048b
commit 875d642f26
6 changed files with 23 additions and 6 deletions

Binary file not shown.

View File

@ -2,7 +2,7 @@ package de.hsadmin.core.util;
public class TextUtil {
public static String replaceUmlauts(String umlautString) {
public static String replaceUmlautCharacters(String umlautString) {
StringBuffer buffer = new StringBuffer();
for (char c : umlautString.toCharArray()) {
if ( (c >= 'a' && c <= 'z') ||

View File

@ -27,7 +27,7 @@ public class CustomerModuleImpl extends AbstractModuleImpl {
}
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
UnixUser custAccount = new UnixUser();
custAccount.setComment(TextUtil.replaceUmlauts(custComment));
custAccount.setComment(TextUtil.replaceUmlautCharacters(custComment));
custAccount.setName(newCustomer.getName());
custAccount.setPassword(newCustomer.getPassword());
custAccount.setShell("/usr/bin/passwd");

View File

@ -11,6 +11,7 @@ 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.core.util.TextUtil;
import de.hsadmin.mods.cust.Contact;
import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.user.UnixUser;
@ -83,7 +84,7 @@ public class PacModuleImpl extends AbstractModuleImpl {
pac.setUnixUser(users);
UnixUser admin = new UnixUser();
Contact contact = customer.getContractualContact();
admin.setComment(contact.getFirstName() + " " + contact.getLastName());
admin.setComment(TextUtil.replaceUmlautCharacters(contact.getFirstName() + " " + contact.getLastName()));
admin.setHomedir("/home/pacs/" + pac.getName());
admin.setName(pac.getName());
admin.setShell("/bin/bash");

View File

@ -306,10 +306,9 @@ public class UnixUser extends AbstractEntity implements Serializable {
String pacName = pac.getName();
if (!name.equals(pacName) && !name.startsWith(pacName + "-"))
return false;
if (super.isWriteAllowedFor(loginUser))
return true;
return this == loginUser || loginUser.hasPacAdminRoleFor(getPac());
return this.getId() == loginUser.getId() || loginUser.hasPacAdminRoleFor(getPac());
}
@Override

View File

@ -4,6 +4,7 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.cust.Customer;
@ -11,6 +12,7 @@ import de.hsadmin.mods.pac.BasePac;
import de.hsadmin.mods.pac.Hive;
import de.hsadmin.mods.pac.INetAddress;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.pac.PacComponent;
public class PacRemote extends AbstractRemote {
@ -25,6 +27,22 @@ public class PacRemote extends AbstractRemote {
resultMap.put("customer", pac.getCustomer().getName());
resultMap.put("curinetaddr", pac.getCurINetAddr().getInetAddr());
resultMap.put("created", df.format(pac.getCreated()));
resultMap.put("basepac", pac.getBasepac().getName());
Set<PacComponent> pacComponents = pac.getPacComponents();
StringBuffer bf = new StringBuffer();
boolean empty = true;
for (PacComponent comp : pacComponents) {
if (comp.getQuantity() > 0) {
if (!empty) {
bf.append("; ");
}
bf.append(comp.getBaseComponent().getFeature());
bf.append("=");
bf.append(comp.getQuantity());
empty = false;
}
}
resultMap.put("components", bf.toString());
}
@Override
@ -69,7 +87,6 @@ public class PacRemote extends AbstractRemote {
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "customer", "customer.name");
replaceKey(whereParams, "basepac", "customer.name");
}
}