Compare commits

...

14 Commits

Author SHA1 Message Date
Peter Hormanns
2f5794350b error handling 2013-11-27 13:43:28 +01:00
Peter Hormanns
4d1b69d682 Benutzer statt Unix User 2013-11-12 12:20:50 +01:00
Peter Hormanns
8123764154 support numbers 2013-11-08 16:49:17 +01:00
Peter Hormanns
e4157cbfb8 find root exception 2013-11-04 17:28:41 +01:00
Peter Hormanns
2d4bb80ac6 EMailAddressModule working 2013-07-01 19:15:50 +02:00
Peter Hormanns
7c7404e380 clean 2013-07-01 13:35:44 +02:00
Peter Hormanns
b41827e66a local test are running 2013-06-28 18:55:15 +02:00
Peter Hormanns
1988b1a30c merged 2013-06-28 16:05:00 +02:00
Peter Hormanns
46bde679fe use stateful bean 2013-06-28 15:56:53 +02:00
Peter Hormanns
77d85ba91e neue Hives h67/h68 2013-06-26 15:02:05 +02:00
Peter Hormanns
2cf0d6c4b8 transform EMailAliasModul zu SessionBean 2013-06-21 17:32:38 +02:00
Peter Hormanns
3a1aefc396 add dependencies for openjap enhancement 2013-06-20 15:09:42 +02:00
Peter Hormanns
8fd0e6e500 jars from tomee 2013-06-20 13:35:11 +02:00
Peter Hormanns
3148273f2d README for new branch 2013-06-20 12:45:05 +02:00
67 changed files with 937 additions and 1387 deletions

View File

@ -3,33 +3,17 @@
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/> <classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/activemq-core-5.4.2.jar"/>
<classpathentry kind="lib" path="lib/commons-beanutils-1.8.3.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="lib/commons-dbcp-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="lib/commons-net2-2.0.jar"/>
<classpathentry kind="lib" path="lib/commons-pool-1.5.4.jar"/>
<classpathentry kind="lib" path="lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-jms_1.1_spec-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-jpa_2.0_spec-1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-jta_1.1_spec-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-validation_1.0_spec-1.1.jar"/>
<classpathentry kind="lib" path="lib/jpwgen-1.2.0.jar"/> <classpathentry kind="lib" path="lib/jpwgen-1.2.0.jar"/>
<classpathentry kind="lib" path="lib/mail.jar"/>
<classpathentry kind="lib" path="lib/openjpa-2.1.1.jar"/>
<classpathentry kind="lib" path="lib/org.apache.bval.bundle-0.2-incubating.jar"/>
<classpathentry kind="lib" path="lib/serp-1.13.1.jar"/>
<classpathentry kind="lib" path="lib/servlet-api-2.4.jar"/>
<classpathentry kind="lib" path="lib/ws-commons-util-1.0.2.jar"/> <classpathentry kind="lib" path="lib/ws-commons-util-1.0.2.jar"/>
<classpathentry kind="lib" path="lib/xmlrpc-client-3.1.3.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-client-3.1.3.jar"/>
<classpathentry kind="lib" path="lib/xmlrpc-common-3.1.3.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-common-3.1.3.jar"/>
<classpathentry kind="lib" path="lib/xmlrpc-server-3.1.3.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-server-3.1.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/velocity-1.7.jar"/> <classpathentry kind="lib" path="lib/velocity-1.7.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/> <classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-api-1.1.1.jar"/> <classpathentry kind="lib" path="lib/javaee-api-6.0-5-tomcat.jar"/>
<classpathentry kind="lib" path="lib/commons-net-3.2.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -25,6 +25,9 @@
<fileset dir="lib"> <fileset dir="lib">
<include name="*.jar" /> <include name="*.jar" />
</fileset> </fileset>
<fileset dir="lib/enhance">
<include name="*.jar" />
</fileset>
<dirset dir="conf"/> <dirset dir="conf"/>
<dirset dir="${build.home}"/> <dirset dir="${build.home}"/>
</path> </path>
@ -68,11 +71,9 @@
</copy> </copy>
<war destfile="build/hsar.war" basedir="webapp" needxmlfile="false"> <war destfile="build/hsar.war" basedir="webapp" needxmlfile="false">
<lib dir="lib"> <lib dir="lib">
<include name="**/*.jar"/> <include name="*.jar"/>
<exclude name="**/servlet*.jar"/> <exclude name="servlet*.jar"/>
<exclude name="**/geronimo-jms*.jar"/> <exclude name="javaee*.jar"/>
<exclude name="**/geronimo-j2ee-management*.jar"/>
<exclude name="**/activemq*.jar"/>
</lib> </lib>
<classes dir="build/cls" /> <classes dir="build/cls" />
<classes dir="src"> <classes dir="src">

View File

@ -1,8 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="hsadmin" transaction-type="RESOURCE_LOCAL"> <persistence-unit name="hsadmin">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <jta-data-source>java:/comp/env/jdbc/HSAdminDB</jta-data-source>
<non-jta-data-source>java:/comp/env/jdbc/HSAdminDB</non-jta-data-source> <class>de.hsadmin.core.qserv.QueueTask</class>
<class>de.hsadmin.mods.cust.Customer</class>
<class>de.hsadmin.mods.cust.Contact</class>
<class>de.hsadmin.mods.cust.BankAccount</class>
<class>de.hsadmin.mods.pac.Pac</class>
<class>de.hsadmin.mods.pac.BasePac</class>
<class>de.hsadmin.mods.pac.BaseComponent</class>
<class>de.hsadmin.mods.pac.Component</class>
<class>de.hsadmin.mods.pac.PacComponent</class>
<class>de.hsadmin.mods.pac.Hive</class>
<class>de.hsadmin.mods.pac.INetAddress</class>
<class>de.hsadmin.mods.user.UnixUser</class>
<class>de.hsadmin.mods.dom.Domain</class>
<class>de.hsadmin.mods.dom.DomainOption</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.PgSqlUser</class>
<class>de.hsadmin.mods.db.Database</class>
<class>de.hsadmin.mods.db.MySqlDatabase</class>
<class>de.hsadmin.mods.db.PgSqlDatabase</class>
</persistence-unit>
<persistence-unit name="hsar">
<jta-data-source>HsarDataSource</jta-data-source>
<class>de.hsadmin.core.qserv.QueueTask</class> <class>de.hsadmin.core.qserv.QueueTask</class>
<class>de.hsadmin.mods.cust.Customer</class> <class>de.hsadmin.mods.cust.Customer</class>
<class>de.hsadmin.mods.cust.Contact</class> <class>de.hsadmin.mods.cust.Contact</class>
@ -25,9 +49,5 @@
<class>de.hsadmin.mods.db.Database</class> <class>de.hsadmin.mods.db.Database</class>
<class>de.hsadmin.mods.db.MySqlDatabase</class> <class>de.hsadmin.mods.db.MySqlDatabase</class>
<class>de.hsadmin.mods.db.PgSqlDatabase</class> <class>de.hsadmin.mods.db.PgSqlDatabase</class>
<properties>
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/>
<property name="openjpa.Compatibility" value="QuotedNumbersInQueries=true"/>
</properties>
</persistence-unit> </persistence-unit>
</persistence> </persistence>

View File

@ -135,6 +135,16 @@
global="jms/hsadminSystem-h66" global="jms/hsadminSystem-h66"
type="javax.jms.Queue"/> type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h67"
global="jms/hsadminSystem-h67"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h68"
global="jms/hsadminSystem-h68"
type="javax.jms.Queue"/>
<ResourceLink <ResourceLink
name="jms/hsadminSystem-mail1" name="jms/hsadminSystem-mail1"
global="jms/hsadminSystem-mail1" global="jms/hsadminSystem-mail1"

View File

