23 files added
21 files modified
| | |
| | | <class>de.hsadmin.mods.dom.Domain</class> |
| | | <class>de.hsadmin.mods.email.EMailAddress</class> |
| | | <class>de.hsadmin.mods.email.EMailAlias</class> |
| | | <!-- |
| | | <class>de.hsadmin.mods.db.DatabaseUser</class> |
| | | <class>de.hsadmin.mods.db.MySqlUser</class> |
| | | <class>de.hsadmin.mods.db.MySqlDatabase</class> |
| | | <class>de.hsadmin.mods.db.PgSqlUser</class> |
| | | <class>de.hsadmin.mods.db.Database</class> |
| | | <class>de.hsadmin.mods.db.MySqlDatabase</class> |
| | | <class>de.hsadmin.mods.db.PgSqlDatabase</class> |
| | | --> |
| | | <properties> |
| | | <property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/> |
| | | </properties> |
| | |
| | | import java.io.Serializable; |
| | | |
| | | import javax.persistence.Column; |
| | | import javax.persistence.DiscriminatorColumn; |
| | | import javax.persistence.DiscriminatorType; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.GeneratedValue; |
| | | import javax.persistence.Id; |
| | | import javax.persistence.Inheritance; |
| | | import javax.persistence.InheritanceType; |
| | | import javax.persistence.JoinColumn; |
| | | import javax.persistence.ManyToOne; |
| | | import javax.persistence.MappedSuperclass; |
| | | import javax.persistence.NoResultException; |
| | | import javax.persistence.Query; |
| | | import javax.persistence.SequenceGenerator; |
| | | import javax.persistence.Table; |
| | | |
| | | import de.hsadmin.core.model.AbstractEntity; |
| | | import de.hsadmin.core.model.AbstractModuleImpl; |
| | |
| | | import de.hsadmin.mods.pac.Pac; |
| | | import de.hsadmin.mods.user.UnixUser; |
| | | |
| | | @MappedSuperclass |
| | | @SearchFilter("pac = :loginUserPac OR pac.customer.memberCode = :loginUserName") |
| | | @Entity |
| | | @Table(name = "database") |
| | | @Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
| | | @DiscriminatorColumn(name="engine", discriminatorType=DiscriminatorType.STRING) |
| | | @SequenceGenerator(name = "DatabaseSeqGen", sequenceName = "database_database_id_seq") |
| | | @SearchFilter("obj.pac = :loginUserPac OR obj.pac.customer.name = :loginUserName") |
| | | public abstract class Database extends AbstractEntity implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 6243815106074846080L; |
| | |
| | | String pacName = name.substring(0, 5); |
| | | try { |
| | | // get the entities name (query part from FROM to WHERE) |
| | | javax.persistence.Entity entityAnnot = Pac.class.getAnnotation(Entity.class); |
| | | String queryString = "FROM " + entityAnnot.name() + " WHERE " |
| | | Entity entityAnnot = Pac.class.getAnnotation(Entity.class); |
| | | String queryString = "SELECT obj FROM " + entityAnnot.name() + " obj WHERE " |
| | | + Pac.createQueryFromStringKey(pacName); |
| | | |
| | | // set parameters |
| | |
| | | public static String restriction() { |
| | | return |
| | | // all databases of all pacs of customer |
| | | "pac.customer.memberCode=:loginUserName OR " + |
| | | "obj.pac.customer.name=:loginUserName OR " + |
| | | // all aliases of packet admin |
| | | "pac.name=:loginUserName"; |
| | | "obj.pac.name=:loginUserName"; |
| | | } |
| | | } |
| | |
| | | import java.io.Serializable; |
| | | |
| | | import javax.persistence.Column; |
| | | import javax.persistence.DiscriminatorColumn; |
| | | import javax.persistence.DiscriminatorType; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.EntityManager; |
| | | import javax.persistence.GeneratedValue; |
| | | import javax.persistence.Id; |
| | | import javax.persistence.Inheritance; |
| | | import javax.persistence.InheritanceType; |
| | | import javax.persistence.JoinColumn; |
| | | import javax.persistence.ManyToOne; |
| | | import javax.persistence.MappedSuperclass; |
| | | import javax.persistence.NoResultException; |
| | | import javax.persistence.Query; |
| | | import javax.persistence.SequenceGenerator; |
| | | import javax.persistence.Table; |
| | | import javax.persistence.Transient; |
| | | |
| | | import de.hsadmin.core.model.AbstractEntity; |
| | |
| | | import de.hsadmin.mods.pac.Pac; |
| | | import de.hsadmin.mods.user.UnixUser; |
| | | |
| | | @MappedSuperclass |
| | | @Entity |
| | | @Table(name = "database_user") |
| | | @Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
| | | @DiscriminatorColumn(name="engine", discriminatorType=DiscriminatorType.STRING) |
| | | @SequenceGenerator(name = "DatabaseUserSeqGen", sequenceName = "dbuser_dbuser_id_seq") |
| | | public abstract class DatabaseUser extends AbstractEntity implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -4840133372566213014L; |
| | |
| | | // get the entities name (query part from FROM to WHERE) |
| | | javax.persistence.Entity entityAnnot = Pac.class |
| | | .getAnnotation(javax.persistence.Entity.class); |
| | | String queryString = "FROM " + entityAnnot.name() + " WHERE " |
| | | String queryString = "SELECT obj FROM " + entityAnnot.name() + " obj WHERE " |
| | | + Pac.createQueryFromStringKey(pacName); |
| | | |
| | | // set parameters |
| | |
| | | public static String restriction() { |
| | | return |
| | | // all databases of all pacs of customer |
| | | "pac.customer.memberCode=:loginUserName OR " + |
| | | "obj.pac.customer.name=:loginUserName OR " + |
| | | // all aliases of packet admin |
| | | "pac.name=:loginUserName"; |
| | | "obj.pac.name=:loginUserName"; |
| | | } |
| | | } |
| | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import javax.persistence.DiscriminatorValue; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.SequenceGenerator; |
| | | import javax.persistence.Table; |
| | | |
| | | import de.hsadmin.core.model.EntityInfo; |
| | | import de.hsadmin.core.model.SearchFilter; |
| | | import de.hsadmin.mods.pac.Pac; |
| | | |
| | | @Entity(name = "MySqlDatabases") |
| | | @Table(name = "database") |
| | | @SequenceGenerator(name = "DatabaseSeqGen", sequenceName = "database_database_id_seq") |
| | | @DiscriminatorValue("mysql") |
| | | @EntityInfo(name = "MySQL Datenbank") |
| | | @SearchFilter("instance = 'mysql' AND (" + " pac = :loginUserPac OR " |
| | | + " pac.customer.memberCode = :loginUserName )") |
| | | @SearchFilter("obj.instance = 'mysql' AND (" + " obj.pac = :loginUserPac OR " |
| | | + " obj.pac.customer.memberCode = :loginUserName )") |
| | | public class MySqlDatabase extends Database implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 2862112440807946042L; |
| | |
| | | } |
| | | |
| | | public static String restriction() { |
| | | return "instance='mysql' AND ( " + Database.restriction() + " )"; |
| | | return "obj.instance='mysql' AND ( " + Database.restriction() + " )"; |
| | | } |
| | | |
| | | } |
| | |
| | | public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, |
| | | String condition, String orderBy) throws HSAdminException { |
| | | if (orderBy == null || orderBy.length() == 0) { |
| | | orderBy = "ORDER BY name ASC"; |
| | | orderBy = "ORDER BY obj.name ASC"; |
| | | } |
| | | return super.search(entityClass, condition, orderBy); |
| | | } |
| | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import javax.persistence.DiscriminatorValue; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.SequenceGenerator; |
| | | import javax.persistence.Table; |
| | | |
| | | import de.hsadmin.core.model.EntityInfo; |
| | | import de.hsadmin.core.model.SearchFilter; |
| | | import de.hsadmin.mods.pac.Pac; |
| | | |
| | | @Entity(name = "MySqlUsers") |
| | | @Table(name = "database_user") |
| | | @SequenceGenerator(name = "DatabaseUserSeqGen", sequenceName = "dbuser_dbuser_id_seq") |
| | | @DiscriminatorValue("mysql") |
| | | @EntityInfo(name = "MySQL Konto") |
| | | @SearchFilter("instance = 'mysql' AND (" |
| | | + " pac = :loginUserPac OR " |
| | | + " pac.customer.memberCode = :loginUserName )") |
| | | @SearchFilter("obj.instance = 'mysql' AND (" |
| | | + " obj.pac = :loginUserPac OR " |
| | | + " obj.pac.customer.memberCode = :loginUserName )") |
| | | public class MySqlUser extends DatabaseUser implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 6218494776881999478L; |
| | | |
| | | public static String createQueryFromStringKey(String humanKey) { |
| | | return "name='" + humanKey + "' AND instance='mysql'"; |
| | | return "obj.name='" + humanKey + "' AND obj.instance='mysql'"; |
| | | } |
| | | |
| | | public MySqlUser() { |
| | |
| | | * query restriction for access control |
| | | */ |
| | | public static String restriction() { |
| | | return "instance='mysql' AND ( " + DatabaseUser.restriction() + " )"; |
| | | return "obj.instance='mysql' AND ( " + DatabaseUser.restriction() + " )"; |
| | | } |
| | | |
| | | } |
| | |
| | | public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, |
| | | String condition, String orderBy) throws HSAdminException { |
| | | if (orderBy == null || orderBy.length() == 0) { |
| | | orderBy = "ORDER BY name ASC"; |
| | | orderBy = "ORDER BY obj.name ASC"; |
| | | } |
| | | return super.search(entityClass, condition, orderBy); |
| | | } |
| | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import javax.persistence.DiscriminatorValue; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.SequenceGenerator; |
| | | import javax.persistence.Table; |
| | | |
| | | import de.hsadmin.core.model.EntityInfo; |
| | | import de.hsadmin.core.model.SearchFilter; |
| | | import de.hsadmin.mods.pac.Pac; |
| | | |
| | | @Entity(name = "PgSqlDatabases") |
| | | @Table(name = "database") |
| | | @SequenceGenerator(name = "DatabaseSeqGen", sequenceName = "database_database_id_seq") |
| | | @DiscriminatorValue("pgsql") |
| | | @EntityInfo(name = "PostgreSQL Datenbank") |
| | | @SearchFilter("instance = 'pgsql' AND (" |
| | | + " pac = :loginUserPac OR " |
| | | + " pac.customer.memberCode = :loginUserName )") |
| | | @SearchFilter("obj.instance = 'pgsql' AND (" |
| | | + " obj.pac = :loginUserPac OR " |
| | | + " obj.pac.customer.memberCode = :loginUserName )") |
| | | public class PgSqlDatabase extends Database implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 6688358817554938015L; |
| | |
| | | * query restriction for access control |
| | | */ |
| | | public static String restriction() { |
| | | return "instance='pgsql' AND ( " + Database.restriction() + " )"; |
| | | return "obj.instance='pgsql' AND ( " + Database.restriction() + " )"; |
| | | } |
| | | |
| | | } |
| | |
| | | @Override |
| | | public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException { |
| | | if (orderBy == null || orderBy.length() == 0) { |
| | | orderBy = "ORDER BY name ASC"; |
| | | orderBy = "ORDER BY obj.name ASC"; |
| | | } |
| | | return super.search(entityClass, condition, orderBy); |
| | | } |
| | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import javax.persistence.DiscriminatorValue; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.SequenceGenerator; |
| | | import javax.persistence.Table; |
| | | |
| | | import de.hsadmin.core.model.EntityInfo; |
| | | import de.hsadmin.core.model.SearchFilter; |
| | | import de.hsadmin.mods.pac.Pac; |
| | | |
| | | @Entity(name = "PgSqlUsers") |
| | | @Table(name = "database_user") |
| | | @SequenceGenerator(name = "DatabaseUserSeqGen", sequenceName = "dbuser_dbuser_id_seq") |
| | | @DiscriminatorValue("pgsql") |
| | | @EntityInfo(name = "PostgreSQL Konto") |
| | | @SearchFilter("instance = 'pgsql' AND (" + " pac = :loginUserPac OR " |
| | | + " pac.customer.memberCode = :loginUserName )") |
| | | @SearchFilter("obj.instance = 'pgsql' AND (" + " obj.pac = :loginUserPac OR " |
| | | + " obj.pac.customer.memberCode = :loginUserName )") |
| | | public class PgSqlUser extends DatabaseUser implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -1097602753310286629L; |
| | | |
| | | public static String createQueryFromStringKey(String humanKey) { |
| | | return "name='" + humanKey + "' AND instance='pgsql'"; |
| | | return "obj.name='" + humanKey + "' AND obj.instance='pgsql'"; |
| | | } |
| | | |
| | | public PgSqlUser() { |
| | |
| | | * query restriction for access control |
| | | */ |
| | | public static String restriction() { |
| | | return "instance='pgsql' AND ( " + DatabaseUser.restriction() + " )"; |
| | | return "obj.instance='pgsql' AND ( " + DatabaseUser.restriction() + " )"; |
| | | } |
| | | |
| | | } |
| | |
| | | public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, |
| | | String condition, String orderBy) throws HSAdminException { |
| | | if (orderBy == null || orderBy.length() == 0) { |
| | | orderBy = "ORDER BY name ASC"; |
| | | orderBy = "ORDER BY obj.name ASC"; |
| | | } |
| | | return super.search(entityClass, condition, orderBy); |
| | | } |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import de.hsadmin.core.model.AbstractEntity; |
| | | import de.hsadmin.mods.db.MySqlDatabase; |
| | | |
| | | public class MysqlDbRemote extends AbstractRemote { |
| | | |
| | | @Override |
| | | protected void entity2map(AbstractEntity entity, Map<String, String> map) { |
| | | MySqlDatabase db = (MySqlDatabase) entity; |
| | | String id = Long.toString(db.getId()); |
| | | String name = db.getName(); |
| | | String instance = db.getInstance(); |
| | | String owner = db.getOwner(); |
| | | String encoding = db.getEncoding(); |
| | | String pac = db.getPac().getName(); |
| | | String hive = db.getHiveName(); |
| | | map.put("id", id); |
| | | map.put("name", name); |
| | | map.put("instance", instance); |
| | | map.put("pac", pac); |
| | | map.put("hive", hive); |
| | | map.put("owner", owner); |
| | | map.put("encoding", encoding); |
| | | } |
| | | |
| | | @Override |
| | | protected Class<? extends AbstractEntity> getEntityClass() { |
| | | return MySqlDatabase.class; |
| | | } |
| | | |
| | | @Override |
| | | protected void map2entity(Map<String, String> map, AbstractEntity entity) { |
| | | MySqlDatabase db = (MySqlDatabase) entity; |
| | | db.setInstance("mysql"); |
| | | String name = map.get("name"); |
| | | String owner = map.get("owner"); |
| | | String encoding = map.get("encoding"); |
| | | if (assertNotNull(name)) { |
| | | db.setName(name); |
| | | } |
| | | if (assertNotNull(owner)) { |
| | | db.setOwner(owner); |
| | | } |
| | | if (assertNotNull(encoding)) { |
| | | db.setEncoding(encoding); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void regularizeKeys(Map<String, String> whereParams) { |
| | | replaceKey(whereParams, "pac", "pac.name"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import de.hsadmin.core.model.AbstractEntity; |
| | | import de.hsadmin.mods.db.MySqlUser; |
| | | |
| | | public class MysqlUserRemote extends AbstractRemote { |
| | | |
| | | @Override |
| | | protected void entity2map(AbstractEntity entity, Map<String, String> map) { |
| | | MySqlUser user = (MySqlUser) entity; |
| | | String id = Long.toString(user.getId()); |
| | | String name = user.getName(); |
| | | String instance = user.getInstance(); |
| | | String pac = user.getPac().getName(); |
| | | String hive = user.getHiveName(); |
| | | map.put("id", id); |
| | | map.put("name", name); |
| | | map.put("pac", pac); |
| | | map.put("hive", hive); |
| | | map.put("instance", instance); |
| | | } |
| | | |
| | | @Override |
| | | protected Class<? extends AbstractEntity> getEntityClass() { |
| | | return MySqlUser.class; |
| | | } |
| | | |
| | | @Override |
| | | protected void map2entity(Map<String, String> map, AbstractEntity entity) { |
| | | MySqlUser user = (MySqlUser) entity; |
| | | user.setInstance("mysql"); |
| | | String name = map.get("name"); |
| | | String password = map.get("password"); |
| | | if (assertNotNull(name)) { |
| | | user.setName(name); |
| | | } |
| | | if (assertNotNull(password)) { |
| | | user.setPassword(password); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void regularizeKeys(Map<String, String> whereParams) { |
| | | replaceKey(whereParams, "pac", "pac.name"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import de.hsadmin.core.model.AbstractEntity; |
| | | import de.hsadmin.mods.db.PgSqlDatabase; |
| | | |
| | | public class PgsqlDbRemote extends AbstractRemote { |
| | | |
| | | @Override |
| | | protected void entity2map(AbstractEntity entity, Map<String, String> map) { |
| | | PgSqlDatabase db = (PgSqlDatabase) entity; |
| | | String id = Long.toString(db.getId()); |
| | | String name = db.getName(); |
| | | String instance = db.getInstance(); |
| | | String owner = db.getOwner(); |
| | | String encoding = db.getEncoding(); |
| | | String pac = db.getPac().getName(); |
| | | String hive = db.getHiveName(); |
| | | map.put("id", id); |
| | | map.put("name", name); |
| | | map.put("instance", instance); |
| | | map.put("pac", pac); |
| | | map.put("hive", hive); |
| | | map.put("owner", owner); |
| | | map.put("encoding", encoding); |
| | | } |
| | | |
| | | @Override |
| | | protected Class<? extends AbstractEntity> getEntityClass() { |
| | | return PgSqlDatabase.class; |
| | | } |
| | | |
| | | @Override |
| | | protected void map2entity(Map<String, String> map, AbstractEntity entity) { |
| | | PgSqlDatabase db = (PgSqlDatabase) entity; |
| | | db.setInstance("pgsql"); |
| | | String name = map.get("name"); |
| | | String owner = map.get("owner"); |
| | | String encoding = map.get("encoding"); |
| | | if (assertNotNull(name)) { |
| | | db.setName(name); |
| | | } |
| | | if (assertNotNull(owner)) { |
| | | db.setOwner(owner); |
| | | } |
| | | if (assertNotNull(encoding)) { |
| | | db.setEncoding(encoding); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void regularizeKeys(Map<String, String> whereParams) { |
| | | replaceKey(whereParams, "pac", "pac.name"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import de.hsadmin.core.model.AbstractEntity; |
| | | import de.hsadmin.mods.db.PgSqlUser; |
| | | |
| | | public class PgsqlUserRemote extends AbstractRemote { |
| | | |
| | | @Override |
| | | protected void entity2map(AbstractEntity entity, Map<String, String> map) { |
| | | PgSqlUser user = (PgSqlUser) entity; |
| | | String id = Long.toString(user.getId()); |
| | | String name = user.getName(); |
| | | String instance = user.getInstance(); |
| | | String pac = user.getPac().getName(); |
| | | String hive = user.getHiveName(); |
| | | map.put("id", id); |
| | | map.put("name", name); |
| | | map.put("pac", pac); |
| | | map.put("hive", hive); |
| | | map.put("instance", instance); |
| | | } |
| | | |
| | | @Override |
| | | protected Class<? extends AbstractEntity> getEntityClass() { |
| | | return PgSqlUser.class; |
| | | } |
| | | |
| | | @Override |
| | | protected void map2entity(Map<String, String> map, AbstractEntity entity) { |
| | | PgSqlUser user = (PgSqlUser) entity; |
| | | user.setInstance("pgsql"); |
| | | String name = map.get("name"); |
| | | String password = map.get("password"); |
| | | if (assertNotNull(name)) { |
| | | user.setName(name); |
| | | } |
| | | if (assertNotNull(password)) { |
| | | user.setPassword(password); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void regularizeKeys(Map<String, String> whereParams) { |
| | | replaceKey(whereParams, "pac", "pac.name"); |
| | | } |
| | | |
| | | } |
| | |
| | | emailaddress=de.hsadmin.remote.EMailAddressRemote |
| | | q=de.hsadmin.remote.QueueTaskRemote |
| | | role=de.hsadmin.remote.RoleRemote |
| | | mysqluser=de.hsadmin.remote.MysqlUserRemote |
| | | postgresqluser=de.hsadmin.remote.PgsqlUserRemote |
| | | mysqldb=de.hsadmin.remote.MysqlDbRemote |
| | | postgresqldb=de.hsadmin.remote.PgsqlDbRemote |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import static org.junit.Assert.assertEquals; |
| | | import static org.junit.Assert.assertNull; |
| | | import static org.junit.Assert.assertTrue; |
| | | import static org.junit.Assert.fail; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.xmlrpc.XmlRpcException; |
| | | import org.apache.xmlrpc.client.XmlRpcClient; |
| | | import org.junit.After; |
| | | import org.junit.Before; |
| | | import org.junit.Test; |
| | | |
| | | public class MysqlDbTest { |
| | | |
| | | private static final String MODULE = "mysqldb"; |
| | | |
| | | private XmlRpcClient client; |
| | | private RemoteCASHelper cas; |
| | | |
| | | @Before |
| | | public void setUp() throws Exception { |
| | | client = RemoteTestHelper.getClient(); |
| | | cas = new RemoteCASHelper(); |
| | | } |
| | | |
| | | @After |
| | | public void tearDown() throws Exception { |
| | | client = null; |
| | | cas = null; |
| | | } |
| | | |
| | | @Test |
| | | public void testCreate() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> setParams = new HashMap<String, String>(); |
| | | setParams.put("name", "aaa00_db1"); |
| | | setParams.put("owner", "aaa00_dba"); |
| | | setParams.put("encoding", "utf8"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | setParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".add", params); |
| | | assertTrue(execute instanceof Map<?, ?>); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count + 1, getDBsCount()); |
| | | } |
| | | |
| | | @Test |
| | | public void testSearch() { |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | assertEquals(1, result.length); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void testDelete() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | whereParams.put("name", "aaa00_db1"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".delete", params); |
| | | assertNull(execute); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count - 1, getDBsCount()); |
| | | } |
| | | |
| | | private int getDBsCount() { |
| | | int count = 0; |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | count = result.length; |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import static org.junit.Assert.assertEquals; |
| | | import static org.junit.Assert.assertNull; |
| | | import static org.junit.Assert.assertTrue; |
| | | import static org.junit.Assert.fail; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.xmlrpc.XmlRpcException; |
| | | import org.apache.xmlrpc.client.XmlRpcClient; |
| | | import org.junit.After; |
| | | import org.junit.Before; |
| | | import org.junit.Test; |
| | | |
| | | public class MysqlUserTest { |
| | | |
| | | private static final String MODULE = "mysqluser"; |
| | | |
| | | private XmlRpcClient client; |
| | | private RemoteCASHelper cas; |
| | | |
| | | @Before |
| | | public void setUp() throws Exception { |
| | | client = RemoteTestHelper.getClient(); |
| | | cas = new RemoteCASHelper(); |
| | | } |
| | | |
| | | @After |
| | | public void tearDown() throws Exception { |
| | | client = null; |
| | | cas = null; |
| | | } |
| | | |
| | | @Test |
| | | public void testCreate() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> setParams = new HashMap<String, String>(); |
| | | setParams.put("name", "aaa00_dba"); |
| | | setParams.put("password", "geHeimNis"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | setParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".add", params); |
| | | assertTrue(execute instanceof Map<?, ?>); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count + 1, getDBsCount()); |
| | | } |
| | | |
| | | @Test |
| | | public void testSearch() { |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | assertEquals(1, result.length); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void testDelete() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | whereParams.put("name", "aaa00_dba"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".delete", params); |
| | | assertNull(execute); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count - 1, getDBsCount()); |
| | | } |
| | | |
| | | private int getDBsCount() { |
| | | int count = 0; |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | count = result.length; |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import static org.junit.Assert.assertEquals; |
| | | import static org.junit.Assert.assertNull; |
| | | import static org.junit.Assert.assertTrue; |
| | | import static org.junit.Assert.fail; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.xmlrpc.XmlRpcException; |
| | | import org.apache.xmlrpc.client.XmlRpcClient; |
| | | import org.junit.After; |
| | | import org.junit.Before; |
| | | import org.junit.Test; |
| | | |
| | | public class PgsqlDbTest { |
| | | |
| | | private static final String MODULE = "postgresqldb"; |
| | | |
| | | private XmlRpcClient client; |
| | | private RemoteCASHelper cas; |
| | | |
| | | @Before |
| | | public void setUp() throws Exception { |
| | | client = RemoteTestHelper.getClient(); |
| | | cas = new RemoteCASHelper(); |
| | | } |
| | | |
| | | @After |
| | | public void tearDown() throws Exception { |
| | | client = null; |
| | | cas = null; |
| | | } |
| | | |
| | | @Test |
| | | public void testCreate() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> setParams = new HashMap<String, String>(); |
| | | setParams.put("name", "aaa00_db1"); |
| | | setParams.put("owner", "aaa00_dba"); |
| | | setParams.put("encoding", "UTF-8"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | setParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".add", params); |
| | | assertTrue(execute instanceof Map<?, ?>); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count + 1, getDBsCount()); |
| | | } |
| | | |
| | | @Test |
| | | public void testSearch() { |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | assertEquals(1, result.length); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void testDelete() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | whereParams.put("name", "aaa00_db1"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".delete", params); |
| | | assertNull(execute); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count - 1, getDBsCount()); |
| | | } |
| | | |
| | | private int getDBsCount() { |
| | | int count = 0; |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | count = result.length; |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.remote; |
| | | |
| | | import static org.junit.Assert.assertEquals; |
| | | import static org.junit.Assert.assertNull; |
| | | import static org.junit.Assert.assertTrue; |
| | | import static org.junit.Assert.fail; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.xmlrpc.XmlRpcException; |
| | | import org.apache.xmlrpc.client.XmlRpcClient; |
| | | import org.junit.After; |
| | | import org.junit.Before; |
| | | import org.junit.Test; |
| | | |
| | | public class PgsqlUserTest { |
| | | |
| | | private static final String MODULE = "postgresqluser"; |
| | | |
| | | private XmlRpcClient client; |
| | | private RemoteCASHelper cas; |
| | | |
| | | @Before |
| | | public void setUp() throws Exception { |
| | | client = RemoteTestHelper.getClient(); |
| | | cas = new RemoteCASHelper(); |
| | | } |
| | | |
| | | @After |
| | | public void tearDown() throws Exception { |
| | | client = null; |
| | | cas = null; |
| | | } |
| | | |
| | | @Test |
| | | public void testCreate() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> setParams = new HashMap<String, String>(); |
| | | setParams.put("name", "aaa00_dba"); |
| | | setParams.put("password", "geHeimNis"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | setParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".add", params); |
| | | assertTrue(execute instanceof Map<?, ?>); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count + 1, getDBsCount()); |
| | | } |
| | | |
| | | @Test |
| | | public void testSearch() { |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | assertEquals(1, result.length); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void testDelete() { |
| | | int count = getDBsCount(); |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | whereParams.put("name", "aaa00_dba"); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".delete", params); |
| | | assertNull(execute); |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(count - 1, getDBsCount()); |
| | | } |
| | | |
| | | private int getDBsCount() { |
| | | int count = 0; |
| | | String user = "aaa00"; |
| | | String grantingTicketURL = cas.getGrantingTicketURL(user); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | Object[] params = new Object[] { user, |
| | | cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), |
| | | whereParams }; |
| | | try { |
| | | Object execute = client.execute(MODULE + ".search", params); |
| | | Object[] result = (Object[]) execute; |
| | | count = result.length; |
| | | } catch (XmlRpcException e) { |
| | | fail(e.getMessage()); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | } |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.vaadin.terminal.ExternalResource; |
| | | import com.vaadin.terminal.Sizeable; |
| | | import com.vaadin.terminal.ThemeResource; |
| | | import com.vaadin.ui.Button; |
| | | import com.vaadin.ui.Component; |
| | | import com.vaadin.ui.Form; |
| | | import com.vaadin.ui.HorizontalLayout; |
| | | import com.vaadin.ui.Link; |
| | | import com.vaadin.ui.VerticalLayout; |
| | | import com.vaadin.ui.Window; |
| | | import com.vaadin.ui.Button.ClickEvent; |
| | |
| | | import de.hsadmin.web.vaadin.GenericForm; |
| | | import de.hsadmin.web.vaadin.TableComponentFactory; |
| | | |
| | | public abstract class AbstractModule implements Module { |
| | | public abstract class AbstractModule implements Module, Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private MainApplication application; |
| | | private VerticalLayout layout; |
| | | private Component component; |
New file |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | | |
| | | import de.hsadmin.web.config.ModuleConfig; |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyDefaultValue; |
| | | import de.hsadmin.web.config.PropertySelectValues; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; |
| | | |
| | | public abstract class DatabaseModule extends GenericModule { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private ModuleConfig moduleConfig; |
| | | |
| | | public abstract String getModuleIdent(); |
| | | |
| | | public abstract String getUserModuleIdent(); |
| | | |
| | | public abstract String[] getEncodings(); |
| | | |
| | | @Override |
| | | protected void initModule() { |
| | | MainApplication application = getApplication(); |
| | | moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale()); |
| | | String login = application.getLogin(); |
| | | final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; |
| | | PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); |
| | | idProp.setReadOnly(true); |
| | | PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class); |
| | | nameProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | if (pac.length() >= 5) { |
| | | return pac + "_"; |
| | | } |
| | | return ""; |
| | | } |
| | | }); |
| | | nameProp.setWriteOnce(true); |
| | | PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); |
| | | pacProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | return pac; |
| | | } |
| | | }); |
| | | pacProp.setSelectValues(new PropertySelectValues() { |
| | | @Override |
| | | public boolean newItemsAllowed() { |
| | | return false; |
| | | } |
| | | @Override |
| | | public boolean hasSelectList() { |
| | | return true; |
| | | } |
| | | @Override |
| | | public Map<String, String> getSelectValues() { |
| | | List<String> list = getPackets(); |
| | | TreeMap<String,String> map = new TreeMap<String, String>(); |
| | | for (String pac : list) { |
| | | map.put(pac, pac); |
| | | } |
| | | return map; |
| | | } |
| | | }); |
| | | pacProp.setWriteOnce(true); |
| | | PropertyConfig encodingProp = new PropertyConfig(moduleConfig, "encoding", String.class, new SelectPropertyFieldFactory()); |
| | | encodingProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | return "utf8"; |
| | | } |
| | | }); |
| | | encodingProp.setSelectValues(new PropertySelectValues() { |
| | | @Override |
| | | public boolean newItemsAllowed() { |
| | | return false; |
| | | } |
| | | @Override |
| | | public Map<String, String> getSelectValues() { |
| | | String[] encodings = getEncodings(); |
| | | Map<String,String> map = new TreeMap<String, String>(); |
| | | for (String enc : encodings) { |
| | | map.put(enc, enc); |
| | | } |
| | | return map; |
| | | } |
| | | @Override |
| | | public boolean hasSelectList() { |
| | | return true; |
| | | } |
| | | }); |
| | | encodingProp.setWriteOnce(true); |
| | | PropertyConfig ownerProp = new PropertyConfig(moduleConfig, "owner", String.class, new SelectPropertyFieldFactory()); |
| | | ownerProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | return ""; |
| | | } |
| | | }); |
| | | ownerProp.setSelectValues(new PropertySelectValues() { |
| | | @Override |
| | | public boolean newItemsAllowed() { |
| | | return false; |
| | | } |
| | | @Override |
| | | public boolean hasSelectList() { |
| | | return true; |
| | | } |
| | | @Override |
| | | public Map<String, String> getSelectValues() { |
| | | List<String> list = getDatabaseUsers(); |
| | | TreeMap<String,String> map = new TreeMap<String, String>(); |
| | | for (String usr : list) { |
| | | map.put(usr, usr); |
| | | } |
| | | return map; |
| | | } |
| | | }); |
| | | ownerProp.setWriteOnce(true); |
| | | moduleConfig.addProperty(idProp); |
| | | moduleConfig.addProperty(pacProp); |
| | | moduleConfig.addProperty(nameProp); |
| | | moduleConfig.addProperty(encodingProp); |
| | | moduleConfig.addProperty(ownerProp); |
| | | } |
| | | |
| | | @Override |
| | | public ModuleConfig getModuleConfig() { |
| | | return moduleConfig; |
| | | } |
| | | |
| | | public List<String> getDatabaseUsers() { |
| | | ArrayList<String> list = new ArrayList<String>(); |
| | | try { |
| | | Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap<String, String>()); |
| | | if (callSearch instanceof Object[]) { |
| | | for (Object row : ((Object[])callSearch)) { |
| | | if (row instanceof Map<?, ?>) { |
| | | Object object = ((Map<?, ?>) row).get("name"); |
| | | if (object instanceof String) { |
| | | list.add((String) object); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (HsarwebException e) { |
| | | e.printStackTrace(); |
| | | getApplication().showSystemException(e); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | | |
| | | import de.hsadmin.web.config.ModuleConfig; |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyDefaultValue; |
| | | import de.hsadmin.web.config.PropertySelectValues; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.PasswordPropertyFieldFactory; |
| | | import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; |
| | | |
| | | public abstract class DatabaseUserModule extends GenericModule { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private ModuleConfig moduleConfig; |
| | | |
| | | public abstract String getModuleIdent(); |
| | | |
| | | @Override |
| | | protected void initModule() { |
| | | MainApplication application = getApplication(); |
| | | moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale()); |
| | | String login = application.getLogin(); |
| | | final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; |
| | | PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); |
| | | idProp.setReadOnly(true); |
| | | PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class); |
| | | nameProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | if (pac.length() >= 5) { |
| | | return pac + "_"; |
| | | } |
| | | return ""; |
| | | } |
| | | }); |
| | | nameProp.setWriteOnce(true); |
| | | PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); |
| | | pacProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | return pac; |
| | | } |
| | | }); |
| | | pacProp.setSelectValues(new PropertySelectValues() { |
| | | @Override |
| | | public boolean newItemsAllowed() { |
| | | return false; |
| | | } |
| | | @Override |
| | | public boolean hasSelectList() { |
| | | return true; |
| | | } |
| | | @Override |
| | | public Map<String, String> getSelectValues() { |
| | | List<String> list = getPackets(); |
| | | TreeMap<String,String> map = new TreeMap<String, String>(); |
| | | for (String pac : list) { |
| | | map.put(pac, pac); |
| | | } |
| | | return map; |
| | | } |
| | | }); |
| | | pacProp.setWriteOnce(true); |
| | | PropertyConfig passwordProp = new PropertyConfig(moduleConfig, "password", String.class, PropertyTableColumn.NONE, new PasswordPropertyFieldFactory(this)); |
| | | moduleConfig.addProperty(idProp); |
| | | moduleConfig.addProperty(pacProp); |
| | | moduleConfig.addProperty(nameProp); |
| | | moduleConfig.addProperty(passwordProp); |
| | | } |
| | | |
| | | @Override |
| | | public ModuleConfig getModuleConfig() { |
| | | return moduleConfig; |
| | | } |
| | | |
| | | } |
| | |
| | | import de.hsadmin.web.config.PropertyDefaultValue; |
| | | import de.hsadmin.web.config.PropertySelectValues; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.DatePropertyFieldFactory; |
| | | import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; |
| | | |
| | | public class DomainModule extends GenericModule { |
| | |
| | | pacProp.setReadOnly(true); |
| | | PropertyConfig hiveProp = new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN); |
| | | hiveProp.setReadOnly(true); |
| | | PropertyConfig sinceProp = new PropertyConfig(moduleConfig, "since", Date.class); |
| | | PropertyConfig sinceProp = new PropertyConfig(moduleConfig, "since", Date.class, new DatePropertyFieldFactory()); |
| | | sinceProp.setReadOnly(true); |
| | | moduleConfig.addProperty(idProp); |
| | | moduleConfig.addProperty(nameProp); |
| | |
| | | import de.hsadmin.web.config.ModuleConfig; |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.DatePropertyFieldFactory; |
| | | |
| | | public class DomainReadonlyModule extends AbstractModule { |
| | | |
| | |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class, new DatePropertyFieldFactory())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.vaadin.ui.Embedded; |
| | | import com.vaadin.ui.HorizontalLayout; |
| | | import com.vaadin.ui.Link; |
| | | import com.vaadin.ui.Panel; |
| | | import com.vaadin.ui.TabSheet; |
| | | import com.vaadin.ui.VerticalLayout; |
| | | import com.vaadin.ui.Window; |
| | |
| | | try { |
| | | module.reload(); |
| | | } catch (HsarwebException e) { |
| | | e.printStackTrace(); |
| | | showSystemException(e); |
| | | } |
| | | } |
New file |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | public class MysqlDatabaseModule extends DatabaseModule { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Override |
| | | public String[] getEncodings() { |
| | | return new String[] { "utf8", "latin1" }; |
| | | } |
| | | |
| | | @Override |
| | | public String getModuleIdent() { |
| | | return "mysqldb"; |
| | | } |
| | | |
| | | @Override |
| | | public String getUserModuleIdent() { |
| | | return "mysqluser"; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | public class MysqlUserModule extends DatabaseUserModule { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Override |
| | | public String getModuleIdent() { |
| | | return "mysqluser"; |
| | | } |
| | | |
| | | } |
| | |
| | | import de.hsadmin.web.config.ModuleConfig; |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.DatePropertyFieldFactory; |
| | | |
| | | public class PacketReadonlyModule extends AbstractModule { |
| | | |
| | |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "components", String.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "curinetaddr", String.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "created", Date.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "created", Date.class, new DatePropertyFieldFactory())); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "customer", String.class, PropertyTableColumn.HIDDEN)); |
| | | } |
| | | |
New file |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | public class PgsqlDatabaseModule extends DatabaseModule { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Override |
| | | public String[] getEncodings() { |
| | | return new String[] { "UTF-8", "LATIN1" }; |
| | | } |
| | | |
| | | @Override |
| | | public String getModuleIdent() { |
| | | return "postgresqldb"; |
| | | } |
| | | |
| | | @Override |
| | | public String getUserModuleIdent() { |
| | | return "postgresqluser"; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | public class PgsqlUserModule extends DatabaseUserModule { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Override |
| | | public String getModuleIdent() { |
| | | return "postgresqluser"; |
| | | } |
| | | |
| | | } |
| | |
| | | import de.hsadmin.web.config.ModuleConfig; |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.DatePropertyFieldFactory; |
| | | |
| | | public class QueueTaskModule extends AbstractModule { |
| | | |
| | |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "started", Date.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "finished", Date.class)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "started", Date.class, new DatePropertyFieldFactory())); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "finished", Date.class, new DatePropertyFieldFactory())); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, PropertyTableColumn.HIDDEN)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "details", String.class, PropertyTableColumn.HIDDEN)); |
| | | moduleConfig.addProperty(new PropertyConfig(moduleConfig, "exception", String.class, PropertyTableColumn.HIDDEN)); |
New file |
| | |
| | | package de.hsadmin.web.vaadin; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.util.Date; |
| | | |
| | | import com.vaadin.data.Property.ConversionException; |
| | | import com.vaadin.data.Property.ReadOnlyException; |
| | | import com.vaadin.terminal.Sizeable; |
| | | import com.vaadin.ui.DateField; |
| | | import com.vaadin.ui.PopupDateField; |
| | | |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyFieldFactory; |
| | | |
| | | public class DatePropertyFieldFactory implements PropertyFieldFactory { |
| | | |
| | | public static final DateFormat serverDf = DateFormat.getDateInstance(DateFormat.SHORT); |
| | | |
| | | private boolean readOnly = false; |
| | | private boolean writeOnce; |
| | | |
| | | @Override |
| | | public Object createFieldComponent(PropertyConfig prop, Object value) { |
| | | DateField dateField = new PopupDateField(prop.getLabel()); |
| | | dateField.setDateFormat("dd.MM.yyyy"); |
| | | dateField.setData(prop.getId()); |
| | | dateField.setWidth(480.0f, Sizeable.UNITS_PIXELS); |
| | | try { |
| | | if (value != null) { |
| | | dateField.setValue(serverDf.parse((String) value)); |
| | | dateField.setReadOnly(isReadOnly()); |
| | | return dateField; |
| | | } |
| | | } catch (ReadOnlyException e) { |
| | | } catch (ConversionException e) { |
| | | } catch (ParseException e) { |
| | | } |
| | | dateField.setReadOnly(isReadOnly()); |
| | | return dateField; |
| | | } |
| | | |
| | | @Override |
| | | public String getValue(PropertyConfig prop, Object component) { |
| | | if (component instanceof DateField) { |
| | | return serverDf.format((Date) ((DateField) component).getValue()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadOnly(boolean readOnly) { |
| | | this.readOnly = readOnly; |
| | | } |
| | | |
| | | public boolean isReadOnly() { |
| | | return readOnly; |
| | | } |
| | | |
| | | @Override |
| | | public void setWriteOnce(boolean writeOnce) { |
| | | this.writeOnce = writeOnce; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isWriteOnce() { |
| | | return writeOnce; |
| | | } |
| | | |
| | | } |
| | |
| | | modules.NONE=de.hsadmin.web.HomeModule |
| | | modules.USER=de.hsadmin.web.HomeModule |
| | | modules.DOM_ADMIN=de.hsadmin.web.DomainReadonlyModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.HomeModule |
| | | modules.PAC_ADMIN=de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule |
| | | modules.CUSTOMER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule |
| | | modules.HOSTMASTER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule |
| | | modules.PAC_ADMIN=de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.MysqlDatabaseModule,de.hsadmin.web.MysqlUserModule,de.hsadmin.web.PgsqlDatabaseModule,de.hsadmin.web.PgsqlUserModule,de.hsadmin.web.QueueTaskModule |
| | | modules.CUSTOMER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.MysqlDatabaseModule,de.hsadmin.web.MysqlUserModule,de.hsadmin.web.PgsqlDatabaseModule,de.hsadmin.web.PgsqlUserModule,de.hsadmin.web.QueueTaskModule |
| | | modules.HOSTMASTER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.MysqlDatabaseModule,de.hsadmin.web.MysqlUserModule,de.hsadmin.web.PgsqlDatabaseModule,de.hsadmin.web.PgsqlUserModule,de.hsadmin.web.QueueTaskModule |
New file |
| | |
| | | id=identifier |
| | | name=database |
| | | pac=packet |
| | | encoding=encoding |
| | | owner=owner |
| | | moduletitle=mysql db |
| | | new=create db |
| | | update=update db |
| | | moduleicon=../hs/icons/table.png |
New file |
| | |
| | | id=Schlüssel |
| | | name=MySQL Datenbank |
| | | pac=Paket |
| | | encoding=Zeichensatz |
| | | owner=Verwalter |
| | | moduletitle=MySQL DB |
| | | new=Datenbank anlegen |
| | | update=Datenbank ändern |
| | | moduleicon=../hs/icons/table.png |
New file |
| | |
| | | id=identifier |
| | | name=database username |
| | | password=password |
| | | password1=new password |
| | | password2=repeat password |
| | | pac=packet |
| | | moduletitle=mysql user |
| | | new=create user |
| | | update=change password |
| | | moduleicon=../hs/icons/table_key.png |
New file |
| | |
| | | id=Schlüssel |
| | | name=MySQL User |
| | | password=Passwort |
| | | password1=neues Passwort |
| | | password2=Passwort-Wiederholung |
| | | pac=Paket |
| | | moduletitle=MySQL User |
| | | new=User anlegen |
| | | update=Passwort ändern |
| | | moduleicon=../hs/icons/table_key.png |
| | |
| | | id=identifier |
| | | name=packet |
| | | curinetaddr=inet address |
| | | created=created |
| | | created=created on |
| | | basepac=packet type |
| | | components=packet options |
| | | hive=host |
| | |
| | | id=Schlüssel |
| | | name=Paket |
| | | curinetaddr=IP Adresse |
| | | created=angelegt |
| | | created=angelegt am |
| | | basepac=Pakettyp |
| | | components=Paket-Optionen |
| | | hive=Server |
New file |
| | |
| | | id=identifier |
| | | name=database |
| | | pac=packet |
| | | encoding=encoding |
| | | owner=owner |
| | | moduletitle=postgresql db |
| | | new=create db |
| | | update=database |
| | | moduleicon=../hs/icons/database.png |
New file |
| | |
| | | id=Schlüssel |
| | | name=Datenbank |
| | | pac=Paket |
| | | encoding=Zeichensatz |
| | | owner=Verwalter |
| | | moduletitle=PostgreSQL DB |
| | | new=Datenbank anlegen |
| | | update=Datenbank |
| | | moduleicon=../hs/icons/database.png |
New file |
| | |
| | | id=identifier |
| | | name=postgres username |
| | | password=password |
| | | password1=new password |
| | | password2=repeat password |
| | | pac=packet |
| | | moduletitle=postgres user |
| | | new=create user |
| | | update=change password |
| | | moduleicon=../hs/icons/database_key.png |
New file |
| | |
| | | id=Schlüssel |
| | | name=PostgreSQL User |
| | | password=Passwort |
| | | password1=neues Passwort |
| | | password2=Passwort-Wiederholung |
| | | pac=Paket |
| | | moduletitle=PostgreSQL User |
| | | new=User anlegen |
| | | update=Passwort ändern |
| | | moduleicon=../hs/icons/database_key.png |