diff --git a/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java b/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java index a2d2cb7..85bf1dd 100644 --- a/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java +++ b/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java @@ -21,7 +21,6 @@ import de.hsadmin.mods.user.UnixUser; */ public abstract class AbstractModuleImpl implements ModuleInterface { - private static final long serialVersionUID = 2693948730004920437L; private static Log log = LogFactory.getLog(AbstractModuleImpl.class); private UnixUser loginUser; diff --git a/hsarback/src/de/hsadmin/core/model/GenericModuleImpl.java b/hsarback/src/de/hsadmin/core/model/GenericModuleImpl.java index 8f8173d..a5a3333 100644 --- a/hsarback/src/de/hsadmin/core/model/GenericModuleImpl.java +++ b/hsarback/src/de/hsadmin/core/model/GenericModuleImpl.java @@ -1,7 +1,6 @@ package de.hsadmin.core.model; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import java.util.regex.Pattern; @@ -83,8 +82,17 @@ public class GenericModuleImpl implements ModuleInterface { private void validateFields(AbstractEntity anEntity) throws HSAdminException { Class clasz = anEntity.getClass(); - Field[] fields = clasz.getDeclaredFields(); - for (Field f : fields) { + validateAllFields(clasz, anEntity); + // Bei Datenbanken und DB-Usern stehen die Attribute in der Oberklasse + Class superclass = clasz.getSuperclass(); + if (superclass != AbstractEntity.class) { + validateAllFields(superclass, anEntity); + } + } + + private void validateAllFields(Class clasz, AbstractEntity anEntity) + throws HSAdminException { + for (Field f : clasz.getDeclaredFields()) { FieldValidation fieldValidation = f.getAnnotation(FieldValidation.class); if (fieldValidation != null) { try { @@ -95,45 +103,8 @@ public class GenericModuleImpl implements ModuleInterface { throw new HSAdminException("validation of field " + f.getName() + " failed"); } } - } catch (SecurityException e) { + } catch (Exception e) { throw new HSAdminException(e); - } catch (NoSuchMethodException e) { - throw new HSAdminException(e); - } catch (IllegalArgumentException e) { - throw new HSAdminException(e); - } catch (IllegalAccessException e) { - throw new HSAdminException(e); - } catch (InvocationTargetException e) { - throw new HSAdminException(e); - } - } - } - // Bei Datenbanken und DB-Usern stehen die Attribute in der Oberklasse - Class superclass = clasz.getSuperclass(); - if (superclass != AbstractEntity.class) { - fields = superclass.getDeclaredFields(); - for (Field f : fields) { - FieldValidation fieldValidation = f.getAnnotation(FieldValidation.class); - if (fieldValidation != null) { - try { - Method method = superclass.getMethod(getterName(f)); - Object valueObject = method.invoke(anEntity); - if (valueObject instanceof String) { - if (!Pattern.matches(fieldValidation.value(), (String) valueObject)) { - throw new HSAdminException("validation of field " + f.getName() + " failed"); - } - } - } catch (SecurityException e) { - throw new HSAdminException(e); - } catch (NoSuchMethodException e) { - throw new HSAdminException(e); - } catch (IllegalArgumentException e) { - throw new HSAdminException(e); - } catch (IllegalAccessException e) { - throw new HSAdminException(e); - } catch (InvocationTargetException e) { - throw new HSAdminException(e); - } } } } diff --git a/hsarback/src/de/hsadmin/core/model/SecureDefaultModuleImpl.java b/hsarback/src/de/hsadmin/core/model/SecureDefaultModuleImpl.java index 00c817c..2310bfa 100644 --- a/hsarback/src/de/hsadmin/core/model/SecureDefaultModuleImpl.java +++ b/hsarback/src/de/hsadmin/core/model/SecureDefaultModuleImpl.java @@ -8,8 +8,6 @@ import java.util.List; */ public class SecureDefaultModuleImpl extends AbstractModuleImpl { - private static final long serialVersionUID = 4567381515459292565L; - @Override public AbstractEntity initialize(AbstractEntity newEntity) throws AuthorisationException { return super.initialize(newEntity); diff --git a/hsarback/src/de/hsadmin/mods/dom/Domain.java b/hsarback/src/de/hsadmin/mods/dom/Domain.java index 0133dc2..40e150d 100644 --- a/hsarback/src/de/hsadmin/mods/dom/Domain.java +++ b/hsarback/src/de/hsadmin/mods/dom/Domain.java @@ -25,8 +25,6 @@ import de.hsadmin.mods.user.UnixUser; @SequenceGenerator(name = "DomainsSeqGen", sequenceName = "domain_domain_id_seq") public class Domain extends AbstractEntity { - private static final long serialVersionUID = -7496110900868795840L; - @Id @Column(name = "domain_id", columnDefinition = "integer") @GeneratedValue(strategy = SEQUENCE, generator = "DomainsSeqGen") diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java index b41d402..4b88f7f 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainModuleImpl.java @@ -19,8 +19,6 @@ import de.hsadmin.mods.user.UnixUser; public class DomainModuleImpl extends AbstractModuleImpl { - private static final long serialVersionUID = -3991273357778898175L; - @Override public AbstractEntity initialize(AbstractEntity newEntity) throws AuthorisationException { AbstractEntity newDom = super.initialize(newEntity); diff --git a/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java b/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java index 0ac3ae1..5047489 100644 --- a/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java @@ -2,37 +2,21 @@ package de.hsadmin.mods.qstat; import java.util.List; -import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractEntity; +import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.HSAdminException; -import de.hsadmin.mods.user.UnixUser; public class QTaskModuleImpl extends AbstractModuleImpl { - private static final long serialVersionUID = 3942424688570077274L; - public QTaskModuleImpl() { } @Override public List search(Class entityClass, String condition, String orderBy) throws HSAdminException { - // do query and return result if (orderBy == null || orderBy.length() == 0) { orderBy = "ORDER BY obj.started DESC"; } return super.search(entityClass, condition, orderBy); } - // throws an AuthorisationException if the login user has no write acess - // on the pac of the given UnixUser - @SuppressWarnings("unused") - private boolean hasAccessOnPacOf(UnixUser user) { - // only pac admins (same name as pac) and the owner (customer) have - // write access to the pac - boolean isPacAdmin = getLoginUser().getName().equals( - user.getPac().getName()); - boolean isCustomer = getLoginUser().getName().equals( - user.getPac().getCustomer().getName()); - return isPacAdmin || isCustomer; - } } diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java index f0137aa..ba273e6 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java @@ -14,8 +14,6 @@ import de.hsadmin.mods.pac.Pac; public class UnixUserModuleImpl extends AbstractModuleImpl { - private static final long serialVersionUID = 7480353553685400790L; - public UnixUserModuleImpl() { }