package de.hsadmin.mods.db; import java.util.List; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.HSAdminException; public class PgSqlUserModuleImpl extends AbstractModuleImpl { @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); } @Override public List search(Class entityClass, String condition, String orderBy) throws HSAdminException { if (orderBy == null || orderBy.length() == 0) { orderBy = "ORDER BY obj.name ASC"; } return super.search(entityClass, condition, orderBy); } }