@ -14,112 +14,6 @@
<load-on-startup>1</load-on-startup> <load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet>
<servlet-name>CLI Client Connector</servlet-name>
<servlet-class>de.hsadmin.cliClientConnector.CLIClientConnectorServlet</servlet-class>
<init-param>
<param-name>proxyValidateUrl</param-name>
<param-value>TestUmgebung</param-value>
</init-param>
<init-param>
<param-name>proxyServiceUrl</param-name>
<param-value>TestUmgebung</param-value>
</init-param>
<init-param>
<param-name>Components</param-name>
<param-value>member,pac,user,domain,emailaddress,emailalias,mysqluser,mysqldb,postgresqluser,postgresqldb,q</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_member</param-name>
<param-value>de.hsadmin.mods.cust.Customer</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_member</param-name>
<param-value>Mitglieder</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_pac</param-name>
<param-value>de.hsadmin.mods.pac.Pac</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_pac</param-name>
<param-value>Pakete</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_user</param-name>
<param-value>de.hsadmin.mods.user.UnixUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_user</param-name>
<param-value>Benutzer und Postfaecher anlegen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_domain</param-name>
<param-value>de.hsadmin.mods.dom.Domain</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_domain</param-name>
<param-value>Domains aufschalten</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailaddress</param-name>
<param-value>de.hsadmin.mods.email.EMailAddress</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailaddress</param-name>
<param-value>E-Mail Adressen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailalias</param-name>
<param-value>de.hsadmin.mods.email.EMailAlias</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailalias</param-name>
<param-value>E-Mail Aliases</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqluser</param-name>
<param-value>de.hsadmin.mods.db.PgSqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqluser</param-name>
<param-value>PostgreSQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqldb</param-name>
<param-value>de.hsadmin.mods.db.PgSqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqldb</param-name>
<param-value>PostgreSQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqluser</param-name>
<param-value>de.hsadmin.mods.db.MySqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqluser</param-name>
<param-value>MySQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqldb</param-name>
<param-value>de.hsadmin.mods.db.MySqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqldb</param-name>
<param-value>MySQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_q</param-name>
<param-value>de.hsadmin.core.qserv.QueueTask</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_q</param-name>
<param-value>Offene Aktionen</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet> <servlet>
<servlet-name>XmlRpcServlet</servlet-name> <servlet-name>XmlRpcServlet</servlet-name>
<servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class> <servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class>
@ -134,11 +28,6 @@
<url-pattern>/queueStatus</url-pattern> <url-pattern>/queueStatus</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>CLI Client Connector</servlet-name>
<url-pattern>/hsadmin/cli-interface/</url-pattern>
</servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name> <servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc/*</url-pattern> <url-pattern>/xmlrpc/*</url-pattern>

View File

@ -14,112 +14,6 @@
<load-on-startup>1</load-on-startup> <load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet>
<servlet-name>CLI Client Connector</servlet-name>
<servlet-class>de.hsadmin.cliClientConnector.CLIClientConnectorServlet</servlet-class>
<init-param>
<param-name>proxyValidateUrl</param-name>
<param-value>https://@LOGIN_HOST@:@LOGIN_PORT@/cas/proxyValidate</param-value>
</init-param>
<init-param>
<param-name>proxyServiceUrl</param-name>
<param-value>https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend</param-value>
</init-param>
<init-param>
<param-name>Components</param-name>
<param-value>member,pac,user,domain,emailaddress,emailalias,mysqluser,mysqldb,postgresqluser,postgresqldb,q</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_member</param-name>
<param-value>de.hsadmin.mods.cust.Customer</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_member</param-name>
<param-value>Mitglieder</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_pac</param-name>
<param-value>de.hsadmin.mods.pac.Pac</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_pac</param-name>
<param-value>Pakete</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_user</param-name>
<param-value>de.hsadmin.mods.user.UnixUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_user</param-name>
<param-value>Benutzer und Postfaecher anlegen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_domain</param-name>
<param-value>de.hsadmin.mods.dom.Domain</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_domain</param-name>
<param-value>Domains aufschalten</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailaddress</param-name>
<param-value>de.hsadmin.mods.email.EMailAddress</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailaddress</param-name>
<param-value>E-Mail Adressen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailalias</param-name>
<param-value>de.hsadmin.mods.email.EMailAlias</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailalias</param-name>
<param-value>E-Mail Aliases</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqluser</param-name>
<param-value>de.hsadmin.mods.db.PgSqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqluser</param-name>
<param-value>PostgreSQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqldb</param-name>
<param-value>de.hsadmin.mods.db.PgSqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqldb</param-name>
<param-value>PostgreSQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqluser</param-name>
<param-value>de.hsadmin.mods.db.MySqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqluser</param-name>
<param-value>MySQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqldb</param-name>
<param-value>de.hsadmin.mods.db.MySqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqldb</param-name>
<param-value>MySQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_q</param-name>
<param-value>de.hsadmin.core.qserv.QueueTask</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_q</param-name>
<param-value>Offene Aktionen</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet> <servlet>
<servlet-name>XmlRpcServlet</servlet-name> <servlet-name>XmlRpcServlet</servlet-name>
<servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class> <servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class>
@ -134,11 +28,6 @@
<url-pattern>/queueStatus</url-pattern> <url-pattern>/queueStatus</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>CLI Client Connector</servlet-name>
<url-pattern>/hsadmin/cli-interface/</url-pattern>
</servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name> <servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc/*</url-pattern> <url-pattern>/xmlrpc/*</url-pattern>
@ -313,6 +202,18 @@
<res-auth>Container</res-auth> <res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope> <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref> </resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h67</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h68</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref> <resource-ref>
<res-ref-name>jms/hsadminSystem-dns1</res-ref-name> <res-ref-name>jms/hsadminSystem-dns1</res-ref-name>
<res-type>javax.jms.Queue</res-type> <res-type>javax.jms.Queue</res-type>

View File

@ -14,112 +14,6 @@
<load-on-startup>1</load-on-startup> <load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet>
<servlet-name>CLI Client Connector</servlet-name>
<servlet-class>de.hsadmin.cliClientConnector.CLIClientConnectorServlet</servlet-class>
<init-param>
<param-name>proxyValidateUrl</param-name>
<param-value>https://@LOGIN_HOST@:@LOGIN_PORT@/cas/proxyValidate</param-value>
</init-param>
<init-param>
<param-name>proxyServiceUrl</param-name>
<param-value>https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend</param-value>
</init-param>
<init-param>
<param-name>Components</param-name>
<param-value>member,pac,user,domain,emailaddress,emailalias,mysqluser,mysqldb,postgresqluser,postgresqldb,q</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_member</param-name>
<param-value>de.hsadmin.mods.cust.Customer</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_member</param-name>
<param-value>Mitglieder</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_pac</param-name>
<param-value>de.hsadmin.mods.pac.Pac</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_pac</param-name>
<param-value>Pakete</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_user</param-name>
<param-value>de.hsadmin.mods.user.UnixUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_user</param-name>
<param-value>Benutzer und Postfaecher anlegen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_domain</param-name>
<param-value>de.hsadmin.mods.dom.Domain</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_domain</param-name>
<param-value>Domains aufschalten</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailaddress</param-name>
<param-value>de.hsadmin.mods.email.EMailAddress</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailaddress</param-name>
<param-value>E-Mail Adressen</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_emailalias</param-name>
<param-value>de.hsadmin.mods.email.EMailAlias</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_emailalias</param-name>
<param-value>E-Mail Aliases</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqluser</param-name>
<param-value>de.hsadmin.mods.db.PgSqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqluser</param-name>
<param-value>PostgreSQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_postgresqldb</param-name>
<param-value>de.hsadmin.mods.db.PgSqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_postgresqldb</param-name>
<param-value>PostgreSQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqluser</param-name>
<param-value>de.hsadmin.mods.db.MySqlUser</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqluser</param-name>
<param-value>MySQL DB-Administrator</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_mysqldb</param-name>
<param-value>de.hsadmin.mods.db.MySqlDatabase</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_mysqldb</param-name>
<param-value>MySQL Datenbank</param-value>
</init-param>
<init-param>
<param-name>ComponentClass_q</param-name>
<param-value>de.hsadmin.core.qserv.QueueTask</param-value>
</init-param>
<init-param>
<param-name>ComponentDescription_q</param-name>
<param-value>Offene Aktionen</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet> <servlet>
<servlet-name>XmlRpcServlet</servlet-name> <servlet-name>XmlRpcServlet</servlet-name>
<servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class> <servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class>
@ -134,11 +28,6 @@
<url-pattern>/queueStatus</url-pattern> <url-pattern>/queueStatus</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>CLI Client Connector</servlet-name>
<url-pattern>/hsadmin/cli-interface/</url-pattern>
</servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name> <servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc/*</url-pattern> <url-pattern>/xmlrpc/*</url-pattern>

View File

@ -0,0 +1,3 @@
TODO
transform module implementaions to session beans
create glue from module to xmlrpc from annotations

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,357 +0,0 @@
package de.hsadmin.cliClientConnector;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import de.hsadmin.cliClientConnector.CLIClientConnectorServlet.FunctionNotKnownException;
import de.hsadmin.cliClientConnector.CLIClientConnectorServlet.UnknownModuleException;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.ModuleInterface;
/**
* Parses Arguments for the CLI Client Connector Servlet
*
* @author Christof Donat
*
*/
public class ArgumentParser {
/// I am working for this Servlet instance
private CLIClientConnectorServlet master;
private DateFormat df = new SimpleDateFormat( "yyyy-MM-dd");
public ArgumentParser(CLIClientConnectorServlet master) {
this.master = master;
}
private String getUsageString() {
return " [ (-W name=value|--globalWhere:name=value) ...]\n"+
" [ (-S name=value|--globalSet:name=value) ...]\n"+
" [ (-D displayspec|--globalDisplay=displayspec) ...]\n"+
" [ (-c module.function|--call=module.function)\n" +
" [ (-w name=value|--where:name=value) ...]\n"+
" [ (-s name=value|--set:name=value) ...]\n"+
" [ (-d displayspec|--display:displayspec) ...]\n"+
" [ oids ...] ] ]\n"+
"\n"+
"(" + CLIClientConnectorServlet.version + ")\n";
}
private ArrayList<Method> getMethodList(Object o) {
Method[] meths = o.getClass().getMethods();
ArrayList<Method> methodlist = new ArrayList<Method>();
for( int i = 0; i < meths.length; i++ ) {
Method m = meths[i];
String n = m.getName();
if( n.startsWith("get") && !n.equals("getNew") ) {
String fn = m.getName().substring(3).toLowerCase();
if( fn.equals("class") ) continue;
if (m.getParameterTypes().length == 0) {
methodlist.add(m);
}
}
}
return methodlist;
}
private Hashtable<String,String> getValues(Object o, ArrayList<Method> methodlist, ArrayList<String>fieldNames, boolean deep, ArrayList<Object> foundObjects) {
Hashtable<String,String> row = new Hashtable<String,String>();
int i, j;
if( foundObjects == null ) foundObjects = new ArrayList<Object>();
for( i = 0; i < methodlist.size(); i++ ) {
Method m = methodlist.get(i);
try {
String name = fieldNames.get(i);
String type = m.getReturnType().getCanonicalName();
String val = "";
Object value = null;
try {
value = m.invoke(o);
} catch( Exception e ) {
e.printStackTrace();
}
if( value == null )
val = "";
else if( type.equals("java.lang.String") )
val = (String)value;
else if( type.equals("java.lang.Integer") )
val = String.valueOf((Integer)value);
else if( type.equals("java.lang.Long") )
val = String.valueOf((Long)value);
else if( type.equals("java.lang.Boolean") )
val = String.valueOf((Boolean)value);
else if( type.equals("java.util.Date") ) {
val = df.format((Date)value);
} else if( type.equals("java.util.Set") ) {
val = "<Set>";
} else try {
AbstractEntity v = (AbstractEntity)value;
val = v.createStringKey();
if( deep && !foundObjects.contains(v) ) {
foundObjects.add(v);
ArrayList<String> fieldNamesDeep = new ArrayList<String>();
ArrayList<Method> methodlistDeep = getMethodList(v);
for( j = 0; j < methodlistDeep.size(); j++ ) {
fieldNamesDeep.add(methodlistDeep.get(j).getName().substring(3).toLowerCase());
}
Hashtable<String,String> tmp = getValues(v,methodlistDeep,fieldNamesDeep,deep,foundObjects);
Enumeration<String> keys = tmp.keys();
while(keys.hasMoreElements()) {
try {
String k = (String)keys.nextElement();
row.put(name+"."+k, tmp.get(k));
} catch( Exception e ) {
e.printStackTrace();
}
}
}
} catch(ClassCastException e) {
val = value.toString();
}
if (val != null) row.put(name, val);
} catch (Exception e) {
e.printStackTrace();
}
}
return row;
}
private String formatObjectsWithoutDisplay(int j, ArrayList<String> fieldNames, ArrayList<Integer>columnWidths, ArrayList<Hashtable<String,String> > rows) {
int i;
StringBuffer rval = new StringBuffer();
for( i = 0; i < fieldNames.size(); i++ ) {
StringBuffer name = new StringBuffer(fieldNames.get(i));
int fieldwidth = columnWidths.get(i);
while( name.length() < fieldwidth )
name.append(" ");
rval.append(name.toString()+((i < fieldNames.size()-1)?" | ":""));
}
rval.append("\n");
for( i = 0; i < j; i++ )
rval.append("-");
rval.append("\n");
for( j = 0; j < rows.size(); j++ ) {
for( i = 0; i < fieldNames.size(); i++ ) {
StringBuffer value = new StringBuffer(rows.get(j).get(fieldNames.get(i)));
int fieldwidth = columnWidths.get(i);
while( value.length() < fieldwidth )
value.append(" ");
rval.append(value.toString()+((i < fieldNames.size()-1)?" | ":""));
}
rval.append("\n");
}
return rval.toString();
}
private String formatObjectsWithDisplay(ArrayList<Hashtable<String,String> > rows, String displayDef) {
StringBuffer rval = new StringBuffer();
for( int j = 0; j < rows.size(); j++) {
String rv = displayDef;
Enumeration<String> fNames = rows.get(j).keys();
while( fNames.hasMoreElements() ) {
String f = (String)fNames.nextElement();
rv = rv.replaceAll("\\$\\{"+f+"\\}", rows.get(j).get(f));
}
rv = rv.replaceAll("\\\\n", "\n");
rv = rv.replaceAll("\\\\t", "\t");
rv = rv.replaceAll("\\\\(.)?", "$1");
rval.append(rv);
}
return rval.toString();
}
/**
* format Objects for the output as a Human readable table
*
* @param objects
* format these objects
*
* @return humanReadableString
* a string with the human readable representation of the objects
*/
public String formatObjects(List<?> objects, String displayDef) {
if( objects.size() == 0 ) return "";
if( objects.get(0) == null ) return "";
ArrayList<Method> methodlist = getMethodList(objects.get(0));
ArrayList<Integer>columnWidths = new ArrayList<Integer>();
ArrayList<String>fieldNames = new ArrayList<String>();
ArrayList<Hashtable<String,String> > rows =
new ArrayList<Hashtable<String,String> >();
int i, j;
for( i = 0; i < methodlist.size(); i++ ) {
Method m = methodlist.get(i);
String n = m.getName();
String fn = n.substring(3).toLowerCase();
fieldNames.add(fn);
columnWidths.add(n.length()+3);
}
for( j = 0; j < objects.size(); j++ ) {
Object o = objects.get(j);
Hashtable<String,String> row = getValues(o,methodlist,fieldNames,(displayDef != null), null);
for( i = 0; i < fieldNames.size(); i++ ) {
String val = row.get(fieldNames.get(i));
if( val != null && i < columnWidths.size() && val.length()+3 > columnWidths.get(i) )
columnWidths.set(i, val.length()+3);
}
rows.add(row);
}
if( displayDef == null ) {
j = 0;
for( i = 0; i < columnWidths.size(); i++ ) {
j += columnWidths.get(i)+2;
}
j -= 2;
return formatObjectsWithoutDisplay(j, fieldNames, columnWidths, rows);
} else
return formatObjectsWithDisplay(rows, displayDef);
}
/**
* The main parser function. Parses the Parameters, uses the master to call
* the functions and returns a formatet output.
*
* @param arguments
* @return humanReadableObjectsString
*/
public String parse(List<String> arguments, ModuleInterface module) {
String rval = "";
String currentModule = null;
String currentFunction = null;
Map<String,String> currentWhere = new Hashtable<String,String>();
Map<String,String> currentSet = new Hashtable<String,String>();
ArrayList<String> currentOIDs = new ArrayList<String>();
Map<String,String> globalWhere = new Hashtable<String,String>();
Map<String,String> globalSet = new Hashtable<String,String>();
String display = null;
String globalDisplay = null;
for( int i = 0; i < arguments.size(); i++ ) {
String arg = arguments.get(i);
if( arg.equals("-c") || arg.startsWith("--call:") ) {
// call
if( currentModule != null ) {
try {
// execute the last call now
rval += formatObjects(master.callModule(
currentModule,
currentFunction,
currentWhere,
currentSet,
currentOIDs,
module),(display==null)?globalDisplay:display);
} catch (FunctionNotKnownException e) {
rval += "Function unknown: "+currentModule+'.'+currentFunction+"\n";
} catch (UnknownModuleException e) {
rval += "Module unknown: "+currentModule+"\n";
}
}
// reset parameters for next call
currentWhere = new HashMap<String, String>();
currentWhere.putAll(globalWhere);
currentSet = new HashMap<String, String>();
currentSet.putAll(globalSet);
currentOIDs = new ArrayList<String>();
display = null;
// set the new call
boolean isShortParam = arg.equals("-c");
String calldef = isShortParam?arguments.get(i+1):arg.substring(7);
if( calldef != null ) {
String[] split = calldef.split("[.]", 2);
currentModule = split[0];
currentFunction = split[1];
}
if( isShortParam ) i++;
} else if( arg.equals("-w") || arg.startsWith("--where:") ) {
// where
boolean isShortParam = arg.equals("-w");
String wheredef = isShortParam?arguments.get(i+1):arg.substring(8);
if( wheredef != null ) {
String[] split = wheredef.split("[=]", 2);
currentWhere.put(split[0],split[1]);
}
if( isShortParam ) i++;
} else if( arg.equals("-W") || arg.startsWith("--globalWhere:") ) {
// global where
boolean isShortParam = arg.equals("-W");
String gwheredef = isShortParam?arguments.get(i+1):arg.substring(14);
if( gwheredef != null ) {
String[] split = gwheredef.split("[=]", 2);
globalWhere.put(split[0],split[1]);
}
if( isShortParam ) i++;
} else if( arg.equals("-s") || arg.startsWith("--set:") ) {
// set
boolean isShortParam = arg.equals("-s");
String setdef = isShortParam?arguments.get(i+1):arg.substring(6);
if( setdef != null ) {
String[] split = setdef.split("[=]", 2);
currentSet.put(split[0],split[1]);
}
if( isShortParam ) i++;
} else if( arg.equals("-S") || arg.startsWith("--globalSet:") ) {
// global set
boolean isShortParam = arg.equals("-S");
String gsetdef = isShortParam?arguments.get(i+1):arg.substring(12);
if( gsetdef != null ) {
String[] split = gsetdef.split("[=]", 2);
globalSet.put(split[0],split[1]);
}
if( isShortParam ) i++;
} else if( arg.equals("-d") || arg.startsWith("--display:") ) {
// display
boolean isShortParam = arg.equals("-d");
display = isShortParam?arguments.get(i+1):arg.substring(10);
if( isShortParam ) i++;
} else if( arg.equals("-D") || arg.startsWith("--globalDisplay:") ) {
// global display
boolean isShortParam = arg.equals("-D");
globalDisplay = isShortParam?arguments.get(i+1):arg.substring(16);
if( isShortParam ) i++;
} else if( arg.equals("-h") || arg.equals("--help") ) {
return getUsageString();
} else if( arg.startsWith("-") ) {
return "unknown option '"+arg+"'\n"+getUsageString();
} else currentOIDs.add(arg);
}
if( currentModule != null ) {
try {
rval += formatObjects(master.callModule(
currentModule,
currentFunction,
currentWhere,
currentSet,
currentOIDs,
module),(display==null)?globalDisplay:display);
} catch (FunctionNotKnownException e) {
rval += "Function unknown: "+currentModule+'.'+currentFunction+"\n";
} catch (UnknownModuleException e) {
rval += "Module unknown: "+currentModule+"\n";
}
}
return rval;
}
}

