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="test"/>
<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/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/xmlrpc-client-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="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<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/commons-logging-api-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.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"/>
</classpath>

View File

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

View File

@ -1,8 +1,32 @@
<?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-unit name="hsadmin" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<non-jta-data-source>java:/comp/env/jdbc/HSAdminDB</non-jta-data-source>
<persistence-unit name="hsadmin">
<jta-data-source>java:/comp/env/jdbc/HSAdminDB</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.mods.cust.Customer</class>
<class>de.hsadmin.mods.cust.Contact</class>
@ -25,9 +49,5 @@
<class>de.hsadmin.mods.db.Database</class>
<class>de.hsadmin.mods.db.MySqlDatabase</class>
<class>de.hsadmin.mods.db.PgSqlDatabase</class>
<properties>
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/>
<property name="openjpa.Compatibility" value="QuotedNumbersInQueries=true"/>
</properties>
</persistence-unit>
</persistence>

View File

@ -135,6 +135,16 @@
global="jms/hsadminSystem-h66"
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
name="jms/hsadminSystem-mail1"
global="jms/hsadminSystem-mail1"

View File

@ -14,112 +14,6 @@
<load-on-startup>1</load-on-startup>
</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-name>XmlRpcServlet</servlet-name>
<servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class>
@ -134,11 +28,6 @@
<url-pattern>/queueStatus</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CLI Client Connector</servlet-name>
<url-pattern>/hsadmin/cli-interface/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc/*</url-pattern>

View File

@ -14,112 +14,6 @@
<load-on-startup>1</load-on-startup>
</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-name>XmlRpcServlet</servlet-name>
<servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class>
@ -134,11 +28,6 @@
<url-pattern>/queueStatus</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CLI Client Connector</servlet-name>
<url-pattern>/hsadmin/cli-interface/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/xmlrpc/*</url-pattern>
@ -313,6 +202,18 @@
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</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>
<res-ref-name>jms/hsadminSystem-dns1</res-ref-name>
<res-type>javax.jms.Queue</res-type>

View File

@ -14,112 +14,6 @@
<load-on-startup>1</load-on-startup>
</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-name>XmlRpcServlet</servlet-name>
<servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class>
@ -134,11 +28,6 @@
<url-pattern>/queueStatus</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CLI Client Connector</servlet-name>
<url-pattern>/hsadmin/cli-interface/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name>
<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);
}