1 package mircoders.servlet;
7 import javax.servlet.*;
8 import javax.servlet.http.*;
10 import freemarker.template.*;
19 import mircoders.storage.*;
20 import mircoders.module.*;
23 * ServletModuleHidden - output of so called "censored" articles
29 public class ServletModuleHidden extends ServletModule
32 // Singelton / Kontruktor
33 private static ServletModuleHidden instance = new ServletModuleHidden();
34 public static ServletModule getInstance() { return instance; }
36 private ServletModuleHidden() {
37 theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Hidden.Logfile"));
38 templateListString = MirConfig.getProp("ServletModule.Hidden.ListTemplate");
40 mainModule = new ModuleContent(DatabaseContent.getInstance());
42 catch (StorageObjectException e) {
43 theLog.printError("servletmoduleHidden could not be initialized");
48 public void list(HttpServletRequest req, HttpServletResponse res)
49 throws ServletModuleException
51 // Parameter auswerten
52 SimpleHash mergeData = new SimpleHash();
53 String query_year = req.getParameter("year");
54 String query_month = req.getParameter("month");
55 String order = "webdb_create";
58 String whereClause = "is_published=false AND webdb_create LIKE '"+
59 query_year+"-"+query_month+"%'";
61 theLog.printDebugInfo("sql-whereclause: " + whereClause);
63 // fetch und ausliefern
66 if ((query_year!=null && !query_year.equals(""))
67 && (query_month!=null && !query_month.equals(""))) {
68 EntityList theList = mainModule.getByWhereClause(whereClause, order, -1);
69 if (theList!=null && theList.size()>0) {
71 //make articleHash for comment
72 StringBuffer buf= new StringBuffer("id in (");boolean first=true;
73 for(int i=0;i<theList.size();i++) {
74 if (first==false) buf.append(",");
76 buf.append(theList.elementAt(i).getValue("to_media"));
79 SimpleHash articleHash =
80 HTMLTemplateProcessor.makeSimpleHash(
81 mainModule.getByWhereClause(buf.toString(),-1));
82 mergeData.put("articleHash", articleHash);
84 // send the year and month for use in the list template
85 mergeData.put("year", query_year);
86 mergeData.put("month", query_month);
88 mergeData.put("contentlist",theList);
92 HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req));
94 catch (ModuleException e) {throw new ServletModuleException(e.toString());}
95 catch (IOException e) {throw new ServletModuleException(e.toString());}
96 catch (Exception e) {throw new ServletModuleException(e.toString());}