View File

@ -1,15 +0,0 @@
package de.hsadmin.cliClientConnector;
public class BusinessException extends RuntimeException {
private static final long serialVersionUID = 1L;
public BusinessException(String msg) {
super(msg);
}
public BusinessException(Exception exc) {
super(exc.getMessage());
}
}

View File

@ -1,497 +0,0 @@
package de.hsadmin.cliClientConnector;
import java.io.BufferedReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.GenericModuleImpl;
import de.hsadmin.core.model.ModuleInterface;
import de.hsadmin.core.model.TicketValidator;
import de.hsadmin.core.model.Transaction;
/**
* actually this is the core of the CLI-Client. The other CLI-Client is just a
* rather simple HTTP Client that calls this Servlet.
*
* @author Christof Donat
*
*/
public class CLIClientConnectorServlet extends HttpServlet {
private static final long serialVersionUID = 7150004719303750077L;
public static final String version = "CLI Servlet 2.0.0 (2011/May/21 09:00 MEST)";
private Map<String, Class<?>> componentmap;
private Map<String, String> componentDescriptions;
private ArgumentParser parser;
/**
* Servlet initialization
*/
public void init(ServletConfig cfg) {
// init ticket validator
String validateURL = cfg.getInitParameter("proxyValidateUrl");
String serviceURL = cfg.getInitParameter("proxyServiceUrl");
TicketValidator.getInstance().initialize(validateURL, serviceURL);
// find components
String cstring = cfg.getInitParameter("Components");
String[] components = cstring.split(",");
componentmap = new HashMap<String, Class<?>>();
componentDescriptions = new HashMap<String, String>();
for (int i = 0; i < components.length; i++) {
// get everything for this component and create an entry.
try {
// component class
String classname = cfg.getInitParameter("ComponentClass_"
+ components[i]);
if (classname == null)
throw new NullPointerException(
"no class name found for Component "
+ components[i]);
Class<?> cls = Class.forName(classname);
componentmap.put(components[i], cls);
// description
String descr = cfg.getInitParameter("ComponentDescription_"
+ components[i]);
if (descr != null)
componentDescriptions.put(components[i], descr);
else
componentDescriptions.put(components[i], "");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
// TODO: get username, password from http session
parser = new ArgumentParser(this);
}
/**
* set values to a given entity Object
*
* @param o
* the entity Object
* @param set
* Hashtable with names and values that sould be changed in o
*/
private void setValues(Object o, Map<String, String> set, ModuleInterface module) {
Iterator<String> keys = set.keySet().iterator();
while (keys.hasNext()) {
String key = keys.next();
String[] ns = key.split("[.]", 2);
Object realO = o;
for (int i = 0; i < ns.length - 1; i++) {
Method[] m = realO.getClass().getMethods();
boolean oFound = false;
for (int j = 0; j < m.length; j++) {
if (m[j].getName().toLowerCase().equals(
"get" + ns[i].toLowerCase())) {
try {
realO = m[j].invoke(realO, (Object[]) null);
oFound = (realO != null);
break;
} catch (Exception e) {
new TechnicalException(e);
}
}
}
if (!oFound)
break;
}
Method[] m = realO.getClass().getMethods();
String value = set.get(key);
for (int j = 0; j < m.length; j++) {
if (!m[j].getName().toLowerCase().equals(
"set" + ns[ns.length - 1].toLowerCase()))
continue;
String type = m[j].getParameterTypes()[0].getCanonicalName();
try {
if (type.equals("java.lang.String"))
m[j].invoke(realO, value);
else if (type.equals("java.lang.Integer") || type.equals("int"))
m[j].invoke(realO, Integer.parseInt(value));
else if (type.equals("java.lang.Long") || type.equals("long"))
m[j].invoke(realO, Long.parseLong(value));
else if (type.equals("java.lang.Boolean") || type.equals("boolean"))
m[j].invoke(realO, Boolean.valueOf(value));
else if (type.equals("java.util.Date")) {
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMANY);
m[j].invoke(realO, df.parse(value));
} else {
Method m2 = module.getClass().getMethod(
"findByString", Class.class, String.class);
Object entity =
m2.invoke(module, m[j].getParameterTypes()[0], value);
if (entity != null)
m[j].invoke(realO, entity);
else
throw new BusinessException(
"not object found for '" + value + "'");
}
} catch (Exception e) {
throw new TechnicalException(e); // TODO: this needs to be
// more specific for
// some cases
}
}
}
}
private String hasGetter(Class<?> eType, String name) {
String rval = null;
String[] ns = name.split("[.]", 2);
String n1 = ns[0];
Method meth = null;
for (Method m : eType.getMethods()) {
String n = m.getName();
if (n.startsWith("get")) {
String fn = m.getName().substring(3).toLowerCase();
if (fn != "class" && fn.equals(n1)) {
meth = m;
rval = fn;
break;
}
}
}
if (meth != null) {
Class<?> returnType = meth.getReturnType();
if (rval != null && ns.length > 1 && meth != null)
return hasGetter(returnType, ns[1]);
if (returnType.getCanonicalName().startsWith("de.hsadmin.mods")) {
try {
if (returnType.getMethod("getName") != null) {
return rval + ".name";
}
} catch (Exception e) {
// no method found
}
}
}
return rval;
}
/**
* builds a query from a where clause and some objectIDs.
*
* @param eType
* The class of the Entity Object for which the string should be
* built. We need this to call the static method
* "createQueryFromStringKey"
* @param where
* Hashtable with where parameters. Only objects which match all
* where parameters are found
* @param oids
* Only objects with one of these object IDs are found
*
* @return queryString a query string that can be used to select the
* required Objects
* @throws ServletException
*/
private String buildQuery(Class<?> eType, Map<String, String> where,
ArrayList<String> oids) throws ServletException {
String rval = "";
boolean first = true;
Iterator<String> wkeys = where.keySet().iterator();
while (wkeys.hasNext()) {
String k = (String) wkeys.next();
String kname = hasGetter(eType, k);
String kvalue = ( (k.equals("id"))
? ( AbstractEntity.escapeString(where.get(k)) )
: ( "'" + AbstractEntity.escapeString(where.get(k)) + "'" ) );
if (kname != null) {
rval += (first ? "" : " and ")
+ "(obj." + AbstractEntity.escapeString(kname) + " = " + kvalue + ")";
first = false;
} else {
throw new ServletException("illegal input (unknown field: " + k + ")");
}
}
String rv = "";
if (oids != null)
try {
Method m;
m = eType.getMethod("createQueryFromStringKey", String.class);
first = true;
for (String s : oids) {
rv += (first ? "" : " or ") + "("
+ (String) m.invoke(eType, s) + ")";
first = false;
}
if (rv != "" && rval != "")
rval = rval + " and (" + rv + ")";
else if (rv != "")
rval = rv;
} catch (Exception e) {
throw new TechnicalException(e);
}
return (rval == "") ? null : rval;
}
public class FunctionNotKnownException extends Exception {
private static final long serialVersionUID = -6330015688609717838L;
}
public class UnknownModuleException extends Exception {
private static final long serialVersionUID = 696641072107896601L;
}
private Object callAdd(Class<?> cls, Map<String, String> set, ModuleInterface module) {
Transaction transaction = module.getTransaction();
transaction.beginTransaction();
try {
Method m = module.getClass().getMethod("add", AbstractEntity.class);
Object o = cls.newInstance();
setValues(o, set, module);
m.invoke(module, o);
transaction.commitTransaction();
return null;
} catch (Exception e) {
transaction.rollbackTransaction();
// TODO: this needs to be more specific, but how?
throw new TechnicalException(e);
}
}
@SuppressWarnings("unchecked")
private List<Object> callSearch(Class<?> cls, Map<String, String> where,
ArrayList<String> oids, ModuleInterface module) {
try {
Method m = module.getClass().getMethod("search", Class.class,
String.class, String.class);
return (List<Object>) m.invoke(module, cls,
buildQuery(cls, where, oids), null);
} catch (Exception e) {
throw new TechnicalException(e); // TODO: this needs to be more
// specific, but how?
}
}
// / checks wheather all 'oids' are in 'list'
private void checkOids(List<AbstractEntity> list, List<String> oids) {
List<String> oidsNotFound = new ArrayList<String>();
for (String id : oids) {
boolean found = false;
for (AbstractEntity e : list) {
String foundKey = e.createStringKey();
if (foundKey.equals(id)) {
found = true;
break;
}
}
if (!found)
oidsNotFound.add(id);
}
if (oidsNotFound.size() > 0) {
throw new OidsNotFoundException(oids);
}
}
@SuppressWarnings("unchecked")
private List<Object> callUpdate(Class<?> cls, Map<String, String> where,
ArrayList<String> oids, Map<String, String> set,
ModuleInterface module) {
// better safe than sorry - alsd hso same behavior as UNIX rm
if (where.size() == 0 && oids.size() == 0)
throw new BusinessException(
"better safe than sorry - 'update' needs a -w/--where-query or object id");
Transaction tx = module.getTransaction();
tx.beginTransaction();
try {
Method m = module.getClass().getMethod("search", Class.class,
String.class, String.class);
List<AbstractEntity> list = (List<AbstractEntity>) m.invoke(module, cls,
buildQuery(cls, where, oids), null);
checkOids(list, oids);
Method m2 = module.getClass().getMethod("update", AbstractEntity.class);
for (int i = 0; i < list.size(); i++) {
AbstractEntity entity = list.get(i);
tx.detach(entity);
setValues(entity, set, module);
m2.invoke(module, entity);
}
tx.commitTransaction();
} catch (Exception e) {
tx.rollbackTransaction();
// TODO: this needs to be more specific, but how?
throw new TechnicalException(e);
}
return null;
}
@SuppressWarnings("unchecked")
private void callDelete(Class<?> cls, Map<String, String> where,
ArrayList<String> oids, ModuleInterface module) {
// better safe than sorry - also same behavior as UNIX rm
if (where.size() == 0 && oids.size() == 0)
throw new BusinessException(
"better safe than sorry - 'update' needs a -w/--where-query or object id");
Transaction tx = module.getTransaction();
tx.beginTransaction();
try {
Method m =
module.getClass().getMethod("search", Class.class, String.class, String.class);
List<AbstractEntity> list =
(List<AbstractEntity>) m.invoke(module, cls, buildQuery(cls, where, oids), null);
checkOids(list, oids);
Method m2 = module.getClass().getMethod("delete", AbstractEntity.class);
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
m2.invoke(module, o);
}
tx.commitTransaction();
} catch (Exception e) {
tx.rollbackTransaction();
// TODO: this needs to be more specific, but how?
throw new TechnicalException(e);
}
}
/**
* Call one of the EntitySessions methods
*
* @param moduleName
* Defines the Entity class that will be given to the
* EntitySession
* @param function
* Defines the method that will be called. The function can be
* "add", "search", "update" and "delete".
* @param where
* Reduces the set of Entity objects which the function operates
* on to those matched by the where parameters. Only for
* "search", "update" and "delete". Will be ignored otherwise.
* @param set
* Set these values on all Objects - only for "add" and "update".
* Will be ignored otherwise.
* @param oids
* Works on Objects with these IDs. Only for "search", "update"
* and "delete". Will be ignored for "add".
* @return foundObjects
* @throws FunctionNotKnownException
*/
public List<Object> callModule(String moduleName, String function,
Map<String, String> where, Map<String, String> set,
ArrayList<String> oids, ModuleInterface module)
throws FunctionNotKnownException, UnknownModuleException {
List<Object> rval = new ArrayList<Object>();
// handle calls to the virtual module "modules"
if (moduleName.equals("modules")) {
// only search, no manipulation is possible
if (function.equals("search")) {
Iterator<?> m = componentDescriptions.keySet().iterator();
while (m.hasNext()) {
String mn = (String) m.next();
rval.add(new ModuleModel(mn, componentDescriptions.get(mn)));
}
} else if (function.equals("version")) {
rval.add(new VersionModel(version));
} else {
throw new FunctionNotKnownException();
}
return rval;
}
// find the component for the named module
Class<?> cls = componentmap.get(moduleName);
if (cls == null)
throw (new UnknownModuleException());
// call the appropriate methods
if (function.equals("add"))
rval.add(callAdd(cls, set, module));
else if (function.equals("search")) {
List<Object> r = callSearch(cls, where, oids, module);
if (r != null)
return r;
} else if (function.equals("update")) {
List<Object> r = callUpdate(cls, where, oids, set, module);
if (r != null)
return callUpdate(cls, where, oids, set, module);
} else if (function.equals("delete")) {
callDelete(cls, where, oids, module);
} else
throw (new FunctionNotKnownException());
return rval;
}
/**
* handle put method
*/
public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
try {
ModuleInterface module = null;
Transaction tx = null;
// check login
String auth = req.getHeader("authorization");
if (auth == null) {
// no login information at all - get it
resp.setHeader("WWW-Authenticate",
"Basic realm=\"CLIClientConnector\"");
resp.getOutputStream().println("login Failed.");
resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
} else {
// parse login information
String[] a = auth.split(" ", 2);
String ticket = a[1];
byte[] decoded = Base64.decodeBase64(ticket.trim().getBytes());
String s = new String(decoded);
a = s.split(":", 2);
// try to log in
String login = a[0];
ticket = a[1];
try {
tx = new Transaction(login);
if (tx.login(login, ticket)) {
// login successful
module = new GenericModuleImpl(tx);
// read arguments
BufferedReader read = req.getReader();
String tmpbuf;
ArrayList<String> arguments = new ArrayList<String>();
while ((tmpbuf = read.readLine()) != null) {
arguments.add(tmpbuf);
}
// actually handle the request and write result to output
String output = parser.parse(arguments, module);
resp.getWriter().write(output);
} else {
resp.addHeader("X-hsadmin-error", "authentication failed");
}
} catch (Exception e) {
resp.addHeader("X-hsadmin-error", "exception: " + e.getMessage());
} finally {
if (tx != null) {
tx.close();
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -1,19 +0,0 @@
package de.hsadmin.cliClientConnector;
public class ModuleModel {
private String name;
private String description;
public ModuleModel(String name, String description) {
this.name = name;
this.description = description;
}
public String getName() {
return this.name;
}
public String getDescription() {
return this.description;
}
}

View File

@ -1,25 +0,0 @@
package de.hsadmin.cliClientConnector;
import java.util.List;
@SuppressWarnings("serial")
public class OidsNotFoundException
extends RuntimeException
{
static private String oidsAsString(List<String> oids)
{
StringBuilder oidsBuilder = new StringBuilder();
for ( String id: oids )
oidsBuilder.append(", " + id);
if ( oidsBuilder.length() > 0 )
return oidsBuilder.substring(2);
throw new RuntimeException( "an empty list of missing OIDS does not make sense" );
}
public OidsNotFoundException(List<String> oids)
{
super("OIDS not found: " + oidsAsString(oids));
}
}

View File

@ -1,14 +0,0 @@
package de.hsadmin.cliClientConnector;
public class VersionModel
{
private String version;
public VersionModel( String version) {
this.version = version;
}
public String getVersion() {
return this.version;
}
}

View File

@ -0,0 +1,82 @@
package de.hsadmin.core.model;
import java.util.Set;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@Stateless(name="LoginBean")
@LocalBean
public class LoginBean implements LoginBeanLocal {
@PersistenceContext(unitName="hsar")
private EntityManager entityManager;
@Override
public UnixUser login(String user, String ticket) throws AuthenticationException {
String ticketUser = TicketValidator.getInstance().validateTicket(ticket);
if (user != null && user.equals(ticketUser)) {
return readLoginUser(ticketUser); // user himself
}
if (ticketUser != null && ticketUser.length() == 2) {
return readLoginUser(ticketUser); // 2-letter hostmaster
}
String hostmasterAccountPrefix = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-";
if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 8) {
return readLoginUser(ticketUser); // hsh01 hostmaster
}
if (ticketUser != null && ticketUser.length() == 5) {
Query userQuery = entityManager.createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
userQuery.setParameter("username", user);
UnixUser unixUser = (UnixUser) userQuery.getSingleResult();
String pacName = unixUser.getPac().getName();
boolean loginOk = ticketUser.equals(pacName);
if (loginOk) {
return readLoginUser(ticketUser);
}
throw new AuthenticationException("User " + ticketUser + " is not allowed to run as " + user);
}
String memberAccountPrefix = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-";
if (ticketUser != null && (ticketUser.length() == 3 || (ticketUser.length() >= 9 && ticketUser.startsWith(memberAccountPrefix)))) {
Query memberQuery = entityManager.createQuery("SELECT c FROM Customers c WHERE c.name = :membername");
memberQuery.setParameter("membername", ticketUser.length() == 3 ? (memberAccountPrefix + ticketUser) : ticketUser);
Customer member = (Customer) memberQuery.getSingleResult();
Set<Pac> pacs = member.getPacs();
for (Pac p : pacs) {
if (p.getName().equals(user)) {
return readLoginUser(ticketUser); // member as pac-admin
}
Set<UnixUser> users = p.getUnixUser();
for (UnixUser u : users) {
if (u.getName().equals(user)) {
return readLoginUser(ticketUser); // member as pac-user
}
}
}
}
throw new AuthenticationException("User " + ticketUser + " is not allowed to run as " + user);
}
private UnixUser readLoginUser(String loginName) {
if (loginName != null && loginName.length() == 2) {
loginName = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName;
}
if (loginName != null && loginName.length() == 3) {
loginName = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-" + loginName;
}
Query userQuery = entityManager.createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
userQuery.setParameter("username", loginName);
UnixUser user = (UnixUser) userQuery.getSingleResult();
user.getPac().getCustomer();
return user;
}
}

View File

@ -0,0 +1,12 @@
package de.hsadmin.core.model;
import javax.ejb.Local;
import de.hsadmin.mods.user.UnixUser;
@Local
public interface LoginBeanLocal {
public abstract UnixUser login(String user, String ticket) throws AuthenticationException;
}

View File

@ -0,0 +1,29 @@
package de.hsadmin.core.model;
import javax.ejb.LocalBean;
import javax.ejb.Stateful;
import de.hsadmin.mods.user.UnixUser;
@Stateful(name="LoginSession")
@LocalBean
public class LoginSession implements LoginSessionLocal {
private UnixUser loginUser;
@Override
public UnixUser getLoginUser() {
return loginUser;
}
@Override
public String getLoginName() {
return loginUser.getName();
}
@Override
public void setLoginUser(UnixUser user) {
loginUser = user;
}
}

View File

@ -0,0 +1,16 @@
package de.hsadmin.core.model;
import javax.ejb.Local;
import de.hsadmin.mods.user.UnixUser;
@Local
public interface LoginSessionLocal {
public abstract void setLoginUser(UnixUser user);
public abstract UnixUser getLoginUser();
public abstract String getLoginName();
}

View File

@ -0,0 +1,25 @@
package de.hsadmin.core.model;
import java.util.List;
import javax.ejb.Local;
@Local
public interface Module {
public AbstractEntity initialize(LoginSessionLocal session, AbstractEntity newEntity) throws HSAdminException;
public AbstractEntity find(LoginSessionLocal session, Class<? extends AbstractEntity> entityClass, Object key) throws HSAdminException;
public AbstractEntity findByString(LoginSessionLocal session, Class<? extends AbstractEntity> entityClass, String key) throws HSAdminException;
public List<AbstractEntity> search(LoginSessionLocal session, Class<? extends AbstractEntity> entityClass, String query, String orderBy) throws HSAdminException;
public AbstractEntity add(LoginSessionLocal session, AbstractEntity newEntity) throws HSAdminException;
public AbstractEntity update(LoginSessionLocal session, AbstractEntity existingEntity) throws HSAdminException;
public void delete(LoginSessionLocal session, AbstractEntity existingEntity) throws HSAdminException;
public void detach(AbstractEntity update);
}

View File

@ -0,0 +1,66 @@
package de.hsadmin.core.model;
import java.util.Properties;
import javax.annotation.Resource;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import de.hsadmin.core.qserv.ProcessorException;
import de.hsadmin.core.qserv.QueueClient;
import de.hsadmin.core.qserv.QueueTask;
@Stateless
@LocalBean
public class QueueManager implements QueueManagerLocal {
@Resource
private QueueConnectionFactory connectionFactory;
public QueueManager() {
}
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void enqueue(String hiveName, QueueTask task) {
try {
Queue queue = findHiveQueue(hiveName);
QueueClient queueClient = new QueueClient(connectionFactory, queue);
queueClient.send(task);
queueClient.close();
} catch (JMSException e) {
throw new TechnicalException(e);
} catch (ProcessorException e) {
throw new TechnicalException(e);
}
}
private Queue findHiveQueue(String hiveName) {
Queue queue = null;
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
Context ctx = null;
try {
ctx = new InitialContext(props);
Context env = (Context) ctx.lookup("java:comp/env");
queue = (Queue) env.lookup("jms/hsadminSystem-" + hiveName);
env.close();
return queue;
} catch (NamingException e) {
throw new TechnicalException(e);
} finally {
if (ctx != null) {
try { ctx.close(); } catch (NamingException e) { }
}
}
}
}

View File

@ -0,0 +1,12 @@
package de.hsadmin.core.model;
import javax.ejb.Local;
import de.hsadmin.core.qserv.QueueTask;
@Local
public interface QueueManagerLocal {
public abstract void enqueue(String hiveName, QueueTask task);
}

View File

@ -1,4 +1,4 @@
package de.hsadmin.cliClientConnector; package de.hsadmin.core.model;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -8,6 +8,8 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import de.hsadmin.core.util.Config;
public class TicketValidator { public class TicketValidator {
@ -24,11 +26,15 @@ public class TicketValidator {
public static TicketValidator getInstance() { public static TicketValidator getInstance() {
if (instance == null) { if (instance == null) {
instance = new TicketValidator(); instance = new TicketValidator();
Config config = Config.getInstance();
String validateUrl = config.getProperty("proxyValidateUrl");
String serviceUrl = config.getProperty("proxyServiceUrl");
instance.initialize(validateUrl, serviceUrl);
} }
return instance; return instance;
} }
public void initialize(String validateURL, String serviceURL) { private void initialize(String validateURL, String serviceURL) {
proxyServiceURL = serviceURL; proxyServiceURL = serviceURL;
proxyValidateURL = validateURL; proxyValidateURL = validateURL;
} }

View File

@ -15,9 +15,6 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction; import javax.persistence.EntityTransaction;
import javax.persistence.Query; import javax.persistence.Query;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import de.hsadmin.cliClientConnector.TechnicalException;
import de.hsadmin.core.qserv.QueueClient; import de.hsadmin.core.qserv.QueueClient;
import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;
@ -143,16 +140,8 @@ public class Transaction {
entityManager.close(); entityManager.close();
} }
/**
* Detach entities from hibernate session.
* Used to detach entities before update. Makes it possible to compare
* old and new attribute values.
*/
public void detach(AbstractEntity entity) { public void detach(AbstractEntity entity) {
if (entityManager instanceof OpenJPAEntityManager) { entityManager.detach(entity);
OpenJPAEntityManager openjpaEM = (OpenJPAEntityManager) entityManager;
openjpaEM.detach(entity);
}
} }
class QueueTaskStore { class QueueTaskStore {

View File

@ -23,7 +23,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import de.hsadmin.cliClientConnector.TechnicalException; import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;

View File

@ -8,9 +8,9 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import de.hsadmin.cliClientConnector.TechnicalException;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.TechnicalException;
public class ReflectionUtil { public class ReflectionUtil {

View File

@ -0,0 +1,231 @@
package de.hsadmin.mods.email;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
import javax.ejb.EJB;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.NonUniqueResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.LoginSessionLocal;
import de.hsadmin.core.model.Module;
import de.hsadmin.core.model.QueueManager;
import de.hsadmin.core.qserv.EntityProcessorFactory;
import de.hsadmin.core.qserv.NullProcessor;
import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.mods.user.UnixUser;
public abstract class AbstractStateless implements Module {
@PersistenceContext(name = "hsar")
protected EntityManager entityManager;
@EJB
private QueueManager queueManager;
public List<AbstractEntity> search(LoginSessionLocal session, Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) {
orderBy = "ORDER BY obj.name ASC";
}
UnixUser loginUser = session.getLoginUser();
condition = restrict(entityClass, loginUser, condition);
Entity entityAnnot = entityClass.getAnnotation(Entity.class);
String queryString = "SELECT obj FROM " + entityAnnot.name() + " obj";
if (condition != null && condition.length() > 0) {
queryString += " WHERE " + condition;
}
if (condition != null && condition.contains("AND (FALSE)")) {
return new LinkedList<AbstractEntity>();
}
if (orderBy != null) {
queryString += " ";
queryString += orderBy;
}
entityManager.clear();
Query query = entityManager.createQuery(queryString);
setQueryParameter(query, queryString, "loginUser", loginUser);
setQueryParameter(query, queryString, "loginUserName", loginUser.getName());
setQueryParameter(query, queryString, "loginUserPac", loginUser.getPac());
try {
List<?> res = query.getResultList();
List<AbstractEntity> ret = new LinkedList<AbstractEntity>();
// remove entities where login user has no access rights
for (Object entity : res) {
if (entity instanceof AbstractEntity) {
AbstractEntity returnedEntity = (AbstractEntity) entity;
if (returnedEntity.isReadAllowedFor(session.getLoginUser())) {
ret.add(returnedEntity);
}
}
}
return ret;
} catch (Exception ex) {
throw new HSAdminException(ex);
}
}
public AbstractEntity initialize(LoginSessionLocal session,
AbstractEntity newEntity) throws HSAdminException {
newEntity.initialize(entityManager, session.getLoginUser());
return newEntity;
}
public AbstractEntity add(LoginSessionLocal session, AbstractEntity newEntity) throws HSAdminException {
UnixUser loginUser1 = session.getLoginUser();
newEntity.complete(entityManager, loginUser1);
entityManager.persist(newEntity);
if (!newEntity.isWriteAllowedFor(loginUser1)) {
throw new AuthorisationException(loginUser1, "add", newEntity);
}
EntityProcessorFactory procFact = createProcessorFactory(newEntity.getClass());
if (procFact != null) {
Processor proc = procFact.createCreateProcessor(entityManager, newEntity);
queueProcessor(proc, loginUser1, newEntity, "hinzugefuegt");
}
return newEntity;
}
public AbstractEntity update(LoginSessionLocal session, AbstractEntity existingEntity) throws HSAdminException {
UnixUser loginUser = session.getLoginUser();
existingEntity = existingEntity.merge(entityManager, loginUser);
if (!existingEntity.isWriteAllowedFor(loginUser)) {
throw new AuthorisationException(loginUser, "update", existingEntity);
}
EntityProcessorFactory procFact = createProcessorFactory(existingEntity.getClass());
if (procFact != null) {
Processor proc = procFact.createUpdateProcessor(entityManager, existingEntity);
queueProcessor(proc, loginUser, existingEntity, "aktualisiert");
}
return existingEntity;
}
public void delete(LoginSessionLocal session, AbstractEntity existingEntity) throws HSAdminException {
UnixUser loginUser = session.getLoginUser();
existingEntity = entityManager.find(existingEntity.getClass(), existingEntity.id());
if (!existingEntity.isWriteAllowedFor(loginUser)) {
throw new AuthorisationException(loginUser, "add", existingEntity);
}
entityManager.remove(existingEntity);
EntityProcessorFactory procFact = createProcessorFactory(existingEntity.getClass());
if (procFact != null) {
Processor proc = procFact.createDeleteProcessor(entityManager, existingEntity);
queueProcessor(proc, loginUser, existingEntity, "geloescht");
}
}
public void detach(AbstractEntity attached) {
entityManager.detach(attached);
}
public AbstractEntity find(LoginSessionLocal session, Class<? extends AbstractEntity> entityClass, Object key)
throws HSAdminException {
AbstractEntity entity = entityManager.find(entityClass, key);
UnixUser loginUser = session.getLoginUser();
if (!entity.isReadAllowedFor(loginUser)) {
throw new AuthorisationException(loginUser, "add", entity);
}
return entity;
}
public AbstractEntity findByString(LoginSessionLocal session, Class<? extends AbstractEntity> entityClass, String key)
throws HSAdminException {
Method method = null;
try {
method = entityClass.getDeclaredMethod("createQueryFromStringKey", String.class);
} catch (SecurityException e) {
throw new HSAdminException(e);
} catch (NoSuchMethodException e) {
method = null;
}
AbstractEntity entity = null;
if (method == null) {
entity = entityManager.find(entityClass, key);
} else {
String query = null;
try {
query = (String) method.invoke(null, key);
} catch (Exception e) {
throw new HSAdminException(e);
}
List<AbstractEntity> result = search(session, entityClass, query, null);
if (result.size() > 1) {
throw new NonUniqueResultException();
}
if (result.size() == 0) {
return null;
}
entity = result.get(0);
}
return entity;
}
protected void setQueryParameter(Query query, String queryString, String argName, Object argValue) {
int argLen = argName.length();
int iMax = queryString.length();
int i = 0;
while ((i = queryString.indexOf(argName, i)) >= 0) {
if ((i + argLen) >= iMax || queryString.charAt(i + argLen) < 'A') {
query.setParameter(argName, argValue);
break;
}
++i;
}
}
protected EntityProcessorFactory createProcessorFactory(Class<? extends AbstractEntity> entityClass)
throws HSAdminException {
String procFactName = entityClass.getCanonicalName() + "ProcessorFactory";
Class<?> procFactClass = null;
EntityProcessorFactory procFact = null;
try {
procFactClass = Class.forName(procFactName);
if (procFactClass != null) {
procFact = (EntityProcessorFactory) procFactClass.newInstance();
}
} catch (ClassNotFoundException e) {
// no processor defined
} catch (InstantiationException e) {
throw new HSAdminException(e);
} catch (IllegalAccessException e) {
throw new HSAdminException(e);
}
return procFact;
}
protected void queueProcessor(Processor proc, UnixUser user, AbstractEntity entity,
String action) {
if (proc == null || proc instanceof NullProcessor) {
return;
}
Entity entityInfo = entity.getClass().getAnnotation(Entity.class);
String entityTypeName = entityInfo != null ? entityInfo.name() : entity.getClass().getSimpleName();
StringBuilder details = new StringBuilder();
String title = entityTypeName + " (" + entity.createStringKey() + ") " + action;
QueueTask task = new QueueTask(user, title, details.toString(), proc);
entityManager.persist(task);
queueManager.enqueue(entity.getHiveName(), task);
}
/**
* apply access restriction to JPA-QL condition.
*/
protected String restrict(Class<?> entityClass, UnixUser loginUser, String condition) {
String restriction = AbstractEntity.restriction(entityClass, loginUser);
if (restriction == null)
return condition;
if (condition != null && condition.length() > 0)
condition = "(" + condition + ") AND (" + restriction + ")";
else
condition = restriction;
return condition;
}
}

View File

@ -2,35 +2,38 @@ package de.hsadmin.mods.email;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.Query; import javax.persistence.Query;
import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.LoginSessionLocal;
import de.hsadmin.core.model.Module;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public class EMailAddressModuleImpl extends AbstractModuleImpl { @Stateless(name="EMailAddressModule")
@LocalBean
private static final int EMAIL_PER_MULTI_OPTION = 250; public class EMailAddressModuleImpl extends AbstractStateless implements Module {
@Override @Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, public List<AbstractEntity> search(LoginSessionLocal session, Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException { String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) { if (orderBy == null || orderBy.length() == 0) {
orderBy = "ORDER BY obj.domain.name ASC, obj.subdomain ASC, obj.localpart ASC"; orderBy = "ORDER BY obj.domain.name ASC, obj.subdomain ASC, obj.localpart ASC";
} }
return super.search(entityClass, condition, orderBy); return super.search(session, entityClass, condition, orderBy);
} }
@Override @Override
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException { @TransactionAttribute(TransactionAttributeType.REQUIRED)
Transaction tx = getTransaction(); public AbstractEntity add(LoginSessionLocal session, AbstractEntity newEntity) throws HSAdminException {
EntityManager em = tx.getEntityManager();
EMailAddress adr = (EMailAddress) newEntity; EMailAddress adr = (EMailAddress) newEntity;
if (adr.getTarget() == null || adr.getTarget().length() == 0) { if (adr.getTarget() == null || adr.getTarget().length() == 0) {
throw new HSAdminException("target required"); throw new HSAdminException("target required");
@ -46,11 +49,11 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl {
|| adr.getDomain().getName().length() == 0) { || adr.getDomain().getName().length() == 0) {
throw new HSAdminException("domain required"); throw new HSAdminException("domain required");
} }
Query qDomain = em.createQuery("SELECT d FROM Domains d WHERE d.name = :domName"); Query qDomain = entityManager.createQuery("SELECT d FROM Domains d WHERE d.name = :domName");
qDomain.setParameter("domName", adr.getDomain().getName()); qDomain.setParameter("domName", adr.getDomain().getName());
Domain dom = (Domain) qDomain.getSingleResult(); Domain dom = (Domain) qDomain.getSingleResult();
adr.setDomain(dom); adr.setDomain(dom);
UnixUser loginUser = tx.getLoginUser(); UnixUser loginUser = session.getLoginUser();
if (dom.isPacDomain() && !loginUser.hasHostmasterRole()) { if (dom.isPacDomain() && !loginUser.hasHostmasterRole()) {
throw new AuthorisationException(loginUser, "add", adr); throw new AuthorisationException(loginUser, "add", adr);
} }
@ -60,23 +63,22 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl {
throw new HSAdminException("not allowed for this packet type"); throw new HSAdminException("not allowed for this packet type");
} }
//TODO: Needs better implementation //TODO: Needs better implementation
Query qEmailAliases = em.createQuery("SELECT obj FROM EMailAliases obj WHERE obj.pac.id = :pacId"); Query qEmailAliases = entityManager.createQuery("SELECT obj FROM EMailAliases obj WHERE obj.pac.id = :pacId");
qEmailAliases.setParameter("pacId", dom.getUser().getPac().getId()); qEmailAliases.setParameter("pacId", dom.getUser().getPac().getId());
Query qEmailAddresses = em.createQuery("SELECT obj FROM EMailAddresses obj WHERE obj.domain.user.pac.id = :pacId"); Query qEmailAddresses = entityManager.createQuery("SELECT obj FROM EMailAddresses obj WHERE obj.domain.user.pac.id = :pacId");
qEmailAddresses.setParameter("pacId", dom.getUser().getPac().getId()); qEmailAddresses.setParameter("pacId", dom.getUser().getPac().getId());
if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= EMAIL_PER_MULTI_OPTION * dom.getUser().getPac().getQuantityByComponentName("MULTI")) { if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= MultiOption.EMAIL_ITEMS_PER_OPTION * dom.getUser().getPac().getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included email addresses/aliases exceeded"); throw new HSAdminException("included email addresses/aliases exceeded");
} }
return super.add(newEntity); return super.add(session, newEntity);
} }
@Override @Override
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException { @TransactionAttribute(TransactionAttributeType.REQUIRED)
Transaction transaction = getTransaction(); public AbstractEntity update(LoginSessionLocal session, AbstractEntity existingEntity) throws HSAdminException {
UnixUser loginUser = transaction.getLoginUser(); UnixUser loginUser = session.getLoginUser();
EMailAddress detachedAddr = (EMailAddress) existingEntity; EMailAddress detachedAddr = (EMailAddress) existingEntity;
EntityManager em = transaction.getEntityManager(); EMailAddress attachedAddr = entityManager.find(EMailAddress.class, detachedAddr.getId());
EMailAddress attachedAddr = em.find(EMailAddress.class, detachedAddr.getId());
String domain = detachedAddr.getDomain().getName(); String domain = detachedAddr.getDomain().getName();
if (domain != null && !domain.equals(attachedAddr.getDomain().getName())) { if (domain != null && !domain.equals(attachedAddr.getDomain().getName())) {
detachedAddr.setDomain(attachedAddr.getDomain()); detachedAddr.setDomain(attachedAddr.getDomain());
@ -97,7 +99,7 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl {
throw new HSAdminException("target required"); throw new HSAdminException("target required");
} }
attachedAddr.setTarget(target); attachedAddr.setTarget(target);
return super.update(attachedAddr); return super.update(session, attachedAddr);
} }
} }

View File

@ -25,15 +25,11 @@ import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
/** @Entity(name = "EMailAliases")
* Entity class for email aliases.
*
*/
@javax.persistence.Entity(name = "EMailAliases")
@Table(name = "emailalias") @Table(name = "emailalias")
@SequenceGenerator(name = "EMailAliasesSeqGen", sequenceName = "emailalias_emailalias_id_seq") @SequenceGenerator(name = "EMailAliasesSeqGen", sequenceName = "emailalias_emailalias_id_seq")
@SearchFilter("obj.pac = :loginUserPac OR obj.pac.customer.name = :loginUserName") @SearchFilter("obj.pac = :loginUserPac OR obj.pac.customer.name = :loginUserName")
@AnnModuleImpl(de.hsadmin.mods.email.EMailAliasModuleImpl.class) @AnnModuleImpl(EMailAliasModuleImpl.class)
public class EMailAlias extends AbstractEntity implements Serializable { public class EMailAlias extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -4711415079723587161L; private static final long serialVersionUID = -4711415079723587161L;

View File

@ -1,42 +1,36 @@
package de.hsadmin.mods.email; package de.hsadmin.mods.email;
import java.util.List; import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager; import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.Query; import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.LoginSessionLocal;
import de.hsadmin.core.model.Module;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public class EMailAliasModuleImpl extends AbstractModuleImpl { @Stateless(name="EMailAliasModule")
@LocalBean
public class EMailAliasModuleImpl extends AbstractStateless implements Module {
@Override @Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, @TransactionAttribute(TransactionAttributeType.REQUIRED)
String condition, String orderBy) throws HSAdminException { public AbstractEntity add(LoginSessionLocal session,
if (orderBy == null || orderBy.length() == 0) { AbstractEntity newEntity) throws HSAdminException {
orderBy = "ORDER BY obj.name ASC"; UnixUser loginUser = session.getLoginUser();
}
return super.search(entityClass, condition, orderBy);
}
@Override
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
Transaction transaction = getTransaction();
UnixUser loginUser = transaction.getLoginUser();
EMailAlias alias = (EMailAlias) newEntity; EMailAlias alias = (EMailAlias) newEntity;
String name = alias.getName(); String name = alias.getName();
if (name.length() > 5 && (name.charAt(5) != '-') || name.length() == 6) { if (name.length() > 5 && (name.charAt(5) != '-') || name.length() == 6) {
throw new AuthorisationException(loginUser, "add", newEntity); throw new AuthorisationException(loginUser, "add", newEntity);
} }
EntityManager em = getTransaction().getEntityManager(); Query qPac = entityManager.createQuery("SELECT obj FROM Pacs obj WHERE obj.name = :pacName");
Query qPac = em.createQuery("SELECT obj FROM Pacs obj WHERE obj.name = :pacName");
qPac.setParameter("pacName", name.substring(0, 5)); qPac.setParameter("pacName", name.substring(0, 5));
Object singleResult = qPac.getSingleResult(); Object singleResult = qPac.getSingleResult();
Pac pac = (Pac) singleResult; Pac pac = (Pac) singleResult;
@ -52,15 +46,15 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl {
throw new HSAdminException("not allowed for this packet type"); throw new HSAdminException("not allowed for this packet type");
} }
//TODO: Needs better implementation //TODO: Needs better implementation
Query qEmailAliases = em.createQuery("SELECT obj FROM EMailAliases obj WHERE obj.pac.id = :pacId"); Query qEmailAliases = entityManager.createQuery("SELECT obj FROM EMailAliases obj WHERE obj.pac.id = :pacId");
qEmailAliases.setParameter("pacId", pac.getId()); qEmailAliases.setParameter("pacId", pac.getId());
Query qEmailAddresses = em.createQuery("SELECT obj FROM EMailAddresses obj WHERE obj.domain.user.pac.id = :pacId"); Query qEmailAddresses = entityManager.createQuery("SELECT obj FROM EMailAddresses obj WHERE obj.domain.user.pac.id = :pacId");
qEmailAddresses.setParameter("pacId", pac.getId()); qEmailAddresses.setParameter("pacId", pac.getId());
if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= MultiOption.EMAIL_ITEMS_PER_OPTION * pac.getQuantityByComponentName("MULTI")) { if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= MultiOption.EMAIL_ITEMS_PER_OPTION * pac.getQuantityByComponentName("MULTI")) {
throw new HSAdminException("included email addresses/aliases exceeded"); throw new HSAdminException("included email addresses/aliases exceeded");
} }
alias.setPac(pac); alias.setPac(pac);
return super.add(newEntity); return super.add(session, newEntity);
} }
} }

View File

@ -26,7 +26,7 @@ import de.hsadmin.mods.pac.Pac;
@Entity(name = "UnixUsers") @Entity(name = "UnixUsers")
@Table(name = "unixuser") @Table(name = "unixuser")
@SequenceGenerator(name = "UnixUsersSeqGen", sequenceName = "unixuser_unixuser_id_seq") @SequenceGenerator(name = "UnixUsersSeqGen", sequenceName = "unixuser_unixuser_id_seq")
@AnnModuleImpl(de.hsadmin.mods.user.UnixUserModuleImpl.class) @AnnModuleImpl(UnixUserModuleImpl.class)
public class UnixUser extends AbstractEntity implements Serializable { public class UnixUser extends AbstractEntity implements Serializable {
private static final long serialVersionUID = 7823071611805642906L; private static final long serialVersionUID = 7823071611805642906L;
@ -50,7 +50,7 @@ public class UnixUser extends AbstractEntity implements Serializable {
@AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE) @AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE)
@JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false) @JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false)
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.EAGER)
private Pac pac; private Pac pac;
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\.\\,\\ ]*", rw=ReadWriteAccess.READWRITE) @AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\.\\,\\ ]*", rw=ReadWriteAccess.READWRITE)

