hs.hsadmin/hsarback/src/de/hsadmin/remote/UnixUserRemote.java

82 lines
2.3 KiB
Java
Raw Normal View History

2010-10-01 21:52:51 +02:00
package de.hsadmin.remote;
import java.util.Map;
2010-10-04 19:44:49 +02:00
import de.hsadmin.core.model.AbstractEntity;
2010-10-01 21:52:51 +02:00
import de.hsadmin.mods.user.UnixUser;
public class UnixUserRemote extends AbstractRemote {
@Override
2010-10-04 19:44:49 +02:00
protected Class<? extends AbstractEntity> getEntityClass() {
2010-10-01 21:52:51 +02:00
return UnixUser.class;
}
@Override
2011-10-28 16:08:18 +02:00
protected void entity2map(AbstractEntity entity, Map<String, Object> map) {
2010-10-01 21:52:51 +02:00
UnixUser user = (UnixUser) entity;
map.put("id", Long.toString(user.getId()));
map.put("name", user.getName());
map.put("comment", user.getComment());
map.put("userid", Long.toString(user.getUserId()));
map.put("pac", user.getPac().getName());
map.put("shell", user.getShell());
map.put("homedir", user.getHomedir());
Integer quotaSoft = user.getQuotaSoftlimit();
if (assertNotNull(quotaSoft)) {
map.put("quota_softlimit", quotaSoft.toString());
}
Integer quotaHard = user.getQuotaHardlimit();
if (assertNotNull(quotaHard)) {
map.put("quota_hardlimit", quotaHard.toString());
}
}
@Override
2011-10-28 16:08:18 +02:00
protected void map2entity(Map<String, Object> map, AbstractEntity entity) {
2010-10-01 21:52:51 +02:00
UnixUser user = (UnixUser) entity;
2011-10-28 16:08:18 +02:00
String id = (String) map.get("id");
2010-10-01 21:52:51 +02:00
if (assertNotNull(id)) {
user.setId(Long.parseLong(id));
}
2011-10-28 16:08:18 +02:00
String name = (String) map.get("name");
2010-10-01 21:52:51 +02:00
if (assertNotNull(name)) {
user.setName(name);
}
2011-10-28 16:08:18 +02:00
String password = (String) map.get("password");
2010-10-01 21:52:51 +02:00
if (assertNotNull(password)) {
user.setPassword(password);
}
2011-10-28 16:08:18 +02:00
String comment = (String) map.get("comment");
2010-10-01 21:52:51 +02:00
if (assertNotNull(comment)) {
user.setComment(comment);
}
2011-10-28 16:08:18 +02:00
String userid = (String) map.get("userid");
2010-10-01 21:52:51 +02:00
if (assertNotNull(userid)) {
user.setUserId(Long.parseLong(userid));
}
2011-10-28 16:08:18 +02:00
String shell = (String) map.get("shell");
2010-10-01 21:52:51 +02:00
if (assertNotNull(shell)) {
user.setShell(shell);
}
2011-10-28 16:08:18 +02:00
String homedir = (String) map.get("homedir");
2010-10-01 21:52:51 +02:00
if (assertNotNull(homedir)) {
user.setHomedir(homedir);
}
2011-10-28 16:08:18 +02:00
String quota = (String) map.get("quota_softlimit");
2010-10-01 21:52:51 +02:00
if (assertNotNull(quota)) {
user.setQuotaSoftlimit(Integer.parseInt(quota));
}
2011-10-28 16:08:18 +02:00
String quotaLimit = (String) map.get("quota_hardlimit");
2010-10-01 21:52:51 +02:00
if (assertNotNull(quotaLimit)) {
user.setQuotaHardlimit(Integer.parseInt(quotaLimit));
}
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "pac", "pac.name");
}
}