multi-language support
[pnews.git] / war / src / main / java / pnews / servlet / Pnews.java
index 94475f9..4003fed 100644 (file)
@@ -174,7 +174,7 @@ public class Pnews extends HttpServlet {
                 }
 
                 if (path.equals("/")) {
-                        doTemporaryRedirect(Language.toURL(config.getDefaultLanguage()), resp);
+                        doTemporaryRedirect(config.getDefaultLanguage().toURL(), resp);
                         return ;
                 }
 
@@ -191,16 +191,16 @@ public class Pnews extends HttpServlet {
                                 }
                         }
                         
-                        for (String l: config.getLanguages()) {
-                                if (path.equals("/" + l) || path.equals("/" + l + "/")) {
-                                        doTemporaryRedirect(config.getDefaultCategory().getURL(), resp);
+                        for (Language l: config.getLanguages()) {
+                                if (path.equals(l.toURL())) {
+                                        doTemporaryRedirect(config.getDefaultCategory(l).getURL(), resp);
                                         return ;
                                 }
                         }
                 
                         resp.getWriter().write("Not found " + req.getPathInfo());
                         resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
-                } catch (IOException e) {
+                } catch (IOException | RuntimeException e) {
                         LOG.log(Level.SEVERE, "doGet failure", e);
                         resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                 }