Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) adding servlet to display all deployed SOAP Services - soap related servlets are located in htroot/soap *) new serverContext class for soap
thelif20b596dc035
diff --git a/build.xml b/build.xmlindex 3547aca8b..3c3015650 100644--- a/build.xml+++ b/build.xml@@ -237,6 +237,7 @@<javac srcdir="${htroot}/"classpathref="project.class.path"debug="true" debuglevel="lines,vars,source"+ excludes="soap/*"source="${javacSource}" target="${javacTarget}"/></target>@@ -509,7 +510,8 @@<copy todir="${release_main}/htroot"><fileset dir="${htroot}"><include name="**/*"/>- <exclude name="yacy/seedUpload/**"/>+ <exclude name="yacy/seedUpload/**"/>+ <exclude name="soap/**"/></fileset><fileset dir="${htroot}"><include name="yacy/seedUpload/yacySeedUploadFile.html"/>diff --git a/htroot/soap/ServiceList.html b/htroot/soap/ServiceList.htmlnew file mode 100644index 000000000..79e1d4f44--- /dev/null+++ b/htroot/soap/ServiceList.html@@ -0,0 +1,33 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">+<html xmlns="http://www.w3.org/1999/xhtml">+ <head>+ <title>SOAP Service List</title>+ #%env/templates/metas.template%#+ </head>+ <body>+ #%env/templates/header.template%#+ <h2>Deployed SOAP Services</h2>+ <p>Currently #[services]# services are deployed.</p>++ <table>+ <tr class="TableHeader">+ <td>Service name</td>+ <td>Operation</td>+ <td>WSDL</td>+ </tr>+ #{services}#<tr class="TableCell#(dark)#Light::Dark#(/dark)#">+ <td><b>#[name]#</b> [#[style]#]</td>+ <td>+ <table>+ #{methods}#<tr>+ <td>#[name]#</td>+ <td><tt>#[method]#</tt></td>+ </tr>#{/methods}#+ </table>+ </td>+ <td><a href="/soap/#[name]#?wsdl">WSDL</a></td>+ </tr>#{/services}#++ #%env/templates/footer.template%#+ </body>+</html>\ No newline at end of filediff --git a/htroot/soap/ServiceList.java b/htroot/soap/ServiceList.javanew file mode 100644index 000000000..bac6808e8--- /dev/null+++ b/htroot/soap/ServiceList.java@@ -0,0 +1,105 @@+// ServiceList.java+// -----------------------+// part of YaCy+// (C) by Michael Peter Christen; [email protected]+// first published on http://www.anomic.de+// Frankfurt, Germany, 2004+//+// This File is contributed by Martin Thelian+//+// $LastChangedDate: 2007-02-24 13:56:32 +0000 (Sa, 24 Feb 2007) $+// $LastChangedRevision: 3391 $+// $LastChangedBy: karlchenofhell $+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+//+// Using this software in any meaning (reading, learning, copying, compiling,+// running) means that you agree that the Author(s) is (are) not responsible+// for cost, loss of data or any harm that may be caused directly or indirectly+// by usage of this softare or this documentation. The usage of this software+// is on your own risk. The installation and usage (starting/running) of this+// software may allow other people or application to access your computer and+// any attached devices and is highly dependent on the configuration of the+// software which must be done by the user of the software; the author(s) is+// (are) also not responsible for proper configuration and usage of the+// software, even if provoked by documentation provided together with+// the software.+//+// Any changes to this file according to the GPL as documented in the file+// gpl.txt aside this file in the shipment you received can be done to the+// lines that follows this copyright notice here, but changes must not be+// done inside the copyright notive above. A re-distribution must contain+// the intact and unchanged copyright notice.+// Contributions and changes to the program code must be marked as such.++// You must compile this file with+// javac -classpath .:../classes Blacklist_p.java+// if the shell's current path is HTROOT+++package soap;++import java.util.ArrayList;+import java.util.Iterator;++import org.apache.axis.AxisEngine;+import org.apache.axis.ConfigurationException;+import org.apache.axis.description.OperationDesc;+import org.apache.axis.description.ServiceDesc;++import de.anomic.http.httpHeader;+import de.anomic.server.serverObjects;+import de.anomic.server.serverSwitch;++public class ServiceList {++ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws ConfigurationException {++ serverObjects prop = new serverObjects();++ // getting the SOAP engine+ AxisEngine engine = (AxisEngine) post.get("SOAP.engine");++ // loop through the deployed services+ int i = 0;+ boolean dark = true;+ Iterator serviceIter = engine.getConfig().getDeployedServices();+ while (serviceIter.hasNext()) {+ // getting the service description+ ServiceDesc serviceDescription = (ServiceDesc)serviceIter.next();+ prop.put("services_" + i + "_name",serviceDescription.getName());+ prop.put("services_" + i + "_style",serviceDescription.getStyle());+ prop.put("services_" + i + "_dark", ((dark) ? 1 : 0) ); dark =! dark;++ // loop through the methods of this service+ int j = 0;+ ArrayList operations = serviceDescription.getOperations();+ while (j < operations.size()) {+ OperationDesc op = (OperationDesc)operations.get(j);++ prop.put("services_" + i + "_methods_" + j + "_name",op.getName());+ prop.put("services_" + i + "_methods_" + j + "_method",op.getMethod());+ j++;+ }+ prop.put("services_" + i + "_methods",j);++ i++;+ }+ prop.put("services",i);++ return prop;+ }++}diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.javaindex f5d5f578d..06f011e9c 100644--- a/source/de/anomic/http/httpHeader.java+++ b/source/de/anomic/http/httpHeader.java@@ -159,6 +159,11 @@ public final class httpHeader extends TreeMap implements Map {public static final String UPGRADE = "Upgrade";public static final String TE = "TE";+ /* =============================================================+ * Constants for content-encodings+ * ============================================================= */+ public static final String CONTENT_ENCODING_GZIP = "gzip";+/* =============================================================* Constants defining http methods* ============================================================= */diff --git a/source/de/anomic/soap/AbstractService.java b/source/de/anomic/soap/AbstractService.javaindex 2ff42d4d8..9643643ac 100644--- a/source/de/anomic/soap/AbstractService.java+++ b/source/de/anomic/soap/AbstractService.java@@ -46,12 +46,6 @@package de.anomic.soap;import java.io.ByteArrayInputStream;-import java.io.ByteArrayOutputStream;-import java.io.File;-import java.io.FileInputStream;-import java.io.IOException;-import java.lang.reflect.Method;-import java.util.HashMap;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;@@ -66,19 +60,14 @@ import org.w3c.dom.Document;import org.w3c.dom.Element;import de.anomic.http.httpHeader;-import de.anomic.http.httpTemplate;import de.anomic.http.httpd;-import de.anomic.server.serverClassLoader;-import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;public abstract class AbstractService {- protected String rootPath;- protected serverClassLoader provider;- protected HashMap templates;protected serverSwitch switchboard;protected httpHeader requestHeader;protected MessageContext messageContext;+ protected ServerContext serverContext;protected static final boolean NO_AUTHENTICATION = false;protected static final boolean AUTHENTICATION_NEEDED = true;@@ -92,11 +81,9 @@ public abstract class AbstractService {protected void extractMessageContext(boolean authenticate) throws AxisFault {this.messageContext = MessageContext.getCurrentContext();- this.rootPath = (String) this.messageContext.getProperty(httpdSoapHandler.MESSAGE_CONTEXT_HTTP_ROOT_PATH);- this.provider = (serverClassLoader) this.messageContext.getProperty(httpdSoapHandler.MESSAGE_CONTEXT_SERVER_CLASSLOADER);- this.templates = (HashMap) this.messageContext.getProperty(httpdSoapHandler.MESSAGE_CONTEXT_TEMPLATES);this.switchboard = (serverSwitch) this.messageContext.getProperty(httpdSoapHandler.MESSAGE_CONTEXT_SERVER_SWITCH);this.requestHeader = (httpHeader) this.messageContext.getProperty(httpdSoapHandler.MESSAGE_CONTEXT_HTTP_HEADER);+ this.serverContext = (ServerContext) this.messageContext.getProperty(httpdSoapHandler.MESSAGE_CONTEXT_SERVER_CONTEXT);if (authenticate) {String authInfo = this.doAuthentication();@@ -107,115 +94,7 @@ public abstract class AbstractService {this.requestHeader.put("CLIENTIP","localhost");}- }---- /**- * This function is called by the service functions to- * invoke the desired server-internal method and to generate- * a output document using one of the available templates.- *- * @param templateName- * @param args- * @return the output document- * @throws AxisFault- */- protected byte[] writeTemplate(String templateName, serverObjects args) throws AxisFault {- try {- // invoke servlet- serverObjects tp = invokeServlet(templateName,args);-- // generate output- byte[] result = buildServletOutput(templateName, tp);- return result;- } catch (Exception e) {- if (e instanceof AxisFault) throw (AxisFault) e;-- // create a new AxisFault Object- throw new AxisFault(e.getMessage());- }- }-- protected byte[] buildServletOutput(String templateName, serverObjects tp) throws AxisFault {- try {- File templateFile = getTemplateFile(templateName);-- // generating the output document- ByteArrayOutputStream o = new ByteArrayOutputStream();- FileInputStream fis = new FileInputStream(templateFile);- httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));- o.close();- fis.close();-- // convert it into a byte array and send it back as result- byte[] result = o.toByteArray();- return result;- } catch (Exception e) {- if (e instanceof AxisFault) throw (AxisFault) e;-- // create a new AxisFault Object- throw new AxisFault(e.getMessage());- }- }-- protected serverObjects invokeServlet(String templateName, serverObjects args) throws AxisFault {- try {- // getting the template class file- File rc = getServletClassFile(templateName);-- // invoke the desired method- serverObjects tp = (serverObjects) rewriteMethod(rc).invoke(null, new Object[] {this.requestHeader, args, this.switchboard});-- // testing if a authentication was needed by the invoked method- validateAuthentication(tp);-- // adding all available templates- tp.putAll(this.templates);-- // return result- return tp;- } catch (Exception e) {- if (e instanceof AxisFault) throw (AxisFault) e;-- e.printStackTrace();-- // create a new AxisFault Object- throw new AxisFault(e.getMessage());- }- }-- protected File getTemplateFile(String templateName) {- // determining the proper class that should be invoked- File file = new File(this.rootPath, templateName);- return file;- }-- protected File getServletClassFile(String templateName) {- File templateFile = getTemplateFile(templateName);- File templateClassFile = getServletClassFile(templateFile);- return templateClassFile;- }-- protected File getServletClassFile(File templateFile) {- File templateClassFile = rewriteClassFile(templateFile);- return templateClassFile;- }--- /**- * This function is used to test if an invoked method requires authentication- *- * @param tp the properties returned by a previous method invocation- *- * @throws AxisFault if an authentication was required.- */- protected void validateAuthentication(serverObjects tp) throws AxisFault {- // check if the servlets requests authentification- if (tp.containsKey("AUTHENTICATE")) {- throw new AxisFault("log-in required");- }- }+ }/*** Doing the user authentication. To improve security, this client@@ -246,55 +125,7 @@ public abstract class AbstractService {}throw new AxisFault("log-in required");}-- /**- * This method was copied from the {@link httpdFileHandler httpdFileHandler-class}- * @param template- * @return the .class-{@link File} belonging to the given template or <code>null</code>- * if no fitting .class-{@link File} does exist- */- protected File rewriteClassFile(File template) {- try {- String f = template.getCanonicalPath();- int p = f.lastIndexOf(".");- if (p < 0) return null;- f = f.substring(0, p) + ".class";- //System.out.println("constructed class path " + f);- File cf = new File(f);- if (cf.exists()) return cf;- return null;- } catch (IOException e) {- return null;- }- }-- /**- * This method was copied from the {@link httpdFileHandler httpdFileHandler-class}- * @param classFile- * @return the <code>resond({@link httpHeader}, {@link serverObjects}, {@link serverSwitch})</code>- * {@link Method} of the specified class file or <code>null</code> if this file doesn't contain- * such a method- */- protected Method rewriteMethod(File classFile) {- Method m = null;- // now make a class out of the stream- try {- //System.out.println("**DEBUG** loading class file " + classFile);- Class c = this.provider.loadClass(classFile);- Class[] params = new Class[] {- httpHeader.class, // Class.forName("de.anomic.http.httpHeader"),- serverObjects.class, // Class.forName("de.anomic.server.serverObjects"),- serverSwitch.class }; // Class.forName("de.anomic.server.serverSwitch")};- m = c.getMethod("respond", params);- } catch (ClassNotFoundException e) {- System.out.println("INTERNAL ERROR: class " + classFile + " is missing:" + e.getMessage());- } catch (NoSuchMethodException e) {- System.out.println("INTERNAL ERROR: method respond not found in class " + classFile + ": " + e.getMessage());- }- //System.out.println("found method: " + m.toString());- return m;- }-+protected Document convertContentToXML(String contentString) throws Exception {return convertContentToXML(contentString.getBytes("UTF-8"));}diff --git a/source/de/anomic/soap/ServerContext.java b/source/de/anomic/soap/ServerContext.javanew file mode 100644index 000000000..1ef84e3bf--- /dev/null+++ b/source/de/anomic/soap/ServerContext.java@@ -0,0 +1,234 @@+package de.anomic.soap;++//ServerContext.java+//------------------------+//part of YaCy+//(C) by Michael Peter Christen; [email protected]+//first published on http://www.anomic.de+//Frankfurt, Germany, 2005+//+//this file was contributed by Martin Thelian+//last major change: $LastChangedDate$ by $LastChangedBy$+//Revision: $LastChangedRevision$+//+//This program is free software; you can redistribute it and/or modify+//it under the terms of the GNU General Public License as published by+//the Free Software Foundation; either version 2 of the License, or+//(at your option) any later version.+//+//This program is distributed in the hope that it will be useful,+//but WITHOUT ANY WARRANTY; without even the implied warranty of+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+//GNU General Public License for more details.+//+//You should have received a copy of the GNU General Public License+//along with this program; if not, write to the Free Software+//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+//+//Using this software in any meaning (reading, learning, copying, compiling,+//running) means that you agree that the Author(s) is (are) not responsible+//for cost, loss of data or any harm that may be caused directly or indirectly+//by usage of this softare or this documentation. The usage of this software+//is on your own risk. The installation and usage (starting/running) of this+//software may allow other people or application to access your computer and+//any attached devices and is highly dependent on the configuration of the+//software which must be done by the user of the software; the author(s) is+//(are) also not responsible for proper configuration and usage of the+//software, even if provoked by documentation provided together with+//the software.+//+//Any changes to this file according to the GPL as documented in the file+//gpl.txt aside this file in the shipment you received can be done to the+//lines that follows this copyright notice here, but changes must not be+//done inside the copyright notive above. A re-distribution must contain+//the intact and unchanged copyright notice.+//Contributions and changes to the program code must be marked as such.++import java.io.ByteArrayOutputStream;+import java.io.File;+import java.io.FileInputStream;+import java.io.IOException;+import java.lang.reflect.Method;+import java.util.HashMap;++import org.apache.axis.AxisFault;++import de.anomic.http.httpHeader;+import de.anomic.http.httpTemplate;+import de.anomic.server.serverClassLoader;+import de.anomic.server.serverObjects;+import de.anomic.server.serverSwitch;++public class ServerContext {++ protected String rootPath;+ protected serverClassLoader provider;+ protected HashMap templates;+ protected serverSwitch switchboard;+++ public ServerContext(String root, serverClassLoader cLoader, HashMap templateMap, serverSwitch switchb) {+ this.rootPath = root;+ this.provider = cLoader;+ this.templates = templateMap;+ this.switchboard = switchb;+ }++ public serverClassLoader getProvider() {+ return this.provider;+ }++ /**+ * This function is called by the service functions to+ * invoke the desired server-internal method and to generate+ * a output document using one of the available templates.+ *+ * @param templateName+ * @param args+ * @return the output document+ * @throws AxisFault+ */+ public byte[] writeTemplate(String templateName, serverObjects args, httpHeader requestHeader) throws AxisFault {+ try {+ // invoke servlet+ serverObjects tp = invokeServlet(templateName,args,requestHeader);++ // generate output+ byte[] result = buildServletOutput(templateName, tp);+ return result;+ } catch (Exception e) {+ if (e instanceof AxisFault) throw (AxisFault) e;++ // create a new AxisFault Object+ throw new AxisFault(e.getMessage());+ }+ }++ public byte[] buildServletOutput(String templateName, serverObjects tp) throws AxisFault {+ try {+ File templateFile = getTemplateFile(templateName);++ // generating the output document+ ByteArrayOutputStream o = new ByteArrayOutputStream();+ FileInputStream fis = new FileInputStream(templateFile);+ httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));+ o.close();+ fis.close();++ // convert it into a byte array and send it back as result+ byte[] result = o.toByteArray();+ return result;+ } catch (Exception e) {+ if (e instanceof AxisFault) throw (AxisFault) e;++ // create a new AxisFault Object+ throw new AxisFault(e.getMessage());+ }+ }++ public serverObjects invokeServlet(String templateName, serverObjects args, httpHeader requestHeader) throws AxisFault {+ try {+ // getting the template class file+ File rc = getServletClassFile(templateName);++ // invoke the desired method+ serverObjects tp = (serverObjects) rewriteMethod(rc).invoke(null, new Object[] {requestHeader, args, this.switchboard});++ // testing if a authentication was needed by the invoked method+ validateAuthentication(tp);++ // adding all available templates+ tp.putAll(this.templates);++ // return result+ return tp;+ } catch (Exception e) {+ if (e instanceof AxisFault) throw (AxisFault) e;++ e.printStackTrace();++ // create a new AxisFault Object+ throw new AxisFault(e.getMessage());+ }+ }++ public File getTemplateFile(String templateName) {+ // determining the proper class that should be invoked+ File file = new File(this.rootPath, templateName);+ return file;+ }++ public File getServletClassFile(String templateName) {+ File templateFile = getTemplateFile(templateName);+ File templateClassFile = getServletClassFile(templateFile);+ return templateClassFile;+ }++ public File getServletClassFile(File templateFile) {+ File templateClassFile = rewriteClassFile(templateFile);+ return templateClassFile;+ }++ /**+ * This method was copied from the {@link httpdFileHandler httpdFileHandler-class}+ * @param template+ * @return the .class-{@link File} belonging to the given template or <code>null</code>+ * if no fitting .class-{@link File} does exist+ */+ protected File rewriteClassFile(File template) {+ try {+ String f = template.getCanonicalPath();+ int p = f.lastIndexOf(".");+ if (p < 0) return null;+ f = f.substring(0, p) + ".class";+ //System.out.println("constructed class path " + f);+ File cf = new File(f);+ if (cf.exists()) return cf;+ return null;+ } catch (IOException e) {+ return null;+ }+ }++ /**+ * This method was copied from the {@link httpdFileHandler httpdFileHandler-class}+ * @param classFile+ * @return the <code>resond({@link httpHeader}, {@link serverObjects}, {@link serverSwitch})</code>+ * {@link Method} of the specified class file or <code>null</code> if this file doesn't contain+ * such a method+ */+ protected Method rewriteMethod(File classFile) {+ Method m = null;+ // now make a class out of the stream+ try {+ //System.out.println("**DEBUG** loading class file " + classFile);+ Class c = this.provider.loadClass(classFile);+ Class[] params = new Class[] {+ httpHeader.class, // Class.forName("de.anomic.http.httpHeader"),+ serverObjects.class, // Class.forName("de.anomic.server.serverObjects"),+ serverSwitch.class }; // Class.forName("de.anomic.server.serverSwitch")};+ m = c.getMethod("respond", params);+ } catch (ClassNotFoundException e) {+ System.out.println("INTERNAL ERROR: class " + classFile + " is missing:" + e.getMessage());+ } catch (NoSuchMethodException e) {+ System.out.println("INTERNAL ERROR: method respond not found in class " + classFile + ": " + e.getMessage());+ }+ //System.out.println("found method: " + m.toString());+ return m;+ }+++ /**+ * This function is used to test if an invoked method requires authentication+ *+ * @param tp the properties returned by a previous method invocation+ *+ * @throws AxisFault if an authentication was required.+ */+ protected void validateAuthentication(serverObjects tp) throws AxisFault {+ // check if the servlets requests authentification+ if (tp.containsKey("AUTHENTICATE")) {+ throw new AxisFault("log-in required");+ }+ }+}diff --git a/source/de/anomic/soap/build.xml b/source/de/anomic/soap/build.xmlindex ece09d342..b9d81f6c7 100644--- a/source/de/anomic/soap/build.xml+++ b/source/de/anomic/soap/build.xml@@ -37,15 +37,22 @@</path>- <target name="compile">- <javac srcdir="${src}/de/anomic/soap/"- destdir="${build}"- source="${javacSource}"- target="${javacTarget}"- debug="true"- debuglevel="lines,vars,source"- classpathref="soap.class.path">- </javac>+ <target name="compile">+ <!-- compile main sources -->+ <javac srcdir="${src}/de/anomic/soap/"+ destdir="${build}"+ source="${javacSource}"+ target="${javacTarget}"+ debug="true"+ debuglevel="lines,vars,source"+ classpathref="soap.class.path">+ </javac>++ <!-- compile htroot parts -->+ <javac srcdir="${htroot}/soap/"+ classpathref="soap.class.path"+ debug="true" debuglevel="lines,vars,source"+ source="${javacSource}" target="${javacTarget}"/></target>@@ -60,20 +67,30 @@dirmode="755" mode="644"/><tarfileset dir="${build}/de/anomic/soap/"prefix="${releaseDir}/classes/de/anomic/soap/"- dirmode="755" mode="644"/>+ dirmode="755" mode="644"/>+ <tarfileset dir="${htroot}/soap/"+ prefix="${releaseDir}/htroot/soap/"+ dirmode="755" mode="644"/></tar></target><target name="copy" depends="compile">+ <!-- copy libx --><copy todir="${release}/libx/"><fileset dir="${libx}" includes="axis.jar,axis-ant.jar,commons-discovery.jar,commons-logging.jar,jaxrpc.jar,saaj.jar,wsdl4j.jar,gnumail.jar,activation.jar,inetlib.jar"/></copy>+ <!-- copy source files --><copy todir="${release}/source/de/anomic/soap/"><fileset dir="${src}/de/anomic/soap/" includes="**/*"/></copy>+ <!-- copy classes --><copy todir="${release}/classes/de/anomic/soap/"><fileset dir="${build}/de/anomic/soap/" includes="**/*"/></copy>+ <!-- copy htroot -->+ <copy todir="${release}/htroot/soap/">+ <fileset dir="${htroot}/soap/" includes="**/*"/>+ </copy></target>diff --git a/source/de/anomic/soap/httpdSoapHandler.java b/source/de/anomic/soap/httpdSoapHandler.javaindex 707b60607..3f1024188 100644--- a/source/de/anomic/soap/httpdSoapHandler.java+++ b/source/de/anomic/soap/httpdSoapHandler.java@@ -86,6 +86,7 @@ import de.anomic.plasma.plasmaParser;import de.anomic.server.serverClassLoader;import de.anomic.server.serverCore;import de.anomic.server.serverFileUtils;+import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.logging.serverLog;@@ -158,11 +159,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http/* ===============================================================* Constants needed to set the SOAP message context- * =============================================================== */- /**- * CONSTANT: the http root path- */- public static final String MESSAGE_CONTEXT_HTTP_ROOT_PATH = "htRootPath";+ * =============================================================== *//*** CONSTANT: tge server switchboard*/@@ -172,13 +169,10 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http*/public static final String MESSAGE_CONTEXT_HTTP_HEADER = "httpHeader";/**- * CONSTANT: the server classloader- */- public static final String MESSAGE_CONTEXT_SERVER_CLASSLOADER = "serverClassLoader";- /**- * CONSTANT: available templates+ * CONSTANT: soap utility class*/- public static final String MESSAGE_CONTEXT_TEMPLATES = "templates";+ public static final String MESSAGE_CONTEXT_SERVER_CONTEXT = "serverContext";+/* ===============================================================* Other object fields@@ -341,7 +335,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http* =========================================================================== */try {if (contentEncoding != null && !contentEncoding.equals("identity")) {- if (contentEncoding.equalsIgnoreCase("gzip")) {+ if (contentEncoding.equalsIgnoreCase(httpHeader.CONTENT_ENCODING_GZIP)) {input = new GZIPInputStream(input);} else {String errorMsg = "Unsupported content encoding: " + contentEncoding;@@ -401,31 +395,42 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements httppublic void doGet(Properties conProp, httpHeader requestHeader, OutputStream response) throws IOException {MessageContext msgContext = null;String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);+try {// generating message contextmsgContext = this.generateMessageContext(path, requestHeader, conProp);-- // generating wsdl file- Document doc = generateWSDL(msgContext);-- if (doc != null) {- // TODO: what about doc.getInputEncoding()?- // TODO: what about getXmlEncoding?- // Converting the the wsdl document into a byte-array- String responseDoc = XMLUtils.DocumentToString(doc);- byte[] result = responseDoc.getBytes("UTF-8");-- // send back the result- sendMessage(conProp, requestHeader, response, 200, "OK", "text/xml; charset=utf-8", result);-- if (!(requestHeader.get(httpHeader.CONNECTION, "close").equals("keep-alive"))) {- // wait a little time until everything closes so that clients can read from the streams/sockets- try {Thread.currentThread().join(200);} catch (InterruptedException e) {/* ignore this */}- }- } else {- // if we where unable to generate the wsdl file ....- String errorMsg = "Internal Server Error: Unable to generate the WSDL file.";- sendMessage(conProp, requestHeader, response, 500, "Internal Error", "text/plain",errorMsg.getBytes("UTF-8"));++ if (path.equals("/soap/")) {+ serverObjects args = new serverObjects();+ args.put("SOAP.engine",httpdSoapHandler.engine);+ ServerContext sContext = (ServerContext) msgContext.getProperty(MESSAGE_CONTEXT_SERVER_CONTEXT);+ byte[] result = sContext.writeTemplate("soap/ServiceList.html", args, requestHeader);+ sendMessage(conProp, requestHeader, response, 200, "OK", "text/html; charset=utf-8", result);+ } else if (path.equals("/soap/favicon.ico")) {+ sendMessage(conProp, requestHeader, response, 404, "File not found", "text/plain",null);+ } else {+ // generating wsdl file+ Document doc = generateWSDL(msgContext);++ if (doc != null) {+ // TODO: what about doc.getInputEncoding()?+ // TODO: what about getXmlEncoding?+ // Converting the the wsdl document into a byte-array+ String responseDoc = XMLUtils.DocumentToString(doc);+ byte[] result = responseDoc.getBytes("UTF-8");++ // send back the result+ sendMessage(conProp, requestHeader, response, 200, "OK", "text/xml; charset=utf-8", result);++ if (!(requestHeader.get(httpHeader.CONNECTION, "close").equals("keep-alive"))) {+ // wait a little time until everything closes so that clients can read from the streams/sockets+ try {Thread.currentThread().join(200);} catch (InterruptedException e) {/* ignore this */}+ }+ } else {+ // if we where unable to generate the wsdl file ....+ String errorMsg = "Internal Server Error: Unable to generate the WSDL file.";+ sendMessage(conProp, requestHeader, response, 500, "Internal Error", "text/plain",errorMsg.getBytes("UTF-8"));+ }}return;@@ -630,14 +635,16 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http// the used http versonString version = conProps.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);msgContext.setProperty(MessageContext.HTTP_TRANSPORT_VERSION,version);-++ // generate the serverContext object+ ServerContext serverContext = new ServerContext(this.htRootPath.toString(),this.provider,this.templates,this.switchboard);+ msgContext.setProperty(MESSAGE_CONTEXT_SERVER_CONTEXT ,serverContext);+// YaCy specific objects- msgContext.setProperty(MESSAGE_CONTEXT_HTTP_ROOT_PATH ,this.htRootPath.toString());msgContext.setProperty(MESSAGE_CONTEXT_SERVER_SWITCH,this.switchboard);- msgContext.setProperty(MESSAGE_CONTEXT_HTTP_HEADER ,requestHeader);- msgContext.setProperty(MESSAGE_CONTEXT_SERVER_CLASSLOADER ,this.provider);- msgContext.setProperty(MESSAGE_CONTEXT_TEMPLATES ,this.templates);+ msgContext.setProperty(MESSAGE_CONTEXT_HTTP_HEADER ,requestHeader);+ // setting the service to executemsgContext.setTargetService(serviceName);return msgContext;@@ -727,7 +734,6 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements httpif (contentEncoding != null) bodyOut = gzipOut = new GZIPOutputStream(bodyOut);// sending the body- soapMessage.writeTo(System.out);soapMessage.writeTo(bodyOut);bodyOut.flush();diff --git a/source/de/anomic/soap/services/AdminService.java b/source/de/anomic/soap/services/AdminService.javaindex 0b0865959..5b76f9b58 100644--- a/source/de/anomic/soap/services/AdminService.java+++ b/source/de/anomic/soap/services/AdminService.java@@ -246,7 +246,7 @@ public class AdminService extends AbstractService {extractMessageContext(AUTHENTICATION_NEEDED);// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_CONFIG_XML, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_CONFIG_XML, new serverObjects(),this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -271,7 +271,7 @@ public class AdminService extends AbstractService {extractMessageContext(AUTHENTICATION_NEEDED);// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_VERSION_XML, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_VERSION_XML, new serverObjects(), this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -795,7 +795,7 @@ public class AdminService extends AbstractService {args.put(PEER_HASH,peerhash);// invoke servlet- serverObjects tp = invokeServlet(TEMPLATE_PROFILE_XML,args);+ serverObjects tp = this.serverContext.invokeServlet(TEMPLATE_PROFILE_XML,args, this.requestHeader);// query statusif (tp.containsKey(PEER_PROFILE_FETCH_SUCCESS)) {@@ -809,7 +809,7 @@ public class AdminService extends AbstractService {// generate output- byte[] result = buildServletOutput(TEMPLATE_PROFILE_XML, tp);+ byte[] result = this.serverContext.buildServletOutput(TEMPLATE_PROFILE_XML, tp);// sending back the result to the clientreturn this.convertContentToXML(result);diff --git a/source/de/anomic/soap/services/BlacklistService.java b/source/de/anomic/soap/services/BlacklistService.javaindex 43261c022..c3dabb6fa 100644--- a/source/de/anomic/soap/services/BlacklistService.java+++ b/source/de/anomic/soap/services/BlacklistService.java@@ -113,7 +113,7 @@ public class BlacklistService extends AbstractService {extractMessageContext(AUTHENTICATION_NEEDED);// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_BLACKLIST_XML, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_BLACKLIST_XML, new serverObjects(), this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);diff --git a/source/de/anomic/soap/services/BookmarkService.java b/source/de/anomic/soap/services/BookmarkService.javaindex 8abe98238..dfed25a43 100644--- a/source/de/anomic/soap/services/BookmarkService.java+++ b/source/de/anomic/soap/services/BookmarkService.java@@ -418,7 +418,7 @@ public class BookmarkService extends AbstractService {if (tag != null) args.put("tag",tag);if (date != null) args.put("date",date);- byte[] result = writeTemplate((date != null)?TEMPLATE_BOOKMARK_LIST_GET_XML:TEMPLATE_BOOKMARK_LIST_ALL_XML, args);+ byte[] result = this.serverContext.writeTemplate((date != null)?TEMPLATE_BOOKMARK_LIST_GET_XML:TEMPLATE_BOOKMARK_LIST_ALL_XML, args, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -446,7 +446,7 @@ public class BookmarkService extends AbstractService {extractMessageContext(AUTHENTICATION_NEEDED);// generate the xml document- byte[] result = writeTemplate(TEMPLATE_BOOKMARK_TAGS_XML, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_BOOKMARK_TAGS_XML, new serverObjects(), this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);diff --git a/source/de/anomic/soap/services/CrawlService.java b/source/de/anomic/soap/services/CrawlService.javaindex b053a9ac9..e856f92b9 100644--- a/source/de/anomic/soap/services/CrawlService.java+++ b/source/de/anomic/soap/services/CrawlService.java@@ -117,7 +117,7 @@ public class CrawlService extends AbstractService {args.put("xsstopw",xsstopw.booleanValue()?"on":"off");// triggering the crawling- byte[] result = writeTemplate(TEMPLATE_CRAWLING, args);+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_CRAWLING, args, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);diff --git a/source/de/anomic/soap/services/MessageService.java b/source/de/anomic/soap/services/MessageService.javaindex a180f19a9..0fdcadc5d 100644--- a/source/de/anomic/soap/services/MessageService.java+++ b/source/de/anomic/soap/services/MessageService.java@@ -139,7 +139,7 @@ public class MessageService extends AbstractService {serverObjects args = new serverObjects();args.put("action","list");- byte[] result = writeTemplate(TEMPLATE_MESSAGE_HEADER_LIST_XML, args);+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_MESSAGE_HEADER_LIST_XML, args, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -173,7 +173,7 @@ public class MessageService extends AbstractService {args.put("action","view");args.put("object",messageID);- byte[] result = writeTemplate(TEMPLATE_MESSAGE_HEADER_LIST_XML, args);+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_MESSAGE_HEADER_LIST_XML, args, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);diff --git a/source/de/anomic/soap/services/SearchService.java b/source/de/anomic/soap/services/SearchService.javaindex cd0a321f9..bdee1db99 100644--- a/source/de/anomic/soap/services/SearchService.java+++ b/source/de/anomic/soap/services/SearchService.java@@ -156,7 +156,7 @@ public class SearchService extends AbstractServiceargs.put("Enter","Search");// invoke servlet- serverObjects searchResult = invokeServlet(TEMPLATE_SEARCH, args);+ serverObjects searchResult = this.serverContext.invokeServlet(TEMPLATE_SEARCH, args, this.requestHeader);// Postprocess search ...int count = Integer.valueOf(searchResult.get("type_results","0")).intValue();@@ -167,7 +167,7 @@ public class SearchService extends AbstractService}// format the result- byte[] result = buildServletOutput(TEMPLATE_SEARCH, searchResult);+ byte[] result = this.serverContext.buildServletOutput(TEMPLATE_SEARCH, searchResult);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -233,7 +233,7 @@ public class SearchService extends AbstractServiceargs.put("viewMode",viewModeStr);// generating the template containing the url info- byte[] result = writeTemplate(TEMPLATE_URLINFO, args);+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_URLINFO, args, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -256,7 +256,7 @@ public class SearchService extends AbstractServiceargs.put("search",searchString);// generating the template containing the url info- byte[] result = writeTemplate(TEMPLATE_SNIPPET, args);+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_SNIPPET, args, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -297,7 +297,7 @@ public class SearchService extends AbstractServiceextractMessageContext(false);// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_OPENSEARCH, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_OPENSEARCH, new serverObjects(), this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);diff --git a/source/de/anomic/soap/services/ShareService.java b/source/de/anomic/soap/services/ShareService.javaindex 6bda810c3..1fc2f43df 100644--- a/source/de/anomic/soap/services/ShareService.java+++ b/source/de/anomic/soap/services/ShareService.java@@ -274,7 +274,7 @@ public class ShareService extends AbstractService {private String yacyhURL(yacySeed seed, String filename, String md5) throws AxisFault {try {// getting the template class file- Class c = this.provider.loadClass(getServletClassFile(TEMPLATE_SHARE_XML));+ Class c = this.serverContext.getProvider().loadClass(this.serverContext.getServletClassFile(TEMPLATE_SHARE_XML));Method m = c.getMethod("yacyhURL", new Class[]{yacySeed.class,String.class,String.class});// invoke the desired method@@ -287,7 +287,7 @@ public class ShareService extends AbstractService {private void indexPhrase(String urlstring, String phrase, String descr, byte[] md5) throws AxisFault {try {// getting the template class file- Class c = this.provider.loadClass(getServletClassFile(TEMPLATE_SHARE_XML));+ Class c = this.serverContext.getProvider().loadClass(this.serverContext.getServletClassFile(TEMPLATE_SHARE_XML));Method m = c.getMethod("indexPhrase", new Class[]{plasmaSwitchboard.class,String.class,String.class,String.class,byte[].class});// invoke the desired method@@ -300,7 +300,7 @@ public class ShareService extends AbstractService {private void deletePhrase(String urlstring, String phrase, String descr) throws AxisFault {try {// getting the template class file- Class c = this.provider.loadClass(getServletClassFile(TEMPLATE_SHARE_XML));+ Class c = this.serverContext.getProvider().loadClass(this.serverContext.getServletClassFile(TEMPLATE_SHARE_XML));Method m = c.getMethod("deletePhrase", new Class[]{plasmaSwitchboard.class,String.class,String.class,String.class});// invoke the desired method@@ -336,7 +336,7 @@ public class ShareService extends AbstractService {this.requestHeader.put("PATH",workingDirPath);// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_SHARE_XML, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_SHARE_XML, new serverObjects(), this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);diff --git a/source/de/anomic/soap/services/StatusService.java b/source/de/anomic/soap/services/StatusService.javaindex 153bf3ae7..67fb6fa6d 100644--- a/source/de/anomic/soap/services/StatusService.java+++ b/source/de/anomic/soap/services/StatusService.java@@ -74,7 +74,7 @@ public class StatusService extends AbstractService {extractMessageContext(NO_AUTHENTICATION);// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_NETWORK_XML, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_NETWORK_XML, new serverObjects(), this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -135,7 +135,7 @@ public class StatusService extends AbstractService {if (details) args.put("ip","1");// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_NETWORK_XML, args);+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_NETWORK_XML, args, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -180,7 +180,7 @@ public class StatusService extends AbstractService {// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_QUEUES_XML, input);+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_QUEUES_XML, input, this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);@@ -196,7 +196,7 @@ public class StatusService extends AbstractService {extractMessageContext(AUTHENTICATION_NEEDED);// generating the template containing the network status information- byte[] result = writeTemplate(TEMPLATE_STATUS_XML, new serverObjects());+ byte[] result = this.serverContext.writeTemplate(TEMPLATE_STATUS_XML, new serverObjects(), this.requestHeader);// sending back the result to the clientreturn this.convertContentToXML(result);