View File

@ -0,0 +1,186 @@
package de.hsadmin.remote;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.LoginBeanLocal;
import de.hsadmin.core.model.LoginSessionLocal;
import de.hsadmin.core.model.Module;
import de.hsadmin.mods.user.UnixUser;
public abstract class EJBAbstractRemote {
public EJBAbstractRemote() {
super();
}
public List<Map<String, Object>> search(String runAsUser, String ticket, Map<String, String> whereParams)
throws HSAdminException {
String user = runAsUser;
try {
getSession().setLoginUser(getLogin().login(user, ticket));
UnixUser unixUser = getSession().getLoginUser();
List<AbstractEntity> list = getModule().search(getSession(), getEntityClass(),
buildQueryCondition(whereParams), null);
if (list == null) {
throw new HSAdminException("result list is null, runtime-error?");
}
ArrayList<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
for (AbstractEntity e : list) {
HashMap<String, Object> entry = new HashMap<String, Object>();
entity2map(e, entry);
if (e.isReadAllowedFor(unixUser)) {
result.add(entry);
}
}
return result;
} catch (SecurityException e) {
throw new HSAdminException(e);
} catch (IllegalArgumentException e) {
throw new HSAdminException(e);
}
}
public abstract LoginSessionLocal getSession();
public abstract LoginBeanLocal getLogin();
public abstract Module getModule();
protected abstract Class<? extends AbstractEntity> getEntityClass();
protected abstract void entity2map(AbstractEntity entity, Map<String, Object> resultMap);
protected abstract void map2entity(Map<String, Object> setParams, AbstractEntity entity) throws HSAdminException;
protected abstract void regularizeKeys(Map<String, String> whereParams);
public Map<String, Object> add(String runAsUser, String ticket, Map<String, Object> setParams)
throws HSAdminException {
String user = runAsUser;
try {
getSession().setLoginUser(getLogin().login(user, ticket));
Constructor<? extends AbstractEntity> constructor =
getEntityClass().getConstructor();
AbstractEntity entity = constructor.newInstance();
getModule().initialize(getSession(), entity);
map2entity(setParams, entity);
AbstractEntity insertedEntity = getModule().add(getSession(), entity);
HashMap<String, Object> entry = new HashMap<String, Object>();
entity2map(insertedEntity, entry);
return entry;
} catch (Exception e) {
throw new HSAdminException(e);
}
}
public void delete(String runAsUser, String ticket, Map<String, String> whereParams)
throws HSAdminException {
String user = runAsUser;
try {
getSession().setLoginUser(getLogin().login(user, ticket));
UnixUser unixUser = getSession().getLoginUser();
String queryCondition = buildQueryCondition(whereParams);
if (queryCondition == null || queryCondition.length() == 0) {
throw new HSAdminException(
"better safe than sorry: no where parameter found");
}
List<AbstractEntity> list = getModule().search(getSession(), getEntityClass(),
queryCondition, null);
for (AbstractEntity e : list) {
if (e.isWriteAllowedFor(unixUser)) {
getModule().delete(getSession(), e);
} else {
throw new AuthorisationException(unixUser, "delete", e);
}
}
} catch (SecurityException e) {
throw new HSAdminException(e);
} catch (IllegalArgumentException e) {
throw new HSAdminException(e);
}
}
public List<Map<String, Object>> update(String runAsUser, String ticket, Map<String, Object> setParams, Map<String, String> whereParams)
throws HSAdminException {
String user = runAsUser;
try {
getSession().setLoginUser(getLogin().login(user, ticket));
UnixUser unixUser = getSession().getLoginUser();
ArrayList<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
String queryCondition = buildQueryCondition(whereParams);
if (queryCondition == null || queryCondition.length() == 0) {
throw new HSAdminException(
"better safe than sorry: no where parameter found");
}
List<AbstractEntity> list = getModule().search(getSession(), getEntityClass(),
queryCondition, getOrderBy());
for (AbstractEntity update : list) {
if (update.isWriteAllowedFor(unixUser)) {
getModule().detach(update);
map2entity(setParams, update);
update = getModule().update(getSession(), update);
HashMap<String, Object> entry = new HashMap<String, Object>();
entity2map(update, entry);
result.add(entry);
} else {
throw new AuthorisationException(unixUser, "update", update);
}
}
return result;
} catch (SecurityException e) {
throw new HSAdminException(e);
} catch (IllegalArgumentException e) {
throw new HSAdminException(e);
}
}
private String buildQueryCondition(Map<String, String> whereParams) {
regularizeKeys(whereParams);
StringBuffer cond = new StringBuffer();
Iterator<String> keyIterator = whereParams.keySet().iterator();
while (keyIterator.hasNext()) {
if (cond.length() > 0) {
cond.append(" AND ");
}
String field = keyIterator.next();
String value = whereParams.get(field).replaceAll("'", "\'");
cond.append("obj.");
cond.append(field);
cond.append(" = ");
boolean numeric = "id".equals(field);
if (!numeric) cond.append("'");
cond.append(value);
if (!numeric) cond.append("'");
}
return cond.toString();
}
protected boolean assertNotNull(String string) {
return string != null && string.length() > 0;
}
protected boolean assertNotNull(Integer integ) {
return integ != null;
}
protected void replaceKey(Map<String, String> whereParams, String shortKey, String regularKey) {
if (whereParams.containsKey(shortKey)) {
String value = whereParams.get(shortKey);
whereParams.remove(shortKey);
whereParams.put(regularKey, value);
}
}
protected String getOrderBy() {
return "ORDER BY obj.name ASC";
}
}

