Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) Bugfix wrong chars in soap search result document See: http://www.yacy-forum.de/viewtopic.php?t=2906

theli96f45e9b1565
diff --git a/source/de/anomic/soap/AbstractService.java b/source/de/anomic/soap/AbstractService.java
index 16c761d38..cb44f0928 100644
--- a/source/de/anomic/soap/AbstractService.java
+++ b/source/de/anomic/soap/AbstractService.java
@@ -108,37 +108,85 @@ public abstract class AbstractService {
* @return
* @throws AxisFault
*/
- protected byte[] writeTemplate(String templateName, serverObjects args)
- throws AxisFault {
+ protected byte[] writeTemplate(String templateName, serverObjects args) throws AxisFault {
try {
- // determining the proper class that should be invoked
- File file = new File(this.rootPath, templateName);
- File rc = rewriteClassFile(file);
+ // invoke servlet
+ serverObjects tp = invokeServlet(templateName,args);
- // 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);
-
- // generating the output document
- ByteArrayOutputStream o = new ByteArrayOutputStream();
- FileInputStream fis = new FileInputStream(file);
- 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();
+ // generate output
+ byte[] result = buildServletOutput(templateName, tp);
return result;
} catch (Exception e) {
- throw new AxisFault(e.getMessage());
+ 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;
+
+ // 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
diff --git a/source/de/anomic/soap/httpdSoapHandler.java b/source/de/anomic/soap/httpdSoapHandler.java
index 280e14693..da4b9a8d1 100644
--- a/source/de/anomic/soap/httpdSoapHandler.java
+++ b/source/de/anomic/soap/httpdSoapHandler.java
@@ -145,7 +145,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
public static final String[] services = new String[] {
"search=de.anomic.soap.services.SearchService",
"crawl=de.anomic.soap.services.CrawlService",
- "status=de.anomic.soap.services.StatusSevice"
+ "status=de.anomic.soap.services.StatusService"
};
/* ===============================================================
diff --git a/source/de/anomic/soap/services/SearchService.java b/source/de/anomic/soap/services/SearchService.java
index dd4dd5cf2..7d009a402 100644
--- a/source/de/anomic/soap/services/SearchService.java
+++ b/source/de/anomic/soap/services/SearchService.java
@@ -48,6 +48,7 @@ package de.anomic.soap.services;
import org.apache.axis.AxisFault;
import org.w3c.dom.Document;
+import de.anomic.data.wikiCode;
import de.anomic.index.indexURL;
import de.anomic.net.URL;
import de.anomic.plasma.plasmaSearchPreOrder;
@@ -153,8 +154,19 @@ public class SearchService extends AbstractService
args.put("Enter","Search");
- // generating the template containing the search result
- byte[] result = writeTemplate(TEMPLATE_SEARCH, args);
+ // invoke servlet
+ serverObjects searchResult = invokeServlet(TEMPLATE_SEARCH, args);
+
+ // Postprocess search ...
+ int count = Integer.valueOf(searchResult.get("type_results","0")).intValue();
+ for (int i=0; i < count; i++) {
+ searchResult.put("type_results_" + i + "_url",wikiCode.replaceHTMLonly(searchResult.get("type_results_" + i + "_url","")));
+ searchResult.put("type_results_" + i + "_description",wikiCode.replaceHTMLonly(searchResult.get("type_results_" + i + "_description","")));
+ searchResult.put("type_results_" + i + "_urlnamen",wikiCode.replaceHTMLonly(searchResult.get("type_results_" + i + "_urlname","")));
+ }
+
+ // format the result
+ byte[] result = buildServletOutput(TEMPLATE_SEARCH, searchResult);
// sending back the result to the client
return this.convertContentToXML(result);