X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2FOpenMir.java;h=8a8bb9a70fc97d5d9abcd9d8ce04cd1626c4108c;hb=b331354bb6eddeca54e290810841b6d9bc4095af;hp=37b4d8a72132581f59449f355af50155df4a6874;hpb=86b6f499b413c722acc895346ac5186405b0c44c;p=mir.git diff --git a/source/OpenMir.java b/source/OpenMir.java index 37b4d8a7..8a8bb9a7 100755 --- a/source/OpenMir.java +++ b/source/OpenMir.java @@ -26,7 +26,7 @@ import mircoders.storage.*; public class OpenMir extends AbstractServlet { - private static boolean confed=false; + //private static boolean confed=false; private static String lang; public HttpSession session; @@ -41,38 +41,61 @@ public class OpenMir extends AbstractServlet { long startTime = (new java.util.Date()).getTime(); long sessionConnectTime=0; - - if (!confed){ - confed = getConfig(req); + // get the configration - this could conflict if 2 mirs are in the + // VM maybe? to be checked. -mh + if(getServletContext().getAttribute("mir.confed") == null) { + getConfig(req); } - session = req.getSession(); if(session.getAttribute("Language")==null){ setLanguage(session,getAcceptLanguage(req)); } - res.setContentType("text/html"); + res.setContentType("text/html; charset=" + +MirConfig.getProp("Mir.DefaultEncoding")); try { ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res); } + catch (ServletModuleUserException e) { + handleUserError(req,res,res.getWriter(), e.getMsg()); + } catch (ServletModuleException e){ e.printStackTrace(); - handleError(res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); + handleError(req,res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); } // timing... sessionConnectTime = new java.util.Date().getTime() - startTime; theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms"); } - private void handleError(HttpServletResponse res,PrintWriter out, String errorString) { - + private void handleUserError(HttpServletRequest req, HttpServletResponse res, + PrintWriter out, String errorString) { try { theLog.printError(errorString); SimpleHash modelRoot = new SimpleHash(); modelRoot.put("errorstring", new SimpleScalar(errorString)); modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar()))); - HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.ErrorTemplate"),modelRoot,out); + HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.UserErrorTemplate"), + modelRoot, out, req.getLocale() ); + out.close(); + } + catch (Exception e) { + System.err.println("Fehler in UserErrorTemplate"); + } + + } + + private void handleError(HttpServletRequest req, HttpServletResponse res,PrintWriter out, String errorString) { + + try { + theLog.printError(errorString); + SimpleHash modelRoot = new SimpleHash(); + modelRoot.put("errorstring", new SimpleScalar(errorString)); + modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime( + new GregorianCalendar()))); + HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.ErrorTemplate"), + modelRoot,out, req.getLocale()); out.close(); } catch (Exception e) { @@ -81,7 +104,9 @@ public class OpenMir extends AbstractServlet { } - public String getServletInfo(){ return "OpenIndy 1.0 rev01"; } + public String getServletInfo(){ + return "OpenMir "+MirConfig.getProp("Mir.Version"); + } }