1 package mircoders.servlet;
5 import javax.servlet.http.*;
6 import javax.servlet.*;
7 import freemarker.template.*;
13 import mircoders.module.*;
14 import mircoders.storage.*;
17 * ServletModuleBreaking -
18 * Authentified Navigation for Breaking News
23 public class ServletModuleBreaking extends ServletModule
26 // Singelton / Kontruktor
28 private static ServletModuleBreaking instance = new ServletModuleBreaking();
29 public static ServletModule getInstance() { return instance; }
31 private ServletModuleBreaking() {
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");
38 DatabaseBreaking dbb = DatabaseBreaking.getInstance();
39 mainModule = new ModuleBreaking(dbb);
41 catch (StorageObjectException e) {
42 theLog.printDebugInfo("ServletModuleBreaking konnte nicht initialisiert werden");
46 public void list(HttpServletRequest req, HttpServletResponse res)
47 throws ServletModuleException
49 theLog.printDebugInfo("-- breaking: list");
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()));
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());
71 HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter(), req.getLocale());
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());}