clean code

This commit is contained in:
Peter Hormanns 2012-07-27 09:18:08 +00:00
parent 8396917376
commit 3d4e839918
24 changed files with 90 additions and 143 deletions

View File

@ -3,6 +3,7 @@ package de.hsadmin.cliClientConnector;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import javax.naming.NamingException;
import javax.persistence.RollbackException;
public class TechnicalException extends RuntimeException {
@ -17,6 +18,10 @@ public class TechnicalException extends RuntimeException {
super(errorMsg);
}
public TechnicalException(String errorMsg, NamingException e) {
super(errorMsg + "\n" + extractCauseMessage(e));
}
private static String extractCauseMessage(Throwable e) {
if (e.getMessage() != null && !(e instanceof RollbackException)) {
return e.getMessage();

View File

@ -179,7 +179,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
}
protected void queueProcessor(Processor proc, UnixUser user, AbstractEntity entity, String action) {
EntityInfo entityInfo = entity.getClass().getAnnotation(EntityInfo.class);
Entity entityInfo = entity.getClass().getAnnotation(Entity.class);
String entityTypeName = entityInfo != null ? entityInfo.name() : entity.getClass().getSimpleName();
StringBuilder details = new StringBuilder();
String title = entityTypeName + " (" + entity.createStringKey() + ") " + action;

View File

@ -7,6 +7,6 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface FieldValidation {
public @interface AnnFieldValidation {
String value();
}

View File

@ -4,7 +4,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface ModuleImpl
public @interface AnnModuleImpl
{
Class<?> value();
}

View File

@ -1,12 +0,0 @@
package de.hsadmin.core.model;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(value=RetentionPolicy.RUNTIME)
public @interface EntityInfo
{
/// human readable identifier of the entity
String name();
}

View File

@ -1,12 +1,8 @@
package de.hsadmin.core.model;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class EntitySessionHelper {
private static Log log = LogFactory.getLog(EntitySessionHelper.class);
/**
* helper method to create a wrapper for checking the rights according to
* the entity class.
@ -14,16 +10,11 @@ public class EntitySessionHelper {
* @return
*/
public static AbstractModuleImpl createEntitySessionWrapper(Class<? extends AbstractEntity> entityClass, Transaction tx) {
// get in instance
AbstractModuleImpl impl = null;
try {
Class<?> wrapperClass = determineModuleImpl(entityClass);
// instantiate wrapper
impl = instantiateModuleImpl(tx, wrapperClass);
} catch (ClassNotFoundException exc) {
log.info("entity class '"
+ entityClass.getCanonicalName()
+ "' has no session wrapper => using restrictive default access rights");
impl = new SecureDefaultModuleImpl();
impl.construct(tx);
} catch (Exception exc) {
@ -42,7 +33,7 @@ public class EntitySessionHelper {
private static Class<?> determineModuleImpl(Class<? extends AbstractEntity> entityClass)
throws ClassNotFoundException {
ModuleImpl wrapperAnnot = entityClass.getAnnotation(ModuleImpl.class);
AnnModuleImpl wrapperAnnot = entityClass.getAnnotation(AnnModuleImpl.class);
Class<?> wrapperClass = null;
if (wrapperAnnot != null) {
wrapperClass = wrapperAnnot.value();

View File

@ -5,13 +5,8 @@ import java.lang.reflect.Method;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class GenericModuleImpl implements ModuleInterface {
private static final Log log = LogFactory.getLog(GenericModuleImpl.class);
private Transaction tx;
public GenericModuleImpl(Transaction transaction) {
@ -24,7 +19,6 @@ public class GenericModuleImpl implements ModuleInterface {
@Override
public AbstractEntity initialize(AbstractEntity newEntity) throws HSAdminException {
log.trace("initialize(" + newEntity + ")");
AbstractModuleImpl wrapper =
EntitySessionHelper.createEntitySessionWrapper(newEntity.getClass(), tx);
return wrapper.initialize(newEntity);
@ -35,7 +29,6 @@ public class GenericModuleImpl implements ModuleInterface {
validateFields(newEntity);
if (!newEntity.isNew())
throw new HSAdminException("cannot add an already persistent entity");
log.trace("add(" + newEntity + ")");
AbstractModuleImpl wrapper =
EntitySessionHelper.createEntitySessionWrapper(newEntity.getClass(), tx);
return wrapper.add(newEntity);
@ -43,21 +36,18 @@ public class GenericModuleImpl implements ModuleInterface {
@Override
public AbstractEntity find(Class<? extends AbstractEntity> entityClass, Object key) throws HSAdminException {
log.trace("find(" + entityClass + ", " + key + ")");
AbstractModuleImpl wrapper = EntitySessionHelper.createEntitySessionWrapper(entityClass, tx);
return wrapper.find(entityClass, key);
}
@Override
public AbstractEntity findByString(Class<? extends AbstractEntity> entityClass, String key) throws HSAdminException {
log.trace("find(" + entityClass + ", " + key + ")");
AbstractModuleImpl wrapper = EntitySessionHelper.createEntitySessionWrapper(entityClass, tx);
return wrapper.findByString(entityClass, key);
}
@Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
log.trace("search(" + entityClass + ", " + condition + ")");
AbstractModuleImpl wrapper = EntitySessionHelper.createEntitySessionWrapper(entityClass, tx);
return wrapper.search(entityClass, condition, orderBy);
}
@ -67,14 +57,12 @@ public class GenericModuleImpl implements ModuleInterface {
validateFields(existingEntity);
if (existingEntity.isNew())
return add(existingEntity);
log.debug("update(" + existingEntity + ")");
AbstractModuleImpl wrapper = EntitySessionHelper.createEntitySessionWrapper(existingEntity.getClass(), tx);
return wrapper.update(existingEntity);
}
@Override
public void delete(AbstractEntity existingEntity) throws HSAdminException {
log.trace("delete(" + existingEntity + ")");
AbstractModuleImpl wrapper =
EntitySessionHelper.createEntitySessionWrapper(existingEntity.getClass(), tx);
wrapper.delete(existingEntity);
@ -93,7 +81,7 @@ public class GenericModuleImpl implements ModuleInterface {
private void validateAllFields(Class<?> clasz, AbstractEntity anEntity)
throws HSAdminException {
for (Field f : clasz.getDeclaredFields()) {
FieldValidation fieldValidation = f.getAnnotation(FieldValidation.class);
AnnFieldValidation fieldValidation = f.getAnnotation(AnnFieldValidation.class);
if (fieldValidation != null) {
try {
Method method = clasz.getMethod(getterName(f));

View File

@ -8,14 +8,9 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class TicketValidator {
private static final Log log = LogFactory.getLog(TicketValidator.class);
private static TicketValidator instance;
private String proxyValidateURL;
@ -49,7 +44,6 @@ public class TicketValidator {
}
// real implementation
if (proxyServiceURL == null || proxyValidateURL == null) {
log.fatal("TicketValidator is not initialized.");
throw new RuntimeException("TicketValidator is not initialized.");
}
try {
@ -68,13 +62,10 @@ public class TicketValidator {
nextLine = reader.readLine();
}
inputStream.close();
log.debug("Ticket validation failed: " + ticket);
throw new AuthenticationException("Invalid Ticket: " + ticket);
} catch (MalformedURLException e) {
log.fatal(e);
throw new AuthenticationException(e.getMessage());
} catch (IOException e) {
log.fatal(e);
throw new AuthenticationException(e.getMessage());
}
}

View File

@ -15,10 +15,7 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
//import org.hibernate.Session;
import de.hsadmin.cliClientConnector.TechnicalException;
import de.hsadmin.core.qserv.QueueClient;
@ -30,8 +27,6 @@ import de.hsadmin.mods.user.UnixUser;
public class Transaction {
private static final Log log = LogFactory.getLog(Transaction.class);
private EntityManager entityManager;
private QueueConnectionFactory queueConnectionFactory;
private String loginName;
@ -49,9 +44,7 @@ public class Transaction {
Context env = (Context) ctx.lookup("java:comp/env");
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
} catch (NamingException e) {
log.fatal(e);
e.printStackTrace();
throw new TechnicalException(e);
throw new TechnicalException("no jms queue: jms/QueueCF", e);
}
}
@ -69,9 +62,7 @@ public class Transaction {
Context env = (Context) ctx.lookup("java:comp/env");
return (Queue) env.lookup("jms/" + queueName);
} catch (NamingException e) {
log.fatal(e);
e.printStackTrace();
return null;
throw new TechnicalException("no jms queue: jms/" + queueName, e);
}
}
return null;
@ -141,7 +132,7 @@ public class Transaction {
try {
entityManager.getTransaction().rollback();
} catch (IllegalStateException e) {
log.info(e);
// can't rollback
}
}

View File

@ -3,51 +3,59 @@ package de.hsadmin.core.qserv;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.mods.qstat.QTaskModuleImpl;
import de.hsadmin.mods.user.UnixUser;
@javax.persistence.Entity(name = "QueueTasks")
@javax.persistence.Table(name = "queue_task")
@javax.persistence.SequenceGenerator(name = "QueueTaskSeqGen", sequenceName = "queue_task_id_seq")
@EntityInfo(name = "Systemauftrag")
@ModuleImpl(QTaskModuleImpl.class)
@Entity(name = "QueueTasks")
@Table(name = "queue_task")
@SequenceGenerator(name = "QueueTaskSeqGen", sequenceName = "queue_task_id_seq")
@AnnModuleImpl(QTaskModuleImpl.class)
public class QueueTask extends AbstractEntity implements Serializable {
private static final long serialVersionUID = 2171870783383767875L;
@javax.persistence.Id
@javax.persistence.GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "QueueTaskSeqGen")
@javax.persistence.Column(name = "task_id", columnDefinition = "integer")
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "QueueTaskSeqGen")
@Column(name = "task_id", columnDefinition = "integer")
private long id;
@javax.persistence.JoinColumn(name="user_id", columnDefinition="integer", nullable=true)
@javax.persistence.ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="user_id", columnDefinition="integer", nullable=true)
@ManyToOne(fetch=FetchType.EAGER)
private UnixUser user;
@javax.persistence.Column(name = "started", columnDefinition = "date")
@javax.persistence.Temporal(javax.persistence.TemporalType.TIMESTAMP)
@Column(name = "started", columnDefinition = "date")
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date started;
@javax.persistence.Column(name = "finished", columnDefinition = "date", nullable = true)
@javax.persistence.Temporal(javax.persistence.TemporalType.TIMESTAMP)
@Column(name = "finished", columnDefinition = "date", nullable = true)
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date finished;
@javax.persistence.Column(name = "title", columnDefinition = "character varying(192)")
@Column(name = "title", columnDefinition = "character varying(192)")
private String title;
@javax.persistence.Column(name = "details", columnDefinition = "text", nullable = true)
@Column(name = "details", columnDefinition = "text", nullable = true)
private String details;
private Processor proc;
@javax.persistence.Column(name = "exception", columnDefinition = "text", nullable = true)
@Column(name = "exception", columnDefinition = "text", nullable = true)
private String exception;
public QueueTask() {
@ -136,7 +144,7 @@ public class QueueTask extends AbstractEntity implements Serializable {
* virtual attribute done
* @return
*/
@javax.persistence.Transient
@Transient
public boolean isDone() {
return finished != null;
}
@ -149,7 +157,7 @@ public class QueueTask extends AbstractEntity implements Serializable {
* virtual attribute status
* @return
*/
@javax.persistence.Transient
@Transient
public QueueTaskStatus getStatus() {
return isDone() ? (exception == null ? QueueTaskStatus.DONE
: QueueTaskStatus.ERROR) : QueueTaskStatus.PENDING;

View File

@ -23,13 +23,13 @@ import javax.persistence.Temporal;
import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@Entity(name = "Customers")
@Table(name = "business_partner")
@ModuleImpl(de.hsadmin.mods.cust.CustomerModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.cust.CustomerModuleImpl.class)
public class Customer extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -7450594652238392616L;

View File

@ -23,7 +23,7 @@ import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.model.AnnFieldValidation;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -43,15 +43,15 @@ public abstract class Database extends AbstractEntity implements Serializable {
@Column(name = "database_id", columnDefinition = "integer", updatable=false, insertable=false)
private long id;
@FieldValidation("[a-zA-Z]*")
@AnnFieldValidation("[a-zA-Z]*")
@Column(name = "engine", columnDefinition = "character varying(12)", updatable=false)
private String instance;
@FieldValidation("[a-z0-9\\_]*")
@AnnFieldValidation("[a-z0-9\\_]*")
@Column(name = "name", columnDefinition = "character varying(24)", updatable=false)
private String name;
@FieldValidation("[a-z0-9\\_]*")
@AnnFieldValidation("[a-z0-9\\_]*")
@Column(name = "owner", columnDefinition = "character varying(24)")
private String owner;
@ -59,7 +59,7 @@ public abstract class Database extends AbstractEntity implements Serializable {
@ManyToOne(fetch = EAGER)
private Pac pac;
@FieldValidation("[A-Za-z0-9\\_\\-]*")
@AnnFieldValidation("[A-Za-z0-9\\_\\-]*")
@Column(name = "encoding", columnDefinition = "character varying(24)", updatable=false)
private String encoding;

View File

@ -24,7 +24,7 @@ import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.model.AnnFieldValidation;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -42,15 +42,15 @@ public abstract class DatabaseUser extends AbstractEntity implements Serializabl
@Column(name = "dbuser_id", columnDefinition = "integer", updatable=false, insertable=false)
private long id;
@FieldValidation("[a-z0-9\\_]*")
@AnnFieldValidation("[a-z0-9\\_]*")
@Column(name = "name", columnDefinition = "character varying(24)", updatable=false)
private String name;
@FieldValidation("[^']*")
@AnnFieldValidation("[^']*")
@Transient
private String password;
@FieldValidation("[a-zA-Z]*")
@AnnFieldValidation("[a-zA-Z]*")
@Column(name = "engine", columnDefinition = "character varying(12)", updatable=false)
protected String instance;

View File

@ -5,17 +5,15 @@ import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
@Entity(name = "MySqlDatabases")
@DiscriminatorValue("mysql")
@EntityInfo(name = "MySQL Datenbank")
@SearchFilter("obj.instance = 'mysql' AND (" + " obj.pac = :loginUserPac OR "
+ " obj.pac.customer.memberCode = :loginUserName )")
@ModuleImpl(de.hsadmin.mods.db.MySqlDatabaseModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.db.MySqlDatabaseModuleImpl.class)
public class MySqlDatabase extends Database implements Serializable {
private static final long serialVersionUID = 2862112440807946042L;

View File

@ -5,18 +5,16 @@ import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
@Entity(name = "MySqlUsers")
@DiscriminatorValue("mysql")
@EntityInfo(name = "MySQL Konto")
@SearchFilter("obj.instance = 'mysql' AND ("
+ " obj.pac = :loginUserPac OR "
+ " obj.pac.customer.memberCode = :loginUserName )")
@ModuleImpl(de.hsadmin.mods.db.MySqlUserModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.db.MySqlUserModuleImpl.class)
public class MySqlUser extends DatabaseUser implements Serializable {
private static final long serialVersionUID = 6218494776881999478L;

View File

@ -5,18 +5,16 @@ import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
@Entity(name = "PgSqlDatabases")
@DiscriminatorValue("pgsql")
@EntityInfo(name = "PostgreSQL Datenbank")
@SearchFilter("obj.instance = 'pgsql' AND ("
+ " obj.pac = :loginUserPac OR "
+ " obj.pac.customer.memberCode = :loginUserName )")
@ModuleImpl(de.hsadmin.mods.db.PgSqlDatabaseModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.db.PgSqlDatabaseModuleImpl.class)
public class PgSqlDatabase extends Database implements Serializable {
private static final long serialVersionUID = 6688358817554938015L;

View File

@ -5,17 +5,15 @@ import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
@Entity(name = "PgSqlUsers")
@DiscriminatorValue("pgsql")
@EntityInfo(name = "PostgreSQL Konto")
@SearchFilter("obj.instance = 'pgsql' AND (" + " obj.pac = :loginUserPac OR "
+ " obj.pac.customer.memberCode = :loginUserName )")
@ModuleImpl(de.hsadmin.mods.db.PgSqlUserModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.db.PgSqlUserModuleImpl.class)
public class PgSqlUser extends DatabaseUser implements Serializable {
private static final long serialVersionUID = -1097602753310286629L;

View File

@ -22,14 +22,14 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnFieldValidation;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.mods.user.UnixUser;
@Entity(name = "Domains")
@Table(name = "domain")
@SequenceGenerator(name = "DomainsSeqGen", sequenceName = "domain_domain_id_seq")
@ModuleImpl(de.hsadmin.mods.dom.DomainModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.dom.DomainModuleImpl.class)
public class Domain extends AbstractEntity {
@Id
@ -37,7 +37,7 @@ public class Domain extends AbstractEntity {
@GeneratedValue(strategy = SEQUENCE, generator = "DomainsSeqGen")
private long id;
@FieldValidation("([-a-z0-9]+\\.)+[a-z]{2,}")
@AnnFieldValidation("([-a-z0-9]+\\.)+[a-z]{2,}")
@Column(name = "domain_name", columnDefinition = "character varying(256)", nullable = false)
private String name;
@ -45,7 +45,7 @@ public class Domain extends AbstractEntity {
@ManyToOne(fetch = EAGER)
private UnixUser user;
@FieldValidation("[a-z]*")
@AnnFieldValidation("[a-z]*")
@Column(name = "domain_status", columnDefinition = "character varying(12)", nullable = false)
private String status;
@ -65,7 +65,7 @@ public class Domain extends AbstractEntity {
@Temporal(javax.persistence.TemporalType.DATE)
private Date until;
@FieldValidation("[a-z0-9\\-\\.]*")
@AnnFieldValidation("[a-z0-9\\-\\.]*")
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
private String dnsMaster;

View File

@ -15,7 +15,7 @@ import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.model.AnnFieldValidation;
import de.hsadmin.mods.user.UnixUser;
@Table(name="domain_option")
@ -28,7 +28,7 @@ public class DomainOption extends AbstractEntity {
@GeneratedValue(strategy = SEQUENCE, generator = "DomainOptionSeqGen")
private long id;
@FieldValidation("[a-z0-9]+")
@AnnFieldValidation("[a-z0-9]+")
@Column(name = "domain_option_name", columnDefinition = "character varying(256)", nullable = false)
private String name;

View File

@ -17,10 +17,9 @@ import javax.persistence.Table;
import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.model.AnnFieldValidation;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.user.UnixUser;
@ -31,11 +30,10 @@ import de.hsadmin.mods.user.UnixUser;
@Entity(name = "EMailAddresses")
@Table(name = "emailaddr")
@SequenceGenerator(name = "EMailAddressesSeqGen", sequenceName = "emailaddr_emailaddr_id_seq")
@EntityInfo(name = "E-Mail-Adresse")
@SearchFilter("domain.user = :loginUser OR "
+ "domain.user.pac = :loginUserPac OR "
+ "domain.user.pac.customer.name = :loginUserName")
@ModuleImpl(de.hsadmin.mods.email.EMailAddressModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.email.EMailAddressModuleImpl.class)
public class EMailAddress extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -2265500181746604429L;
@ -45,11 +43,11 @@ public class EMailAddress extends AbstractEntity implements Serializable {
@Column(name = "emailaddr_id", columnDefinition = "integer")
private long id;
@FieldValidation("[A-Za-z0-9\\_\\-\\.\\+]*")
@AnnFieldValidation("[A-Za-z0-9\\_\\-\\.\\+]*")
@Column(name = "localpart", updatable = false, nullable= false)
private String localpart = "";
@FieldValidation("[a-z0-9\\-\\.]*")
@AnnFieldValidation("[a-z0-9\\-\\.]*")
@Column(name = "subdomain")
private String subdomain;
@ -57,7 +55,7 @@ public class EMailAddress extends AbstractEntity implements Serializable {
@JoinColumn(name = "domain_id", columnDefinition = "integer", updatable = false)
private Domain domain;
@FieldValidation("[\\x20-\\x7E]*")
@AnnFieldValidation("[\\x20-\\x7E]*")
@Column(name = "target", nullable= false)
private String target;

View File

@ -18,9 +18,8 @@ import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnFieldValidation;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -32,9 +31,8 @@ import de.hsadmin.mods.user.UnixUser;
@javax.persistence.Entity(name = "EMailAliases")
@Table(name = "emailalias")
@SequenceGenerator(name = "EMailAliasesSeqGen", sequenceName = "emailalias_emailalias_id_seq")
@EntityInfo(name = "E-Mail-Alias")
@SearchFilter("obj.pac = :loginUserPac OR obj.pac.customer.name = :loginUserName")
@ModuleImpl(de.hsadmin.mods.email.EMailAliasModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.email.EMailAliasModuleImpl.class)
public class EMailAlias extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -4711415079723587161L;
@ -48,11 +46,11 @@ public class EMailAlias extends AbstractEntity implements Serializable {
@JoinColumn(name = "pac_id", columnDefinition = "integer")
private Pac pac;
@FieldValidation("[a-z0-9\\_\\-\\.\\+]*")
@AnnFieldValidation("[a-z0-9\\_\\-\\.\\+]*")
@Column(updatable=false)
private String name;
@FieldValidation("[\\x20-\\x7E]*")
@AnnFieldValidation("[\\x20-\\x7E]*")
@Column
private String target;

View File

@ -25,15 +25,14 @@ import javax.persistence.TemporalType;
import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.user.UnixUser;
@Entity(name = "Pacs")
@Table(name = "packet")
@SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq")
@EntityInfo(name = "Paket")
//@ModuleImpl(de.hsadmin.mods.pac.PacModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.pac.PacModuleImpl.class)
public class Pac extends AbstractEntity implements Serializable {
private static final long serialVersionUID = 1L;

View File

@ -17,17 +17,15 @@ import javax.persistence.Table;
import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.AnnFieldValidation;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.pac.Pac;
@Entity(name = "UnixUsers")
@Table(name = "unixuser")
@SequenceGenerator(name = "UnixUsersSeqGen", sequenceName = "unixuser_unixuser_id_seq")
@EntityInfo(name = "UNIX-Zugang/Mailbox")
@ModuleImpl(de.hsadmin.mods.user.UnixUserModuleImpl.class)
@AnnModuleImpl(de.hsadmin.mods.user.UnixUserModuleImpl.class)
public class UnixUser extends AbstractEntity implements Serializable {
private static final long serialVersionUID = 7823071611805642906L;
@ -41,11 +39,11 @@ public class UnixUser extends AbstractEntity implements Serializable {
@Column(name = "userid", columnDefinition = "integer", nullable = false, updatable=false)
private long userId;
@FieldValidation("[a-z0-9\\_\\-\\.]*")
@AnnFieldValidation("[a-z0-9\\_\\-\\.]*")
@Column(name = "name", columnDefinition = "character varying(24)", unique = true, updatable=false)
private String name;
@FieldValidation("[^:]*")
@AnnFieldValidation("[^:]*")
@Transient
private String password;
@ -53,15 +51,15 @@ public class UnixUser extends AbstractEntity implements Serializable {
@ManyToOne(fetch = EAGER)
private Pac pac;
@FieldValidation("[a-zA-Z0-9\\_\\-\\.\\,\\ ]*")
@AnnFieldValidation("[a-zA-Z0-9\\_\\-\\.\\,\\ ]*")
@Column(name = "comment", columnDefinition = "character varying(128)")
private String comment;
@FieldValidation("[a-z\\/]*")
@AnnFieldValidation("[a-z\\/]*")
@Column(name = "shell", columnDefinition = "character varying(32)")
private String shell;
@FieldValidation("[a-z0-9\\/\\_\\-\\.]*")
@AnnFieldValidation("[a-z0-9\\/\\_\\-\\.]*")
@Column(name = "homedir", columnDefinition = "character varying(48)", updatable=false)
private String homedir;