View File

@ -3,17 +3,47 @@ package de.hsadmin.remote;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.LoginBeanLocal;
import de.hsadmin.core.model.LoginSessionLocal;
import de.hsadmin.core.model.Module;
import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.email.EMailAddress; import de.hsadmin.mods.email.EMailAddress;
public class EMailAddressRemote extends AbstractRemote { public class EMailAddressRemote extends EJBAbstractRemote {
private LoginBeanLocal login;
private LoginSessionLocal session;
private Module module;
public EMailAddressRemote() {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
Context ctx = null;
try {
ctx = new InitialContext(props);
session = (LoginSessionLocal) ctx.lookup("LoginSessionLocal");
login = (LoginBeanLocal) ctx.lookup("LoginBeanLocal");
module = (Module) ctx.lookup("EMailAddressModuleLocal");
} catch (NamingException e) {
throw new TechnicalException(e);
} finally {
if (ctx != null) {
try { ctx.close(); } catch (NamingException e) { }
}
}
}
@Override @Override
protected void entity2map(Transaction tx, AbstractEntity entity, Map<String, Object> map) { protected void entity2map(AbstractEntity entity, Map<String, Object> map) {
EMailAddress adr = (EMailAddress) entity; EMailAddress adr = (EMailAddress) entity;
long id = adr.getId(); long id = adr.getId();
String domain = adr.getDomain().getName(); String domain = adr.getDomain().getName();
@ -43,7 +73,7 @@ public class EMailAddressRemote extends AbstractRemote {
} }
@Override @Override
protected void map2entity(Transaction tx, Map<String, Object> map, AbstractEntity entity) { protected void map2entity(Map<String, Object> map, AbstractEntity entity) {
EMailAddress adr = (EMailAddress) entity; EMailAddress adr = (EMailAddress) entity;
String localpart = (String) map.get("localpart"); String localpart = (String) map.get("localpart");
if (assertNotNull(localpart)) { if (assertNotNull(localpart)) {
@ -96,4 +126,16 @@ public class EMailAddressRemote extends AbstractRemote {
return "ORDER BY obj.domain.name ASC, obj.subdomain ASC, obj.localpart ASC"; return "ORDER BY obj.domain.name ASC, obj.subdomain ASC, obj.localpart ASC";
} }
public LoginBeanLocal getLogin() {
return login;
}
public LoginSessionLocal getSession() {
return session;
}
public Module getModule() {
return module;
}
} }

View File

@ -1,18 +1,76 @@
package de.hsadmin.remote; package de.hsadmin.remote;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.LoginBeanLocal;
import de.hsadmin.core.model.LoginSessionLocal;
import de.hsadmin.core.model.Module;
import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.mods.email.EMailAlias; import de.hsadmin.mods.email.EMailAlias;
public class EMailAliasRemote extends AbstractRemote { public class EMailAliasRemote extends EJBAbstractRemote {
@Override private LoginBeanLocal login;
protected void entity2map(Transaction tx, AbstractEntity entity, Map<String, Object> map) { private LoginSessionLocal session;
private Module module;
public EMailAliasRemote() {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
Context ctx = null;
try {
ctx = new InitialContext(props);
session = (LoginSessionLocal) ctx.lookup("LoginSessionLocal");
login = (LoginBeanLocal) ctx.lookup("LoginBeanLocal");
module = (Module) ctx.lookup("EMailAliasModuleLocal");
} catch (NamingException e) {
throw new TechnicalException(e);
} finally {
if (ctx != null) {
try { ctx.close(); } catch (NamingException e) { }
}
}
}
protected boolean assertNotNull(Date aDate) {
return aDate != null;
}
String buildQueryCondition(Map<String, String> whereParams) {
regularizeKeys(whereParams);
StringBuffer cond = new StringBuffer();
Iterator<String> keyIterator = whereParams.keySet().iterator();
while (keyIterator.hasNext()) {
if (cond.length() > 0) {
cond.append(" AND ");
}
String field = keyIterator.next();
String value = whereParams.get(field).replaceAll("'", "\'");
cond.append("obj.");
cond.append(field);
cond.append(" = ");
boolean numeric = "id".equals(field);
if (!numeric) cond.append("'");
cond.append(value);
if (!numeric) cond.append("'");
}
return cond.toString();
}
protected void entity2map(AbstractEntity entity, Map<String, Object> map) {
EMailAlias alias = (EMailAlias) entity; EMailAlias alias = (EMailAlias) entity;
String id = Long.toString(alias.getId()); String id = Long.toString(alias.getId());
String name = alias.getName(); String name = alias.getName();
@ -29,13 +87,13 @@ public class EMailAliasRemote extends AbstractRemote {
map.put("target", tokenList); map.put("target", tokenList);
} }
@Override
protected Class<? extends AbstractEntity> getEntityClass() { protected Class<? extends AbstractEntity> getEntityClass() {
return EMailAlias.class; return EMailAlias.class;
} }
@Override
protected void map2entity(Transaction tx, Map<String, Object> map, AbstractEntity entity) { protected void map2entity(Map<String, Object> map, AbstractEntity entity) {
EMailAlias alias = (EMailAlias) entity; EMailAlias alias = (EMailAlias) entity;
String name = (String) map.get("name"); String name = (String) map.get("name");
if (assertNotNull(name)) { if (assertNotNull(name)) {
@ -64,9 +122,21 @@ public class EMailAliasRemote extends AbstractRemote {
} }
} }
@Override
protected void regularizeKeys(Map<String, String> whereParams) { protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "pac", "pac.name"); replaceKey(whereParams, "pac", "pac.name");
} }
public LoginBeanLocal getLogin() {
return login;
}
public LoginSessionLocal getSession() {
return session;
}
public Module getModule() {
return module;
}
} }

View File

@ -5,11 +5,11 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.hsadmin.cliClientConnector.TechnicalException;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.ReflectionUtil; import de.hsadmin.core.util.ReflectionUtil;

View File

@ -19,6 +19,9 @@ public class JSONFormatter {
if (object instanceof String) { if (object instanceof String) {
return formatString((String) object); return formatString((String) object);
} }
if (object instanceof Number) {
return formatNumber((Number) object);
}
if (object instanceof Object[]) { if (object instanceof Object[]) {
return formatArr((Object[]) object); return formatArr((Object[]) object);
} }
@ -52,6 +55,10 @@ public class JSONFormatter {
return "'" + str + "'"; return "'" + str + "'";
} }
private String formatNumber(Number num) {
return num.toString();
}
public String formatList(List<?> list) { public String formatList(List<?> list) {
return formatArr(list.toArray()); return formatArr(list.toArray());
} }

View File

@ -34,8 +34,8 @@ public class Main {
} }
String expr = cmdParser.getExpression(); String expr = cmdParser.getExpression();
if (expr != null && expr.length() > 0) { if (expr != null && expr.length() > 0) {
scriptClient.execute(expr); Object execute = scriptClient.execute(expr);
console.println(formatter.format(scriptClient.getLastRpcResult())); console.println(formatter.format(execute));
} }
if (cmdParser.isInteractive()) { if (cmdParser.isInteractive()) {
String command = console.readInput(); String command = console.readInput();
@ -43,8 +43,9 @@ public class Main {
try { try {
scriptClient.execute(command); scriptClient.execute(command);
console.println(formatter.format(scriptClient.getLastRpcResult())); console.println(formatter.format(scriptClient.getLastRpcResult()));
} catch (Exception e) { } catch (JSCliException e) {
console.println("Error: " + e.getLocalizedMessage() + "\n"); final String errorMessage = createErrorMessage(e);
console.println(errorMessage + "\n");
} }
command = console.readInput(); command = console.readInput();
} }
@ -55,4 +56,17 @@ public class Main {
} }
} }
private static String createErrorMessage(final JSCliException e) {
String errorMessage = "Error: " + e.getLocalizedMessage();
Throwable cause = e;
while (cause.getCause() != null) {
cause = cause.getCause();
}
errorMessage = cause.getLocalizedMessage();
if (errorMessage.contains("de.hsadmin.module.error.UserException:")) {
errorMessage = errorMessage.substring(errorMessage.indexOf("de.hsadmin.module.error.UserException:") + 31).trim();
}
return errorMessage;
}
} }

