From c8dd78ff9f31d53876ef8c8e00adf87d7299fe6d Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 7 Sep 2015 16:39:16 +0200 Subject: [PATCH 1/9] create newweb branch without sni changes --- .../META-INF/persistence-with-sql-logging.xml | 1 - hsarback/conf/META-INF/persistence.xml | 1 - hsarback/conf/WEB-INF/prod-web.xml | 17 +-- hsarback/conf/WEB-INF/test-web.xml | 13 ++- .../qserv/QueueStatusReceiverServlet.java | 6 + .../src/de/hsadmin/remote/PropertyRemote.java | 104 ++++++++++++++++++ .../xmlrpc/webserver/XmlRpcServlet.properties | 1 + 7 files changed, 129 insertions(+), 14 deletions(-) create mode 100644 hsarback/src/de/hsadmin/remote/PropertyRemote.java diff --git a/hsarback/conf/META-INF/persistence-with-sql-logging.xml b/hsarback/conf/META-INF/persistence-with-sql-logging.xml index f551d23..cbbe3f5 100644 --- a/hsarback/conf/META-INF/persistence-with-sql-logging.xml +++ b/hsarback/conf/META-INF/persistence-with-sql-logging.xml @@ -6,7 +6,6 @@ de.hsadmin.core.qserv.QueueTask de.hsadmin.mods.cust.Customer de.hsadmin.mods.cust.Contact - de.hsadmin.mods.cust.BankAccount de.hsadmin.mods.pac.Pac de.hsadmin.mods.pac.BasePac de.hsadmin.mods.pac.BaseComponent diff --git a/hsarback/conf/META-INF/persistence.xml b/hsarback/conf/META-INF/persistence.xml index 5e0734c..ae4304b 100644 --- a/hsarback/conf/META-INF/persistence.xml +++ b/hsarback/conf/META-INF/persistence.xml @@ -6,7 +6,6 @@ de.hsadmin.core.qserv.QueueTask de.hsadmin.mods.cust.Customer de.hsadmin.mods.cust.Contact - de.hsadmin.mods.cust.BankAccount de.hsadmin.mods.pac.Pac de.hsadmin.mods.pac.BasePac de.hsadmin.mods.pac.BaseComponent diff --git a/hsarback/conf/WEB-INF/prod-web.xml b/hsarback/conf/WEB-INF/prod-web.xml index 1b71c01..4899424 100644 --- a/hsarback/conf/WEB-INF/prod-web.xml +++ b/hsarback/conf/WEB-INF/prod-web.xml @@ -11,6 +11,14 @@ Queue Status Servlet de.hsadmin.core.qserv.QueueStatusReceiverServlet + + proxyValidateUrl + https://@LOGIN_HOST@:@LOGIN_PORT@/cas/proxyValidate + + + proxyServiceUrl + https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend + 1 @@ -18,8 +26,8 @@ XmlRpcServlet de.hsadmin.remote.HSXmlRpcServlet - enabledForExtensions - true + enabledForExtensions + true @@ -28,11 +36,6 @@ /queueStatus - - CLI Client Connector - /hsadmin/cli-interface/ - - XmlRpcServlet /xmlrpc/* diff --git a/hsarback/conf/WEB-INF/test-web.xml b/hsarback/conf/WEB-INF/test-web.xml index df5a9df..47c2dd5 100644 --- a/hsarback/conf/WEB-INF/test-web.xml +++ b/hsarback/conf/WEB-INF/test-web.xml @@ -11,6 +11,14 @@ Queue Status Servlet de.hsadmin.core.qserv.QueueStatusReceiverServlet + + proxyValidateUrl + https://@LOGIN_HOST@:@LOGIN_PORT@/cas/proxyValidate + + + proxyServiceUrl + https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend + 1 @@ -28,11 +36,6 @@ /queueStatus - - CLI Client Connector - /hsadmin/cli-interface/ - - XmlRpcServlet /xmlrpc/* diff --git a/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java b/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java index af52c92..1d70163 100644 --- a/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java +++ b/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java @@ -18,12 +18,14 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.persistence.EntityManager; +import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import de.hsadmin.core.model.TechnicalException; +import de.hsadmin.core.model.TicketValidator; import de.hsadmin.core.model.Transaction; import de.hsadmin.core.util.Config; @@ -43,6 +45,10 @@ public class QueueStatusReceiverServlet extends HttpServlet @Override public void init() throws ServletException { + final ServletConfig cfg = getServletConfig(); + final String validateURL = cfg.getInitParameter("proxyValidateUrl"); + final String serviceURL = cfg.getInitParameter("proxyServiceUrl"); + TicketValidator.getInstance().initialize(validateURL, serviceURL); isConnected = false; messageCount = 0; errorCount = 0; diff --git a/hsarback/src/de/hsadmin/remote/PropertyRemote.java b/hsarback/src/de/hsadmin/remote/PropertyRemote.java new file mode 100644 index 0000000..6d924aa --- /dev/null +++ b/hsarback/src/de/hsadmin/remote/PropertyRemote.java @@ -0,0 +1,104 @@ +package de.hsadmin.remote; + +import java.io.InputStream; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import de.hsadmin.core.model.AbstractEntity; +import de.hsadmin.core.model.AnnFieldIO; +import de.hsadmin.core.model.AuthenticationException; +import de.hsadmin.core.model.HSAdminException; +import de.hsadmin.core.model.ReadWriteAccess; +import de.hsadmin.core.model.Transaction; + +public class PropertyRemote implements IRemote { + + @Override + public List> search(String runAsUser, String ticket, + Map whereParams) throws HSAdminException { + String user = runAsUser; + List> result = new ArrayList>(); + Transaction transaction = new Transaction(user); + try { + if (transaction.login(user, ticket)) { + InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("org/apache/xmlrpc/webserver/XmlRpcServlet.properties"); + Properties properties = new Properties(); + properties.load(resourceAsStream); + for (Object moduleKey : properties.keySet()) { + Class remoteClass = Class.forName(properties.getProperty((String) moduleKey)); + Object newInstance = remoteClass.newInstance(); + if (newInstance instanceof AbstractRemote) { + AbstractRemote remote = (AbstractRemote) newInstance; + Class entityClass = remote.getEntityClass(); + for (Field f: entityClass.getDeclaredFields()) { + AnnFieldIO fieldIO = f.getAnnotation(AnnFieldIO.class); + if (fieldIO != null) { + HashMap propertyProperties = new HashMap(); + String fieldName = f.getName(); + propertyProperties.put("module", (String) moduleKey); + propertyProperties.put("name", fieldName); + propertyProperties.put("searchable", "equals"); + propertyProperties.put("readwriteable", "read"); + ReadWriteAccess rw = fieldIO.rw(); + if (ReadWriteAccess.READONLY.equals(rw)) { + propertyProperties.put("readwriteable", "read"); + } + if (ReadWriteAccess.READWRITE.equals(rw)) { + propertyProperties.put("readwriteable", "readwrite"); + } + if (ReadWriteAccess.WRITEONCE.equals(rw)) { + propertyProperties.put("readwriteable", "writeonce"); + } + if (ReadWriteAccess.WRITEONLY.equals(rw)) { + propertyProperties.put("readwriteable", "none"); + } + propertyProperties.put("type", "string"); + propertyProperties.put("displaySequence", "2"); + if ("name".equals(fieldName)) { + propertyProperties.put("displaySequence", "1"); + } + propertyProperties.put("displayVisible", "always"); + propertyProperties.put("minLength", "0"); + propertyProperties.put("maxLength", "999"); + String regExp = fieldIO.validation(); + propertyProperties.put("validationRegexp", regExp); + result.add(propertyProperties); + } + } + } + } + return result; + } else { + throw new AuthenticationException("authentication failed"); + } + } catch (Exception e) { + throw new HSAdminException(e); + } finally { + transaction.close(); + } + } + + @Override + public Map add(String runAsUser, String ticket, + Map setParams) throws HSAdminException { + throw new HSAdminException("read only module"); + } + + @Override + public void delete(String runAsUser, String ticket, + Map whereParams) throws HSAdminException { + throw new HSAdminException("read only module"); + } + + @Override + public List> update(String runAsUser, String ticket, + Map setParams, Map whereParams) + throws HSAdminException { + throw new HSAdminException("read only module"); + } + +} diff --git a/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties b/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties index fb56deb..d233600 100644 --- a/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties +++ b/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties @@ -10,3 +10,4 @@ postgresqluser=de.hsadmin.remote.PgsqlUserRemote mysqldb=de.hsadmin.remote.MysqlDbRemote postgresqldb=de.hsadmin.remote.PgsqlDbRemote moduleprop=de.hsadmin.remote.ModulePropertiesRemote +property=de.hsadmin.remote.PropertyRemote \ No newline at end of file From fa75194cf3ae74ce338e15f61e9dd73edbd50f35 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 7 Sep 2015 18:19:11 +0200 Subject: [PATCH 2/9] annotate pac properties --- hsarback/src/de/hsadmin/mods/pac/Pac.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hsarback/src/de/hsadmin/mods/pac/Pac.java b/hsarback/src/de/hsadmin/mods/pac/Pac.java index 4fa5ef0..b3969d6 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) + @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,6 +89,7 @@ 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) { From 041111d8459fa1617f9f7608a01764a3251eeb52 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 11 Sep 2015 17:26:42 +0200 Subject: [PATCH 3/9] introduce annotated class property on AbstractRemote pac is readonly property --- hsarback/src/de/hsadmin/core/qserv/QueueTask.java | 8 ++++++++ hsarback/src/de/hsadmin/mods/email/EMailAlias.java | 2 +- hsarback/src/de/hsadmin/mods/user/UnixUser.java | 4 ++-- hsarback/src/de/hsadmin/remote/AbstractRemote.java | 4 ++++ hsarback/src/de/hsadmin/remote/MysqlDbRemote.java | 6 ++++++ hsarback/src/de/hsadmin/remote/MysqlUserRemote.java | 6 ++++++ hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java | 6 ++++++ hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java | 6 ++++++ hsarback/src/de/hsadmin/remote/PropertyRemote.java | 2 +- 9 files changed, 40 insertions(+), 4 deletions(-) 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/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/user/UnixUser.java b/hsarback/src/de/hsadmin/mods/user/UnixUser.java index d71daf1..2653103 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; @@ -65,7 +65,7 @@ public class UnixUser extends AbstractEntity implements Serializable { @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/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/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..2f84044 100644 --- a/hsarback/src/de/hsadmin/remote/PropertyRemote.java +++ b/hsarback/src/de/hsadmin/remote/PropertyRemote.java @@ -33,7 +33,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) { From 9669b268c6f3953d61d91ecf6c69d9eaa79228b6 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 11 Sep 2015 17:31:09 +0200 Subject: [PATCH 4/9] add role to properties module --- .../src/de/hsadmin/remote/PropertyRemote.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hsarback/src/de/hsadmin/remote/PropertyRemote.java b/hsarback/src/de/hsadmin/remote/PropertyRemote.java index 2f84044..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)) { @@ -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 { From 88b6b6e67da2ac1052cf58ff1c18a102ed8d38f6 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 11 Sep 2015 19:32:00 +0200 Subject: [PATCH 5/9] derived field are readonly --- hsarback/src/de/hsadmin/mods/db/Database.java | 4 ++-- hsarback/src/de/hsadmin/mods/db/DatabaseUser.java | 4 ++-- hsarback/src/de/hsadmin/mods/user/UnixUser.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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/user/UnixUser.java b/hsarback/src/de/hsadmin/mods/user/UnixUser.java index 2653103..ed876d3 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUser.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUser.java @@ -61,7 +61,7 @@ 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; From 4d4ed2942ade4f0868fe50c8cdb9a60da37084a0 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 11 Sep 2015 23:03:09 +0200 Subject: [PATCH 6/9] rename basepac property for reflection problems --- hsarback/src/de/hsadmin/mods/pac/Pac.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/Pac.java b/hsarback/src/de/hsadmin/mods/pac/Pac.java index b3969d6..3ed0f14 100644 --- a/hsarback/src/de/hsadmin/mods/pac/Pac.java +++ b/hsarback/src/de/hsadmin/mods/pac/Pac.java @@ -58,7 +58,7 @@ public class Pac extends AbstractEntity implements Serializable { @JoinColumn(name = "basepacket_id") @ManyToOne(fetch = EAGER) @AnnFieldIO(rw=ReadWriteAccess.WRITEONCE,validation="[A-Za-z0-9\\/]*") - private BasePac basePac; + private BasePac basepac; @JoinColumn(name = "hive_id") @ManyToOne(fetch = EAGER) @@ -96,10 +96,10 @@ public class Pac extends AbstractEntity implements Serializable { 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()); @@ -200,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() { From 4d437f2befc66b93abfdf7a8fc2178edfae6efe0 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 11 Sep 2015 23:04:24 +0200 Subject: [PATCH 7/9] organize imports --- hsarback/src/de/hsadmin/core/qserv/JDBCProcessor.java | 2 -- hsarback/src/de/hsadmin/mods/cust/Customer.java | 1 - hsarback/src/de/hsadmin/mods/email/EMailAddress.java | 2 +- hsarback/src/de/hsadmin/mods/email/EMailAddressModuleImpl.java | 2 +- hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java | 2 +- hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java | 2 +- 6 files changed, 4 insertions(+), 7 deletions(-) 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/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/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/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/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 { From f7a0389bc75bc7e33c4af2556fe0a782a00d5462 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 11 Sep 2015 23:19:38 +0200 Subject: [PATCH 8/9] add name property to inetaddr --- hsarback/src/de/hsadmin/core/util/ReflectionUtil.java | 1 + hsarback/src/de/hsadmin/mods/pac/INetAddress.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java b/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java index 5f86d88..4209e96 100644 --- a/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java +++ b/hsarback/src/de/hsadmin/core/util/ReflectionUtil.java @@ -46,6 +46,7 @@ public class ReflectionUtil { } else if (valueObject instanceof AbstractEntity) { Class t = f.getType(); + System.out.println(t.getCanonicalName()); valueObject = invokeGetter((AbstractEntity) valueObject, t, t.getDeclaredField("name")); } } catch (Exception e) { diff --git a/hsarback/src/de/hsadmin/mods/pac/INetAddress.java b/hsarback/src/de/hsadmin/mods/pac/INetAddress.java index 6cb784b..e74d398 100644 --- a/hsarback/src/de/hsadmin/mods/pac/INetAddress.java +++ b/hsarback/src/de/hsadmin/mods/pac/INetAddress.java @@ -75,6 +75,14 @@ public class INetAddress extends AbstractEntity implements Serializable { this.inetAddr = inetAddr; } + public String getName() { + return inetAddr; + } + + public void setName(String inetAddr) { + this.inetAddr = inetAddr; + } + public String getDescription() { return description; } From a147c4406aea714e8fd130b81dc011192af6795f Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 11 Sep 2015 23:26:06 +0200 Subject: [PATCH 9/9] rename field to name --- hsarback/src/de/hsadmin/mods/pac/INetAddress.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/INetAddress.java b/hsarback/src/de/hsadmin/mods/pac/INetAddress.java index e74d398..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,19 +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 inetAddr; + return name; } public void setName(String inetAddr) { - this.inetAddr = inetAddr; + this.name = inetAddr; } public String getDescription() {