*) Bugfix wrong chars in soap search result document

See: http://www.yacy-forum.de/viewtopic.php?t=2906

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2791 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent 6d1db21d0b
commit 96f45e9b15

@ -108,25 +108,29 @@ public abstract class AbstractService {
* @return * @return
* @throws AxisFault * @throws AxisFault
*/ */
protected byte[] writeTemplate(String templateName, serverObjects args) protected byte[] writeTemplate(String templateName, serverObjects args) throws AxisFault {
throws AxisFault {
try { try {
// determining the proper class that should be invoked // invoke servlet
File file = new File(this.rootPath, templateName); serverObjects tp = invokeServlet(templateName,args);
File rc = rewriteClassFile(file);
// invoke the desired method // generate output
serverObjects tp = (serverObjects) rewriteMethod(rc).invoke(null, new Object[] {this.requestHeader, args, this.switchboard}); byte[] result = buildServletOutput(templateName, tp);
return result;
} catch (Exception e) {
if (e instanceof AxisFault) throw (AxisFault) e;
// testing if a authentication was needed by the invoked method // create a new AxisFault Object
validateAuthentication(tp); throw new AxisFault(e.getMessage());
}
}
// adding all available templates protected byte[] buildServletOutput(String templateName, serverObjects tp) throws AxisFault {
tp.putAll(this.templates); try {
File templateFile = getTemplateFile(templateName);
// generating the output document // generating the output document
ByteArrayOutputStream o = new ByteArrayOutputStream(); ByteArrayOutputStream o = new ByteArrayOutputStream();
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(templateFile);
httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8")); httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
o.close(); o.close();
fis.close(); fis.close();
@ -135,10 +139,54 @@ public abstract class AbstractService {
byte[] result = o.toByteArray(); byte[] result = o.toByteArray();
return result; return result;
} catch (Exception e) { } 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()); 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 * This function is used to test if an invoked method requires authentication

@ -145,7 +145,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
public static final String[] services = new String[] { public static final String[] services = new String[] {
"search=de.anomic.soap.services.SearchService", "search=de.anomic.soap.services.SearchService",
"crawl=de.anomic.soap.services.CrawlService", "crawl=de.anomic.soap.services.CrawlService",
"status=de.anomic.soap.services.StatusSevice" "status=de.anomic.soap.services.StatusService"
}; };
/* =============================================================== /* ===============================================================

@ -48,6 +48,7 @@ package de.anomic.soap.services;
import org.apache.axis.AxisFault; import org.apache.axis.AxisFault;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import de.anomic.data.wikiCode;
import de.anomic.index.indexURL; import de.anomic.index.indexURL;
import de.anomic.net.URL; import de.anomic.net.URL;
import de.anomic.plasma.plasmaSearchPreOrder; import de.anomic.plasma.plasmaSearchPreOrder;
@ -153,8 +154,19 @@ public class SearchService extends AbstractService
args.put("Enter","Search"); args.put("Enter","Search");
// generating the template containing the search result // invoke servlet
byte[] result = writeTemplate(TEMPLATE_SEARCH, args); 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 // sending back the result to the client
return this.convertContentToXML(result); return this.convertContentToXML(result);

Loading…
Cancel
Save