From c8dd78ff9f31d53876ef8c8e00adf87d7299fe6d Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Mon, 07 Sep 2015 16:39:16 +0200
Subject: [PATCH] create newweb branch without sni changes

---
 hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties  |    1 
 hsarback/conf/WEB-INF/test-web.xml                                 |   13 ++-
 hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java |    6 ++
 hsarback/src/de/hsadmin/remote/PropertyRemote.java                 |  104 ++++++++++++++++++++++++++++++++++
 hsarback/conf/WEB-INF/prod-web.xml                                 |   17 +++--
 hsarback/conf/META-INF/persistence-with-sql-logging.xml            |    1 
 hsarback/conf/META-INF/persistence.xml                             |    1 
 7 files changed, 129 insertions(+), 14 deletions(-)

diff --git a/hsarback/conf/META-INF/persistence-with-sql-logging.xml b/hsarback/conf/META-INF/persistence-with-sql-logging.xml
index f551d23..cbbe3f5 100644
--- a/hsarback/conf/META-INF/persistence-with-sql-logging.xml
+++ b/hsarback/conf/META-INF/persistence-with-sql-logging.xml
@@ -6,7 +6,6 @@
 		<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>
diff --git a/hsarback/conf/META-INF/persistence.xml b/hsarback/conf/META-INF/persistence.xml
index 5e0734c..ae4304b 100644
--- a/hsarback/conf/META-INF/persistence.xml
+++ b/hsarback/conf/META-INF/persistence.xml
@@ -6,7 +6,6 @@
 		<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>
diff --git a/hsarback/conf/WEB-INF/prod-web.xml b/hsarback/conf/WEB-INF/prod-web.xml
index 1b71c01..4899424 100644
--- a/hsarback/conf/WEB-INF/prod-web.xml
+++ b/hsarback/conf/WEB-INF/prod-web.xml
@@ -11,6 +11,14 @@
     <servlet>
         <servlet-name>Queue Status Servlet</servlet-name>
         <servlet-class>de.hsadmin.core.qserv.QueueStatusReceiverServlet</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>
         <load-on-startup>1</load-on-startup>
     </servlet>
 
@@ -18,19 +26,14 @@
         <servlet-name>XmlRpcServlet</servlet-name>
         <servlet-class>de.hsadmin.remote.HSXmlRpcServlet</servlet-class>
         <init-param>
-          <param-name>enabledForExtensions</param-name>
-          <param-value>true</param-value>
+        	<param-name>enabledForExtensions</param-name>
+        	<param-value>true</param-value>
         </init-param>
     </servlet>
 
     <servlet-mapping>
         <servlet-name>Queue Status Servlet</servlet-name>
         <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>
diff --git a/hsarback/conf/WEB-INF/test-web.xml b/hsarback/conf/WEB-INF/test-web.xml
index df5a9df..47c2dd5 100644
--- a/hsarback/conf/WEB-INF/test-web.xml
+++ b/hsarback/conf/WEB-INF/test-web.xml
@@ -11,6 +11,14 @@
     <servlet>
         <servlet-name>Queue Status Servlet</servlet-name>
         <servlet-class>de.hsadmin.core.qserv.QueueStatusReceiverServlet</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>
         <load-on-startup>1</load-on-startup>
     </servlet>
 
@@ -26,11 +34,6 @@
     <servlet-mapping>
         <servlet-name>Queue Status Servlet</servlet-name>
         <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>
diff --git a/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java b/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java
index af52c92..1d70163 100644
--- a/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java
+++ b/hsarback/src/de/hsadmin/core/qserv/QueueStatusReceiverServlet.java
@@ -18,12 +18,14 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.persistence.EntityManager;
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import de.hsadmin.core.model.TechnicalException;
+import de.hsadmin.core.model.TicketValidator;
 import de.hsadmin.core.model.Transaction;
 import de.hsadmin.core.util.Config;
 