View File

@ -7,7 +7,7 @@
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ws-commons-util-1.0.2.jar"/> <classpathentry kind="lib" path="WebContent/WEB-INF/lib/ws-commons-util-1.0.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-client-3.1.3.jar"/> <classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-client-3.1.3.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-common-3.1.3.jar"/> <classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-common-3.1.3.jar"/>
<classpathentry kind="lib" path="/hsarback/lib/servlet-api-2.4.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/vaadin-6.8.7.jar"/> <classpathentry kind="lib" path="WebContent/WEB-INF/lib/vaadin-6.8.7.jar"/>
<classpathentry kind="lib" path="/hsarback/lib/servlet-api.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -57,7 +57,7 @@
</init-param> </init-param>
</filter> </filter>
<!--
<filter-mapping> <filter-mapping>
<filter-name>CAS Validation Filter</filter-name> <filter-name>CAS Validation Filter</filter-name>
<url-pattern>/*</url-pattern> <url-pattern>/*</url-pattern>
@ -67,6 +67,7 @@
<filter-name>CAS Authentication Filter</filter-name> <filter-name>CAS Authentication Filter</filter-name>
<url-pattern>/*</url-pattern> <url-pattern>/*</url-pattern>
</filter-mapping> </filter-mapping>
-->
<servlet> <servlet>
<servlet-name>Logout Servlet</servlet-name> <servlet-name>Logout Servlet</servlet-name>

View File

@ -13,7 +13,7 @@ homedir=Heimat Verzeichnis
pac=Paket pac=Paket
quota_softlimit=Soft-Quota [MB] quota_softlimit=Soft-Quota [MB]
quota_hardlimit=Hard-Quota [MB] quota_hardlimit=Hard-Quota [MB]
moduletitle=Unix User moduletitle=Benutzer
moduleicon=../runo/icons/16/users.png moduleicon=../runo/icons/16/users.png
new=Benutzer anlegen new=Benutzer anlegen
update=Benutzer ändern update=Benutzer ändern