1 package info.magnolia.cms.servlets; 2 3 import info.magnolia.cms.gui.misc.Sources; 4 import info.magnolia.cms.i18n.MessagesManager; 5 6 import java.io.IOException ; 7 import java.io.PrintWriter ; 8 import java.text.SimpleDateFormat ; 9 import java.util.Date ; 10 11 import javax.servlet.ServletException ; 12 import javax.servlet.http.HttpServlet ; 13 import javax.servlet.http.HttpServletRequest ; 14 import javax.servlet.http.HttpServletResponse ; 15 16 17 21 public class ReloadI18nServlet extends HttpServlet { 22 23 26 private static final long serialVersionUID = 222L; 27 28 31 private static final String PARAM_RELOAD_ACTION = "reload"; 33 36 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { 37 PrintWriter out = response.getWriter(); 38 displayReloadForm(request, out); 39 out.flush(); 40 out.close(); 41 } 42 43 47 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException , 48 IOException { 49 PrintWriter out = response.getWriter(); 50 displayReloadForm(request, out); 51 out.println("----------------------<br/>"); executeReload(request, out); 53 out.flush(); 54 out.close(); 55 } 56 57 private void executeReload(HttpServletRequest request, PrintWriter out) { 58 try { 59 MessagesManager.getMessages(request, null, MessagesManager.getDefaultLocale()).reloadBundles(); 60 out 61 .println(MessagesManager.get(request, "reloadi18n.reloaded") + ":" + new SimpleDateFormat ().format(new Date ()) + "<br><br>"); } 63 catch (Exception e) { 64 out.println(MessagesManager.get(request, "reloadi18n.error") + "<br/><br/>"); } 66 67 } 68 69 75 private void displayReloadForm(HttpServletRequest request, PrintWriter out) { 76 77 out.println("<html><head><title>Magnolia</title>"); out.println(new Sources(request.getContextPath()).getHtmlCss()); 79 out.println("</head><body class=\"mgnlBgLight mgnlImportExport\">"); 81 out.println("<h2>"); out.println(MessagesManager.get(request, "reloadi18n.title")); out.println("</h2>"); out.println("<form method=\"post\" action=\"\">"); 86 out.println("<input type=\"submit\" name=\"" + PARAM_RELOAD_ACTION + "\" value=\"" + MessagesManager.get(request, "reloadi18n.action") + "\" />"); 91 out.println("</form></body></html>"); } 93 } 94 | Popular Tags |