tuning full production of content
[mir.git] / source / OpenMir.java
index 4b1d178..96820b2 100755 (executable)
@@ -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;
 
@@ -42,10 +42,11 @@ public class OpenMir extends AbstractServlet {
     long            sessionConnectTime=0;
 
     
-    if (!confed){
-      confed = getConfig(req);
-    }
     
+    // get the configration
+    if(getServletContext().getAttribute("mir.confed") == null) {
+      getConfig(req);
+    }
     session = req.getSession();
 
     if(session.getAttribute("Language")==null){
@@ -56,6 +57,9 @@ public class OpenMir extends AbstractServlet {
     try {
       ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
     }
+    catch (ServletModuleUserException e) {
+      handleUserError(res,res.getWriter(), e.getMsg());  
+    }
     catch (ServletModuleException e){
       e.printStackTrace();
       handleError(res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString());
@@ -65,6 +69,22 @@ public class OpenMir extends AbstractServlet {
     theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
   }
 
+  private void handleUserError(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.UserErrorTemplate"),modelRoot,out);
+      out.close();
+    }
+    catch (Exception e) {
+      System.err.println("Fehler in UserErrorTemplate");
+    }
+
+  }
+
   private void handleError(HttpServletResponse res,PrintWriter out, String errorString) {
 
     try {
@@ -72,7 +92,7 @@ public class OpenMir extends AbstractServlet {
       SimpleHash modelRoot = new SimpleHash();
       modelRoot.put("errorstring", new SimpleScalar(errorString));
       modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
-      HTMLTemplateProcessor.process(res,Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
+      HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.ErrorTemplate"),modelRoot,out);
       out.close();
     }
     catch (Exception e) {