get rid of deprecated makeSimpleList and makeSimpleHash usage. this should be it...
[mir.git] / source / mircoders / servlet / ServletModuleBreaking.java
1 package mircoders.servlet;
2
3 import java.io.*;
4 import java.net.*;
5 import javax.servlet.http.*;
6 import javax.servlet.*;
7 import freemarker.template.*;
8 import mir.servlet.*;
9 import mir.misc.*;
10 import mir.entity.*;
11 import mir.storage.*;
12 import mir.module.*;
13 import mircoders.module.*;
14 import mircoders.storage.*;
15
16 /*
17  *  ServletModuleBreaking -
18  *  Authentified Navigation for Breaking News
19  *
20  *
21  */
22
23 public class ServletModuleBreaking extends ServletModule
24 {
25
26         // Singelton / Kontruktor
27
28         private static ServletModuleBreaking instance = new ServletModuleBreaking();
29         public static ServletModule getInstance() { return instance; }
30
31         private ServletModuleBreaking() {
32
33                 theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Breaking.Logfile"));
34                 templateListString = MirConfig.getProp("ServletModule.Breaking.ListTemplate");
35                 templateObjektString = MirConfig.getProp("ServletModule.Breaking.ObjektTemplate");
36                 templateConfirmString = MirConfig.getProp("ServletModule.Breaking.ConfirmTemplate");
37                 try {
38       DatabaseBreaking dbb = DatabaseBreaking.getInstance();
39                         mainModule = new ModuleBreaking(dbb);
40                 }
41                 catch (StorageObjectException e) {
42                         theLog.printDebugInfo("ServletModuleBreaking konnte nicht initialisiert werden");
43                 }
44         }
45
46         public void list(HttpServletRequest req, HttpServletResponse res)
47                 throws ServletModuleException
48         {
49     theLog.printDebugInfo("-- breaking: list");
50                 // fetch and deliver
51                 try {
52                         SimpleHash mergeData = new SimpleHash();
53                         String offset = req.getParameter("offset");
54                         if (offset==null || offset.equals("")) offset="0";
55                         mergeData.put("offset",offset);
56                         EntityList theList = mainModule.getByWhereClause(null, "webdb_create desc", (new Integer(offset)).intValue());
57                         mergeData.put("contentlist",theList);
58                         if(theList.getOrder()!=null) {
59                                 mergeData.put("order", theList.getOrder());
60                                 mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));
61                         }
62                         mergeData.put("count", (new Integer(theList.getCount())).toString());
63                         mergeData.put("from", (new Integer(theList.getFrom())).toString());
64                         mergeData.put("to", (new Integer(theList.getTo())).toString());
65                         if (theList.hasNextBatch())
66                                 mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
67                         if (theList.hasPrevBatch())
68                                 mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
69
70                         // raus damit
71                         HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
72                 }
73                 catch (ModuleException e) {throw new ServletModuleException(e.toString());}
74                 catch (IOException e) {throw new ServletModuleException(e.toString());}
75                 catch (Exception e) {throw new ServletModuleException(e.toString());}
76         }
77 }