summaryrefslogtreecommitdiff
path: root/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/WebappErrorHandler.java
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2011-08-18 15:04:09 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2011-08-18 15:04:09 +0000
commit0bba8c08d29aa16cdba91e25fcf3ba754800993b (patch)
tree9cfed62635b0976c3d2796c2a2f1bc943270b301 /BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/WebappErrorHandler.java
parent4800d1a9e2d8b90f81a95662ace7aa6e7bee32cd (diff)
downloadmocca-0bba8c08d29aa16cdba91e25fcf3ba754800993b.tar.gz
mocca-0bba8c08d29aa16cdba91e25fcf3ba754800993b.tar.bz2
mocca-0bba8c08d29aa16cdba91e25fcf3ba754800993b.zip
Help update: Show specific 404 pages
* Locale-dependent * 404h.html if page not found was a help page * 404.html else git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@956 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/WebappErrorHandler.java')
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/WebappErrorHandler.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/WebappErrorHandler.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/WebappErrorHandler.java
new file mode 100644
index 00000000..c11f5345
--- /dev/null
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/WebappErrorHandler.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2011 by Graz University of Technology, Austria
+ * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint
+ * initiative of the Federal Chancellery Austria and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+package at.gv.egiz.bku.webstart;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.mortbay.jetty.HttpConnection;
+import org.mortbay.jetty.HttpMethods;
+import org.mortbay.jetty.servlet.ErrorPageErrorHandler;
+import org.mortbay.jetty.servlet.ServletHandler;
+
+/**
+ * @author tkellner_local
+ *
+ */
+public class WebappErrorHandler extends ErrorPageErrorHandler {
+ private String link404, link404help;
+
+ public WebappErrorHandler(Locale locale) {
+ super();
+
+ link404 = "/help/404.html";
+ link404help = "/help/404h.html";
+ if (locale != null)
+ {
+ String language = locale.getLanguage();
+ if (!language.isEmpty())
+ {
+ link404 = "/help/" + language + "/404.html";
+ link404help = "/help/" + language + "/404h.html";
+ }
+ }
+ }
+
+ @Override
+ public void handle(String target, HttpServletRequest request,
+ HttpServletResponse response, int dispatch) throws IOException {
+ String method = request.getMethod();
+ if(!method.equals(HttpMethods.GET) && !method.equals(HttpMethods.POST))
+ {
+ HttpConnection.getCurrentConnection().getRequest().setHandled(true);
+ return;
+ }
+
+ Integer code=(Integer)request.getAttribute(ServletHandler.__J_S_ERROR_STATUS_CODE);
+ if (code.equals(404))
+ {
+ HttpConnection.getCurrentConnection().getRequest().setHandled(true);
+ response.sendRedirect(request.getRequestURI().startsWith("/help") ? link404help : link404);
+ return;
+ }
+
+ super.handle(target, request, response, dispatch);
+ }
+}