diff --git a/hsarback/src/de/hsadmin/core/qserv/JDBCProcessor.java b/hsarback/src/de/hsadmin/core/qserv/JDBCProcessor.java index b191730..edb8db9 100644 --- a/hsarback/src/de/hsadmin/core/qserv/JDBCProcessor.java +++ b/hsarback/src/de/hsadmin/core/qserv/JDBCProcessor.java @@ -7,8 +7,6 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; -import de.hsadmin.core.qserv.AbstractProcessor; -import de.hsadmin.core.qserv.ProcessorException; import de.hsadmin.core.util.Config; public class JDBCProcessor extends AbstractProcessor { diff --git a/hsarback/src/de/hsadmin/core/qserv/QueueTask.java b/hsarback/src/de/hsadmin/core/qserv/QueueTask.java index 8b0b310..23cc72c 100644 --- a/hsarback/src/de/hsadmin/core/qserv/QueueTask.java +++ b/hsarback/src/de/hsadmin/core/qserv/QueueTask.java @@ -18,7 +18,9 @@ import javax.persistence.Temporal; import javax.persistence.Transient; import de.hsadmin.core.model.AbstractEntity; +import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnModuleImpl; +import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.mods.qstat.QTaskModuleImpl; import de.hsadmin.mods.user.UnixUser; @@ -35,26 +37,32 @@ public class QueueTask extends AbstractEntity implements Serializable { @Column(name = "task_id", columnDefinition = "integer") private long id; + @AnnFieldIO(rw=ReadWriteAccess.READONLY) @JoinColumn(name="user_id", columnDefinition="integer", nullable=true) @ManyToOne(fetch=FetchType.EAGER) private UnixUser user; + @AnnFieldIO(rw=ReadWriteAccess.READONLY) @Column(name = "started", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.TIMESTAMP) private Date started; + @AnnFieldIO(rw=ReadWriteAccess.READONLY) @Column(name = "finished", columnDefinition = "date", nullable = true) @Temporal(javax.persistence.TemporalType.TIMESTAMP) private Date finished; + @AnnFieldIO(rw=ReadWriteAccess.READONLY) @Column(name = "title", columnDefinition = "character varying(192)") private String title; + @AnnFieldIO(rw=ReadWriteAccess.READONLY) @Column(name = "details", columnDefinition = "text", nullable = true) private String details; private Processor proc; + @AnnFieldIO(rw=ReadWriteAccess.READONLY) @Column(name = "exception", columnDefinition = "text", nullable = true) private String exception; diff --git a/hsarback/src/de/hsadmin/mods/cust/Customer.java b/hsarback/src/de/hsadmin/mods/cust/Customer.java index df6fb13..b9bedd3 100644 --- a/hsarback/src/de/hsadmin/mods/cust/Customer.java +++ b/hsarback/src/de/hsadmin/mods/cust/Customer.java @@ -25,7 +25,6 @@ import javax.persistence.Temporal; import javax.persistence.Transient; import de.hsadmin.core.model.AbstractEntity; -import de.hsadmin.core.model.AnnModuleImpl; import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.user.UnixUser; diff --git a/hsarback/src/de/hsadmin/mods/db/Database.java b/hsarback/src/de/hsadmin/mods/db/Database.java index 74161e7..9ffb6c6 100644 --- a/hsarback/src/de/hsadmin/mods/db/Database.java +++ b/hsarback/src/de/hsadmin/mods/db/Database.java @@ -44,7 +44,7 @@ public abstract class Database extends AbstractEntity implements Serializable { @Column(name = "database_id", columnDefinition = "integer", updatable=false, insertable=false) private long id; - @AnnFieldIO(validation="[a-zA-Z]*", rw=ReadWriteAccess.WRITEONCE) + @AnnFieldIO(validation="[a-zA-Z]*", rw=ReadWriteAccess.READONLY) @Column(name = "engine", columnDefinition = "character varying(12)", updatable=false) private String instance; @@ -58,7 +58,7 @@ public abstract class Database extends AbstractEntity implements Serializable { @JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false) @ManyToOne(fetch = EAGER) - @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE) + @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.READONLY) private Pac pac; @AnnFieldIO(validation="[A-Za-z0-9\\_\\-]*", rw=ReadWriteAccess.WRITEONCE) diff --git a/hsarback/src/de/hsadmin/mods/db/DatabaseUser.java b/hsarback/src/de/hsadmin/mods/db/DatabaseUser.java index 39a0684..7bd4895 100644 --- a/hsarback/src/de/hsadmin/mods/db/DatabaseUser.java +++ b/hsarback/src/de/hsadmin/mods/db/DatabaseUser.java @@ -51,13 +51,13 @@ public abstract class DatabaseUser extends AbstractEntity implements Serializabl @Transient private String password; - @AnnFieldIO(validation="[a-zA-Z]*", rw=ReadWriteAccess.WRITEONCE) + @AnnFieldIO(validation="[a-zA-Z]*", rw=ReadWriteAccess.READONLY) @Column(name = "engine", columnDefinition = "character varying(12)", updatable=false) protected String instance; @JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false) @ManyToOne(fetch = EAGER) - @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE) + @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.READONLY) protected Pac pac; protected DatabaseUser() { diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddress.java b/hsarback/src/de/hsadmin/mods/email/EMailAddress.java index dcd2ee0..2dad272 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAddress.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAddress.java @@ -18,8 +18,8 @@ import javax.persistence.Transient; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AnnFieldIO; -import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.AnnModuleImpl; +import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.SearchFilter; import de.hsadmin.mods.dom.Domain; diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java index d4a773d..1933357 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java @@ -5,9 +5,9 @@ import java.util.List; import javax.persistence.EntityManager; import javax.persistence.Query; +import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AuthorisationException; -import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.Transaction; import de.hsadmin.hostsharing.BasePacType; diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAlias.java b/hsarback/src/de/hsadmin/mods/email/EMailAlias.java index f494555..1390d6f 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAlias.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAlias.java @@ -45,7 +45,7 @@ public class EMailAlias extends AbstractEntity implements Serializable { @ManyToOne() @JoinColumn(name = "pac_id", columnDefinition = "integer") - @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE) + @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.READONLY) private Pac pac; @AnnFieldIO(validation="[a-z0-9\\_\\-\\.\\+]*", rw=ReadWriteAccess.WRITEONCE) diff --git a/hsarback/src/de/hsadmin/mods/pac/INetAddress.java b/hsarback/src/de/hsadmin/mods/pac/INetAddress.java index 6cb784b..bfaeff3 100644 --- a/hsarback/src/de/hsadmin/mods/pac/INetAddress.java +++ b/hsarback/src/de/hsadmin/mods/pac/INetAddress.java @@ -28,7 +28,7 @@ public class INetAddress extends AbstractEntity implements Serializable { private long id; @Column(name = "inet_addr", unique = true, length=-1) - private String inetAddr; + private String name; @Column(name = "description", columnDefinition = "character varying(100)") private String description; @@ -37,7 +37,7 @@ public class INetAddress extends AbstractEntity implements Serializable { } public INetAddress(String inetAddr) { - this.inetAddr = inetAddr; + this.name = inetAddr; } public INetAddress(String inetAddr, String desc) { @@ -68,11 +68,19 @@ public class INetAddress extends AbstractEntity implements Serializable { } public String getInetAddr() { - return inetAddr; + return name; } public void setInetAddr(String inetAddr) { - this.inetAddr = inetAddr; + this.name = inetAddr; + } + + public String getName() { + return name; + } + + public void setName(String inetAddr) { + this.name = inetAddr; } public String getDescription() { diff --git a/hsarback/src/de/hsadmin/mods/pac/Pac.java b/hsarback/src/de/hsadmin/mods/pac/Pac.java index 4fa5ef0..3ed0f14 100644 --- a/hsarback/src/de/hsadmin/mods/pac/Pac.java +++ b/hsarback/src/de/hsadmin/mods/pac/Pac.java @@ -25,7 +25,9 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import de.hsadmin.core.model.AbstractEntity; +import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnModuleImpl; +import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.mods.cust.Customer; import de.hsadmin.mods.user.UnixUser; @@ -46,6 +48,7 @@ public class Pac extends AbstractEntity implements Serializable { private long id; @Column(name = "packet_name", unique = true) + @AnnFieldIO(rw=ReadWriteAccess.WRITEONCE,validation="[a-z0-9]*") private String name; @JoinColumn(name = "bp_id") @@ -54,10 +57,12 @@ public class Pac extends AbstractEntity implements Serializable { @JoinColumn(name = "basepacket_id") @ManyToOne(fetch = EAGER) - private BasePac basePac; + @AnnFieldIO(rw=ReadWriteAccess.WRITEONCE,validation="[A-Za-z0-9\\/]*") + private BasePac basepac; @JoinColumn(name = "hive_id") @ManyToOne(fetch = EAGER) + @AnnFieldIO(rw=ReadWriteAccess.WRITEONCE,validation="[a-z0-9]*") private Hive hive; @Column(name = "created") @@ -73,6 +78,7 @@ public class Pac extends AbstractEntity implements Serializable { @JoinColumn(name = "cur_inet_addr_id", nullable = true) @ManyToOne(fetch = EAGER) + @AnnFieldIO(rw=ReadWriteAccess.WRITEONCE,validation="[0-9\\.]*") private INetAddress curINetAddr; @JoinColumn(name = "old_inet_addr_id", nullable = true) @@ -83,16 +89,17 @@ public class Pac extends AbstractEntity implements Serializable { private Set pacComponents; @OneToMany(fetch = LAZY, cascade = ALL, mappedBy="pac") + @AnnFieldIO(rw=ReadWriteAccess.WRITEONCE,validation="[a-z0-9\\-\\.\\_]*") private Set unixUser; public void initPacComponents(EntityManager em, BasePac aBasepac, boolean setDefaults) { Query qAttachedBasepac = em.createQuery("SELECT b FROM BasePacs b WHERE b.valid = :valid AND b.name = :name"); qAttachedBasepac.setParameter("valid", Boolean.TRUE); qAttachedBasepac.setParameter("name", aBasepac.getName()); - basePac = (BasePac) qAttachedBasepac.getSingleResult(); + basepac = (BasePac) qAttachedBasepac.getSingleResult(); pacComponents = new HashSet(); Date today = new Date(); - for (Component comp : basePac.getComponents()) { + for (Component comp : basepac.getComponents()) { PacComponent pacComp = new PacComponent(); pacComp.setCreated(today); pacComp.setBaseComponent(comp.getBaseComponent()); @@ -193,11 +200,11 @@ public class Pac extends AbstractEntity implements Serializable { } public BasePac getBasepac() { - return basePac; + return basepac; } public void setBasepac(BasePac basepac) { - this.basePac = basepac; + this.basepac = basepac; } public Set getPacComponents() { diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUser.java b/hsarback/src/de/hsadmin/mods/user/UnixUser.java index d71daf1..ed876d3 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUser.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUser.java @@ -48,7 +48,7 @@ public class UnixUser extends AbstractEntity implements Serializable { @Transient private String password; - @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE) + @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.READONLY) @JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false) @ManyToOne(fetch = FetchType.LAZY) private Pac pac; @@ -61,11 +61,11 @@ public class UnixUser extends AbstractEntity implements Serializable { @Column(name = "shell", columnDefinition = "character varying(32)") private String shell; - @AnnFieldIO(validation="[a-z0-9\\/\\_\\-\\.]*", rw=ReadWriteAccess.WRITEONCE) + @AnnFieldIO(validation="[a-z0-9\\/\\_\\-\\.]*", rw=ReadWriteAccess.READONLY) @Column(name = "homedir", columnDefinition = "character varying(48)", updatable=false) private String homedir; - @AnnFieldIO(rw=ReadWriteAccess.READWRITE) + @AnnFieldIO(rw=ReadWriteAccess.READONLY) @Column(name = "locked", columnDefinition = "boolean") private boolean locked; diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java index b6dc605..9b3253c 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java @@ -6,9 +6,9 @@ import java.util.List; import javax.persistence.EntityManager; import javax.persistence.Query; -import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractModuleImpl; +import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.Transaction; import de.hsadmin.hostsharing.BasePacType; diff --git a/hsarback/src/de/hsadmin/remote/AbstractRemote.java b/hsarback/src/de/hsadmin/remote/AbstractRemote.java index fd19c68..1f7bf91 100644 --- a/hsarback/src/de/hsadmin/remote/AbstractRemote.java +++ b/hsarback/src/de/hsadmin/remote/AbstractRemote.java @@ -21,6 +21,10 @@ public abstract class AbstractRemote implements IRemote { protected abstract Class getEntityClass(); + protected Class getAnnotatedEntityClass() { + return getEntityClass(); + } + protected abstract void entity2map(Transaction tx, AbstractEntity entity, Map resultMap); protected abstract void map2entity(Transaction tx, Map setParams, AbstractEntity entity) throws HSAdminException; diff --git a/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java b/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java index ab206ac..3e9a66f 100644 --- a/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java +++ b/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java @@ -13,10 +13,10 @@ import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AuthenticationException; import de.hsadmin.core.model.DefaultSelectableValues; import de.hsadmin.core.model.HSAdminException; +import de.hsadmin.core.model.KindOfSelectableValue; import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.SelectableValue; import de.hsadmin.core.model.Transaction; -import de.hsadmin.core.model.KindOfSelectableValue; public class ModulePropertiesRemote implements IRemote { diff --git a/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java b/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java index c6d3d7a..107e10a 100644 --- a/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java +++ b/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java @@ -4,6 +4,7 @@ import java.util.Map; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.Transaction; +import de.hsadmin.mods.db.Database; import de.hsadmin.mods.db.MySqlDatabase; public class MysqlDbRemote extends AbstractRemote { @@ -27,6 +28,11 @@ public class MysqlDbRemote extends AbstractRemote { map.put("encoding", encoding); } + @Override + protected Class getAnnotatedEntityClass() { + return Database.class; + } + @Override protected Class getEntityClass() { return MySqlDatabase.class; diff --git a/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java b/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java index 3990843..781c6e1 100644 --- a/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java +++ b/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java @@ -4,6 +4,7 @@ import java.util.Map; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.Transaction; +import de.hsadmin.mods.db.DatabaseUser; import de.hsadmin.mods.db.MySqlUser; public class MysqlUserRemote extends AbstractRemote { @@ -23,6 +24,11 @@ public class MysqlUserRemote extends AbstractRemote { map.put("instance", instance); } + @Override + protected Class getAnnotatedEntityClass() { + return DatabaseUser.class; + } + @Override protected Class getEntityClass() { return MySqlUser.class; diff --git a/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java b/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java index b0046a3..129e899 100644 --- a/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java +++ b/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java @@ -4,6 +4,7 @@ import java.util.Map; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.Transaction; +import de.hsadmin.mods.db.Database; import de.hsadmin.mods.db.PgSqlDatabase; public class PgsqlDbRemote extends AbstractRemote { @@ -27,6 +28,11 @@ public class PgsqlDbRemote extends AbstractRemote { map.put("encoding", encoding); } + @Override + protected Class getAnnotatedEntityClass() { + return Database.class; + } + @Override protected Class getEntityClass() { return PgSqlDatabase.class; diff --git a/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java b/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java index fce99bb..2b59455 100644 --- a/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java +++ b/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java @@ -4,6 +4,7 @@ import java.util.Map; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.Transaction; +import de.hsadmin.mods.db.DatabaseUser; import de.hsadmin.mods.db.PgSqlUser; public class PgsqlUserRemote extends AbstractRemote { @@ -23,6 +24,11 @@ public class PgsqlUserRemote extends AbstractRemote { map.put("instance", instance); } + @Override + protected Class getAnnotatedEntityClass() { + return DatabaseUser.class; + } + @Override protected Class getEntityClass() { return PgSqlUser.class; diff --git a/hsarback/src/de/hsadmin/remote/PropertyRemote.java b/hsarback/src/de/hsadmin/remote/PropertyRemote.java index 6d924aa..a4d7595 100644 --- a/hsarback/src/de/hsadmin/remote/PropertyRemote.java +++ b/hsarback/src/de/hsadmin/remote/PropertyRemote.java @@ -22,6 +22,7 @@ public class PropertyRemote implements IRemote { Map whereParams) throws HSAdminException { String user = runAsUser; List> result = new ArrayList>(); + addRolesModule(result); Transaction transaction = new Transaction(user); try { if (transaction.login(user, ticket)) { @@ -33,7 +34,7 @@ public class PropertyRemote implements IRemote { Object newInstance = remoteClass.newInstance(); if (newInstance instanceof AbstractRemote) { AbstractRemote remote = (AbstractRemote) newInstance; - Class entityClass = remote.getEntityClass(); + Class entityClass = remote.getAnnotatedEntityClass(); for (Field f: entityClass.getDeclaredFields()) { AnnFieldIO fieldIO = f.getAnnotation(AnnFieldIO.class); if (fieldIO != null) { @@ -82,6 +83,21 @@ public class PropertyRemote implements IRemote { } } + private void addRolesModule(final List> result) { + final HashMap propertyProperties = new HashMap(); + propertyProperties.put("module", "role"); + propertyProperties.put("name", "role"); + propertyProperties.put("searchable", "equals"); + propertyProperties.put("readwriteable", "read"); + propertyProperties.put("type", "string"); + propertyProperties.put("displaySequence", "1"); + propertyProperties.put("displayVisible", "always"); + propertyProperties.put("minLength", "0"); + propertyProperties.put("maxLength", "20"); + propertyProperties.put("validationRegexp", "[A-Z_]*"); + result.add(propertyProperties); + } + @Override public Map add(String runAsUser, String ticket, Map setParams) throws HSAdminException {