@@ -43,6 +45,10 @@
 
 	@Override
 	public void init() throws ServletException {
+		final ServletConfig cfg = getServletConfig();
+		final String validateURL = cfg.getInitParameter("proxyValidateUrl");
+		final String serviceURL = cfg.getInitParameter("proxyServiceUrl");
+		TicketValidator.getInstance().initialize(validateURL, serviceURL);	
 		isConnected = false;
 		messageCount = 0;
 		errorCount = 0;
diff --git a/hsarback/src/de/hsadmin/remote/PropertyRemote.java b/hsarback/src/de/hsadmin/remote/PropertyRemote.java
new file mode 100644
index 0000000..6d924aa
--- /dev/null
+++ b/hsarback/src/de/hsadmin/remote/PropertyRemote.java
@@ -0,0 +1,104 @@
+package de.hsadmin.remote;
+
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import de.hsadmin.core.model.AbstractEntity;
+import de.hsadmin.core.model.AnnFieldIO;
+import de.hsadmin.core.model.AuthenticationException;
+import de.hsadmin.core.model.HSAdminException;
+import de.hsadmin.core.model.ReadWriteAccess;
+import de.hsadmin.core.model.Transaction;
+
+public class PropertyRemote implements IRemote {
+
+	@Override
+	public List<Map<String, Object>> search(String runAsUser, String ticket,
+			Map<String, String> whereParams) throws HSAdminException {
+		String user = runAsUser;
+		List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();
+		Transaction transaction = new Transaction(user);
+		try {
+			if (transaction.login(user, ticket)) {
+				InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("org/apache/xmlrpc/webserver/XmlRpcServlet.properties");
+				Properties properties = new Properties();
+				properties.load(resourceAsStream);				
+				for (Object moduleKey : properties.keySet()) {
+					Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey));
+					Object newInstance = remoteClass.newInstance();
+					if (newInstance instanceof AbstractRemote) {
+						AbstractRemote remote = (AbstractRemote) newInstance;
+						Class<? extends AbstractEntity> entityClass = remote.getEntityClass();
+						for (Field f: entityClass.getDeclaredFields()) {
+							AnnFieldIO fieldIO = f.getAnnotation(AnnFieldIO.class);
+							if (fieldIO != null) {
+								HashMap<String, Object> propertyProperties = new HashMap<String, Object>();
+								String fieldName = f.getName();
+								propertyProperties.put("module", (String) moduleKey);
+								propertyProperties.put("name", fieldName);
+								propertyProperties.put("searchable", "equals");
+								propertyProperties.put("readwriteable", "read");
+								ReadWriteAccess rw = fieldIO.rw();
+								if (ReadWriteAccess.READONLY.equals(rw)) {
+									propertyProperties.put("readwriteable", "read");
+								}
+								if (ReadWriteAccess.READWRITE.equals(rw)) {
+									propertyProperties.put("readwriteable", "readwrite");
+								}
+								if (ReadWriteAccess.WRITEONCE.equals(rw)) {
+									propertyProperties.put("readwriteable", "writeonce");
+								}
+								if (ReadWriteAccess.WRITEONLY.equals(rw)) {
+									propertyProperties.put("readwriteable", "none");
+								}
+								propertyProperties.put("type", "string");
+								propertyProperties.put("displaySequence", "2");
+								if ("name".equals(fieldName)) {
+									propertyProperties.put("displaySequence", "1");
+								}
+								propertyProperties.put("displayVisible", "always");
+								propertyProperties.put("minLength", "0");
+								propertyProperties.put("maxLength", "999");
+								String regExp = fieldIO.validation();
+								propertyProperties.put("validationRegexp", regExp);
+								result.add(propertyProperties);
+							}
+						}											
+					}
+				}
+				return result;
+			} else {
+				throw new AuthenticationException("authentication failed");
+			}
+		} catch (Exception e) {
+			throw new HSAdminException(e);
+		} finally {
+			transaction.close();
+		}
+	}
+
+	@Override
+	public Map<String, Object> add(String runAsUser, String ticket,
+			Map<String, Object> setParams) throws HSAdminException {
+		throw new HSAdminException("read only module");
+	}
+
+	@Override
+	public void delete(String runAsUser, String ticket,
+			Map<String, String> whereParams) throws HSAdminException {
+		throw new HSAdminException("read only module");
+	}
+
+	@Override
+	public List<Map<String, Object>> update(String runAsUser, String ticket,
+			Map<String, Object> setParams, Map<String, String> whereParams)
+			throws HSAdminException {
+		throw new HSAdminException("read only module");
+	}
+
+}
diff --git a/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties b/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
index fb56deb..d233600 100644
--- a/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
+++ b/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
@@ -10,3 +10,4 @@
 mysqldb=de.hsadmin.remote.MysqlDbRemote
 postgresqldb=de.hsadmin.remote.PgsqlDbRemote
 moduleprop=de.hsadmin.remote.ModulePropertiesRemote
+property=de.hsadmin.remote.PropertyRemote
\ No newline at end of file

--
Gitblit v1.9.0-SNAPSHOT