Initial revision
[mir.git] / source / OpenMir.java
1 import java.io.*;
2 import java.util.*;
3 import java.net.*;
4 import java.lang.reflect.*;
5 import javax.servlet.*;
6 import javax.servlet.http.*;
7 import java.sql.*;
8
9 import freemarker.template.*;
10
11 import webdb.misc.*;
12 import webdb.servlet.*;
13
14 import mir.servlet.*;
15 import mir.module.*;
16 import mir.entity.*;
17 import mir.storage.*;
18
19 /**
20  *  OpenMir.java - main servlet for open posting and comment feature to articles
21  *
22  *  @author RK 1999-2001
23  *
24  */
25
26
27 public class OpenMir extends AbstractServlet
28 {
29         private static Logfile                theLog;
30         private static boolean                confed=false;
31         private static String   lang;
32
33         public void doGet(HttpServletRequest req, HttpServletResponse res)
34                 throws ServletException, IOException {
35                 doPost(req,res);
36         }
37
38         public void doPost(HttpServletRequest req, HttpServletResponse res)
39                 throws ServletException, IOException {
40
41                 long            startTime = (new java.util.Date()).getTime();
42                 long            sessionConnectTime=0;
43
44     if (!confed){
45       confed = getConfig(req);
46     }
47
48                 HttpSession session = req.getSession(true);
49     if(session.getAttribute("Language")==null){
50       setLanguage(req,getAcceptLanguage(req));
51     }
52
53                 res.setContentType("text/html");
54                 try {
55                         ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
56                 }
57                 catch (ServletModuleException e){ handleError(res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); }
58                 // timing...
59                 sessionConnectTime = new java.util.Date().getTime() - startTime;
60                 theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
61         }
62
63         private void handleError(PrintWriter out, String errorString) {
64
65                 try {
66                         theLog.printError(errorString);
67                         SimpleHash modelRoot = new SimpleHash();
68                         modelRoot.put("errorstring", new SimpleScalar(errorString));
69                         modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
70                         HTMLTemplateProcessor.process(Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
71                         out.close();
72                 }
73                 catch (Exception e) {
74                         System.err.println("Fehler in ErrorTemplate");
75                 }
76
77         }
78
79         public String getServletInfo(){ return "OpenIndy 1.0 rev01"; }
80
81 }
82