merged with 1.1
[mir.git] / source / mircoders / servlet / ServletModuleComment.java
index 4593413..251c37c 100755 (executable)
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
-package mircoders.servlet;
-
-import java.io.*;
-import java.sql.*;
-import java.util.*;
-import java.net.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-import org.apache.struts.util.MessageResources;
-
-import freemarker.template.*;
-
-import mir.servlet.*;
-import mir.module.*;
-import mir.misc.*;
-import mir.entity.*;
-import mir.storage.*;
-import mir.generator.*;
-import mir.entity.*;
-import mir.entity.adapter.*;
-import mir.util.*;
-
-import mircoders.storage.*;
-import mircoders.global.*;
-import mircoders.localizer.*;
-import mircoders.module.*;
-
-/*
- *  ServletModuleComment - controls navigation for Comments
- *
- *
- * @author RK
- */
-
-public class ServletModuleComment extends ServletModule
-{
-
-  private ModuleContent     moduleContent;
-
-  // Singelton / Kontruktor
-  private static ServletModuleComment instance = new ServletModuleComment();
-  public static ServletModule getInstance() { return instance; }
-
-  private ServletModuleComment() {
-    theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Comment.Logfile"));
-    templateListString = MirConfig.getProp("ServletModule.Comment.ListTemplate");
-    templateObjektString = MirConfig.getProp("ServletModule.Comment.ObjektTemplate");
-    templateConfirmString = MirConfig.getProp("ServletModule.Comment.ConfirmTemplate");
-    try {
-      mainModule = new ModuleComment(DatabaseComment.getInstance());
-      moduleContent = new ModuleContent(DatabaseContent.getInstance());
-    }
-    catch (StorageObjectException e) {
-      theLog.printError("servletmodule: comment could not be initialized");
-    }
-  }
-
-  public void list(HttpServletRequest req, HttpServletResponse res)
-      throws ServletModuleException
-  {
-    // Parameter auswerten
-    SimpleHash mergeData = new SimpleHash();
-    String query_text = req.getParameter("query_text");
-    mergeData.put("query_text",query_text);
-    if (query_text!=null) mergeData.put("query_text_encoded",URLEncoder.encode(query_text));
-    String query_field = req.getParameter("query_field");
-    mergeData.put("query_field",query_field);
-    String query_is_published = req.getParameter("query_is_published");
-    mergeData.put("query_is_published",query_is_published);
-
-    String offset = req.getParameter("offset");
-    if (offset==null || offset.equals("")) offset="0";
-    mergeData.put("offset",offset);
-
-    // patching order
-    String order = req.getParameter("order");
-    if(order!=null) {
-      mergeData.put("order", order);
-      mergeData.put("order_encoded", URLEncoder.encode(order));
-      if (order.equals("webdb_create")) order="webdb_create desc";
-    }
-
-    // sql basteln
-    String whereClause=""; boolean isFirst=true;
-    if (query_text!=null && !query_text.equalsIgnoreCase("")) {
-    whereClause += "lower("+query_field+") like lower('%"+query_text+"%')"; isFirst=false;}
-    if (query_is_published != null && !query_is_published.equals("")) {
-      if (isFirst==false) whereClause+=" and ";
-      whereClause += "is_published='"+query_is_published+"'";
-      isFirst=false;
-    }
-
-    theLog.printDebugInfo("sql-whereclause: " + whereClause + " order: " + order + " offset: " + offset);
-
-    // fetch und ausliefern
-    try {
-
-      if (query_text!=null || query_is_published!=null ) {
-        EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue());
-        if (theList!=null && theList.size()>0) {
-
-          //make articleHash for comment
-          StringBuffer buf= new StringBuffer("id in (");boolean first=true;
-          for(int i=0;i<theList.size();i++) {
-            if (first==false) buf.append(",");
-            first=false;
-            buf.append(theList.elementAt(i).getValue("to_media"));
-          }
-          buf.append(")");
-          SimpleHash articleHash = HTMLTemplateProcessor.makeSimpleHash(moduleContent.getByWhereClause(buf.toString(),-1));
-          mergeData.put("articleHash", articleHash);
-
-          // get comment
-          mergeData.put("contentlist",theList);
-          mergeData.put("count", (new Integer(theList.getCount())).toString());
-          mergeData.put("from", (new Integer(theList.getFrom())).toString());
-          mergeData.put("to", (new Integer(theList.getTo())).toString());
-          if (theList.hasNextBatch())
-            mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
-          if (theList.hasPrevBatch())
-            mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
-        }
-      }
-      // raus damit
-      HTMLTemplateProcessor.process(res, templateListString, mergeData, res.getWriter(), getLocale(req));
-    }
-    catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-    catch (IOException e) {throw new ServletModuleException(e.toString());}
-    catch (Exception e) {throw new ServletModuleException(e.toString());}
-  }
-
-  public void showArticleCommentList(Object aWriter, int anOffset, int anArticleId, Locale aLocale) throws ServletModuleException {
-    int nrCommentsPerPage = 20;
-
-    Object comments;
-    Map generationData;
-    Generator generator;
-    int totalNrComments;
-    EntityAdapterModel model;
-    MessageResources messages = MessageResources.getMessageResources("bundles.admin");
-
-    try {
-      generator = MirGlobal.localizer().generators().makeGeneratorLibrary().makeGenerator("admin/commentlist2.template");
-      model = MirGlobal.localizer().dataModel().adapterModel();
-
-//    commentList = mainModule.getByWhereClause(whereClause, order, offset);
-
-      generationData = new HashMap();
-      MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(generationData);
-
-      comments =
-        new CachingRewindableIterator(
-          new EntityIteratorAdapter( "to_media = " + anArticleId,
-               "webdb_create desc",
-               nrCommentsPerPage,
-               model,
-              "comment",
-              nrCommentsPerPage,
-              anOffset
-          )
-        );
-
-      totalNrComments = model.getMappingForName("comment").getStorage().getSize("to_media = " + anArticleId);
-
-      generationData.put( "comments", comments);
-      generationData.put( "offset", new Integer(anOffset));
-      generationData.put( "articleid", new Integer(anArticleId));
-      generationData.put( "lang", new MessageMethodModel(aLocale, messages) );
-      generationData.put( "thisurl", "module=Comment&do=listarticlecomments&offset="+anOffset+"&articleid="+anArticleId);
-
-      if (anOffset>0) {
-        generationData.put( "previousurl", "module=Comment&do=listarticlecomments&offset="+
-                            Math.max( 0, anOffset - nrCommentsPerPage )+"&articleid="+anArticleId);
-        generationData.put("previous", new Integer(Math.max( 0, anOffset - nrCommentsPerPage )));
-      }
-
-      if (anOffset + nrCommentsPerPage < totalNrComments) {
-        generationData.put( "nexturl", "module=Comment&do=listarticlecomments&offset="+
-                            Math.min( anOffset + nrCommentsPerPage, totalNrComments-1 )+"&articleid="+anArticleId);
-        generationData.put("next", new Integer(Math.min( anOffset + nrCommentsPerPage, totalNrComments-1 )));
-      }
-
-      generator.generate(aWriter, generationData, new PrintWriter(new NullWriter()));
-    }
-    catch (Throwable t) {
-      t.printStackTrace(System.out);
-      throw new ServletModuleException(t.getMessage());
-    }
-  }
-
-  public void listarticlecomments(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
-  {
-    String articleIdString = req.getParameter("articleid");
-    String offsetString = req.getParameter("offset");
-    int offset = 0;
-    int articleId = 0;
-
-    try {
-      offset = Integer.parseInt(offsetString);
-    }
-    catch (Throwable t) {
-    }
-
-    try {
-      articleId  = Integer.parseInt(articleIdString);
-
-      showArticleCommentList( res.getWriter(), offset, articleId, getLocale(req));
-    }
-    catch (ServletModuleException e) {
-      throw e;
-    }
-    catch (Throwable e) {
-      e.printStackTrace(System.out);
-      throw new ServletModuleException(e.getMessage());
-    }
-  }
-
-  public void performarticlecommentsoperation(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {
-    String commentIdString = req.getParameter("commentid");
-    String articleIdString = req.getParameter("articleid");
-    String offsetString = req.getParameter("offset");
-    String operation = req.getParameter("operation");
-    int offset = 0;
-    int articleId = 0;
-
-    try {
-      articleId  = Integer.parseInt(articleIdString);
-
-      showArticleCommentList( res.getWriter(), offset, articleId, getLocale(req));
-    }
-    catch (ServletModuleException e) {
-      throw e;
-    }
-    catch (Throwable e) {
-      e.printStackTrace(System.out);
-      throw new ServletModuleException(e.getMessage());
-    }
-  }
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with  any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two.  You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries.  If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.servlet;\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.entity.adapter.EntityAdapterModel;\r
+import mir.entity.adapter.EntityIteratorAdapter;\r
+import mir.log.LoggerWrapper;\r
+import mir.servlet.ServletModule;\r
+import mir.servlet.ServletModuleExc;\r
+import mir.servlet.ServletModuleFailure;\r
+import mir.servlet.ServletModuleUserExc;\r
+import mir.util.CachingRewindableIterator;\r
+import mir.util.HTTPRequestParser;\r
+import mir.util.JDBCStringRoutines;\r
+import mir.util.SQLQueryBuilder;\r
+import mir.util.URLBuilder;\r
+import mircoders.entity.EntityComment;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.module.ModuleComment;\r
+import mircoders.module.ModuleContent;\r
+import mircoders.storage.DatabaseComment;\r
+import mircoders.storage.DatabaseContent;\r
+\r
+/*\r
+ *  ServletModuleComment - controls navigation for Comments\r
+ *\r
+ *\r
+ *  @author the mir-coders\r
+ */\r
+\r
+public class ServletModuleComment extends ServletModule\r
+{\r
+  private ModuleContent  moduleContent;\r
+\r
+  private static ServletModuleComment instance = new ServletModuleComment();\r
+  public static ServletModule getInstance() { return instance; }\r
+\r
+  private ServletModuleComment() {\r
+    logger = new LoggerWrapper("ServletModule.Comment");\r
+    try {\r
+      mainModule = new ModuleComment(DatabaseComment.getInstance());\r
+      moduleContent = new ModuleContent(DatabaseContent.getInstance());\r
+    }\r
+    catch (Exception e) {\r
+      logger.error("servletmodule comment could not be initialized:" + e.getMessage());\r
+    }\r
+  }\r
+\r
+  public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {\r
+    try {\r
+      MirGlobal.accessControl().general().assertMayDeleteComments(ServletHelper.getUser(aRequest));\r
+\r
+      super.delete(aRequest, aResponse);\r
+    }\r
+    catch (Throwable t) {\r
+      throw new ServletModuleFailure(t);\r
+    }\r
+  }\r
+\r
+  public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    String idParam = aRequest.getParameter("id");\r
+\r
+    if (idParam == null)\r
+      throw new ServletModuleExc("Invalid call: id not supplied ");\r
+\r
+    showComment(idParam, aRequest, aResponse);\r
+  }\r
+\r
+  public void showComment(String anId, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
+    try {\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)});\r
+      EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();\r
+      Map comment;\r
+      URLBuilder urlBuilder = new URLBuilder();\r
+\r
+      urlBuilder.setValue("module", "Comment");\r
+      urlBuilder.setValue("do", "edit");\r
+      urlBuilder.setValue("id", anId);\r
+      urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));\r
+\r
+      if (anId != null) {\r
+        responseData.put("new", Boolean.FALSE);\r
+        comment = model.makeEntityAdapter("comment", mainModule.getById(anId));\r
+      }\r
+      else {\r
+        List fields = DatabaseComment.getInstance().getFields();\r
+        responseData.put("new", Boolean.TRUE);\r
+        comment = new HashMap();\r
+        Iterator i = fields.iterator();\r
+        while (i.hasNext()) {\r
+          comment.put(i.next(), null);\r
+        }\r
+      }\r
+      responseData.put("comment", comment);\r
+\r
+      responseData.put("returnurl", requestParser.getParameter("returnurl"));\r
+      responseData.put("thisurl", urlBuilder.getQuery());\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, editGenerator);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    String  mediaIdParam = aRequest.getParameter("mid");\r
+    String  commentId = aRequest.getParameter("commentid");\r
+\r
+    if (commentId == null || mediaIdParam==null) throw new ServletModuleExc("smod comment :: attach :: commentid/mid missing");\r
+\r
+    try {\r
+      EntityComment comment = (EntityComment) mainModule.getById(commentId);\r
+      comment.attach(mediaIdParam);\r
+    }\r
+    catch(Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+\r
+    showComment(commentId, aRequest, aResponse);\r
+  }\r
+\r
+  public void dettach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    String  commentId = aRequest.getParameter("commentid");\r
+    String  midParam = aRequest.getParameter("mid");\r
+    if (commentId == null)\r
+      throw new ServletModuleExc("smod comment :: dettach :: commentid missing");\r
+    if (midParam == null)\r
+      throw new ServletModuleExc("smod comment :: dettach :: mid missing");\r
+\r
+    try {\r
+      EntityComment comment = (EntityComment)mainModule.getById(commentId);\r
+      comment.dettach(commentId, midParam);\r
+    }\r
+    catch(Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+\r
+    showComment(commentId, aRequest, aResponse);\r
+  }\r
+\r
+\r
+  public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+    String where = requestParser.getParameter("where");\r
+    String order = requestParser.getParameterWithDefault("order", "webdb_create desc");\r
+    int offset = requestParser.getIntegerWithDefault("offset", 0);\r
+\r
+    returnCommentList(aRequest, aResponse, where, order, offset);\r
+  }\r
+\r
+  public void search(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+    SQLQueryBuilder queryBuilder = new SQLQueryBuilder();\r
+\r
+    String queryField = "";\r
+    String searchField = requestParser.getParameter("searchfield");\r
+    String searchText = requestParser.getParameter("searchtext");\r
+    String searchIsPublished = requestParser.getParameter("searchispublished");\r
+    String searchStatus = requestParser.getParameter("searchstatus");\r
+    String searchOrder = requestParser.getParameter("searchorder");\r
+\r
+    if (searchIsPublished.equals("0")) {\r
+      queryBuilder.appendAndCondition("is_published='f'");\r
+    }\r
+    else if (searchIsPublished.equals("1")) {\r
+      queryBuilder.appendAndCondition("is_published='t'");\r
+    }\r
+\r
+    if (searchText.length()>0) {\r
+        queryBuilder.appendAndCondition(\r
+          "lower("+ searchField + ") like " +\r
+          "'%" + JDBCStringRoutines.escapeStringLiteral(searchText.toLowerCase()) + "%'");\r
+    }\r
+\r
+    if (searchStatus.length()>0) {\r
+      queryBuilder.appendAndCondition("to_comment_status="+Integer.parseInt(searchStatus));\r
+    }\r
+\r
+    if (searchOrder.length()>0) {\r
+      if (searchOrder.equals("datedesc"))\r
+        queryBuilder.appendAscendingOrder("webdb_create");\r
+      else if (searchOrder.equals("dateasc"))\r
+        queryBuilder.appendDescendingOrder("webdb_create");\r
+      else if (searchOrder.equals("articletitle"))\r
+        queryBuilder.appendAscendingOrder("(select content.title from content where content.id = comment.to_media)");\r
+      else if (searchOrder.equals("creator"))\r
+        queryBuilder.appendDescendingOrder("creator");\r
+    }\r
+\r
+    returnCommentList(aRequest, aResponse, queryBuilder.getWhereClause(), queryBuilder.getOrderByClause(), 0);\r
+  }\r
+\r
+  public void articlecomments(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    String articleIdString = aRequest.getParameter("articleid");\r
+    int articleId;\r
+\r
+    try {\r
+      articleId  = Integer.parseInt(articleIdString);\r
+\r
+      returnCommentList( aRequest, aResponse, "to_media="+articleId, "webdb_create desc", 0);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void returnCommentList(HttpServletRequest aRequest, HttpServletResponse aResponse,\r
+     String aWhereClause, String anOrderByClause, int anOffset) throws ServletModuleExc {\r
+\r
+    HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+    URLBuilder urlBuilder = new URLBuilder();\r
+    EntityAdapterModel model;\r
+    int count;\r
+\r
+    try {\r
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});\r
+      model = MirGlobal.localizer().dataModel().adapterModel();\r
+\r
+      Object commentList =\r
+          new CachingRewindableIterator(\r
+            new EntityIteratorAdapter( aWhereClause, anOrderByClause, nrEntitiesPerListPage,\r
+              MirGlobal.localizer().dataModel().adapterModel(), "comment", nrEntitiesPerListPage, anOffset)\r
+      );\r
+\r
+      responseData.put("nexturl", null);\r
+      responseData.put("prevurl", null);\r
+\r
+      count=mainModule.getSize(aWhereClause);\r
+\r
+      urlBuilder.setValue("module", "Comment");\r
+      urlBuilder.setValue("do", "list");\r
+      urlBuilder.setValue("where", aWhereClause);\r
+      urlBuilder.setValue("order", anOrderByClause);\r
+\r
+      urlBuilder.setValue("searchfield", requestParser.getParameter("searchfield"));\r
+      urlBuilder.setValue("searchtext", requestParser.getParameter("searchtext"));\r
+      urlBuilder.setValue("searchispublished", requestParser.getParameter("searchispublished"));\r
+      urlBuilder.setValue("searchstatus", requestParser.getParameter("searchstatus"));\r
+      urlBuilder.setValue("searchorder", requestParser.getParameter("searchorder"));\r
+\r
+      responseData.put("searchfield", requestParser.getParameter("searchfield"));\r
+      responseData.put("searchtext", requestParser.getParameter("searchtext"));\r
+      responseData.put("searchispublished", requestParser.getParameter("searchispublished"));\r
+      responseData.put("searchstatus", requestParser.getParameter("searchstatus"));\r
+      responseData.put("searchorder", requestParser.getParameter("searchorder"));\r
+\r
+      urlBuilder.setValue("offset", anOffset);\r
+      responseData.put("offset" , new Integer(anOffset).toString());\r
+      responseData.put("thisurl" , urlBuilder.getQuery());\r
+\r
+      if (count>=anOffset+nrEntitiesPerListPage) {\r
+        urlBuilder.setValue("offset", anOffset + nrEntitiesPerListPage);\r
+        responseData.put("nexturl" , urlBuilder.getQuery());\r
+      }\r
+\r
+      if (anOffset>0) {\r
+        urlBuilder.setValue("offset", Math.max(anOffset - nrEntitiesPerListPage, 0));\r
+        responseData.put("prevurl" , urlBuilder.getQuery());\r
+      }\r
+\r
+      responseData.put("comments", commentList);\r
+      responseData.put("from" , Integer.toString(anOffset+1));\r
+      responseData.put("count", Integer.toString(count));\r
+      responseData.put("to", Integer.toString(Math.min(anOffset+nrEntitiesPerListPage, count)));\r
+\r
+      ServletHelper.generateResponse(aResponse.getWriter(), responseData, listGenerator);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+\r
+  public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc\r
+  {\r
+    try {\r
+      HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+      String returnUrl = requestParser.getParameter("returnurl");\r
+\r
+      String idParam = aRequest.getParameter("id");\r
+      if (idParam == null)\r
+        throw new ServletModuleExc("Wrong call: (id) is missing");\r
+\r
+      Map withValues = getIntersectingValues(aRequest, DatabaseComment.getInstance());\r
+\r
+      String content_id = aRequest.getParameter("id");\r
+\r
+      if (!withValues.containsKey("is_published"))\r
+        withValues.put("is_published","0");\r
+      if (!withValues.containsKey("is_html"))\r
+        withValues.put("is_html","0");\r
+\r
+      String webdbCreate = (String) withValues.get("webdb_create");\r
+      if (webdbCreate==null || webdbCreate.trim().length()==0)\r
+        withValues.remove("webdb_create");\r
+\r
+      String id = mainModule.set(withValues);\r
+\r
+      if (returnUrl!=null){\r
+        redirect(aResponse, returnUrl);\r
+      }\r
+      else\r
+        showComment(idParam, aRequest, aResponse);\r
+    }\r
+    catch (Throwable e) {\r
+      throw new ServletModuleFailure(e);\r
+    }\r
+  }\r
+}
\ No newline at end of file