hs.hsadmin/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java

36 lines
1.1 KiB
Java
Raw Normal View History

2011-03-22 23:02:06 +01:00
package de.hsadmin.mods.db;
import java.util.List;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl;
2011-05-20 16:25:45 +02:00
import de.hsadmin.core.model.AuthorisationException;
2011-03-22 23:02:06 +01:00
import de.hsadmin.core.model.HSAdminException;
public class PgSqlUserModuleImpl extends AbstractModuleImpl {
2011-05-20 16:25:45 +02:00
@Override
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
PgSqlUser user = (PgSqlUser) newEntity;
String name = user.getName();
String pacname = user.getPac().getName();
if (!name.startsWith(pacname) || name.length() < 7) {
throw new AuthorisationException(getLoginUser(), "add", newEntity);
}
if (name.charAt(5) != '_') {
throw new AuthorisationException(getLoginUser(), "add", newEntity);
}
return super.add(newEntity);
}
2011-03-22 23:02:06 +01:00
@Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) {
2011-04-01 18:53:37 +02:00
orderBy = "ORDER BY obj.name ASC";
2011-03-22 23:02:06 +01:00
}
return super.search(entityClass, condition, orderBy);
}
}