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.lang.reflect.InvocationTargetException;
import java.sql.SQLException; import java.sql.SQLException;
import javax.naming.NamingException;
import javax.persistence.RollbackException; import javax.persistence.RollbackException;
public class TechnicalException extends RuntimeException { public class TechnicalException extends RuntimeException {
@ -17,6 +18,10 @@ public class TechnicalException extends RuntimeException {
super(errorMsg); super(errorMsg);
} }
public TechnicalException(String errorMsg, NamingException e) {
super(errorMsg + "\n" + extractCauseMessage(e));
}
private static String extractCauseMessage(Throwable e) { private static String extractCauseMessage(Throwable e) {
if (e.getMessage() != null && !(e instanceof RollbackException)) { if (e.getMessage() != null && !(e instanceof RollbackException)) {
return e.getMessage(); 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) { 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(); String entityTypeName = entityInfo != null ? entityInfo.name() : entity.getClass().getSimpleName();
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
String title = entityTypeName + " (" + entity.createStringKey() + ") " + action; String title = entityTypeName + " (" + entity.createStringKey() + ") " + action;

View File

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

View File

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

View File

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

View File

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

View File

@ -15,10 +15,7 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction; import javax.persistence.EntityTransaction;
import javax.persistence.Query; import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.openjpa.persistence.OpenJPAEntityManager; import org.apache.openjpa.persistence.OpenJPAEntityManager;
//import org.hibernate.Session;
import de.hsadmin.cliClientConnector.TechnicalException; import de.hsadmin.cliClientConnector.TechnicalException;
import de.hsadmin.core.qserv.QueueClient; import de.hsadmin.core.qserv.QueueClient;
@ -30,8 +27,6 @@ import de.hsadmin.mods.user.UnixUser;
public class Transaction { public class Transaction {
private static final Log log = LogFactory.getLog(Transaction.class);
private EntityManager entityManager; private EntityManager entityManager;
private QueueConnectionFactory queueConnectionFactory; private QueueConnectionFactory queueConnectionFactory;
private String loginName; private String loginName;
@ -49,9 +44,7 @@ public class Transaction {
Context env = (Context) ctx.lookup("java:comp/env"); Context env = (Context) ctx.lookup("java:comp/env");
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF"); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
} catch (NamingException e) { } catch (NamingException e) {
log.fatal(e); throw new TechnicalException("no jms queue: jms/QueueCF", e);
e.printStackTrace();
throw new TechnicalException(e);
} }
} }
@ -69,9 +62,7 @@ public class Transaction {
Context env = (Context) ctx.lookup("java:comp/env"); Context env = (Context) ctx.lookup("java:comp/env");
return (Queue) env.lookup("jms/" + queueName); return (Queue) env.lookup("jms/" + queueName);
} catch (NamingException e) { } catch (NamingException e) {
log.fatal(e); throw new TechnicalException("no jms queue: jms/" + queueName, e);
e.printStackTrace();
return null;
} }
} }
return null; return null;
@ -141,7 +132,7 @@ public class Transaction {
try { try {
entityManager.getTransaction().rollback(); entityManager.getTransaction().rollback();
} catch (IllegalStateException e) { } 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.io.Serializable;
import java.util.Date; import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; 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.AbstractEntity;
import de.hsadmin.core.model.EntityInfo; import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.mods.qstat.QTaskModuleImpl; import de.hsadmin.mods.qstat.QTaskModuleImpl;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
@javax.persistence.Entity(name = "QueueTasks") @Entity(name = "QueueTasks")
@javax.persistence.Table(name = "queue_task") @Table(name = "queue_task")
@javax.persistence.SequenceGenerator(name = "QueueTaskSeqGen", sequenceName = "queue_task_id_seq") @SequenceGenerator(name = "QueueTaskSeqGen", sequenceName = "queue_task_id_seq")
@EntityInfo(name = "Systemauftrag") @AnnModuleImpl(QTaskModuleImpl.class)
@ModuleImpl(QTaskModuleImpl.class)
public class QueueTask extends AbstractEntity implements Serializable { public class QueueTask extends AbstractEntity implements Serializable {
private static final long serialVersionUID = 2171870783383767875L; private static final long serialVersionUID = 2171870783383767875L;
@javax.persistence.Id @Id
@javax.persistence.GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "QueueTaskSeqGen") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "QueueTaskSeqGen")
@javax.persistence.Column(name = "task_id", columnDefinition = "integer") @Column(name = "task_id", columnDefinition = "integer")
private long id; private long id;
@javax.persistence.JoinColumn(name="user_id", columnDefinition="integer", nullable=true) @JoinColumn(name="user_id", columnDefinition="integer", nullable=true)
@javax.persistence.ManyToOne(fetch=FetchType.EAGER) @ManyToOne(fetch=FetchType.EAGER)
private UnixUser user; private UnixUser user;
@javax.persistence.Column(name = "started", columnDefinition = "date") @Column(name = "started", columnDefinition = "date")
@javax.persistence.Temporal(javax.persistence.TemporalType.TIMESTAMP) @Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date started; private Date started;
@javax.persistence.Column(name = "finished", columnDefinition = "date", nullable = true) @Column(name = "finished", columnDefinition = "date", nullable = true)
@javax.persistence.Temporal(javax.persistence.TemporalType.TIMESTAMP) @Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date finished; private Date finished;
@javax.persistence.Column(name = "title", columnDefinition = "character varying(192)") @Column(name = "title", columnDefinition = "character varying(192)")
private String title; private String title;
@javax.persistence.Column(name = "details", columnDefinition = "text", nullable = true) @Column(name = "details", columnDefinition = "text", nullable = true)
private String details; private String details;
private Processor proc; private Processor proc;
@javax.persistence.Column(name = "exception", columnDefinition = "text", nullable = true) @Column(name = "exception", columnDefinition = "text", nullable = true)
private String exception; private String exception;
public QueueTask() { public QueueTask() {
@ -136,7 +144,7 @@ public class QueueTask extends AbstractEntity implements Serializable {
* virtual attribute done * virtual attribute done
* @return * @return
*/ */
@javax.persistence.Transient @Transient
public boolean isDone() { public boolean isDone() {
return finished != null; return finished != null;
} }
@ -149,7 +157,7 @@ public class QueueTask extends AbstractEntity implements Serializable {
* virtual attribute status * virtual attribute status
* @return * @return
*/ */
@javax.persistence.Transient @Transient
public QueueTaskStatus getStatus() { public QueueTaskStatus getStatus() {
return isDone() ? (exception == null ? QueueTaskStatus.DONE return isDone() ? (exception == null ? QueueTaskStatus.DONE
: QueueTaskStatus.ERROR) : QueueTaskStatus.PENDING; : QueueTaskStatus.ERROR) : QueueTaskStatus.PENDING;

View File

@ -23,13 +23,13 @@ import javax.persistence.Temporal;
import javax.persistence.Transient; import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity; 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.pac.Pac;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
@Entity(name = "Customers") @Entity(name = "Customers")
@Table(name = "business_partner") @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 { public class Customer extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -7450594652238392616L; 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.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; 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.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser; 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) @Column(name = "database_id", columnDefinition = "integer", updatable=false, insertable=false)
private long id; private long id;
@FieldValidation("[a-zA-Z]*") @AnnFieldValidation("[a-zA-Z]*")
@Column(name = "engine", columnDefinition = "character varying(12)", updatable=false) @Column(name = "engine", columnDefinition = "character varying(12)", updatable=false)
private String instance; private String instance;
@FieldValidation("[a-z0-9\\_]*") @AnnFieldValidation("[a-z0-9\\_]*")
@Column(name = "name", columnDefinition = "character varying(24)", updatable=false) @Column(name = "name", columnDefinition = "character varying(24)", updatable=false)
private String name; private String name;
@FieldValidation("[a-z0-9\\_]*") @AnnFieldValidation("[a-z0-9\\_]*")
@Column(name = "owner", columnDefinition = "character varying(24)") @Column(name = "owner", columnDefinition = "character varying(24)")
private String owner; private String owner;
@ -59,7 +59,7 @@ public abstract class Database extends AbstractEntity implements Serializable {
@ManyToOne(fetch = EAGER) @ManyToOne(fetch = EAGER)
private Pac pac; private Pac pac;
@FieldValidation("[A-Za-z0-9\\_\\-]*") @AnnFieldValidation("[A-Za-z0-9\\_\\-]*")
@Column(name = "encoding", columnDefinition = "character varying(24)", updatable=false) @Column(name = "encoding", columnDefinition = "character varying(24)", updatable=false)
private String encoding; private String encoding;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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