Skip to content

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

*) adding new sendRespondError method to httpd which accepts a template include file for individual error messages

thelia9e25c26e136
diff --git a/htroot/proxymsg/error.html b/htroot/proxymsg/error.html
index 7f4dab6cf..4ae8f963f 100644
--- a/htroot/proxymsg/error.html
+++ b/htroot/proxymsg/error.html
@@ -9,7 +9,7 @@
<meta name="copyright" content="Michael Christen">
<base href="http://#[host]#:#[port]#/">
-<link rel="stylesheet" media="all" href="http://#[host]#:#[port]#/env/style.css">
+<link rel="stylesheet" media="all" href="/env/style.css">
<!-- (C), Architecture and Realisation: Michael Peter Christen; Contact: mc <at> anomic.de -->
@@ -21,7 +21,7 @@
<tr height="36">
<td width="240">
<a href="http://www.yacy.net">
- <img width="52" height="33" border="0" src="http://#[host]#:#[port]#//env/grafics/yacy.gif" align="top">
+ <img width="52" height="33" border="0" src="/env/grafics/yacy.gif" align="top">
</a>
</td>
<td width="50%" align="center">
@@ -56,7 +56,7 @@
::<!-- 4 -->
#[detailedErrorMsg]#
::<!-- 5 -->
- Your Internet-Timelimit is reached.
+ #%[file]%#
#(/errorMessageType)#
</b>
</p>
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index c32c0192b..236b4724c 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -963,6 +963,7 @@ public final class httpd implements serverHandler {
respond.flush();
}
+
public static final void sendRespondError(
Properties conProp,
OutputStream respond,
@@ -972,6 +973,50 @@ public final class httpd implements serverHandler {
String detailedErrorMsg,
Exception stackTrace
) throws IOException {
+ sendRespondError(
+ conProp,
+ respond,
+ errorcase,
+ httpStatusCode,
+ httpStatusText,
+ detailedErrorMsg,
+ null,
+ stackTrace
+ );
+ }
+
+ public static final void sendRespondError(
+ Properties conProp,
+ OutputStream respond,
+ int errorcase,
+ int httpStatusCode,
+ String httpStatusText,
+ File detailedErrorMsgFile,
+ HashMap detailedErrorMsgValues,
+ Exception stackTrace
+ ) throws IOException {
+ sendRespondError(
+ conProp,
+ respond,
+ errorcase,
+ httpStatusCode,
+ httpStatusText,
+ detailedErrorMsgFile,
+ detailedErrorMsgValues,
+ stackTrace
+ );
+ }
+
+ private static final void sendRespondError(
+ Properties conProp,
+ OutputStream respond,
+ int errorcase,
+ int httpStatusCode,
+ String httpStatusText,
+ Object detailedErrorMsg,
+ HashMap detailedErrorMsgValues,
+ Exception stackTrace
+ ) throws IOException {
FileInputStream fis = null;
ByteArrayOutputStream o = null;
@@ -1036,7 +1081,28 @@ public final class httpd implements serverHandler {
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD));
tp.put("requestURL", urlString);
- tp.put("errorMessageType_detailedErrorMsg",(detailedErrorMsg != null) ? detailedErrorMsg : "");
+
+ if (detailedErrorMsg == null ) {
+ if (errorcase == 4)
+ tp.put("errorMessageType_detailedErrorMsg","");
+ else if (errorcase == 5)
+ tp.put("errorMessageType_file","");
+ } else {
+ if (detailedErrorMsg instanceof String ) {
+ tp.put("errorMessageType_detailedErrorMsg",detailedErrorMsg);
+ } else if (detailedErrorMsg instanceof File) {
+ tp.put("errorMessageType_file",detailedErrorMsg);
+
+ if ((detailedErrorMsgValues != null)&&(detailedErrorMsgValues.size()>0)) {
+ // rewriting the value-names and add the proper name prefix:
+ Iterator nameIter = detailedErrorMsgValues.keySet().iterator();
+ while (nameIter.hasNext()) {
+ String name = (String) nameIter.next();
+ tp.put("errorMessageType_" + name,detailedErrorMsgValues.get(name));
+ }
+ }
+ }
+ }
// building the stacktrace
if (stackTrace != null) {