*) adding new sendRespondError method to httpd which accepts a template include file

for individual error messages

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@902 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent 5605cc8018
commit a9e25c26e1

@ -9,7 +9,7 @@
<meta name="copyright" content="Michael Christen"> <meta name="copyright" content="Michael Christen">
<base href="http://#[host]#:#[port]#/"> <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 --> <!-- (C), Architecture and Realisation: Michael Peter Christen; Contact: mc <at> anomic.de -->
@ -21,7 +21,7 @@
<tr height="36"> <tr height="36">
<td width="240"> <td width="240">
<a href="http://www.yacy.net"> <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> </a>
</td> </td>
<td width="50%" align="center"> <td width="50%" align="center">
@ -56,7 +56,7 @@
::<!-- 4 --> ::<!-- 4 -->
#[detailedErrorMsg]# #[detailedErrorMsg]#
::<!-- 5 --> ::<!-- 5 -->
Your Internet-Timelimit is reached. #%[file]%#
#(/errorMessageType)# #(/errorMessageType)#
</b> </b>
</p> </p>

@ -963,6 +963,7 @@ public final class httpd implements serverHandler {
respond.flush(); respond.flush();
} }
public static final void sendRespondError( public static final void sendRespondError(
Properties conProp, Properties conProp,
OutputStream respond, OutputStream respond,
@ -972,6 +973,50 @@ public final class httpd implements serverHandler {
String detailedErrorMsg, String detailedErrorMsg,
Exception stackTrace Exception stackTrace
) throws IOException { ) 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; FileInputStream fis = null;
ByteArrayOutputStream o = null; ByteArrayOutputStream o = null;
@ -1036,7 +1081,28 @@ public final class httpd implements serverHandler {
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText); tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD)); tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD));
tp.put("requestURL", urlString); 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 // building the stacktrace
if (stackTrace != null) { if (stackTrace != null) {

Loading…
Cancel
Save