X-Git-Url: https://wpitchoune.net/gitweb/?a=blobdiff_plain;f=war%2Fsrc%2Fmain%2Fjava%2Fpnews%2Fservlet%2FPnews.java;h=029f3c76f0dfc50e02b6b4f1e94412220e045435;hb=47bc9d3dc6b3cf77957f11bceea1bcda492f8818;hp=57ea4be6accb90f0553dece7ec464dc53a0a1702;hpb=6f411daf8bfd05580744e3c46a8c1497e8cd7898;p=pnews.git diff --git a/war/src/main/java/pnews/servlet/Pnews.java b/war/src/main/java/pnews/servlet/Pnews.java index 57ea4be..029f3c7 100644 --- a/war/src/main/java/pnews/servlet/Pnews.java +++ b/war/src/main/java/pnews/servlet/Pnews.java @@ -22,6 +22,7 @@ import com.rometools.rome.io.FeedException; import pnews.Article; import pnews.Category; +import pnews.Language; public class Pnews extends HttpServlet { private static final String CLASS_NAME = Pnews.class.getName(); @@ -111,13 +112,13 @@ public class Pnews extends HttpServlet { try { articles = provider.getArticles(cat); if (articles != null) { - html = HTML.toHTML(articles, cat, config.getCategories()); + html = HTML.toHTML(articles, cat, config); rp.setContentType("text/html;charset=utf-8"); rp.getWriter().write(html); rp.setCharacterEncoding("utf-8"); } else { LOG.severe("writeArticles cannot retrieve any articles"); - html = HTML.toHTML(new ArrayList
(), cat, config.getCategories()); + html = HTML.toHTML(new ArrayList
(), cat, config); rp.setContentType("text/html"); rp.getWriter().write(html); } @@ -173,7 +174,7 @@ public class Pnews extends HttpServlet { } if (path.equals("/")) { - writeArticles(config.getDefaultCategory(), resp); + doTemporaryRedirect(config.getDefaultLanguage().toURL(), resp); return ; } @@ -190,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); }