[jboss-svn-commits] JBL Code SVN: r6157 - in labs/jbossforums/trunk/forums/portal-forums-src-readonly: . main/org/jboss/portlet/forums main/org/jboss/portlet/forums/action main/org/jboss/portlet/forums/commands main/org/jboss/portlet/forums/commands/admin main/org/jboss/portlet/forums/commands/moderation main/org/jboss/portlet/forums/commands/post main/org/jboss/portlet/forums/helper main/org/jboss/portlet/forums/impl main/org/jboss/portlet/forums/interceptors main/org/jboss/portlet/forums/model main/org/jboss/portlet/forums/properties main/org/jboss/portlet/forums/servlet main/org/jboss/portlet/forums/theme main/org/jboss/portlet/test/forums

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 11 18:05:08 EDT 2006


Author: unibrew
Date: 2006-09-11 18:04:18 -0400 (Mon, 11 Sep 2006)
New Revision: 6157

Removed:
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/security/
Modified:
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/README.txt
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/Context.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsConstants.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsModule.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsPortlet.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/Action.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/EditPostAction.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ForumAction.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/NewTopicAction.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/PostAction.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ProcessCommandAction.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ReplyAction.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/TopicAction.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/AbstractCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/BBAttributeType.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CommandConstants.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeResult.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/SimpleResultType.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/ValidationException.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateCategoryCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateForumCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteCategoryCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteForumCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveCategoryCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveForumCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderCategoryCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderForumCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateCategoryCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateForumCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/DeleteTopicCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/LockTopicCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/MoveTopicCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/SplitTopicCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePollCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePostCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/EditPostCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ForumCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/NewTopicCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostTools.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ReplyCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/RepostCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/TopicCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/VoteTopicCommand.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentToken.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/FileBinding.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/ForumsTools.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Goto.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/GotoWithOffset.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/IndexIterator.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Range.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/TempFileBinding.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Time.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/AttachmentImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/CategoryImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumWatchImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/MessageImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollOptionImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PostImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PosterImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicWatchImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/UploadedFileImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/WatchImpl.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/FloodControlInterceptor.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/IndexInterceptor.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/ResourceCacheInvalidatorInterceptor.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Attachment.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/AuthType.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Category.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Forum.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/ForumWatch.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Message.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poll.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/PollOption.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Post.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poster.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Topic.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/TopicWatch.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/UploadedFile.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Watch.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/TCCLXProperties.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/XProperties.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/servlet/DownloadAttachmentsServlet.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/FolderType.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/ForumsTheme.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminFullTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPollPostEditTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPostTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AnonymousUserTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumModelTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumsModelTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/PostModelTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TestConstants.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TopicModelTestCase.java
   labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/UserTestCase.java
Log:
[JBFORUMS-105] Commiting old forums code from most up to date JBPortal2.4 branch.

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/README.txt
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/README.txt	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/README.txt	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,2 +1,2 @@
-JBoss Portal Version = 2.2.1RC1
+JBoss Portal Version = 2.4
 

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/Context.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/Context.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/Context.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,889 +1,889 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums;
-
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portlet.forums.action.*;
-import org.jboss.portlet.forums.commands.post.*;
-import org.jboss.portlet.forums.impl.*;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.forums.model.UploadedFile;
-import org.jboss.portlet.forums.helper.TempFileBinding;
-import org.jboss.portlet.forums.helper.ForumsTools;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.portlet.PortletFileUpload;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUploadException;
-
-import javax.portlet.PortletPreferences;
-import javax.servlet.http.HttpSessionBindingListener;
-import javax.servlet.http.HttpSessionBindingEvent;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.13 $
- */
-public class Context
-{
-   // Request parameters
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean p_submit;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean p_confirm;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean p_preview;
-
-   /**
-    * Scope : NewTopic/EditPost/Reply
-    * When it's true that means the button add attachment is pressed.
-    */
-   public boolean p_attach;
-
-   /**
-    * Scope : NewTopic/EditPost/Reply
-    * When it's true the user choosed to see the add attachment panel.
-    */
-   public boolean p_attach_box;
-
-   /**
-    * Scope : editing a post.
-    * When it's true the user choosed to see the posted attachment.
-    */
-   public boolean p_posted_attach;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int p_mode;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int p_forum_id;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int p_topic_id;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int p_post_id;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int p_post_parent_topic_id;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int p_topic_type;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean p_cancel;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean p_notify;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int p_vote_option_id;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean p_poll_delete;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean p_topic_first_post = false;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Poll p_poll;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Message p_message;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Poster p_poster;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public List p_deleted_attachments = new ArrayList();
-
-   /**
-    * DOCUMENT_ME
-    */
-   public List p_session_attachments = new ArrayList();
-
-   public Map p_updated_attachments = new HashMap();
-
-   /**
-    * DOCUMENT_ME
-    */
-   boolean c_refresh;
-
-   /**
-    * DOCUMENT_ME
-    */
-   private ForumsModule forumsModule;
-
-   private Map files = new HashMap();
-
-   /**
-    * Creates a new {@link Context} object.
-    */
-   public Context()
-   {
-      //forumsModule = new ForumsModuleImpl();
-
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param req  DOCUMENT_ME
-    * @param resp DOCUMENT_ME
-    */
-   public void update(JBossActionRequest req,
-                      JBossActionResponse resp)
-   {
-      //So because posting form is probably multipart at the beggining we must parse form fields
-      try
-      {
-         files = new HashMap();
-         DiskFileItemFactory factory = new DiskFileItemFactory();
-         PortletFileUpload upload = new PortletFileUpload(factory);
-
-         //if posting() was called with action link it won't be multipart
-         if ((req.getContentType() != null) && req.getContentType().startsWith("multipart/form-data"))
-         {
-            // Merge with upload fields
-            for (Iterator i = upload.parseRequest(req).iterator(); i.hasNext();)
-            {
-               FileItem item = (FileItem)i.next();
-               if (item.isFormField())
-               {
-                  //if it's form field just add it to request params map
-                  //TODO:Be aware that this adds single value as we won't have multiply values in new topic form for now...
-                  req.getParameterMap().put(item.getFieldName(), new String[]{item.getString()});
-               }
-               else
-               {
-                  if (item.getSize() != 0)
-                  {
-                     files.put(item.getName(), new UploadedFileImpl(item.getContentType(), item.get(), item.getName(), item.getSize()));
-
-                  }
-               }
-            }
-         }
-      }
-      catch (FileUploadException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         //TODO:Some nice error message
-      }
-      //if we started editing post, already stored attachs in sessions should be cleaned.
-      if (req.getParameters().get("editPostInit","none").equals("true"))
-      {
-         //clear stored files from session
-         req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, null);
-      }
-      //Uncoment for debug purposes:
-      /*System.out.println("@@@@@@@@@@@@@@@@@@@@@@");
-      System.out.println("in Context.update(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
-      for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
-      {
-         String key = (String)i.next();
-         System.out.println("param key: " + key + " ||param val[1/" + req.getParameterValues(key).length + "]: " + req.getParameter(key));
-      }
-      System.out.println("Parsed file names in request:");
-      for (Iterator i = files.keySet().iterator(); i.hasNext();)
-      {
-         String key = (String)i.next();
-         System.out.println(" -- filename: " + key);
-      }*/
-      //DEBUG code
-      /*AttachmentsManager tflf = (AttachmentsManager)req.getPortletSession().getAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS);
-      if (!(tflf == null))
-      {
-         System.out.println("Already stored files");
-         for (Iterator i = tflf.getFiles().iterator(); i.hasNext();)
-         {
-            TempFileBinding tfb = (TempFileBinding)i.next();
-            System.out.println("+++" + tfb.getFileName() + "<==>" + tfb.getFilePath());
-         }
-      }*/
-
-      //System.out.println("Doing Context.update()");
-      PortletPreferences pp = req.getPreferences();
-      p_mode = ForumsConstants.ModeDecoder.decodePosting(req.getParameter("mode"));
-      //System.out.println("Decoded mode: "+ req.getParameter("mode"));
-      p_forum_id = req.getParameters().getInt(ForumsConstants.POST_FORUM_URL, -1);
-      //System.out.println("Decoded forum id: "+ p_forum_id);
-      p_topic_id = req.getParameters().getInt(ForumsConstants.POST_TOPIC_URL, -1);
-      //System.out.println("Decoded topic id: " +p_topic_id);
-      p_post_id = req.getParameters().getInt(ForumsConstants.POST_POST_URL, -1);
-      //System.out.println("Decoded post id: " +p_post_id);
-      p_topic_type = req.getParameters().getInt("topictype", ForumsConstants.POST_NORMAL);
-      /*p_notify = req.getParameters().getParameterExists("notify");*/
-      p_notify = pp.getValue("notifyreply", "1").equals("1");
-      p_vote_option_id = req.getParameters().getInt("vote_id", -1);
-
-      p_message = new MessageImpl();
-      p_message.setSubject(req.getParameters().get("subject", ""));
-      p_message.setText(req.getParameters().get("message", ""));
-
-      /*if (pp.getValue("attachsig","0").equals("1")){
-          p_message.setText(req.getParameters().get("message", "")+ '\n' + pp.getValue("signature",""));
-      } else {
-          p_message.setText(req.getParameters().get("message", ""));
-      }*/
-      //p_message.setHTMLEnabled(!req.getParameters().getParameterExists("disable_html"));
-      //p_message.setHTMLEnabled(pp.getValue("allowhtml","1").equals("1"));
-      p_message.setBBCodeEnabled(!req.getParameters().getParameterExists("disable_bbcode"));
-      /*p_message.setBBCodeEnabled(pp.getValue("allowbbcode","1").equals("1"));*/
-      p_message.setSmiliesEnabled(!req.getParameters().getParameterExists("disable_smilies"));
-      /*p_message.setSignatureEnabled(req.getParameters().getParameterExists("attach_sig"));*/
-      p_message.setSignatureEnabled(pp.getValue("attachsig", "1").equals("1"));
-
-      String sessionId = req.getPortletSession().getId();
-
-      /**
-       * So... attachments are stored in AttachmentsManager as String path to disk temp file. Manager
-       * is stored in session so when session is broken it will remove files from disk.
-       * When NewTopic view is created for the first time AttachmentManager is removed from session
-       * to deal with clean attachments state. When EditPost link is clicked removal of Manager from session
-       * is done some lines above
-       */
-
-      //persisting attachments to disk
-      int filescount = 0;
-      AttachmentsManager attachmentsManager = (AttachmentsManager)req.getPortletSession().getAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS);
-      //if there is no Manager object in session create one
-      if (attachmentsManager == null)
-      {
-         attachmentsManager = new AttachmentsManager();
-         req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, attachmentsManager);
-      }
-      //add newly uploaded files to Manager
-      for (Iterator i = files.keySet().iterator(); i.hasNext(); filescount++)
-      {
-         String fileName = (String)i.next();
-         UploadedFile uf = (UploadedFile)files.get(fileName);
-         try
-         {
-            TempFileBinding tfb = new TempFileBinding(uf.getContentType(),
-               uf.getByteContent(),
-               uf.getName(),
-               sessionId.toString() + "_" + getNextFileIndex(req));
-            tfb.setComment(req.getParameters().get("filecomment", ""));
-            attachmentsManager.addBinding(tfb);
-         }
-         catch (Exception e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            //TODO:Some nice error message
-         }
-      }
-      //p_session_attachments = attachmentsManager.getFiles();
-
-      //
-      String userId = req.getUser().getId().toString();
-      try
-      {
-         p_poster = getForumsModule().findPosterByUserId(userId);
-      }
-      catch (ModuleException e)
-      {
-         //TODO:Some nice error message
-         e.printStackTrace();
-      }
-
-      if (p_post_id != -1)
-      {
-         try
-         {
-            Integer tid = getForumsModule().findPostById(new Integer(p_post_id)).getTopic().getId();
-            p_post_parent_topic_id = tid.intValue();
-            Integer fpid = getForumsModule().findTopicById(tid).getFirstPost().getId();
-            p_topic_first_post = p_post_id == fpid.intValue();
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         }
-      }
-
-      if (p_poster == null)
-      {
-         p_poster = new PosterImpl(userId);
-      }
-
-      //
-      p_poll = new PollImpl();
-      p_poll.setTitle(req.getParameters().get("poll_title", ""));
-      p_poll.setLength(Math.max(req.getParameters().getInt("poll_length", 0),
-         0));
-      p_poll.setOptions(new LinkedList());
-
-      String p_add_poll_option_text = req.getParameter("add_poll_option_text");
-      boolean p_poll_add = req.getParameters().getParameterExists("add_poll_option");
-      boolean p_poll_edit = req.getParameters().getParameterExists("edit_poll_option");
-
-      boolean option_deleted = false;
-      for (int index = 0; true; index++)
-      {
-         String param = "poll_option_text[" + index + "]";
-         String value = req.getParameter(param);
-         boolean deleted = req.getParameter("del_poll_option[" + index + "]") != null;
-         option_deleted |= deleted;
-         if ((value != null))
-         {
-            if (!deleted)
-            {
-               /*p_poll.getOptions().add(deleted ? null : value);*/
-               //p_poll.getOptions().add(value);
-
-               p_poll.getOptions().add(new PollOptionImpl(value));
-            }
-         }
-         else
-         {
-            break;
-         }
-      }
-
-      if (p_poll_add)
-      {
-         //p_poll.getOptions().add(p_add_poll_option_text);
-         p_poll.getOptions().add(new PollOptionImpl(p_add_poll_option_text));
-      }
-
-      //      if (p_poll_add && p_add_poll_option_text != null)
-      //      {
-      //         // htmlspecialchars(trim(stripslashes(
-      //         p_poll_option_text.add(p_add_poll_option_text);
-      //      }
-      boolean toggle_attach_box = req.getParameters().getParameterExists("add_attachment_box");
-      boolean toggle_posted_attachments = req.getParameters().getParameterExists("posted_attachments");
-
-      p_poll_delete = req.getParameters().getParameterExists("poll_delete");
-      p_cancel = req.getParameters().getParameterExists("cancel");
-      p_submit = req.getParameters().getParameterExists("post");
-      p_confirm = req.getParameters().getParameterExists("confirm");
-      p_preview = req.getParameters().getParameterExists("preview");
-      p_attach_box = toggle_attach_box | req.getParameters().getParameterExists("add_attachment_box_flag");
-      p_posted_attach = toggle_posted_attachments ^ req.getParameters().getParameterExists("posted_attachments_flag");
-      p_attach = req.getParameters().getParameterExists("add_attachment");
-
-      // Handle Delete/update attachments buttons
-      boolean session_attachment_deleted = false;
-      //search thru params for update/delete command
-      for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
-      {
-         String parameter = (String)i.next();
-         if (parameter.startsWith("del_attachment["))
-         {
-            //attach id can be for attachment in DB or file in AttachmentsManager
-            boolean isStored = parameter.startsWith("del_attachment[stored_attach_");
-            int from = (isStored ? "del_attachment[stored_attach_" : "del_attachment[").length();
-
-            int to = parameter.length() - 1;
-            String s = parameter.substring(from, to);
-            //int index = Integer.parseInt(s);
-            //if it's for attachment in DB just remember it's ID to remove it during executin proper command
-            if (isStored)
-            {
-               int index = Integer.parseInt(s);
-               attachmentsManager.getDeletedAttachments().add(new Integer(index));
-            }
-            //if it's previosly uploaded file just remove binding from Manager
-            else
-            {
-               attachmentsManager.removeBinding(s);
-            }
-            session_attachment_deleted = true;
-            break;
-         }
-         //check if this is update button
-         if (parameter.startsWith("update_attachment["))
-         {
-            boolean isStored = parameter.startsWith("update_attachment[stored_attach_");
-            int from = (isStored ? "update_attachment[stored_attach_" : "update_attachment[").length();
-            int to = parameter.length() - 1;
-            String s = parameter.substring(from, to);
-            //int index = Integer.parseInt(s);
-            //if this is attachment in DB remember it's index and new comment
-            if (isStored)
-            {
-               int index = Integer.parseInt(s);
-               String newComment = req.getParameters().get("attach_comment[stored_attach_"+ s +"]","");
-               attachmentsManager.getUpdatedAttachments().put(new Integer(index), newComment);
-            }
-            //if this is previously uploaded file update comment in binding in Manager
-            else
-            {
-               attachmentsManager.updateBindingComment(s, req.getParameters().get("attach_comment["+ s +"]",""));
-            }
-            session_attachment_deleted = true;
-            break;
-         }
-      }
-      //[List]newly uploaded files
-      p_session_attachments = attachmentsManager.getFiles();
-      //[List]indexes of attachments that should be removed from DB
-      p_deleted_attachments = attachmentsManager.getDeletedAttachments();
-      //[Map]indexes of attachments and new comments that should be updated in DB
-      p_updated_attachments = attachmentsManager.getUpdatedAttachments();
-
-
-      // Are we refreshing the page ?
-      boolean c_refresh = p_preview;
-      c_refresh |= p_poll_delete;
-      c_refresh |= p_poll_add;
-      c_refresh |= p_poll_edit;
-      c_refresh |= p_attach;
-      c_refresh |= option_deleted;
-
-      //      c_refresh |= session_attachment_deleted;
-      c_refresh |= toggle_attach_box;
-      c_refresh |= toggle_posted_attachments;
-
-      this.c_refresh = c_refresh;
-
-      // Clean up the attachments if necessary
-      /*if (((p_mode == ForumsConstants.PMODE_EDIT_POST) || (p_mode == ForumsConstants.PMODE_NEW_TOPIC)
-         || (p_mode == ForumsConstants.PMODE_REPLY))
-         && (c_refresh || p_submit))
-      {
-         //
-      }
-      else
-      {
-         //p_deleted_attachments.clear();
-         //p_session_attachments.clear();
-
-      }*/
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param req  DOCUMENT_ME
-    * @param resp DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public Action action(JBossActionRequest req,
-                        JBossActionResponse resp)
-   {
-      //System.out.println("Doing Context.action()");
-      Action action = null;
-      switch (p_mode)
-      {
-
-         case ForumsConstants.PMODE_VOTE:
-         {
-            VoteTopicCommand vtc = new VoteTopicCommand(req, resp);
-            vtc.setPoster(p_poster);
-            vtc.topicId = p_topic_id;
-            vtc.forumId = p_forum_id;
-            vtc.voteOptionId = p_vote_option_id;
-            action = new ProcessCommandAction(vtc);
-            break;
-         }
-         case ForumsConstants.PMODE_REPLY:
-         {
-            if (c_refresh)
-            {
-               ReplyAction rra = new ReplyAction(p_post_id, p_message, p_poster, p_session_attachments);
-               rra.setModule(getForumsModule());
-               action = rra;
-            }
-            else if (p_submit)
-            {
-               ReplyCommand rc = new ReplyCommand(req, resp);
-               rc.setPoster(p_poster);
-               rc.postId = p_post_id;
-               PortletPreferences pp = req.getPreferences();
-               /*if (pp.getValue("attachsig","0").equals("1")){
-                   String tmp = p_message.getText();
-                   p_message.setText(tmp + "\n\n" + pp.getValue("signature",""));
-               }*/
-               List attachments = new LinkedList();
-               for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
-               {
-                  attachments.add(((TempFileBinding)i.next()).produceAttachment());
-               }
-               rc.attachments = attachments;
-               rc.message = p_message;
-               rc.current_time = new Date();
-               rc.setModule(getForumsModule());
-               //               rc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
-               action = new ProcessCommandAction(rc);
-            }
-            else
-            {
-               ReplyAction rra = new ReplyAction(false, p_post_id, p_message, p_poster);
-               rra.setModule(getForumsModule());
-               action = rra;
-            }
-
-            break;
-         }
-
-         case ForumsConstants.PMODE_QUOTE:
-         {
-            ReplyAction rra = new ReplyAction(true, p_post_id, p_message, p_poster);
-            rra.setModule(getForumsModule());
-            action = rra;
-            break;
-         }
-
-         case ForumsConstants.PMODE_EDIT_POST:
-         {
-            if (c_refresh)
-            {
-               EditPostAction epa =
-                  new EditPostAction(p_message, p_poster, p_post_id, p_session_attachments, p_poll);
-               epa.setModule(getForumsModule());
-               action = epa;
-            }
-            else if (p_submit)
-            {
-               EditPostCommand epc = new EditPostCommand(req, resp);
-               epc.setPoster(p_poster);
-               epc.postId = p_post_id;
-               PortletPreferences pp = req.getPreferences();
-               /*if (pp.getValue("attachsig","0").equals("1")){
-                   String tmp = p_message.getText();
-                   p_message.setText(tmp + "\n\n");
-               }*/
-               epc.message = p_message;
-               p_poll.setCreationDate(new Date());
-               if (ForumsTools.hasPermission(req, "EditPollInPost"))
-               {
-                  epc.poll = p_poll;
-               }
-
-               //               epc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
-
-
-               List attachments = new LinkedList();
-               for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
-               {
-                  attachments.add(((TempFileBinding)i.next()).produceAttachment());
-               }
-               epc.attachments = attachments;
-
-               epc.topic_type = p_topic_type;
-               epc.current_time = new Date();
-               epc.poll_delete = p_poll_delete;
-               epc.notify = p_notify;
-               /*epc.deletedAttachments =
-                  (Integer[])p_deleted_attachments.toArray(new Integer[p_deleted_attachments.size()]);*/
-               epc.deletedAttachments = p_deleted_attachments;
-
-               epc.updatedAttachments = p_updated_attachments;
-               action = new ProcessCommandAction(epc);
-            }
-            else
-            {
-               EditPostAction epa =
-                  new EditPostAction(p_message, p_poster, p_post_id, p_session_attachments, p_poll);
-               epa.setModule(getForumsModule());
-               action = epa;
-            }
-
-            break;
-         }
-
-         case ForumsConstants.PMODE_DELETE:
-         {
-            DeletePostCommand dpc = new DeletePostCommand(req, resp);
-            dpc.setPoster(p_poster);
-            dpc.postId = p_post_id;
-            dpc.setModule(getForumsModule());
-            action = new ProcessCommandAction(dpc);
-            break;
-         }
-
-         case ForumsConstants.PMODE_POLL_DELETE:
-         {
-            DeletePollCommand dpc = new DeletePollCommand(req, resp);
-            dpc.setPoster(p_poster);
-            dpc.postId = p_post_id;
-            action = new ProcessCommandAction(dpc);
-            break;
-         }
-
-         case ForumsConstants.PMODE_NEW_TOPIC:
-         {
-            if (c_refresh)
-            {
-
-               NewTopicAction nta =
-                  new NewTopicAction(p_poster, p_message, p_forum_id, p_session_attachments, p_poll);
-               nta.setModule(getForumsModule());
-               action = nta;
-            }
-            else if (p_submit)
-            {
-               NewTopicCommand ntc = new NewTopicCommand(req, resp);
-               ntc.setPoster(p_poster);
-               ntc.forumId = p_forum_id;
-
-               /*ntc.message = p_message;*/
-
-               PortletPreferences pp = req.getPreferences();
-               /*if (pp.getValue("attachsig","0").equals("1")){
-                   String tmp = p_message.getText();
-                   p_message.setText(tmp + "\n\n" + pp.getValue("signature",""));
-               }*/
-               List attachments = new LinkedList();
-               for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
-               {
-                  attachments.add(((TempFileBinding)i.next()).produceAttachment());
-               }
-               ntc.attachments = attachments;
-
-               ntc.message = p_message;
-               p_poll.setCreationDate(new Date());
-               ntc.poll = p_poll;
-               //               ntc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
-               ntc.topic_type = p_topic_type;
-               ntc.current_time = new Date();
-               ntc.notify = p_notify;
-               ntc.setModule(getForumsModule());
-               action = new ProcessCommandAction(ntc);
-            }
-            else
-            {
-               NewTopicAction nta = new NewTopicAction(p_forum_id);
-               nta.setModule(getForumsModule());
-               action = nta;
-            }
-
-            break;
-         }
-
-
-         case ForumsConstants.PMODE_REPOST:
-         {
-            RepostCommand rc = new RepostCommand(req, resp);
-            rc.setPoster(p_poster);
-            rc.postId = p_post_id;
-            action = new ProcessCommandAction(rc);
-            break;
-         }
-      }
-
-      return action;
-   }
-
-   public ForumsModule getForumsModule()
-   {
-      return forumsModule;
-   }
-
-   public void setForumsModule(ForumsModule forumsModule)
-   {
-      this.forumsModule = forumsModule;
-   }
-
-
-   /**
-    * Object that stores binding to uploaded and stored as Temp Files attachments. Object is stored in
-    * session and implements HttpSessionBindingListener so when session is invalidated it removes stored
-    * files from disk
-    */
-   private class AttachmentsManager implements HttpSessionBindingListener
-   {
-      //uploaded and stored to disk attachments bindings.
-      private List files;
-      //indexes of attachments that should be deleted from DB
-      private List deletedAttachments;
-      //indexes of attachments in DB that should have updated comment + new comment value
-      private Map updatedAttachments;
-
-      AttachmentsManager()
-      {
-         files = new LinkedList();
-         setDeletedAttachments(new LinkedList());
-         setUpdatedAttachments(new HashMap());
-
-
-      }
-
-      /**
-       * Simply adds new TempFileBinding
-       * @param tmp
-       */
-      public void addBinding(TempFileBinding tmp)
-      {
-         files.add(tmp);
-      }
-
-      /**
-       * Removes Binding of id such as in argument
-       * @param id
-       */
-      public void removeBinding(String id)
-      {
-         for (Iterator i = files.iterator(); i.hasNext();)
-         {
-            TempFileBinding tfb = (TempFileBinding)i.next();
-            if (tfb.getFileId().equals(id))
-            {
-               tfb.delete();
-               files.remove(tfb);
-               break;
-            }
-         }
-      }
-
-      /**
-       * Updates comment for attachment
-       * @param id
-       * @param comment
-       */
-      public void updateBindingComment(String id, String comment)
-      {
-         for (Iterator i = files.iterator(); i.hasNext();)
-         {
-            TempFileBinding tfb = (TempFileBinding)i.next();
-            if (tfb.getFileId().equals(id))
-            {
-               tfb.setComment(comment);
-               break;
-            }
-         }
-      }
-
-      public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent)
-      {
-      }
-
-      /**
-       * If object removed from session we do clean up and removes every file stored to disk
-       * @param httpSessionBindingEvent
-       */
-      public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent)
-      {
-         for (Iterator i = files.iterator(); i.hasNext();)
-         {
-            TempFileBinding tmpb = (TempFileBinding)i.next();
-            tmpb.delete();
-         }
-      }
-
-      public List getFiles()
-      {
-         return files;
-      }
-
-      public void setFiles(List files)
-      {
-         this.files = files;
-      }
-
-      /**
-       * Stores indexes of persisted attachments which should be deleted
-       * @return
-       */
-      public List getDeletedAttachments()
-      {
-         return deletedAttachments;
-      }
-
-      public void setDeletedAttachments(List deletedAttachments)
-      {
-         this.deletedAttachments = deletedAttachments;
-      }
-
-      /**
-       * Stores indexes of persisted attachments and their new comments.
-       * @return
-       */
-      public Map getUpdatedAttachments()
-      {
-         return updatedAttachments;
-      }
-
-      public void setUpdatedAttachments(Map updatedAttachments)
-      {
-         this.updatedAttachments = updatedAttachments;
-      }
-   }
-
-   /**
-    * provides session unique integer value
-    * @param req
-    * @return
-    */
-   int getNextFileIndex(JBossActionRequest req)
-   {
-      Integer index = (Integer)req.getPortletSession().getAttribute(ForumsConstants.FILE_SESSION_INDEX);
-      if (index == null)
-      {
-         index = new Integer(0);
-         req.getPortletSession().setAttribute(ForumsConstants.FILE_SESSION_INDEX, index);
-      }
-      else
-      {
-         int i = index.intValue();
-         index = new Integer(i + 1);
-         req.getPortletSession().setAttribute(ForumsConstants.FILE_SESSION_INDEX, index);
-
-      }
-      return index.intValue();
-   }
-}
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums;
+
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portlet.forums.action.*;
+import org.jboss.portlet.forums.commands.post.*;
+import org.jboss.portlet.forums.impl.*;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Poll;
+import org.jboss.portlet.forums.model.Poster;
+import org.jboss.portlet.forums.model.UploadedFile;
+import org.jboss.portlet.forums.helper.TempFileBinding;
+import org.jboss.portlet.forums.helper.ForumsTools;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.portlet.PortletFileUpload;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+
+import javax.portlet.PortletPreferences;
+import javax.servlet.http.HttpSessionBindingListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.13 $
+ */
+public class Context
+{
+   // Request parameters
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean p_submit;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean p_confirm;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean p_preview;
+
+   /**
+    * Scope : NewTopic/EditPost/Reply
+    * When it's true that means the button add attachment is pressed.
+    */
+   public boolean p_attach;
+
+   /**
+    * Scope : NewTopic/EditPost/Reply
+    * When it's true the user choosed to see the add attachment panel.
+    */
+   public boolean p_attach_box;
+
+   /**
+    * Scope : editing a post.
+    * When it's true the user choosed to see the posted attachment.
+    */
+   public boolean p_posted_attach;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int p_mode;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int p_forum_id;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int p_topic_id;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int p_post_id;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int p_post_parent_topic_id;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int p_topic_type;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean p_cancel;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean p_notify;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int p_vote_option_id;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean p_poll_delete;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean p_topic_first_post = false;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Poll p_poll;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Message p_message;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Poster p_poster;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public List p_deleted_attachments = new ArrayList();
+
+   /**
+    * DOCUMENT_ME
+    */
+   public List p_session_attachments = new ArrayList();
+
+   public Map p_updated_attachments = new HashMap();
+
+   /**
+    * DOCUMENT_ME
+    */
+   boolean c_refresh;
+
+   /**
+    * DOCUMENT_ME
+    */
+   private ForumsModule forumsModule;
+
+   private Map files = new HashMap();
+
+   /**
+    * Creates a new {@link Context} object.
+    */
+   public Context()
+   {
+      //forumsModule = new ForumsModuleImpl();
+
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param req  DOCUMENT_ME
+    * @param resp DOCUMENT_ME
+    */
+   public void update(JBossActionRequest req,
+                      JBossActionResponse resp)
+   {
+      //So because posting form is probably multipart at the beggining we must parse form fields
+      try
+      {
+         files = new HashMap();
+         DiskFileItemFactory factory = new DiskFileItemFactory();
+         PortletFileUpload upload = new PortletFileUpload(factory);
+
+         //if posting() was called with action link it won't be multipart
+         if ((req.getContentType() != null) && req.getContentType().startsWith("multipart/form-data"))
+         {
+            // Merge with upload fields
+            for (Iterator i = upload.parseRequest(req).iterator(); i.hasNext();)
+            {
+               FileItem item = (FileItem)i.next();
+               if (item.isFormField())
+               {
+                  //if it's form field just add it to request params map
+                  //TODO:Be aware that this adds single value as we won't have multiply values in new topic form for now...
+                  req.getParameterMap().put(item.getFieldName(), new String[]{item.getString()});
+               }
+               else
+               {
+                  if (item.getSize() != 0)
+                  {
+                     files.put(item.getName(), new UploadedFileImpl(item.getContentType(), item.get(), item.getName(), item.getSize()));
+
+                  }
+               }
+            }
+         }
+      }
+      catch (FileUploadException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         //TODO:Some nice error message
+      }
+      //if we started editing post, already stored attachs in sessions should be cleaned.
+      if (req.getParameters().get("editPostInit","none").equals("true"))
+      {
+         //clear stored files from session
+         req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, null);
+      }
+      //Uncoment for debug purposes:
+      /*System.out.println("@@@@@@@@@@@@@@@@@@@@@@");
+      System.out.println("in Context.update(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
+      for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
+      {
+         String key = (String)i.next();
+         System.out.println("param key: " + key + " ||param val[1/" + req.getParameterValues(key).length + "]: " + req.getParameter(key));
+      }
+      System.out.println("Parsed file names in request:");
+      for (Iterator i = files.keySet().iterator(); i.hasNext();)
+      {
+         String key = (String)i.next();
+         System.out.println(" -- filename: " + key);
+      }*/
+      //DEBUG code
+      /*AttachmentsManager tflf = (AttachmentsManager)req.getPortletSession().getAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS);
+      if (!(tflf == null))
+      {
+         System.out.println("Already stored files");
+         for (Iterator i = tflf.getFiles().iterator(); i.hasNext();)
+         {
+            TempFileBinding tfb = (TempFileBinding)i.next();
+            System.out.println("+++" + tfb.getFileName() + "<==>" + tfb.getFilePath());
+         }
+      }*/
+
+      //System.out.println("Doing Context.update()");
+      PortletPreferences pp = req.getPreferences();
+      p_mode = ForumsConstants.ModeDecoder.decodePosting(req.getParameter("mode"));
+      //System.out.println("Decoded mode: "+ req.getParameter("mode"));
+      p_forum_id = req.getParameters().getInt(ForumsConstants.POST_FORUM_URL, -1);
+      //System.out.println("Decoded forum id: "+ p_forum_id);
+      p_topic_id = req.getParameters().getInt(ForumsConstants.POST_TOPIC_URL, -1);
+      //System.out.println("Decoded topic id: " +p_topic_id);
+      p_post_id = req.getParameters().getInt(ForumsConstants.POST_POST_URL, -1);
+      //System.out.println("Decoded post id: " +p_post_id);
+      p_topic_type = req.getParameters().getInt("topictype", ForumsConstants.POST_NORMAL);
+      /*p_notify = req.getParameters().getParameterExists("notify");*/
+      p_notify = pp.getValue("notifyreply", "1").equals("1");
+      p_vote_option_id = req.getParameters().getInt("vote_id", -1);
+
+      p_message = new MessageImpl();
+      p_message.setSubject(req.getParameters().get("subject", ""));
+      p_message.setText(req.getParameters().get("message", ""));
+
+      /*if (pp.getValue("attachsig","0").equals("1")){
+          p_message.setText(req.getParameters().get("message", "")+ '\n' + pp.getValue("signature",""));
+      } else {
+          p_message.setText(req.getParameters().get("message", ""));
+      }*/
+      //p_message.setHTMLEnabled(!req.getParameters().getParameterExists("disable_html"));
+      //p_message.setHTMLEnabled(pp.getValue("allowhtml","1").equals("1"));
+      p_message.setBBCodeEnabled(!req.getParameters().getParameterExists("disable_bbcode"));
+      /*p_message.setBBCodeEnabled(pp.getValue("allowbbcode","1").equals("1"));*/
+      p_message.setSmiliesEnabled(!req.getParameters().getParameterExists("disable_smilies"));
+      /*p_message.setSignatureEnabled(req.getParameters().getParameterExists("attach_sig"));*/
+      p_message.setSignatureEnabled(pp.getValue("attachsig", "1").equals("1"));
+
+      String sessionId = req.getPortletSession().getId();
+
+      /**
+       * So... attachments are stored in AttachmentsManager as String path to disk temp file. Manager
+       * is stored in session so when session is broken it will remove files from disk.
+       * When NewTopic view is created for the first time AttachmentManager is removed from session
+       * to deal with clean attachments state. When EditPost link is clicked removal of Manager from session
+       * is done some lines above
+       */
+
+      //persisting attachments to disk
+      int filescount = 0;
+      AttachmentsManager attachmentsManager = (AttachmentsManager)req.getPortletSession().getAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS);
+      //if there is no Manager object in session create one
+      if (attachmentsManager == null)
+      {
+         attachmentsManager = new AttachmentsManager();
+         req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, attachmentsManager);
+      }
+      //add newly uploaded files to Manager
+      for (Iterator i = files.keySet().iterator(); i.hasNext(); filescount++)
+      {
+         String fileName = (String)i.next();
+         UploadedFile uf = (UploadedFile)files.get(fileName);
+         try
+         {
+            TempFileBinding tfb = new TempFileBinding(uf.getContentType(),
+               uf.getByteContent(),
+               uf.getName(),
+               sessionId.toString() + "_" + getNextFileIndex(req));
+            tfb.setComment(req.getParameters().get("filecomment", ""));
+            attachmentsManager.addBinding(tfb);
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            //TODO:Some nice error message
+         }
+      }
+      //p_session_attachments = attachmentsManager.getFiles();
+
+      //
+      String userId = req.getUser().getId().toString();
+      try
+      {
+         p_poster = getForumsModule().findPosterByUserId(userId);
+      }
+      catch (ModuleException e)
+      {
+         //TODO:Some nice error message
+         e.printStackTrace();
+      }
+
+      if (p_post_id != -1)
+      {
+         try
+         {
+            Integer tid = getForumsModule().findPostById(new Integer(p_post_id)).getTopic().getId();
+            p_post_parent_topic_id = tid.intValue();
+            Integer fpid = getForumsModule().findTopicById(tid).getFirstPost().getId();
+            p_topic_first_post = p_post_id == fpid.intValue();
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         }
+      }
+
+      if (p_poster == null)
+      {
+         p_poster = new PosterImpl(userId);
+      }
+
+      //
+      p_poll = new PollImpl();
+      p_poll.setTitle(req.getParameters().get("poll_title", ""));
+      p_poll.setLength(Math.max(req.getParameters().getInt("poll_length", 0),
+         0));
+      p_poll.setOptions(new LinkedList());
+
+      String p_add_poll_option_text = req.getParameter("add_poll_option_text");
+      boolean p_poll_add = req.getParameters().getParameterExists("add_poll_option");
+      boolean p_poll_edit = req.getParameters().getParameterExists("edit_poll_option");
+
+      boolean option_deleted = false;
+      for (int index = 0; true; index++)
+      {
+         String param = "poll_option_text[" + index + "]";
+         String value = req.getParameter(param);
+         boolean deleted = req.getParameter("del_poll_option[" + index + "]") != null;
+         option_deleted |= deleted;
+         if ((value != null))
+         {
+            if (!deleted)
+            {
+               /*p_poll.getOptions().add(deleted ? null : value);*/
+               //p_poll.getOptions().add(value);
+
+               p_poll.getOptions().add(new PollOptionImpl(value));
+            }
+         }
+         else
+         {
+            break;
+         }
+      }
+
+      if (p_poll_add)
+      {
+         //p_poll.getOptions().add(p_add_poll_option_text);
+         p_poll.getOptions().add(new PollOptionImpl(p_add_poll_option_text));
+      }
+
+      //      if (p_poll_add && p_add_poll_option_text != null)
+      //      {
+      //         // htmlspecialchars(trim(stripslashes(
+      //         p_poll_option_text.add(p_add_poll_option_text);
+      //      }
+      boolean toggle_attach_box = req.getParameters().getParameterExists("add_attachment_box");
+      boolean toggle_posted_attachments = req.getParameters().getParameterExists("posted_attachments");
+
+      p_poll_delete = req.getParameters().getParameterExists("poll_delete");
+      p_cancel = req.getParameters().getParameterExists("cancel");
+      p_submit = req.getParameters().getParameterExists("post");
+      p_confirm = req.getParameters().getParameterExists("confirm");
+      p_preview = req.getParameters().getParameterExists("preview");
+      p_attach_box = toggle_attach_box | req.getParameters().getParameterExists("add_attachment_box_flag");
+      p_posted_attach = toggle_posted_attachments ^ req.getParameters().getParameterExists("posted_attachments_flag");
+      p_attach = req.getParameters().getParameterExists("add_attachment");
+
+      // Handle Delete/update attachments buttons
+      boolean session_attachment_deleted = false;
+      //search thru params for update/delete command
+      for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
+      {
+         String parameter = (String)i.next();
+         if (parameter.startsWith("del_attachment["))
+         {
+            //attach id can be for attachment in DB or file in AttachmentsManager
+            boolean isStored = parameter.startsWith("del_attachment[stored_attach_");
+            int from = (isStored ? "del_attachment[stored_attach_" : "del_attachment[").length();
+
+            int to = parameter.length() - 1;
+            String s = parameter.substring(from, to);
+            //int index = Integer.parseInt(s);
+            //if it's for attachment in DB just remember it's ID to remove it during executin proper command
+            if (isStored)
+            {
+               int index = Integer.parseInt(s);
+               attachmentsManager.getDeletedAttachments().add(new Integer(index));
+            }
+            //if it's previosly uploaded file just remove binding from Manager
+            else
+            {
+               attachmentsManager.removeBinding(s);
+            }
+            session_attachment_deleted = true;
+            break;
+         }
+         //check if this is update button
+         if (parameter.startsWith("update_attachment["))
+         {
+            boolean isStored = parameter.startsWith("update_attachment[stored_attach_");
+            int from = (isStored ? "update_attachment[stored_attach_" : "update_attachment[").length();
+            int to = parameter.length() - 1;
+            String s = parameter.substring(from, to);
+            //int index = Integer.parseInt(s);
+            //if this is attachment in DB remember it's index and new comment
+            if (isStored)
+            {
+               int index = Integer.parseInt(s);
+               String newComment = req.getParameters().get("attach_comment[stored_attach_"+ s +"]","");
+               attachmentsManager.getUpdatedAttachments().put(new Integer(index), newComment);
+            }
+            //if this is previously uploaded file update comment in binding in Manager
+            else
+            {
+               attachmentsManager.updateBindingComment(s, req.getParameters().get("attach_comment["+ s +"]",""));
+            }
+            session_attachment_deleted = true;
+            break;
+         }
+      }
+      //[List]newly uploaded files
+      p_session_attachments = attachmentsManager.getFiles();
+      //[List]indexes of attachments that should be removed from DB
+      p_deleted_attachments = attachmentsManager.getDeletedAttachments();
+      //[Map]indexes of attachments and new comments that should be updated in DB
+      p_updated_attachments = attachmentsManager.getUpdatedAttachments();
+
+
+      // Are we refreshing the page ?
+      boolean c_refresh = p_preview;
+      c_refresh |= p_poll_delete;
+      c_refresh |= p_poll_add;
+      c_refresh |= p_poll_edit;
+      c_refresh |= p_attach;
+      c_refresh |= option_deleted;
+
+      //      c_refresh |= session_attachment_deleted;
+      c_refresh |= toggle_attach_box;
+      c_refresh |= toggle_posted_attachments;
+
+      this.c_refresh = c_refresh;
+
+      // Clean up the attachments if necessary
+      /*if (((p_mode == ForumsConstants.PMODE_EDIT_POST) || (p_mode == ForumsConstants.PMODE_NEW_TOPIC)
+         || (p_mode == ForumsConstants.PMODE_REPLY))
+         && (c_refresh || p_submit))
+      {
+         //
+      }
+      else
+      {
+         //p_deleted_attachments.clear();
+         //p_session_attachments.clear();
+
+      }*/
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param req  DOCUMENT_ME
+    * @param resp DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public Action action(JBossActionRequest req,
+                        JBossActionResponse resp)
+   {
+      //System.out.println("Doing Context.action()");
+      Action action = null;
+      switch (p_mode)
+      {
+
+         case ForumsConstants.PMODE_VOTE:
+         {
+            VoteTopicCommand vtc = new VoteTopicCommand(req, resp);
+            vtc.setPoster(p_poster);
+            vtc.topicId = p_topic_id;
+            vtc.forumId = p_forum_id;
+            vtc.voteOptionId = p_vote_option_id;
+            action = new ProcessCommandAction(vtc);
+            break;
+         }
+         case ForumsConstants.PMODE_REPLY:
+         {
+            if (c_refresh)
+            {
+               ReplyAction rra = new ReplyAction(p_post_id, p_message, p_poster, p_session_attachments);
+               rra.setModule(getForumsModule());
+               action = rra;
+            }
+            else if (p_submit)
+            {
+               ReplyCommand rc = new ReplyCommand(req, resp);
+               rc.setPoster(p_poster);
+               rc.postId = p_post_id;
+               PortletPreferences pp = req.getPreferences();
+               /*if (pp.getValue("attachsig","0").equals("1")){
+                   String tmp = p_message.getText();
+                   p_message.setText(tmp + "\n\n" + pp.getValue("signature",""));
+               }*/
+               List attachments = new LinkedList();
+               for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
+               {
+                  attachments.add(((TempFileBinding)i.next()).produceAttachment());
+               }
+               rc.attachments = attachments;
+               rc.message = p_message;
+               rc.current_time = new Date();
+               rc.setModule(getForumsModule());
+               //               rc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
+               action = new ProcessCommandAction(rc);
+            }
+            else
+            {
+               ReplyAction rra = new ReplyAction(false, p_post_id, p_message, p_poster);
+               rra.setModule(getForumsModule());
+               action = rra;
+            }
+
+            break;
+         }
+
+         case ForumsConstants.PMODE_QUOTE:
+         {
+            ReplyAction rra = new ReplyAction(true, p_post_id, p_message, p_poster);
+            rra.setModule(getForumsModule());
+            action = rra;
+            break;
+         }
+
+         case ForumsConstants.PMODE_EDIT_POST:
+         {
+            if (c_refresh)
+            {
+               EditPostAction epa =
+                  new EditPostAction(p_message, p_poster, p_post_id, p_session_attachments, p_poll);
+               epa.setModule(getForumsModule());
+               action = epa;
+            }
+            else if (p_submit)
+            {
+               EditPostCommand epc = new EditPostCommand(req, resp);
+               epc.setPoster(p_poster);
+               epc.postId = p_post_id;
+               PortletPreferences pp = req.getPreferences();
+               /*if (pp.getValue("attachsig","0").equals("1")){
+                   String tmp = p_message.getText();
+                   p_message.setText(tmp + "\n\n");
+               }*/
+               epc.message = p_message;
+               p_poll.setCreationDate(new Date());
+               if (ForumsTools.hasPermission(req, "EditPollInPost"))
+               {
+                  epc.poll = p_poll;
+               }
+
+               //               epc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
+
+
+               List attachments = new LinkedList();
+               for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
+               {
+                  attachments.add(((TempFileBinding)i.next()).produceAttachment());
+               }
+               epc.attachments = attachments;
+
+               epc.topic_type = p_topic_type;
+               epc.current_time = new Date();
+               epc.poll_delete = p_poll_delete;
+               epc.notify = p_notify;
+               /*epc.deletedAttachments =
+                  (Integer[])p_deleted_attachments.toArray(new Integer[p_deleted_attachments.size()]);*/
+               epc.deletedAttachments = p_deleted_attachments;
+
+               epc.updatedAttachments = p_updated_attachments;
+               action = new ProcessCommandAction(epc);
+            }
+            else
+            {
+               EditPostAction epa =
+                  new EditPostAction(p_message, p_poster, p_post_id, p_session_attachments, p_poll);
+               epa.setModule(getForumsModule());
+               action = epa;
+            }
+
+            break;
+         }
+
+         case ForumsConstants.PMODE_DELETE:
+         {
+            DeletePostCommand dpc = new DeletePostCommand(req, resp);
+            dpc.setPoster(p_poster);
+            dpc.postId = p_post_id;
+            dpc.setModule(getForumsModule());
+            action = new ProcessCommandAction(dpc);
+            break;
+         }
+
+         case ForumsConstants.PMODE_POLL_DELETE:
+         {
+            DeletePollCommand dpc = new DeletePollCommand(req, resp);
+            dpc.setPoster(p_poster);
+            dpc.postId = p_post_id;
+            action = new ProcessCommandAction(dpc);
+            break;
+         }
+
+         case ForumsConstants.PMODE_NEW_TOPIC:
+         {
+            if (c_refresh)
+            {
+
+               NewTopicAction nta =
+                  new NewTopicAction(p_poster, p_message, p_forum_id, p_session_attachments, p_poll);
+               nta.setModule(getForumsModule());
+               action = nta;
+            }
+            else if (p_submit)
+            {
+               NewTopicCommand ntc = new NewTopicCommand(req, resp);
+               ntc.setPoster(p_poster);
+               ntc.forumId = p_forum_id;
+
+               /*ntc.message = p_message;*/
+
+               PortletPreferences pp = req.getPreferences();
+               /*if (pp.getValue("attachsig","0").equals("1")){
+                   String tmp = p_message.getText();
+                   p_message.setText(tmp + "\n\n" + pp.getValue("signature",""));
+               }*/
+               List attachments = new LinkedList();
+               for (Iterator i = p_session_attachments.iterator(); i.hasNext();)
+               {
+                  attachments.add(((TempFileBinding)i.next()).produceAttachment());
+               }
+               ntc.attachments = attachments;
+
+               ntc.message = p_message;
+               p_poll.setCreationDate(new Date());
+               ntc.poll = p_poll;
+               //               ntc.attachments = (UploadedFile[])p_session_attachments.toArray(new UploadedFile[p_session_attachments.size()]);
+               ntc.topic_type = p_topic_type;
+               ntc.current_time = new Date();
+               ntc.notify = p_notify;
+               ntc.setModule(getForumsModule());
+               action = new ProcessCommandAction(ntc);
+            }
+            else
+            {
+               NewTopicAction nta = new NewTopicAction(p_forum_id);
+               nta.setModule(getForumsModule());
+               action = nta;
+            }
+
+            break;
+         }
+
+
+         case ForumsConstants.PMODE_REPOST:
+         {
+            RepostCommand rc = new RepostCommand(req, resp);
+            rc.setPoster(p_poster);
+            rc.postId = p_post_id;
+            action = new ProcessCommandAction(rc);
+            break;
+         }
+      }
+
+      return action;
+   }
+
+   public ForumsModule getForumsModule()
+   {
+      return forumsModule;
+   }
+
+   public void setForumsModule(ForumsModule forumsModule)
+   {
+      this.forumsModule = forumsModule;
+   }
+
+
+   /**
+    * Object that stores binding to uploaded and stored as Temp Files attachments. Object is stored in
+    * session and implements HttpSessionBindingListener so when session is invalidated it removes stored
+    * files from disk
+    */
+   private class AttachmentsManager implements HttpSessionBindingListener
+   {
+      //uploaded and stored to disk attachments bindings.
+      private List files;
+      //indexes of attachments that should be deleted from DB
+      private List deletedAttachments;
+      //indexes of attachments in DB that should have updated comment + new comment value
+      private Map updatedAttachments;
+
+      AttachmentsManager()
+      {
+         files = new LinkedList();
+         setDeletedAttachments(new LinkedList());
+         setUpdatedAttachments(new HashMap());
+
+
+      }
+
+      /**
+       * Simply adds new TempFileBinding
+       * @param tmp
+       */
+      public void addBinding(TempFileBinding tmp)
+      {
+         files.add(tmp);
+      }
+
+      /**
+       * Removes Binding of id such as in argument
+       * @param id
+       */
+      public void removeBinding(String id)
+      {
+         for (Iterator i = files.iterator(); i.hasNext();)
+         {
+            TempFileBinding tfb = (TempFileBinding)i.next();
+            if (tfb.getFileId().equals(id))
+            {
+               tfb.delete();
+               files.remove(tfb);
+               break;
+            }
+         }
+      }
+
+      /**
+       * Updates comment for attachment
+       * @param id
+       * @param comment
+       */
+      public void updateBindingComment(String id, String comment)
+      {
+         for (Iterator i = files.iterator(); i.hasNext();)
+         {
+            TempFileBinding tfb = (TempFileBinding)i.next();
+            if (tfb.getFileId().equals(id))
+            {
+               tfb.setComment(comment);
+               break;
+            }
+         }
+      }
+
+      public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent)
+      {
+      }
+
+      /**
+       * If object removed from session we do clean up and removes every file stored to disk
+       * @param httpSessionBindingEvent
+       */
+      public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent)
+      {
+         for (Iterator i = files.iterator(); i.hasNext();)
+         {
+            TempFileBinding tmpb = (TempFileBinding)i.next();
+            tmpb.delete();
+         }
+      }
+
+      public List getFiles()
+      {
+         return files;
+      }
+
+      public void setFiles(List files)
+      {
+         this.files = files;
+      }
+
+      /**
+       * Stores indexes of persisted attachments which should be deleted
+       * @return
+       */
+      public List getDeletedAttachments()
+      {
+         return deletedAttachments;
+      }
+
+      public void setDeletedAttachments(List deletedAttachments)
+      {
+         this.deletedAttachments = deletedAttachments;
+      }
+
+      /**
+       * Stores indexes of persisted attachments and their new comments.
+       * @return
+       */
+      public Map getUpdatedAttachments()
+      {
+         return updatedAttachments;
+      }
+
+      public void setUpdatedAttachments(Map updatedAttachments)
+      {
+         this.updatedAttachments = updatedAttachments;
+      }
+   }
+
+   /**
+    * provides session unique integer value
+    * @param req
+    * @return
+    */
+   int getNextFileIndex(JBossActionRequest req)
+   {
+      Integer index = (Integer)req.getPortletSession().getAttribute(ForumsConstants.FILE_SESSION_INDEX);
+      if (index == null)
+      {
+         index = new Integer(0);
+         req.getPortletSession().setAttribute(ForumsConstants.FILE_SESSION_INDEX, index);
+      }
+      else
+      {
+         int i = index.intValue();
+         index = new Integer(i + 1);
+         req.getPortletSession().setAttribute(ForumsConstants.FILE_SESSION_INDEX, index);
+
+      }
+      return index.intValue();
+   }
+}
+
+

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsConstants.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsConstants.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsConstants.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,1060 +1,1060 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums;
-
-import org.jboss.portlet.forums.model.AuthType;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.5 $
- */
-public interface ForumsConstants //extends Constants
-{
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_SMALL_HEADER = "small_header";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_TOPIC_NOTIFY = "search_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_SEARCH_BODY = "search_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_MESSAGE_BODY = "message_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_INDEX_BODY = "index_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_VIEWFORUM_BODY = "viewforum_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_VIEWTOPIC_BODY = "viewtopic_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_VIEWTOPIC_ATTACH_BODY = "viewtopic_attach_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_VIEWTOPIC_POLL_RESULT = "viewtopic_poll_result";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_VIEWTOPIC_POLL_BALLOT = "viewtopic_poll_ballot";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_JUMP_BOX = "jumpbox";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_POSTING_BODY = "posting_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_POSTING_POLL_BODY = "posting_poll_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_POSTING_ATTACH_BODY = "posting_attach_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADD_ATTACHMENT_BODY = "add_attachment_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_POSTED_ATTACHMENTS_BODY = "posted_attachments_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_POSTING_TOPIC_REVIEW = "posting_topic_review";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_POSTING_PREVIEW = "posting_preview";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_MODCP_BODY = "modcp_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_MODCP_MOVE = "modcp_move";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CONFIRM_BODY = "confirm_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ERROR_BODY = "error_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_SEARCH_RESULTS_POSTS = "search_results_posts";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_SEARCH_RESULTS_TOPICS = "search_results_topics";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_WATCHED_TOPICS_BODY = "watched_topics_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_WATCHED_FORUMS_BODY = "watched_forums_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADMIN_AUTH_FORUM_BODY = "admin/auth_forum_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADMIN_AUTH_SELECT_BODY = "admin/auth_select_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADMIN_FORUM_ADMIN_BODY = "admin/forum_admin_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADMIN_FORUM_EDIT_BODY = "admin/forum_edit_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADMIN_CATEGORY_EDIT_BODY = "admin/category_edit_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String THEMENAME = "subSilver";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADMIN_FORUM_DELETE_BODY = "admin/forum_delete_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_ADMIN_ATTACH_MANAGE_BODY = "admin/attach_manage_body";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_B_CLOSE = "code/b_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_B_OPEN = "code/b_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_CODE_CLOSE = "code/code_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_CODE_OPEN = "code/code_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_COLOR_CLOSE = "code/color_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_COLOR_OPEN = "code/color_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_EMAIL = "code/email";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_I_CLOSE = "code/i_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_I_OPEN = "code/i_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_IMG = "code/img";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_LISTITEM = "code/listitem";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_OLIST_CLOSE = "code/olist_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_OLIST_OPEN = "code/olist_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_QUOTE_CLOSE = "code/quote_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_QUOTE_OPEN = "code/quote_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_QUOTE_USERNAME_OPEN = "code/quote_username_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_SIZE_CLOSE = "code/size_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_SIZE_OPEN = "code/size_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_U_CLOSE = "code/u_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_U_OPEN = "code/u_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_ULIST_CLOSE = "code/ulist_close";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_ULIST_OPEN = "code/ulist_open";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_CODE_URL = "code/url";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_THEME_BLOCK_TOPICS = "block/topics";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_MAIL_TOPIC_NOTIFY = "topic_notify";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String TPL_MAIL_FORUM_NOTIFY = "forum_notify";
-
-   /**
-    * DOCUMENT_ME
-    */
-   int BLOCK_TOPICS_MODE_LATEST_POSTS = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int BLOCK_TOPICS_MODE_HOT_TOPICS = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int BLOCK_TOPICS_MODE_HOTTEST_TOPICS = 2;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int BLOCK_TOPICS_MODE_MOST_VIEWED = 3;
-
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] SORT_BY_TYPES =
-      {
-         "${bb.Sort_Time}",
-         "${bb.Sort_Post_Subject}",
-         "${bb.Sort_Author}",
-         "${bb.Sort_Forum}"
-      };
-
-   /**
-    * DOCUMENT_ME
-    */
-   int[] PREVIOUS_DAYS =
-      {
-         0,
-         1,
-         7,
-         14,
-         30,
-         90,
-         180,
-         364
-      };
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] PREVIOUS_DAYS_TEXT_TOPICS =
-      {
-         "${bb.All_Topics}",
-         "${bb.1_Day}",
-         "${bb.7_Days}",
-         "${bb.2_Weeks}",
-         "${bb.1_Month}",
-         "${bb.3_Months}",
-         "${bb.6_Months}",
-         "${bb.1_Year}"
-      };
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] PREVIOUS_DAYS_TEXT_POSTS =
-      {
-         "${bb.All_Posts}",
-         "${bb.1_Day}",
-         "${bb.7_Days}",
-         "${bb.2_Weeks}",
-         "${bb.1_Month}",
-         "${bb.3_Months}",
-         "${bb.6_Months}",
-         "${bb.1_Year}"
-      };
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] FORUM_AUTH_FORM_FIELD_NAMES =
-      {
-         "auth_view",
-         "auth_read",
-         "auth_post",
-         "auth_reply",
-         "auth_edit",
-         "auth_delete",
-         "auth_sticky",
-         "auth_announce",
-         "auth_vote",
-         "auth_pollcreate",
-         "auth_attachment"
-      };
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] FORUM_AUTH_FORM_FIELD_LABELS =
-      {
-         "${bb.View}",
-         "${bb.Read}",
-         "${bb.Post}",
-         "${bb.Reply}",
-         "${bb.Edit}",
-         "${bb.Delete}",
-         "${bb.Sticky}",
-         "${bb.Announce}",
-         "${bb.Vote}",
-         "${bb.Pollcreate}",
-         "${bb.UploadedFile}"
-      };
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] FORUM_AUTH_LEVEL_LABELS =
-      {
-         "ALL",
-         "REG",
-         "PRIVATE",
-         "MOD",
-         "ADMIN"
-      };
-
-   /*
-      int[] FORUM_AUTH_LEVEL = {
-         Auth.LEVEL_ALL, Auth.LEVEL_REG, Auth.LEVEL_ACL, Auth.LEVEL_MOD, Auth.LEVEL_ADM
-      };
-    */
-
-   /**
-    * DOCUMENT_ME
-    */
-   int GENERAL_MESSAGE = 200;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int GENERAL_ERROR = 202;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int CRITICAL_MESSAGE = 203;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int CRITICAL_ERROR = 204;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int POST_NORMAL = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int POST_STICKY = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int POST_ANNOUNCE = 2;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int POST_GLOBAL_ANNONCE = 3;
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] AUTH_TYPE_TO_MESSAGE =
-      {
-         null,
-         null,
-         "Sorry_auth_read_",
-         "Sorry_auth_post_",
-         "Sorry_auth_reply_",
-         "Sorry_auth_edit_",
-         "Sorry_auth_delete_",
-         "Sorry_auth_announce_",
-         "Sorry_auth_sticky_",
-         null,
-         null,
-         "Sorry_auth_vote_",
-         null,
-      };
-
-   /**
-    * DOCUMENT_ME
-    */
-   int[] TOPIC_TYPE_TO_AUTH_TYPE =
-      {
-         AuthType.POST,
-         AuthType.STICKY,
-         AuthType.ANNOUNCE,
-         AuthType.POST
-      };
-
-   // modes
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_NO_MODE = -1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_VOTE = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_REPLY = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_QUOTE = 2;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_EDIT_POST = 3;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_DELETE = 4;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_POLL_DELETE = 5;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_NEW_TOPIC = 6;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_REPOST = 7;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_SMILIES = 8;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMODE_TOPIC_REVIEW = 9;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_VOTE = 0x0000001;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_REPLY = 0x0000002;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_QUOTE = 0x0000004;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_EDIT_POST = 0x0000008;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_DELETE = 0x0000010;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_POLL_DELETE = 0x0000020;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_NEW_TOPIC = 0x0000040;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_SMILIES = 0x0000080;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int PMASK_TOPIC_REVIEW = 0x0000100;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int[] PMASKS =
-      {
-         PMASK_VOTE,
-         PMASK_REPLY,
-         PMASK_QUOTE,
-         PMASK_EDIT_POST,
-         PMASK_DELETE,
-         PMASK_POLL_DELETE,
-         PMASK_NEW_TOPIC,
-         PMASK_SMILIES,
-         PMASK_TOPIC_REVIEW
-      };
-
-   /*
-      int[] PMODE_TO_AUTH_TYPE = {
-         Auth.TYPE_READ,
-         Auth.TYPE_REPLY,
-         Auth.TYPE_REPLY,
-         Auth.TYPE_EDIT,
-         Auth.TYPE_DELETE,
-         Auth.TYPE_DELETE
-      };
-    */
-
-   /**
-    * DOCUMENT_ME
-    */
-   int MMODE_NO_MODE = -1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int MMODE_DELETE = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int MMODE_MOVE = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int MMODE_LOCK = 2;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int MMODE_UNLOCK = 3;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int MMODE_SPLIT = 4;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int MMODE_IP = 5;
-
-   /**
-    * DOCUMENT_ME
-    */
-   String[] AUTH_PRESETS_NAMES =
-      {
-         "${bb.Public}",
-         "${bb.Registered}",
-         "${bb.Registered}[${bb.Hidden}]",
-         "${bb.Private}",
-         "${bb.Private}[${bb.Hidden}]",
-         "${bb.Moderators}",
-         "${bb.Moderators}[${bb.Hidden}]"
-      };
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @author $author$
-    * @version $Revision: 1.5 $
-    */
-   class ModeDecoder
-   {
-      private static final String[] P_TO_HTML = new String[10];
-
-      static
-      {
-         P_TO_HTML[PMODE_VOTE] = "vote";
-         P_TO_HTML[PMODE_REPLY] = "reply";
-         P_TO_HTML[PMODE_QUOTE] = "reply";
-         P_TO_HTML[PMODE_EDIT_POST] = "editpost";
-         P_TO_HTML[PMODE_DELETE] = "delete";
-         P_TO_HTML[PMODE_POLL_DELETE] = "poll_delete";
-         P_TO_HTML[PMODE_NEW_TOPIC] = "newtopic";
-         P_TO_HTML[PMODE_REPOST] = "repost";
-         P_TO_HTML[PMODE_SMILIES] = "smilies";
-         P_TO_HTML[PMODE_TOPIC_REVIEW] = "topicreview";
-      }
-
-      /**
-       * DOCUMENT_ME
-       *
-       * @param mode DOCUMENT_ME
-       * @return DOCUMENT_ME
-       */
-      public static final String encodePosting(int mode)
-      {
-         return P_TO_HTML[mode];
-      }
-
-      /**
-       * DOCUMENT_ME
-       *
-       * @param mode DOCUMENT_ME
-       * @return DOCUMENT_ME
-       */
-      public static final int decodePosting(String mode)
-      {
-         if ("topicreview".equals(mode))
-         {
-            return PMODE_TOPIC_REVIEW;
-         }
-
-         if ("smilies".equals(mode))
-         {
-            return PMODE_SMILIES;
-         }
-
-         if ("reply".equals(mode))
-         {
-            return PMODE_REPLY;
-         }
-
-         if ("quote".equals(mode))
-         {
-            return PMODE_QUOTE;
-         }
-
-         if ("editpost".equals(mode))
-         {
-            return PMODE_EDIT_POST;
-         }
-
-         if ("delete".equals(mode))
-         {
-            return PMODE_DELETE;
-         }
-
-         if ("poll_delete".equals(mode))
-         {
-            return PMODE_POLL_DELETE;
-         }
-
-         if ("vote".equals(mode))
-         {
-            return PMODE_VOTE;
-         }
-
-         if ("newtopic".equals(mode))
-         {
-            return PMODE_NEW_TOPIC;
-         }
-
-         if ("repost".equals(mode))
-         {
-            return PMODE_REPOST;
-         }
-
-         return PMODE_NO_MODE;
-      }
-
-      /*
-         public static final int decodeModcp(Page page)
-         {
-            String mode = page.getParameter("mode");
-            if (mode != null)
-            {
-               if ("delete".equals(mode))
-               {
-                  return MMODE_DELETE;
-               }
-               if ("move".equals(mode))
-               {
-                  return MMODE_MOVE;
-               }
-               if ("lock".equals(mode))
-               {
-                  return MMODE_LOCK;
-               }
-               if ("unlock".equals(mode))
-               {
-                  return MMODE_UNLOCK;
-               }
-               if ("split".equals(mode))
-               {
-                  return MMODE_SPLIT;
-               }
-            }
-            else
-            {
-               if (page.getParameter("delete") != null)
-               {
-                  return MMODE_DELETE;
-               }
-               else if (page.getParameter("move") != null)
-               {
-                  return MMODE_MOVE;
-               }
-               else if (page.getParameter("lock") != null)
-               {
-                  return MMODE_LOCK;
-               }
-               else if (page.getParameter("unlock") != null)
-               {
-                  return MMODE_LOCK;
-               }
-            }
-            return MMODE_NO_MODE;
-         }
-       */
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   int FORUM_UNLOCKED = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int FORUM_LOCKED = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int TOPIC_UNLOCKED = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int TOPIC_LOCKED = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int TOPIC_MOVED = 2;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int TOPIC_WATCH_UN_NOTIFIED = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   int TOPIC_WATCH_NOTIFIED = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   String POST_CAT_URL = "c";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String POST_FORUM_URL = "f";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String POST_TOPIC_URL = "t";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String POST_POST_URL = "p";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String POST_USERS_URL = "u";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String POST_ROLES_URL = "g";
-
-   /**
-    * When a notification message is sent, send a link to the message.
-    */
-   int WATCH_MODE_LINKED = 0;
-
-   /**
-    * When a notification message is sent, send the message content.
-    */
-   int WATCH_MODE_EMBEDED = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final String FORUMSMODULE_JNDINAME = "java:portal/ForumsModule";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String USER_SIGNATURE_PROPERTY = "portal.user.forums.signature";
-
-   /**
-    * DOCUMENT_ME
-    */
-   String USER_SIGNATURE_ADD_PROPERTY = "portal.user.forums.addsignature";
-
-   String DEFAULT_DATE_PATTERN = "EEE MMM d, yyyy HH:mm aaa";
-
-   String DISK_PERSISTED_ATTACHEMENTS = "EEE MMM d, yyyy HH:mm aaa";
-
-   String POSTING_POSTBACK_FLAG = "posting_postback_flag";
-
-   String FILE_SESSION_INDEX = "portal.user.forums.file_session_index";
-
-   String ATTACHMENT_TOKENS_MANAGER = "org.jboss.portlet.forums.helper.AttachmentTokenManager";
-                                             
-}
-
-//// Debug Level
-////define('DEBUG', 1); // Debugging on
-//define('DEBUG', 1); // Debugging off
-//
-//
-//// User Levels <- Do not change the values of USER or ADMIN
-//define('DELETED', -1);
-//define('ANONYMOUS', -1);
-//
-//define('USER', 0);
-//define('ADMIN', 1);
-//define('MOD', 2);
-//
-//
-//// User related
-//define('USER_ACTIVATION_NONE', 0);
-//define('USER_ACTIVATION_SELF', 1);
-//define('USER_ACTIVATION_ADMIN', 2);
-//
-//define('USER_AVATAR_NONE', 0);
-//define('USER_AVATAR_UPLOAD', 1);
-//define('USER_AVATAR_REMOTE', 2);
-//define('USER_AVATAR_GALLERY', 3);
-//
-//
-//// Group settings
-//define('GROUP_OPEN', 0);
-//define('GROUP_CLOSED', 1);
-//define('GROUP_HIDDEN', 2);
-//
-//
-//// Forum state
-//define('FORUM_UNLOCKED', 0);
-//define('FORUM_LOCKED', 1);
-//
-//
-//
-//
-//
-//
-//// SQL codes
-//define('BEGIN_TRANSACTION', 1);
-//define('END_TRANSACTION', 2);
-//
-//
-//
-//
-//// Private messaging
-//define('PRIVMSGS_READ_MAIL', 0);
-//define('PRIVMSGS_NEW_MAIL', 1);
-//define('PRIVMSGS_SENT_MAIL', 2);
-//define('PRIVMSGS_SAVED_IN_MAIL', 3);
-//define('PRIVMSGS_SAVED_OUT_MAIL', 4);
-//define('PRIVMSGS_UNREAD_MAIL', 5);
-//
-//
-//
-//// Session parameters
-//define('SESSION_METHOD_COOKIE', 100);
-//define('SESSION_METHOD_GET', 101);
-//
-//
-//// Page numbers for session handling
-//define('PAGE_INDEX', 0);
-//define('PAGE_LOGIN', -1);
-//define('PAGE_SEARCH', -2);
-//define('PAGE_REGISTER', -3);
-//define('PAGE_PROFILE', -4);
-//define('PAGE_VIEWONLINE', -6);
-//define('PAGE_VIEWMEMBERS', -7);
-//define('PAGE_FAQ', -8);
-//define('PAGE_POSTING', -9);
-//define('PAGE_PRIVMSGS', -10);
-//define('PAGE_GROUPCP', -11);
-//define('PAGE_TOPIC_OFFSET', 5000);
-//
-//
-//
-//
-//// Table names
-//define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access');
-//define('BANLIST_TABLE', $table_prefix.'banlist');
-//define('CATEGORIES_TABLE', $table_prefix.'categories');
-//define('CONFIG_TABLE', $table_prefix.'config');
-//define('DISALLOW_TABLE', $table_prefix.'disallow');
-//define('FORUMS_TABLE', $table_prefix.'forums');
-//define('GROUPS_TABLE', $table_prefix.'groups');
-//define('POSTS_TABLE', $table_prefix.'posts');
-//define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
-//define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');
-//define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text');
-//define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore');
-//define('PRUNE_TABLE', $table_prefix.'forum_prune');
-//define('RANKS_TABLE', $table_prefix.'ranks');
-//define('SEARCH_TABLE', $table_prefix.'search_results');
-//define('SEARCH_WORD_TABLE', $table_prefix.'search_wordlist');
-//define('SEARCH_MATCH_TABLE', $table_prefix.'search_wordmatch');
-//define('SESSIONS_TABLE', $table_prefix.'sessions');
-//define('SMILIES_TABLE', $table_prefix.'smilies');
-//define('THEMES_TABLE', $table_prefix.'themes');
-//define('THEMES_NAME_TABLE', $table_prefix.'themes_name');
-//define('TOPICS_TABLE', $table_prefix.'topics');
-//define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch');
-//define('USER_GROUP_TABLE', $table_prefix.'user_group');
-//define('USERS_TABLE', $table_prefix.'users');
-//define('WORDS_TABLE', $table_prefix.'words');
-//define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
-//define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
-//define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
-//
-//?>
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums;
+
+import org.jboss.portlet.forums.model.AuthType;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.5 $
+ */
+public interface ForumsConstants //extends Constants
+{
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_SMALL_HEADER = "small_header";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_TOPIC_NOTIFY = "search_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_SEARCH_BODY = "search_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_MESSAGE_BODY = "message_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_INDEX_BODY = "index_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_VIEWFORUM_BODY = "viewforum_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_VIEWTOPIC_BODY = "viewtopic_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_VIEWTOPIC_ATTACH_BODY = "viewtopic_attach_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_VIEWTOPIC_POLL_RESULT = "viewtopic_poll_result";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_VIEWTOPIC_POLL_BALLOT = "viewtopic_poll_ballot";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_JUMP_BOX = "jumpbox";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_POSTING_BODY = "posting_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_POSTING_POLL_BODY = "posting_poll_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_POSTING_ATTACH_BODY = "posting_attach_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADD_ATTACHMENT_BODY = "add_attachment_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_POSTED_ATTACHMENTS_BODY = "posted_attachments_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_POSTING_TOPIC_REVIEW = "posting_topic_review";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_POSTING_PREVIEW = "posting_preview";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_MODCP_BODY = "modcp_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_MODCP_MOVE = "modcp_move";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CONFIRM_BODY = "confirm_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ERROR_BODY = "error_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_SEARCH_RESULTS_POSTS = "search_results_posts";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_SEARCH_RESULTS_TOPICS = "search_results_topics";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_WATCHED_TOPICS_BODY = "watched_topics_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_WATCHED_FORUMS_BODY = "watched_forums_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADMIN_AUTH_FORUM_BODY = "admin/auth_forum_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADMIN_AUTH_SELECT_BODY = "admin/auth_select_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADMIN_FORUM_ADMIN_BODY = "admin/forum_admin_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADMIN_FORUM_EDIT_BODY = "admin/forum_edit_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADMIN_CATEGORY_EDIT_BODY = "admin/category_edit_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String THEMENAME = "subSilver";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADMIN_FORUM_DELETE_BODY = "admin/forum_delete_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_ADMIN_ATTACH_MANAGE_BODY = "admin/attach_manage_body";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_B_CLOSE = "code/b_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_B_OPEN = "code/b_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_CODE_CLOSE = "code/code_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_CODE_OPEN = "code/code_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_COLOR_CLOSE = "code/color_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_COLOR_OPEN = "code/color_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_EMAIL = "code/email";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_I_CLOSE = "code/i_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_I_OPEN = "code/i_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_IMG = "code/img";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_LISTITEM = "code/listitem";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_OLIST_CLOSE = "code/olist_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_OLIST_OPEN = "code/olist_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_QUOTE_CLOSE = "code/quote_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_QUOTE_OPEN = "code/quote_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_QUOTE_USERNAME_OPEN = "code/quote_username_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_SIZE_CLOSE = "code/size_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_SIZE_OPEN = "code/size_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_U_CLOSE = "code/u_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_U_OPEN = "code/u_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_ULIST_CLOSE = "code/ulist_close";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_ULIST_OPEN = "code/ulist_open";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_CODE_URL = "code/url";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_THEME_BLOCK_TOPICS = "block/topics";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_MAIL_TOPIC_NOTIFY = "topic_notify";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String TPL_MAIL_FORUM_NOTIFY = "forum_notify";
+
+   /**
+    * DOCUMENT_ME
+    */
+   int BLOCK_TOPICS_MODE_LATEST_POSTS = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int BLOCK_TOPICS_MODE_HOT_TOPICS = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int BLOCK_TOPICS_MODE_HOTTEST_TOPICS = 2;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int BLOCK_TOPICS_MODE_MOST_VIEWED = 3;
+
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] SORT_BY_TYPES =
+      {
+         "${bb.Sort_Time}",
+         "${bb.Sort_Post_Subject}",
+         "${bb.Sort_Author}",
+         "${bb.Sort_Forum}"
+      };
+
+   /**
+    * DOCUMENT_ME
+    */
+   int[] PREVIOUS_DAYS =
+      {
+         0,
+         1,
+         7,
+         14,
+         30,
+         90,
+         180,
+         364
+      };
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] PREVIOUS_DAYS_TEXT_TOPICS =
+      {
+         "${bb.All_Topics}",
+         "${bb.1_Day}",
+         "${bb.7_Days}",
+         "${bb.2_Weeks}",
+         "${bb.1_Month}",
+         "${bb.3_Months}",
+         "${bb.6_Months}",
+         "${bb.1_Year}"
+      };
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] PREVIOUS_DAYS_TEXT_POSTS =
+      {
+         "${bb.All_Posts}",
+         "${bb.1_Day}",
+         "${bb.7_Days}",
+         "${bb.2_Weeks}",
+         "${bb.1_Month}",
+         "${bb.3_Months}",
+         "${bb.6_Months}",
+         "${bb.1_Year}"
+      };
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] FORUM_AUTH_FORM_FIELD_NAMES =
+      {
+         "auth_view",
+         "auth_read",
+         "auth_post",
+         "auth_reply",
+         "auth_edit",
+         "auth_delete",
+         "auth_sticky",
+         "auth_announce",
+         "auth_vote",
+         "auth_pollcreate",
+         "auth_attachment"
+      };
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] FORUM_AUTH_FORM_FIELD_LABELS =
+      {
+         "${bb.View}",
+         "${bb.Read}",
+         "${bb.Post}",
+         "${bb.Reply}",
+         "${bb.Edit}",
+         "${bb.Delete}",
+         "${bb.Sticky}",
+         "${bb.Announce}",
+         "${bb.Vote}",
+         "${bb.Pollcreate}",
+         "${bb.UploadedFile}"
+      };
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] FORUM_AUTH_LEVEL_LABELS =
+      {
+         "ALL",
+         "REG",
+         "PRIVATE",
+         "MOD",
+         "ADMIN"
+      };
+
+   /*
+      int[] FORUM_AUTH_LEVEL = {
+         Auth.LEVEL_ALL, Auth.LEVEL_REG, Auth.LEVEL_ACL, Auth.LEVEL_MOD, Auth.LEVEL_ADM
+      };
+    */
+
+   /**
+    * DOCUMENT_ME
+    */
+   int GENERAL_MESSAGE = 200;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int GENERAL_ERROR = 202;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int CRITICAL_MESSAGE = 203;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int CRITICAL_ERROR = 204;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int POST_NORMAL = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int POST_STICKY = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int POST_ANNOUNCE = 2;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int POST_GLOBAL_ANNONCE = 3;
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] AUTH_TYPE_TO_MESSAGE =
+      {
+         null,
+         null,
+         "Sorry_auth_read_",
+         "Sorry_auth_post_",
+         "Sorry_auth_reply_",
+         "Sorry_auth_edit_",
+         "Sorry_auth_delete_",
+         "Sorry_auth_announce_",
+         "Sorry_auth_sticky_",
+         null,
+         null,
+         "Sorry_auth_vote_",
+         null,
+      };
+
+   /**
+    * DOCUMENT_ME
+    */
+   int[] TOPIC_TYPE_TO_AUTH_TYPE =
+      {
+         AuthType.POST,
+         AuthType.STICKY,
+         AuthType.ANNOUNCE,
+         AuthType.POST
+      };
+
+   // modes
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_NO_MODE = -1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_VOTE = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_REPLY = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_QUOTE = 2;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_EDIT_POST = 3;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_DELETE = 4;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_POLL_DELETE = 5;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_NEW_TOPIC = 6;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_REPOST = 7;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_SMILIES = 8;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMODE_TOPIC_REVIEW = 9;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_VOTE = 0x0000001;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_REPLY = 0x0000002;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_QUOTE = 0x0000004;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_EDIT_POST = 0x0000008;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_DELETE = 0x0000010;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_POLL_DELETE = 0x0000020;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_NEW_TOPIC = 0x0000040;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_SMILIES = 0x0000080;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int PMASK_TOPIC_REVIEW = 0x0000100;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int[] PMASKS =
+      {
+         PMASK_VOTE,
+         PMASK_REPLY,
+         PMASK_QUOTE,
+         PMASK_EDIT_POST,
+         PMASK_DELETE,
+         PMASK_POLL_DELETE,
+         PMASK_NEW_TOPIC,
+         PMASK_SMILIES,
+         PMASK_TOPIC_REVIEW
+      };
+
+   /*
+      int[] PMODE_TO_AUTH_TYPE = {
+         Auth.TYPE_READ,
+         Auth.TYPE_REPLY,
+         Auth.TYPE_REPLY,
+         Auth.TYPE_EDIT,
+         Auth.TYPE_DELETE,
+         Auth.TYPE_DELETE
+      };
+    */
+
+   /**
+    * DOCUMENT_ME
+    */
+   int MMODE_NO_MODE = -1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int MMODE_DELETE = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int MMODE_MOVE = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int MMODE_LOCK = 2;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int MMODE_UNLOCK = 3;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int MMODE_SPLIT = 4;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int MMODE_IP = 5;
+
+   /**
+    * DOCUMENT_ME
+    */
+   String[] AUTH_PRESETS_NAMES =
+      {
+         "${bb.Public}",
+         "${bb.Registered}",
+         "${bb.Registered}[${bb.Hidden}]",
+         "${bb.Private}",
+         "${bb.Private}[${bb.Hidden}]",
+         "${bb.Moderators}",
+         "${bb.Moderators}[${bb.Hidden}]"
+      };
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @author $author$
+    * @version $Revision: 1.5 $
+    */
+   class ModeDecoder
+   {
+      private static final String[] P_TO_HTML = new String[10];
+
+      static
+      {
+         P_TO_HTML[PMODE_VOTE] = "vote";
+         P_TO_HTML[PMODE_REPLY] = "reply";
+         P_TO_HTML[PMODE_QUOTE] = "reply";
+         P_TO_HTML[PMODE_EDIT_POST] = "editpost";
+         P_TO_HTML[PMODE_DELETE] = "delete";
+         P_TO_HTML[PMODE_POLL_DELETE] = "poll_delete";
+         P_TO_HTML[PMODE_NEW_TOPIC] = "newtopic";
+         P_TO_HTML[PMODE_REPOST] = "repost";
+         P_TO_HTML[PMODE_SMILIES] = "smilies";
+         P_TO_HTML[PMODE_TOPIC_REVIEW] = "topicreview";
+      }
+
+      /**
+       * DOCUMENT_ME
+       *
+       * @param mode DOCUMENT_ME
+       * @return DOCUMENT_ME
+       */
+      public static final String encodePosting(int mode)
+      {
+         return P_TO_HTML[mode];
+      }
+
+      /**
+       * DOCUMENT_ME
+       *
+       * @param mode DOCUMENT_ME
+       * @return DOCUMENT_ME
+       */
+      public static final int decodePosting(String mode)
+      {
+         if ("topicreview".equals(mode))
+         {
+            return PMODE_TOPIC_REVIEW;
+         }
+
+         if ("smilies".equals(mode))
+         {
+            return PMODE_SMILIES;
+         }
+
+         if ("reply".equals(mode))
+         {
+            return PMODE_REPLY;
+         }
+
+         if ("quote".equals(mode))
+         {
+            return PMODE_QUOTE;
+         }
+
+         if ("editpost".equals(mode))
+         {
+            return PMODE_EDIT_POST;
+         }
+
+         if ("delete".equals(mode))
+         {
+            return PMODE_DELETE;
+         }
+
+         if ("poll_delete".equals(mode))
+         {
+            return PMODE_POLL_DELETE;
+         }
+
+         if ("vote".equals(mode))
+         {
+            return PMODE_VOTE;
+         }
+
+         if ("newtopic".equals(mode))
+         {
+            return PMODE_NEW_TOPIC;
+         }
+
+         if ("repost".equals(mode))
+         {
+            return PMODE_REPOST;
+         }
+
+         return PMODE_NO_MODE;
+      }
+
+      /*
+         public static final int decodeModcp(Page page)
+         {
+            String mode = page.getParameter("mode");
+            if (mode != null)
+            {
+               if ("delete".equals(mode))
+               {
+                  return MMODE_DELETE;
+               }
+               if ("move".equals(mode))
+               {
+                  return MMODE_MOVE;
+               }
+               if ("lock".equals(mode))
+               {
+                  return MMODE_LOCK;
+               }
+               if ("unlock".equals(mode))
+               {
+                  return MMODE_UNLOCK;
+               }
+               if ("split".equals(mode))
+               {
+                  return MMODE_SPLIT;
+               }
+            }
+            else
+            {
+               if (page.getParameter("delete") != null)
+               {
+                  return MMODE_DELETE;
+               }
+               else if (page.getParameter("move") != null)
+               {
+                  return MMODE_MOVE;
+               }
+               else if (page.getParameter("lock") != null)
+               {
+                  return MMODE_LOCK;
+               }
+               else if (page.getParameter("unlock") != null)
+               {
+                  return MMODE_LOCK;
+               }
+            }
+            return MMODE_NO_MODE;
+         }
+       */
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   int FORUM_UNLOCKED = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int FORUM_LOCKED = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int TOPIC_UNLOCKED = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int TOPIC_LOCKED = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int TOPIC_MOVED = 2;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int TOPIC_WATCH_UN_NOTIFIED = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   int TOPIC_WATCH_NOTIFIED = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   String POST_CAT_URL = "c";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String POST_FORUM_URL = "f";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String POST_TOPIC_URL = "t";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String POST_POST_URL = "p";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String POST_USERS_URL = "u";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String POST_ROLES_URL = "g";
+
+   /**
+    * When a notification message is sent, send a link to the message.
+    */
+   int WATCH_MODE_LINKED = 0;
+
+   /**
+    * When a notification message is sent, send the message content.
+    */
+   int WATCH_MODE_EMBEDED = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final String FORUMSMODULE_JNDINAME = "java:portal/ForumsModule";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String USER_SIGNATURE_PROPERTY = "portal.user.forums.signature";
+
+   /**
+    * DOCUMENT_ME
+    */
+   String USER_SIGNATURE_ADD_PROPERTY = "portal.user.forums.addsignature";
+
+   String DEFAULT_DATE_PATTERN = "EEE MMM d, yyyy HH:mm aaa";
+
+   String DISK_PERSISTED_ATTACHEMENTS = "EEE MMM d, yyyy HH:mm aaa";
+
+   String POSTING_POSTBACK_FLAG = "posting_postback_flag";
+
+   String FILE_SESSION_INDEX = "portal.user.forums.file_session_index";
+
+   String ATTACHMENT_TOKENS_MANAGER = "org.jboss.portlet.forums.helper.AttachmentTokenManager";
+                                             
+}
+
+//// Debug Level
+////define('DEBUG', 1); // Debugging on
+//define('DEBUG', 1); // Debugging off
+//
+//
+//// User Levels <- Do not change the values of USER or ADMIN
+//define('DELETED', -1);
+//define('ANONYMOUS', -1);
+//
+//define('USER', 0);
+//define('ADMIN', 1);
+//define('MOD', 2);
+//
+//
+//// User related
+//define('USER_ACTIVATION_NONE', 0);
+//define('USER_ACTIVATION_SELF', 1);
+//define('USER_ACTIVATION_ADMIN', 2);
+//
+//define('USER_AVATAR_NONE', 0);
+//define('USER_AVATAR_UPLOAD', 1);
+//define('USER_AVATAR_REMOTE', 2);
+//define('USER_AVATAR_GALLERY', 3);
+//
+//
+//// Group settings
+//define('GROUP_OPEN', 0);
+//define('GROUP_CLOSED', 1);
+//define('GROUP_HIDDEN', 2);
+//
+//
+//// Forum state
+//define('FORUM_UNLOCKED', 0);
+//define('FORUM_LOCKED', 1);
+//
+//
+//
+//
+//
+//
+//// SQL codes
+//define('BEGIN_TRANSACTION', 1);
+//define('END_TRANSACTION', 2);
+//
+//
+//
+//
+//// Private messaging
+//define('PRIVMSGS_READ_MAIL', 0);
+//define('PRIVMSGS_NEW_MAIL', 1);
+//define('PRIVMSGS_SENT_MAIL', 2);
+//define('PRIVMSGS_SAVED_IN_MAIL', 3);
+//define('PRIVMSGS_SAVED_OUT_MAIL', 4);
+//define('PRIVMSGS_UNREAD_MAIL', 5);
+//
+//
+//
+//// Session parameters
+//define('SESSION_METHOD_COOKIE', 100);
+//define('SESSION_METHOD_GET', 101);
+//
+//
+//// Page numbers for session handling
+//define('PAGE_INDEX', 0);
+//define('PAGE_LOGIN', -1);
+//define('PAGE_SEARCH', -2);
+//define('PAGE_REGISTER', -3);
+//define('PAGE_PROFILE', -4);
+//define('PAGE_VIEWONLINE', -6);
+//define('PAGE_VIEWMEMBERS', -7);
+//define('PAGE_FAQ', -8);
+//define('PAGE_POSTING', -9);
+//define('PAGE_PRIVMSGS', -10);
+//define('PAGE_GROUPCP', -11);
+//define('PAGE_TOPIC_OFFSET', 5000);
+//
+//
+//
+//
+//// Table names
+//define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access');
+//define('BANLIST_TABLE', $table_prefix.'banlist');
+//define('CATEGORIES_TABLE', $table_prefix.'categories');
+//define('CONFIG_TABLE', $table_prefix.'config');
+//define('DISALLOW_TABLE', $table_prefix.'disallow');
+//define('FORUMS_TABLE', $table_prefix.'forums');
+//define('GROUPS_TABLE', $table_prefix.'groups');
+//define('POSTS_TABLE', $table_prefix.'posts');
+//define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
+//define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');
+//define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text');
+//define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore');
+//define('PRUNE_TABLE', $table_prefix.'forum_prune');
+//define('RANKS_TABLE', $table_prefix.'ranks');
+//define('SEARCH_TABLE', $table_prefix.'search_results');
+//define('SEARCH_WORD_TABLE', $table_prefix.'search_wordlist');
+//define('SEARCH_MATCH_TABLE', $table_prefix.'search_wordmatch');
+//define('SESSIONS_TABLE', $table_prefix.'sessions');
+//define('SMILIES_TABLE', $table_prefix.'smilies');
+//define('THEMES_TABLE', $table_prefix.'themes');
+//define('THEMES_NAME_TABLE', $table_prefix.'themes_name');
+//define('TOPICS_TABLE', $table_prefix.'topics');
+//define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch');
+//define('USER_GROUP_TABLE', $table_prefix.'user_group');
+//define('USERS_TABLE', $table_prefix.'users');
+//define('WORDS_TABLE', $table_prefix.'words');
+//define('VOTE_DESC_TABLE', $table_prefix.'vote_desc');
+//define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results');
+//define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
+//
+//?>

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsModule.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsModule.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsModule.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,499 +1,499 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums;
-
-import org.jboss.portal.identity.User;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portal.core.hibernate.HibernateProvider;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portlet.forums.model.*;
-import org.jboss.portlet.command.ActionCommand;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.15 $
- */
-public interface ForumsModule
-{
-
-   public HibernateProvider getHibernate();
-   /**
-    *
-    */
-   int getFloodInterval();
-
-   /**
-    *
-    */
-   void setFloodInterval(int floodInterval);
-
-   /**
-    *
-    */
-   String getFromAddress();
-
-   /**
-    *
-    */
-   void setFromAddress(String fromAddress);
-
-   /**
-    * Returns all the announcements of the forum
-    *
-    * @param forum Forum in which we want to search for the announcements
-    * @return List of topics
-    * @throws ModuleException Throws an exception if unable to find the announcements.
-    */
-   List findAnnouncements(Forum forum)
-      throws ModuleException;
-
-   /**
-    * Returns some topics of a forum that are not of a certain type
-    *
-    * @return List of topics
-    * @throws ModuleException Throws an excpetion if unable to find the topics.
-    */
-   List findTopics()
-      throws ModuleException;
-
-
-   /**
-    * Returns some topics of a forum that are not of a certain type
-    * The topics are ordered by creation date from oldest to newest
-    *
-    * @param forum   Forum in which we want to search for topics
-    * @param type    Type to avoid
-    * @param start   Index for fetching result
-    * @param perPage Number of result to return
-    * @return List of perPage topics ordered by creation date.
-    * @throws ModuleException Throws an excpetion if unable to find the topics.
-    */
-   List findTopicsAsc(Forum forum,
-                      int type,
-                      int start,
-                      int perPage)
-      throws ModuleException;
-
-   /**
-    * Returns some topics of a forum that are not of a certain type
-    * The topics are ordered by creation date from newest to oldest
-    *
-    * @param forum   Forum in which we want to search for topics
-    * @param type    Type to avoid
-    * @param start   Index for fetching result
-    * @param perPage Number of result to return
-    * @return List of perPage topics ordered by opposite creation date.
-    * @throws ModuleException Throws an excpetion if unable to find the topics.
-    */
-   List findTopicsDesc(Forum forum,
-                       int type,
-                       int start,
-                       int perPage)
-      throws ModuleException;
-
-
-   /**
-    * *
-    *
-    * @param forum Forum in which we want to search for topics
-    * @return List of perPage topics ordered by creation date.
-    * @throws ModuleException Throws an excpetion if unable to find the topics.
-    */
-   List findTopics(Forum forum)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum   DOCUMENT_ME
-    * @param type    DOCUMENT_ME
-    * @param start   DOCUMENT_ME
-    * @param perPage DOCUMENT_ME
-    * @param date    DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findTopicsBefore(Forum forum,
-                         int type,
-                         int start,
-                         int perPage,
-                         Date date)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param replies DOCUMENT_ME
-    * @param limit   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findTopicsHot(int replies, int limit)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param limit DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findTopicsByLatestPosts(int limit)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param after DOCUMENT_ME
-    * @param limit DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findTopicsHottest(Date after, int limit)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param after DOCUMENT_ME
-    * @param limit DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findTopicsMostViewed(Date after, int limit)
-      throws ModuleException;
-
-
-   /**
-    * Find a forum by specifying its ID
-    *
-    * @param id ID of the forum to retrieve
-    * @return Forum with specified ID
-    * @throws ModuleException Throws an exception if the forum cannot be found
-    */
-   Forum findForumById(Integer id)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param category    DOCUMENT_ME
-    * @param name        DOCUMENT_ME
-    * @param description DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Forum createForum(Category category,
-                     String name,
-                     String description)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   public List findPosts() throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param id DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Post findPostById(Integer id)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param userID DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Poster findPosterByUserId(String userID)
-      throws ModuleException;
-
-   /**
-    * Get all the categories of forums.
-    *
-    * @return All the categories
-    * @throws ModuleException
-    */
-   List findCategories()
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findForums()
-      throws ModuleException;
-
-   /**
-    * Get all the forums of a category
-    *
-    * @param categoryID Category of forums
-    * @return Forums of one category
-    */
-   List findForumsByCategoryId(Integer categoryID)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum        DOCUMENT_ME
-    * @param message      DOCUMENT_ME
-    * @param creationDate DOCUMENT_ME
-    * @param poster       DOCUMENT_ME
-    * @return The new post created
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Post createTopic(Forum forum,
-                    Message message,
-                    Date creationDate,
-                    Poster poster,
-                    Poll poll,
-                    List attachments,
-                    int type)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum   DOCUMENT_ME
-    * @param userID  DOCUMENT_ME
-    * @param subject DOCUMENT_ME
-    * @param type    DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Topic createTopic(Forum forum,
-                     String userID,
-                     String subject,
-                     int type)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topic        DOCUMENT_ME
-    * @param forum        DOCUMENT_ME
-    * @param message      DOCUMENT_ME
-    * @param creationTime DOCUMENT_ME
-    * @param poster       DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Post createPost(Topic topic,
-                   Forum forum,
-                   Message message,
-                   Date creationTime,
-                   Poster poster,
-                   List attachments)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topic DOCUMENT_ME
-    * @param poll  DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   public Poll addPollToTopic(Topic topic,
-                              Poll poll)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Category createCategory(String name)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param category DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   void removeCategory(Category category)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   void removeForum(Forum forum)
-      throws ModuleException;
-
-   /**
-    * Delete a post
-    *
-    * @param post Post to delete
-    * @throws ModuleException DOCUMENT_ME
-    */
-   void removePost(Post post)
-      throws ModuleException;
-
-   /**
-    * Delete a post
-    *
-    * @param topic Post to delete
-    * @throws ModuleException DOCUMENT_ME
-    */
-   void removePollInTopic(Topic topic)
-      throws ModuleException;
-
-   /**
-    * Delete a topic
-    *
-    * @param topic Topic to delete
-    * @throws ModuleException DOCUMENT_ME
-    */
-   void removeTopic(Topic topic)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param categoryID DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   Category findCategoryById(Integer categoryID)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param source DOCUMENT_ME
-    * @param target DOCUMENT_ME
-    */
-   void addAllForums(Category source,
-                     Category target);
-
-   /**
-    * @param topicID
-    * @return DOCUMENT_ME
-    */
-   Topic findTopicById(Integer topicID)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topicID DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findPostsByTopicId(Integer topicID)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topicID DOCUMENT_ME
-    * @param start   DOCUMENT_ME
-    * @param limit   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findPostsByTopicIdAsc(Integer topicID,
-                              int start,
-                              int limit)
-      throws ModuleException;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topicID DOCUMENT_ME
-    * @param start   DOCUMENT_ME
-    * @param limit   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws ModuleException DOCUMENT_ME
-    */
-   List findPostsByTopicIdDesc(Integer topicID,
-                               int start,
-                               int limit)
-      throws ModuleException;
-
-
-   Date findLastPostDateForUser(User user) throws ModuleException;
-
-   Post findLastPost(Forum forum) throws ModuleException;
-
-   Post findFirstPost(Topic topic) throws ModuleException;
-
-   Post findLastPost(Topic topic) throws ModuleException;
-
-   List findForumWatchByUser(User user) throws ModuleException;
-
-   Attachment findFindAttachmentById(Integer attachID)
-        throws ModuleException;
-
-
-   Poster createPoster(String userID) throws ModuleException;
-
-   /**
-    * @param poster
-    * @param forum
-    * @param i
-    */
-   void createWatch(Poster poster, Forum forum, int i) throws ModuleException;
-
-   /**
-    * @param forumWatchID
-    * @return DOCUMENT_ME
-    */
-   ForumWatch findForumWatchById(Integer forumWatchID) throws ModuleException;
-
-   /**
-    * @param poster
-    * @param topic
-    */
-   void createWatch(Poster poster, Topic topic) throws ModuleException;
-
-   /**
-    * @param topicWatchID
-    * @return DOCUMENT_ME
-    */
-   TopicWatch findTopicWatchById(Integer topicWatchID) throws ModuleException;
-
-   /**
-    * @param watch
-    */
-   void removeWatch(Watch watch) throws ModuleException;
-
-   /**
-    *
-    * @param cmd
-    * @return
-    * @throws CommandException
-    */
-   Result invoke(ActionCommand cmd) throws CommandException;
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.jems.hibernate.HibernateProvider;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portlet.forums.model.*;
+import org.jboss.portlet.command.ActionCommand;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.16 $
+ */
+public interface ForumsModule
+{
+
+   public HibernateProvider getHibernate();
+   /**
+    *
+    */
+   int getFloodInterval();
+
+   /**
+    *
+    */
+   void setFloodInterval(int floodInterval);
+
+   /**
+    *
+    */
+   String getFromAddress();
+
+   /**
+    *
+    */
+   void setFromAddress(String fromAddress);
+
+   /**
+    * Returns all the announcements of the forum
+    *
+    * @param forum Forum in which we want to search for the announcements
+    * @return List of topics
+    * @throws ModuleException Throws an exception if unable to find the announcements.
+    */
+   List findAnnouncements(Forum forum)
+      throws ModuleException;
+
+   /**
+    * Returns some topics of a forum that are not of a certain type
+    *
+    * @return List of topics
+    * @throws ModuleException Throws an excpetion if unable to find the topics.
+    */
+   List findTopics()
+      throws ModuleException;
+
+
+   /**
+    * Returns some topics of a forum that are not of a certain type
+    * The topics are ordered by creation date from oldest to newest
+    *
+    * @param forum   Forum in which we want to search for topics
+    * @param type    Type to avoid
+    * @param start   Index for fetching result
+    * @param perPage Number of result to return
+    * @return List of perPage topics ordered by creation date.
+    * @throws ModuleException Throws an excpetion if unable to find the topics.
+    */
+   List findTopicsAsc(Forum forum,
+                      int type,
+                      int start,
+                      int perPage)
+      throws ModuleException;
+
+   /**
+    * Returns some topics of a forum that are not of a certain type
+    * The topics are ordered by creation date from newest to oldest
+    *
+    * @param forum   Forum in which we want to search for topics
+    * @param type    Type to avoid
+    * @param start   Index for fetching result
+    * @param perPage Number of result to return
+    * @return List of perPage topics ordered by opposite creation date.
+    * @throws ModuleException Throws an excpetion if unable to find the topics.
+    */
+   List findTopicsDesc(Forum forum,
+                       int type,
+                       int start,
+                       int perPage)
+      throws ModuleException;
+
+
+   /**
+    * *
+    *
+    * @param forum Forum in which we want to search for topics
+    * @return List of perPage topics ordered by creation date.
+    * @throws ModuleException Throws an excpetion if unable to find the topics.
+    */
+   List findTopics(Forum forum)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum   DOCUMENT_ME
+    * @param type    DOCUMENT_ME
+    * @param start   DOCUMENT_ME
+    * @param perPage DOCUMENT_ME
+    * @param date    DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findTopicsBefore(Forum forum,
+                         int type,
+                         int start,
+                         int perPage,
+                         Date date)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param replies DOCUMENT_ME
+    * @param limit   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findTopicsHot(int replies, int limit)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param limit DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findTopicsByLatestPosts(int limit)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param after DOCUMENT_ME
+    * @param limit DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findTopicsHottest(Date after, int limit)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param after DOCUMENT_ME
+    * @param limit DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findTopicsMostViewed(Date after, int limit)
+      throws ModuleException;
+
+
+   /**
+    * Find a forum by specifying its ID
+    *
+    * @param id ID of the forum to retrieve
+    * @return Forum with specified ID
+    * @throws ModuleException Throws an exception if the forum cannot be found
+    */
+   Forum findForumById(Integer id)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param category    DOCUMENT_ME
+    * @param name        DOCUMENT_ME
+    * @param description DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Forum createForum(Category category,
+                     String name,
+                     String description)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   public List findPosts() throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param id DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Post findPostById(Integer id)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param userID DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Poster findPosterByUserId(String userID)
+      throws ModuleException;
+
+   /**
+    * Get all the categories of forums.
+    *
+    * @return All the categories
+    * @throws ModuleException
+    */
+   List findCategories()
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findForums()
+      throws ModuleException;
+
+   /**
+    * Get all the forums of a category
+    *
+    * @param categoryID Category of forums
+    * @return Forums of one category
+    */
+   List findForumsByCategoryId(Integer categoryID)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum        DOCUMENT_ME
+    * @param message      DOCUMENT_ME
+    * @param creationDate DOCUMENT_ME
+    * @param poster       DOCUMENT_ME
+    * @return The new post created
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Post createTopic(Forum forum,
+                    Message message,
+                    Date creationDate,
+                    Poster poster,
+                    Poll poll,
+                    List attachments,
+                    int type)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum   DOCUMENT_ME
+    * @param userID  DOCUMENT_ME
+    * @param subject DOCUMENT_ME
+    * @param type    DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Topic createTopic(Forum forum,
+                     String userID,
+                     String subject,
+                     int type)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topic        DOCUMENT_ME
+    * @param forum        DOCUMENT_ME
+    * @param message      DOCUMENT_ME
+    * @param creationTime DOCUMENT_ME
+    * @param poster       DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Post createPost(Topic topic,
+                   Forum forum,
+                   Message message,
+                   Date creationTime,
+                   Poster poster,
+                   List attachments)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topic DOCUMENT_ME
+    * @param poll  DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   public Poll addPollToTopic(Topic topic,
+                              Poll poll)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Category createCategory(String name)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param category DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   void removeCategory(Category category)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   void removeForum(Forum forum)
+      throws ModuleException;
+
+   /**
+    * Delete a post
+    *
+    * @param post Post to delete
+    * @throws ModuleException DOCUMENT_ME
+    */
+   void removePost(Post post)
+      throws ModuleException;
+
+   /**
+    * Delete a post
+    *
+    * @param topic Post to delete
+    * @throws ModuleException DOCUMENT_ME
+    */
+   void removePollInTopic(Topic topic)
+      throws ModuleException;
+
+   /**
+    * Delete a topic
+    *
+    * @param topic Topic to delete
+    * @throws ModuleException DOCUMENT_ME
+    */
+   void removeTopic(Topic topic)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param categoryID DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   Category findCategoryById(Integer categoryID)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param source DOCUMENT_ME
+    * @param target DOCUMENT_ME
+    */
+   void addAllForums(Category source,
+                     Category target);
+
+   /**
+    * @param topicID
+    * @return DOCUMENT_ME
+    */
+   Topic findTopicById(Integer topicID)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topicID DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findPostsByTopicId(Integer topicID)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topicID DOCUMENT_ME
+    * @param start   DOCUMENT_ME
+    * @param limit   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findPostsByTopicIdAsc(Integer topicID,
+                              int start,
+                              int limit)
+      throws ModuleException;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topicID DOCUMENT_ME
+    * @param start   DOCUMENT_ME
+    * @param limit   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws ModuleException DOCUMENT_ME
+    */
+   List findPostsByTopicIdDesc(Integer topicID,
+                               int start,
+                               int limit)
+      throws ModuleException;
+
+
+   Date findLastPostDateForUser(User user) throws ModuleException;
+
+   Post findLastPost(Forum forum) throws ModuleException;
+
+   Post findFirstPost(Topic topic) throws ModuleException;
+
+   Post findLastPost(Topic topic) throws ModuleException;
+
+   List findForumWatchByUser(User user) throws ModuleException;
+
+   Attachment findFindAttachmentById(Integer attachID)
+        throws ModuleException;
+
+
+   Poster createPoster(String userID) throws ModuleException;
+
+   /**
+    * @param poster
+    * @param forum
+    * @param i
+    */
+   void createWatch(Poster poster, Forum forum, int i) throws ModuleException;
+
+   /**
+    * @param forumWatchID
+    * @return DOCUMENT_ME
+    */
+   ForumWatch findForumWatchById(Integer forumWatchID) throws ModuleException;
+
+   /**
+    * @param poster
+    * @param topic
+    */
+   void createWatch(Poster poster, Topic topic) throws ModuleException;
+
+   /**
+    * @param topicWatchID
+    * @return DOCUMENT_ME
+    */
+   TopicWatch findTopicWatchById(Integer topicWatchID) throws ModuleException;
+
+   /**
+    * @param watch
+    */
+   void removeWatch(Watch watch) throws ModuleException;
+
+   /**
+    *
+    * @param cmd
+    * @return
+    * @throws CommandException
+    */
+   Result invoke(ActionCommand cmd) throws CommandException;
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsPortlet.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsPortlet.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/ForumsPortlet.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,6811 +1,6821 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums;
-
-
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.result.ResultType;
-import org.jboss.portal.common.context.DelegateContext;
-import org.jboss.portal.common.util.ProxyInfo;
-
-import org.jboss.portal.identity.PropertyMap;
-import org.jboss.portal.identity.User;
-
-//import org.jboss.portal.core.model.PropertyMap;
-//import org.jboss.portal.core.model.User;
-
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portal.core.servlet.jsp.PortalJsp;
-import org.jboss.portal.format.render.bbcodehtml.ToHTMLConfig;
-import org.jboss.portal.format.render.bbcodehtml.ToHTMLRenderer;
-import org.jboss.portal.format.util.CLLoader;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portlet.JBossPortlet;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
-import org.jboss.portlet.forums.action.Action;
-import org.jboss.portlet.forums.action.EditPostAction;
-import org.jboss.portlet.forums.action.ForumAction;
-import org.jboss.portlet.forums.action.NewTopicAction;
-import org.jboss.portlet.forums.action.PostAction;
-import org.jboss.portlet.forums.action.ProcessCommandAction;
-import org.jboss.portlet.forums.action.ReplyAction;
-import org.jboss.portlet.forums.action.TopicAction;
-import org.jboss.portlet.forums.commands.CommandConstants;
-import org.jboss.portlet.forums.commands.admin.CreateCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.CreateForumCommand;
-import org.jboss.portlet.forums.commands.admin.DeleteForumCommand;
-import org.jboss.portlet.forums.commands.admin.DeleteMoveCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.DeleteMoveForumCommand;
-import org.jboss.portlet.forums.commands.admin.OrderCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.OrderForumCommand;
-import org.jboss.portlet.forums.commands.admin.UpdateCategoryCommand;
-import org.jboss.portlet.forums.commands.admin.UpdateForumCommand;
-import org.jboss.portlet.forums.commands.moderation.DeleteTopicCommand;
-import org.jboss.portlet.forums.commands.moderation.LockTopicCommand;
-import org.jboss.portlet.forums.commands.moderation.MoveTopicCommand;
-import org.jboss.portlet.forums.commands.moderation.SplitTopicCommand;
-import org.jboss.portlet.forums.commands.post.DeletePostCommand;
-import org.jboss.portlet.forums.commands.post.EditPostCommand;
-import org.jboss.portlet.forums.commands.post.ForumCommand;
-import org.jboss.portlet.forums.commands.post.NewTopicCommand;
-import org.jboss.portlet.forums.commands.post.ReplyCommand;
-import org.jboss.portlet.forums.helper.ForumsTools;
-import org.jboss.portlet.forums.helper.Goto;
-import org.jboss.portlet.forums.helper.GotoWithOffset;
-import org.jboss.portlet.forums.helper.IndexIterator;
-import org.jboss.portlet.forums.helper.FileBinding;
-import org.jboss.portlet.forums.helper.AttachmentTokenManager;
-import org.jboss.portlet.forums.helper.AttachmentToken;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.ForumWatch;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.PollOption;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.TopicWatch;
-import org.jboss.portlet.forums.model.Attachment;
-import org.jboss.portlet.forums.properties.TCCLXProperties;
-import org.jboss.portlet.forums.theme.FolderType;
-import org.jboss.portlet.forums.theme.ForumsTheme;
-import org.jboss.util.collection.CompoundIterator;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.PortletURL;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
-import javax.portlet.PortletSession;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.35 $
- */
-public class ForumsPortlet
-   extends JBossPortlet
-   implements ForumsConstants
-{
-   // private ForumsModule forumsModule;
-
-   private final String OP_MAIN = "main";
-
-   public static final String OP_SHOWFORUM = "showForum";
-
-   private final String OP_POSTING = "showPosting";
-
-   public final static String OP_SHOWTOPIC = "showTopic";
-
-   public static final String OP_SHOWADMINFORUMS = "showAdminForums";
-
-   public static final String OP_SHOWMODERATEFORUM = "showModerateForum";
-
-   public static final String OP_SHOWMOVETOPIC = "showMoveTopic";
-
-   public static final String OP_SHOWODELETETOPIC = "showDeleteTopic";
-
-   public static final String OP_SHOWSPLITTOPIC = "showSplitTopic";
-
-   public static final String OP_SHOWUSERPROFILE = "showUserProfile";
-
-   private final String OP_SHOWADDEDITFORUM = "showAddEditForum";
-
-   private final String OP_SHOWEDITCATEGORY = "showEditCategory";
-
-   private final String OP_SHOWDELETEFORUM = "showDeleteForum";
-
-   private final String OP_CONFIRM = "showConfirm";
-
-   private final String OP_SHOWWATCHEDTOPICS = "showWatchedTopics";
-
-   private final String OP_SHOWWATCHEDFORUMS = "showWatchedForums";
-
-   private ForumsTheme theme;
-
-   private ProxyInfo proxyInfo;
-
-   private CLLoader loader;
-
-   private ForumsModule forumsModule;
-
-   /**
-    * Initialization method of the portlet
-    *
-    * @throws PortletException DOCUMENT_ME
-    */
-   public void init() throws PortletException
-   {
-      super.init();
-
-      try
-      {
-         forumsModule = (ForumsModule)new InitialContext().lookup("java:portal/ForumsModule");
-         getPortletContext().setAttribute("forumsModule", forumsModule);
-      }
-      catch (NamingException e)
-      {
-         throw new PortletException(e);
-      }
-
-      /*
-       try
-       {
-       userModule = (UserModule) new InitialContext()
-       .lookup(ModuleConstants.USERMODULE_JNDINAME);
-       roleModule = (RoleModule) new InitialContext()
-       .lookup(ModuleConstants.ROLEMODULE_JNDINAME);
-       }
-       catch (NamingException e)
-       {
-       throw new PortletException(e);
-       }
-       */
-      // Start the theme
-      theme = new ForumsTheme();
-      try
-      {
-         // start theme
-         theme.setExtendedProperties(new TCCLXProperties(ForumsConstants.THEMENAME, "theme.properties"));
-         theme.start();
-      }
-      catch (IOException e)
-      {
-         throw new PortletException("Cannot start the forums theme, can't read template files", e);
-      }
-      catch (Exception e)
-      {
-         throw new PortletException("Cannot start the forums theme", e);
-      }
-
-      // Preferences proxy
-      /*
-       Class proxyClass = Proxy.getProxyClass(Thread.currentThread().getContextClassLoader(), new Class[]{PreferencesProxy.class});
-       try
-       {
-       proxyInfo = new ProxyInfo(proxyClass);
-       }
-       catch (Exception e1)
-       {
-       throw new PortletException();
-       }
-       */
-
-      // Loader that will load the resource from the war file
-      loader = new CLLoader("template");
-   }
-
-   public String getDefaultOperation()
-   {
-      return OP_MAIN;
-   }
-
-   /**
-    * doEdit Portlet method
-    *
-    * @param req  Portlet render request
-    * @param resp Portlet response request
-    * @throws PortletException For any unexpected exception
-    * @throws IOException      If cannot write HTML chunk
-    */
-   protected void doEdit(JBossRenderRequest req, JBossRenderResponse resp)
-      throws PortletException, IOException
-   {
-
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-      resp.setContentType("text/html");
-      PrintWriter writer = resp.getWriter();
-      writer.write("<div class=\"bb\">");
-      if (req.getWindowState() != WindowState.MAXIMIZED)
-      {
-         writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
-         writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
-         PortletURL showProfileURL = resp.createRenderURL();
-         showProfileURL.setWindowState(WindowState.MAXIMIZED);
-         showProfileURL.setPortletMode(PortletMode.EDIT);
-         writer.write("<a href=\"" + showProfileURL.toString() + "\">"
-            + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums.gif" + "\"><br>"
-            + bundle.getString("Preferences_edit") + "</a>");
-         writer.write("</td></tr></table>");
-      }
-      else
-      {
-         DelegateContext root = new DelegateContext();
-         if (!(req.getRemoteUser() != null))
-         {
-            writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
-            writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
-            writer.write("Sorry but you must login to change preferences");
-            writer.write("</td></tr></table>");
-            writer.write("</div>");
-            writer.close();
-            return;
-         }
-         else
-         {
-            resp.setTitle("Forums");
-            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowPreferencesContext(req, resp, root));
-            PortletRequestDispatcher rd = getPortletContext()
-               .getRequestDispatcher("/WEB-INF/subSilver/jsp/preferences_body.jsp");
-            rd.include(req, resp);
-         }
-      }
-      writer.write("</div>");
-      writer.close();
-   }
-
-   /**
-    * doView Portlet method
-    *
-    * @param req  Portlet render request
-    * @param resp Portlet response request
-    * @throws PortletException For any unexpected exception
-    * @throws IOException      If cannot write HTML chunk
-    */
-   protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
-      throws PortletException, IOException
-   {
-      //Use this to do debug
-      /*System.out.println("#####################");
-      System.out.println("in doView(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
-      for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
-      {
-         String key = (String)i.next();
-         System.out.println("param key: " + key + " ||param val: " + req.getParameter(key));
-      }*/
-
-
-
-
-
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-
-      resp.setContentType("text/html");
-      PrintWriter writer = resp.getWriter();
-      writer.write("<div class=\"bb\">");
-      String op = req.getParameters().get(getOperationName(),
-         getDefaultOperation());
-      if (req.getWindowState() != WindowState.MAXIMIZED)
-      {
-         DelegateContext root = new DelegateContext();
-         resp.setTitle("Forums");
-         req.setAttribute(PortalJsp.CTX_REQUEST, fillShowBlockTopicsContext(req, resp, root));
-         PortletRequestDispatcher rd = getPortletContext()
-            .getRequestDispatcher("/WEB-INF/subSilver/jsp/block/topics.jsp");
-         rd.include(req, resp);
-
-         /*writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
-
-         // Window is is normal mode
-         // Check if the user is an administrator
-         boolean isAdmin = hasPermission(req,"Admin");
-         if (isAdmin)
-         {
-            writer.write("<td width=\"50%\" align=\"center\" class=\"portlet-menu-item\">");
-
-            // Create a link to the administration interface
-            PortletURL adminURL = resp.createRenderURL();
-            adminURL.setParameter("op", "" + OP_SHOWADMINFORUMS);
-            adminURL.setWindowState(WindowState.MAXIMIZED);
-            writer.write("<a href=\"" + adminURL.toString() + "\">"
-                    + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums_admin.gif\"><br>"
-                    + bundle.getString("Admin_panel") + "</a>");
-            writer.write("</td>");
-            writer.write("<td width=\"50%\" align=\"center\" class=\"portlet-menu-item\">");
-         }
-         else
-         {
-            writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
-         }
-
-         //Create a link to the forum index
-         PortletURL showForumsURL = resp.createRenderURL();
-         showForumsURL.setWindowState(WindowState.MAXIMIZED);
-         showForumsURL.setParameter("op", "" + OP_MAIN);
-         writer.write("<a href=\"" + showForumsURL.toString() + "\">"
-                 + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums.gif" + "\"><br>"
-                 + bundle.getString("Main_index") + "</a>");
-         writer.write("</td></tr></table>");*/
-
-
-      }
-      else
-      {
-         DelegateContext logged_in = null;
-         DelegateContext root = new DelegateContext();
-         if ((req.getRemoteUser() != null))
-         {
-            logged_in = root.next("switch_user_logged_in");
-         }
-         boolean isAdmin = ForumsTools.hasPermission(req, "Admin");
-         if (isAdmin && (req.getRemoteUser() != null))
-         {
-            // Create a link to the administration interface
-            PortletURL adminURL = resp.createRenderURL();
-            adminURL.setParameter("op", "" + OP_SHOWADMINFORUMS);
-            String adminLink = new String("<a id=\"adminPanel\" class=\"mainmenu\" href=\"" + adminURL.toString() + "\">"
-               + "<img src=\"" + req.getContextPath() + "/subSilver/images/icon_mini_admin.gif\"\n" +
-               "                               width=\"12\" height=\"13\" border=\"0\"\n" +
-               "                               hspace=\"3\"/>"
-               + bundle.getString("Admin_panel") + "</a><br/>");
-            logged_in.put("ADMIN_PANEL_LINK", adminLink);
-         }
-
-         req.setAttribute(PortalJsp.CTX_REQUEST, root);
-         PortletRequestDispatcher rdisp = getPortletContext()
-            .getRequestDispatcher("/WEB-INF/subSilver/jsp/small_header.jsp");
-         rdisp.include(req, resp);
-
-         if (OP_MAIN.equals(op))
-         {
-            // Forum index
-            resp.setTitle("Forums");
-            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowIndexContext(req,
-               resp, root));
-
-
-            PortletRequestDispatcher rd = getPortletContext()
-               .getRequestDispatcher("/WEB-INF/subSilver/jsp/index_body.jsp");
-            rd.include(req, resp);
-         }
-         else if (OP_SHOWFORUM.equals(op))
-         {
-            // Display topics of a forums
-            resp.setTitle("Forums");
-            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowForumContext(req,
-               resp, root));
-            PortletRequestDispatcher rd = getPortletContext()
-               .getRequestDispatcher("/WEB-INF/subSilver/jsp/viewforum_body.jsp");
-            rd.include(req, resp);
-         }
-         else if (OP_POSTING.equals(op))
-         {
-            // Display new post form
-            resp.setTitle("Forums");
-            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowNewTopicContext(req, resp, root));
-            PortletRequestDispatcher rd = getPortletContext()
-               .getRequestDispatcher("/WEB-INF/subSilver/jsp/posting_body.jsp");
-            rd.include(req, resp);
-         }
-         else if (OP_SHOWTOPIC.equals(op))
-         {
-            // Display a topic
-            resp.setTitle("Forums");
-            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowTopicContext(req,
-               resp, root));
-            PortletRequestDispatcher rd = getPortletContext()
-               .getRequestDispatcher("/WEB-INF/subSilver/jsp/viewtopic_body.jsp");
-            rd.include(req, resp);
-         }
-         else if (OP_SHOWADMINFORUMS.equals(op))
-         {
-            // Display administration interface
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "Admin");
-            if (auth)
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST,
-                  fillShowAdminForumsContext(req, resp, root));
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_admin_body.jsp");
-               rd.include(req, resp);
-            }
-         }
-         else if (OP_SHOWMODERATEFORUM.equals(op))
-         {
-            // Display administration interface
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
-            if (auth)
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST,
-                  fillShowModerateForumContext(req, resp, root));
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_body.jsp");
-               rd.include(req, resp);
-            }
-         }
-
-         else if (OP_SHOWUSERPROFILE.equals(op))
-         {
-            // Display administration interface
-            resp.setTitle("Forums");
-            if ((req.getRemoteUser() != null))
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST,
-                  fillShowUserProfileContext(req, resp, root));
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/profile_view_body.jsp");
-               rd.include(req, resp);
-            }
-         }
-
-         else if (OP_SHOWMOVETOPIC.equals(op))
-         {
-            // Display administration interface
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
-            if (auth)
-            {
-               /*req.setAttribute(PortalJsp.CTX_REQUEST,
-                       fillShowModerateForumContext(req, resp, root));*/
-               PortletURL forumGotoURL = resp.createActionURL();
-               forumGotoURL.setParameter(getOperationName(), OP_SHOWFORUM);
-               forumGotoURL.setParameter("f", "" + req.getParameters().get("U_INDEX_f", "-1"));
-               root.put("U_INDEX", forumGotoURL.toString());
-               root.put("L_INDEX", req.getParameters().get("L_INDEX", ""));
-               root.put("S_HIDDEN_FIELDS", req.getParameters().get("S_HIDDEN_FIELDS", ""));
-               root.put("S_FORUM_SELECT", req.getParameters().get("S_FORUM_SELECT", ""));
-               req.setAttribute(PortalJsp.CTX_REQUEST, root);
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_move.jsp");
-               rd.include(req, resp);
-            }
-         }
-         else if (OP_SHOWSPLITTOPIC.equals(op))
-         {
-            // Display administration interface
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
-            if (auth)
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST,
-                  fillShowSplitTopicContext(req, resp, root));
-               req.setAttribute(PortalJsp.CTX_REQUEST, root);
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_split.jsp");
-               rd.include(req, resp);
-            }
-         }
-         else if (OP_SHOWADDEDITFORUM.equals(op))
-         {
-            // Display new or edit a forum form
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "Admin");
-            if (auth)
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST,
-                  fillShowAddEditForumContext(req, resp, root));
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_edit_body.jsp");
-               rd.include(req, resp);
-            }
-         }
-         else if (OP_SHOWDELETEFORUM.equals(op))
-         {
-            // Show form to delete an exisiting forum
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "Admin");
-            if (auth)
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST, root);
-               root.put("NAME", req.getParameter("NAME"));
-               root.put("S_SELECT_TO", req.getParameter("S_SELECT_TO"));
-               root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
-               PortletURL postURL = resp.createActionURL();
-               root.put("POST_URL", postURL.toString());
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_delete_body.jsp");
-               rd.include(req, resp);
-            }
-         }
-         else if (OP_SHOWEDITCATEGORY.equals(op))
-         {
-            // Show form to edit or create a category
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "Admin");
-            if (auth)
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST, root);
-               root.put("CAT_TITLE", req.getParameter("CAT_TITLE"));
-               root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
-               PortletURL postURL = resp.createActionURL();
-               root.put("POST_URL", postURL.toString());
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/category_edit_body.jsp");
-               rd.include(req, resp);
-            }
-         }
-         else if (OP_CONFIRM.equals(op))
-         {
-            // Show form to edit or create a category
-            resp.setTitle("Forums");
-            boolean auth = ForumsTools.hasPermission(req, "Delete");
-            if (auth)
-            {
-               req.setAttribute(PortalJsp.CTX_REQUEST, root);
-               root.put("MESSAGE_TITLE", req.getParameter("MESSAGE_TITLE"));
-               root.put("MESSAGE_TEXT", req.getParameter("MESSAGE_TEXT"));
-               root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
-               PortletURL postURL = resp.createActionURL();
-               root.put("POST_URL", postURL.toString());
-               PortletRequestDispatcher rd = getPortletContext()
-                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/confirm_body.jsp");
-               rd.include(req, resp);
-            }
-         }
-         else if (OP_SHOWWATCHEDFORUMS.equals(op))
-         {
-            resp.setTitle("Forums");
-            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowWatchedForums(req,
-               resp, root));
-            PortletRequestDispatcher rd = getPortletContext()
-               .getRequestDispatcher("/WEB-INF/subSilver/jsp/watched_forums_body.jsp");
-            rd.include(req, resp);
-         }
-
-         /*NAVIGATION JUMP BOX*/
-         String selectTo = "";
-         selectTo = "<select name=\"nav_id\">"
-            + "<option value=\"main\">" + "All categories view" + "</option>\n";
-         selectTo += ForumsTools.listForumsCategories(forumsModule);
-         selectTo += "</select>";
-
-         PortletURL navigationActionURL = resp.createActionURL();
-         navigationActionURL.setParameter("op", "navigation");
-         root.put("S_JUMPBOX_ACTION", navigationActionURL.toString());
-         root.put("S_JUMPBOX_SELECT", selectTo);
-         req.setAttribute(PortalJsp.CTX_REQUEST, root);
-         PortletRequestDispatcher rdispend = getPortletContext()
-            .getRequestDispatcher("/WEB-INF/subSilver/jsp/jumpbox.jsp");
-         rdispend.include(req, resp);
-      }
-
-
-      writer.write("</div>");
-      writer.close();
-   }
-
-   public void navigation(JBossActionRequest request, JBossActionResponse response)
-      throws CommandException
-   {
-      //Use this to do debug
-      /*System.out.println("!@!@!@!@!@!@!@!@!@!@!@!@");
-      System.out.println("in navigation(); op: " + request.getParameter("op") + " and mode: " + request.getParameter("mode"));
-      for (Iterator i=request.getParameterMap().keySet().iterator(); i.hasNext();)
-      {
-         String key = (String)i.next();
-         System.out.println("param key: " + key + " ||param val: " + request.getParameter(key));
-      }*/
-      String nav = "main";
-      nav = request.getParameter("nav_id");
-      response.setRenderParameter(getOperationName(), OP_MAIN);
-      if (nav.equals("main"))
-      {
-         return;
-      }
-      else
-      {
-         String toGo[] = nav.split("x");
-         if (toGo.length == 2)
-         {
-            response.setRenderParameter(toGo[0], toGo[1]);
-            if (toGo[0].equals("f"))
-            {
-               response.setRenderParameter(getOperationName(), OP_SHOWFORUM);
-            }
-         }
-
-      }
-
-
-   }
-
-   /**
-    * Method do action processing for Moderator functions from moderator panel
-    * in forum view and moderator bar in topic view.
-    * <p/>
-    * This method <b>MUST</b> get both proper "f" (forum id) and "t" (topic id) params.
-    *
-    * @param request
-    * @param response
-    * @throws CommandException
-    */
-   public void moderate_forum(JBossActionRequest request, JBossActionResponse response)
-      throws CommandException
-   {
-      //Use this to do debug
-      /*System.out.println("!@!@!@!@!@!@!@!@!@!@!@!@");
-      System.out.println("in moderate_forum(); op: " + request.getParameter("op") + " and mode: " + request.getParameter("mode"));
-      for (Iterator i=request.getParameterMap().keySet().iterator(); i.hasNext();)
-      {
-         String key = (String)i.next();
-         System.out.println("param key: " + key + " ||param val: " + request.getParameter(key));
-      }*/
-
-      ResourceBundle bundle = getResourceBundle(request.getLocale());
-
-      //get all parameters passed
-      Map paramMap = request.getParameterMap();
-
-      //is this return from confirmation page?
-      boolean confirmed = paramMap.containsKey("comfirmPage");
-
-      //if no button was pressed let's jump to main view
-      if (paramMap.containsKey("cancel"))
-      {
-         response.setRenderParameter(getOperationName(), getDefaultOperation());
-         return;
-      }
-      //if its confirmed and it's not cancel button then it should be yes button
-
-      //type of action
-      String mode = request.getParameters().get("mode", "");
-
-      //forum id:
-      int fid = Integer.parseInt(request.getParameters().get("f", "-1"));
-      int tid = Integer.parseInt(request.getParameters().get("t", "-1"));
-
-      //get forum from fid
-      Forum forum = null;
-      try
-      {
-         //if (fid != -1)
-         //{
-         forum = forumsModule.findForumById(new Integer(fid));
-         //}
-      }
-      catch (ModuleException e)
-      {
-
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         //if no forum then goto main
-         response.setRenderParameter(getOperationName(), OP_MAIN);
-         addErrorMessage(response, "moderate", "ERR_INTERNAL");
-         return;
-      }
-
-      //Initial perrmisions check
-      String[] testArray = new String[]{forum.getCategory().getTitle(), forum.getName()};
-      boolean authMod = ForumsTools.hasPermission(request, testArray, "ModerateForum");
-      if (!authMod)
-      {
-         response.setRenderParameter(getOperationName(), OP_MAIN);
-         addErrorMessage(response, "moderate", "ERR_PERMISSION_VIOLATION");
-         return;
-      }
-
-      //if not specified jump to OP_MAIN at end
-      response.setRenderParameter(getOperationName(), OP_MAIN);
-
-      //let decode which button was pressed in moderator panel
-      //or what command is confirmed
-      if (paramMap.containsKey("delete"))
-      {
-
-         mode = "delete";
-      }
-      else if (paramMap.containsKey("move"))
-      {
-
-         mode = "move";
-      }
-      else if (paramMap.containsKey("lock"))
-      {
-
-         mode = "lock";
-      }
-      else if (paramMap.containsKey("unlock"))
-      {
-
-         mode = "unlock";
-      }
-      else if (paramMap.containsKey("split"))
-      {
-
-         mode = "split";
-      }
-
-      //list of passed topic number
-      List topicsPassedList = new LinkedList();
-
-      //we need to know how many topics could be passed in topic_id_list[N]= pattern
-      int topicsPerPage = Integer.parseInt(request.getPreferences().getValue("topicsperforum", "10"));
-
-      //let's get all passed topics
-      for (int i = 0; i <= topicsPerPage; i++)
-      {
-         String pattern = "topic_id_list[" + i + "]";
-         String topicNum = request.getParameters().get(pattern, "none");
-
-         if (!topicNum.equals("none"))
-         {
-
-            topicsPassedList.add(new Integer(topicNum));
-         }
-      }
-      //plus the one from "t" param
-      if (tid != -1)
-      {
-         topicsPassedList.add(new Integer(tid));
-      }
-
-      //process delete button
-      if (mode.equals("delete"))
-      {
-
-         //show confirmation page in doView()
-         response.setRenderParameter(getOperationName(), OP_CONFIRM);
-         //action url for the confirmation form
-
-         StringBuffer hiddenFields = new StringBuffer();
-         hiddenFields.append("<input type=\"hidden\" name=\"deleteConfirm\" value=\"yes\"/>").
-            append("<input type=\"hidden\" name=\"op\" value=\"moderate_forum\"/>").
-            append("<input type=\"hidden\" name=\"f\" value=\"" + fid + "\"/>");
-         int i = 0;
-         //we must passed all topics number in response
-         for (Iterator itp = topicsPassedList.iterator(); itp.hasNext(); i++)
-         {
-            hiddenFields.append("<input type=\"hidden\" name=\"topic_id_list[" + i + "]" + "\" value=\"" + ((Integer)itp.next()).toString() + "\"/>");
-         }
-         response.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields.toString());
-         response.setRenderParameter("MESSAGE_TITLE", bundle.getString("Topic_delete_confirm"));
-         response.setRenderParameter("MESSAGE_TEXT", bundle.getString("Topic_delete_message"));
-         return;
-      }
-      // proces deletion confirmation
-      else if (paramMap.containsKey("deleteConfirm"))
-      {
-
-
-         DeleteTopicCommand cmd = new DeleteTopicCommand(request, response);
-         cmd.topicIds = topicsPassedList;
-         cmd.module = forumsModule;
-         Result result = forumsModule.invoke(cmd);
-         ResultType type = result.getType();
-         if (type == CommandConstants.TYPE_CANNOT_REMOVE_TOPICS)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_CANNOT_REMOVE_TOPIC");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOPICS_REMOVED)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
-            response.setRenderParameter("f", "" + fid);
-            addSuccessMessage(response, "moderate", "SUCC_TOPIC_REMOVED");
-            return;
-         }
-         return;
-      }
-      // process move button
-      else if (mode.equals("move"))
-      {
-
-         /*response.setRenderParameter(getOperationName(), OP_SHOWMOVETOPIC);
-         //url for navigation link - show our forum
-         PortletURL forumGotoURL = response.createActionURL();
-         forumGotoURL.setParameter(getOperationName(), OP_SHOWFORUM);
-         forumGotoURL.setParameter("f", "" + fid);
-         //<a href=...
-         response
-         response.setRenderParameter("U_INDEX", forumGotoURL.toString());*/
-         //>forum name</a>
-         //ass render urls should be created from RenderResponse we pass it to doView
-         response.setRenderParameter("U_INDEX_f", "" + fid);
-         response.setRenderParameter("L_INDEX", forum.getName());
-
-         //hidden fields
-         StringBuffer hiddenFields = new StringBuffer();
-         hiddenFields.append("<input type=\"hidden\" name=\"moveConfirm\" value=\"yes\"/>").
-            append("<input type=\"hidden\" name=\"op\" value=\"moderate_forum\"/>").
-            append("<input type=\"hidden\" name=\"f\" value=\"" + fid + "\" />");
-         int i = 0;
-         //we must passed all topics number in response
-         for (Iterator itp = topicsPassedList.iterator(); itp.hasNext(); i++)
-         {
-            hiddenFields.append("<input type=\"hidden\" name=\"topic_id_list[" + i + "]" + "\" value=\"" + ((Integer)itp.next()).toString() + "\"/>");
-         }
-         response.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields.toString());
-
-
-         try
-         {
-            String selectTo = new StringBuffer().
-               append("<select name=\"forum_to_id\">").
-               append("<option value=\"-1\"").
-               append(" selected=\"selected\">").
-               append("Select destination forum").append("</option>\n").
-               append(ForumsTools.listForums(forumsModule.findForums(), -1)).
-               append("</select>").toString();
-            response.setRenderParameter("S_FORUM_SELECT", selectTo);
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-            return;
-         }
-         return;
-
-      }
-
-      //process move confirmation
-      else if (paramMap.containsKey("moveConfirm"))
-      {
-
-         int toForumId = request.getParameters().getInt("forum_to_id", -1);
-         if (toForumId == -1)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_NO_DEST_FORUM");
-            return;
-         }
-
-         MoveTopicCommand cmd = new MoveTopicCommand(request, response);
-         cmd.topicIds = topicsPassedList;
-         cmd.module = forumsModule;
-         cmd.destinationForumId = new Integer(toForumId);
-
-         Result result = forumsModule.invoke(cmd);
-         ResultType type = result.getType();
-         if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOPIC_MOVED)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
-            response.setRenderParameter("f", "" + fid);
-            addSuccessMessage(response, "moderate", "SUCC_TOPIC_MOVED");
-            return;
-         }
-         return;
-      }
-
-      //process lock button
-      else if (mode.equals("lock"))
-      {
-
-         LockTopicCommand cmd = new LockTopicCommand(request, response);
-         cmd.topicIds = topicsPassedList;
-         cmd.module = forumsModule;
-
-         Result result = forumsModule.invoke(cmd);
-         ResultType type = result.getType();
-         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOPIC_LOCKED)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
-            response.setRenderParameter("f", "" + fid);
-            addSuccessMessage(response, "moderate", "SUCC_TOPIC_LOCKED");
-            return;
-         }
-         return;
-
-
-      }
-      //process unlock button
-      else if (mode.equals("unlock"))
-      {
-
-         LockTopicCommand cmd = new LockTopicCommand(request, response);
-         cmd.topicIds = topicsPassedList;
-         cmd.module = forumsModule;
-         cmd.unlockAction = true;
-
-         Result result = forumsModule.invoke(cmd);
-         ResultType type = result.getType();
-         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOPIC_UNLOCKED)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
-            response.setRenderParameter("f", "" + fid);
-            addSuccessMessage(response, "moderate", "SUCC_TOPIC_UNLOCKED");
-
-            return;
-         }
-         return;
-      }
-      //process split button
-      else if (mode.equals("split"))
-      {
-
-         response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-         response.setRenderParameter("t", "" + tid);
-         response.setRenderParameter("f", "" + fid);
-         return;
-      }
-      //process split all button
-      else if (paramMap.containsKey("split_type_all"))
-      {
-
-
-         Topic topic = null;
-         try
-         {
-            topic = forumsModule.findTopicById(new Integer(tid));
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-            return;
-         }
-         if (topic.getPosts().size() == 1)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            //response.setRenderParameter("t","" + tid);
-            addErrorMessage(response, "moderate", "ERR_SPLIT_ONE_POST_TOPIC");
-            return;
-         }
-
-         //first get all post numbers passed in request
-         List postsPassedList = new LinkedList();
-         for (int i = 0; i < topic.getPosts().size(); i++)
-         {
-            String pattern = "post_id_list[" + i + "]";
-            String postNum = request.getParameters().get(pattern, "none");
-
-            if (!postNum.equals("none"))
-            {
-
-               postsPassedList.add(new Integer(postNum));
-            }
-            else
-            {
-               //break;
-            }
-         }
-         //check if we don't want to move all posts from source topic
-         if (postsPassedList.size() == 0)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_NO_POST_SELECTED");
-            return;
-         }
-         else if ((topic.getPosts().size() - postsPassedList.size()) == 0)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_SPLIT_ALL");
-            return;
-         }
-
-         int toForumId = request.getParameters().getInt("forum_to_id", -1);
-         if (toForumId == -1)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_DEST_FORUM");
-            return;
-         }
-         SplitTopicCommand cmd = new SplitTopicCommand(request, response);
-         cmd.postIds = postsPassedList;
-         cmd.module = forumsModule;
-         cmd.destinationForumId = new Integer(toForumId);
-         cmd.newSubject = request.getParameters().get("subject", "default");
-         cmd.topicId = new Integer(tid);
-         cmd.userId = request.getUser().getId().toString();
-
-         Result result = forumsModule.invoke(cmd);
-         ResultType type = result.getType();
-         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOPIC_SPLITED)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addSuccessMessage(response, "moderate", "SUCC_TOPIC_SPLITTED");
-            ;
-            return;
-         }
-         return;
-      }
-      //process split after button
-      else if (paramMap.containsKey("split_type_beyond"))
-      {
-
-         if (topicsPassedList.size() > 1)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "Too_many_error");
-            return;
-         }
-
-         Topic topic = null;
-         try
-         {
-            topic = forumsModule.findTopicById(new Integer(tid));
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
-            return;
-         }
-         if (topic.getPosts().size() == 1)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            //response.setRenderParameter("t","" + tid);
-            addErrorMessage(response, "moderate", "ERR_SPLIT_ONE_POST_TOPIC");
-            return;
-         }
-
-         //first get all post numbers passed in request
-         List postsPassedList = new LinkedList();
-         for (int i = 0; i < topic.getPosts().size(); i++)
-         {
-            String pattern = "post_id_list[" + i + "]";
-            String postNum = request.getParameters().get(pattern, "none");
-
-            if (!postNum.equals("none"))
-            {
-
-               postsPassedList.add(new Integer(postNum));
-            }
-            else
-            {
-               //break;
-            }
-         }
-         if (postsPassedList.size() == 0)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_NO_POST_SELECTED");
-            return;
-         }
-         else if (postsPassedList.size() != 1)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "Too_many_error");
-            return;
-         }
-         //check if user selected first post
-         else if (topic.getFirstPost().getId().equals((Integer)(postsPassedList.iterator()).next()))
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_SPLIT_ALL");
-            return;
-         }
-
-         int toForumId = request.getParameters().getInt("forum_to_id", -1);
-         if (toForumId == -1)
-         {
-            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
-            response.setRenderParameter("t", "" + tid);
-            response.setRenderParameter("f", "" + fid);
-            addErrorMessage(response, "moderate", "ERR_DEST_FORUM");
-            return;
-         }
-         SplitTopicCommand cmd = new SplitTopicCommand(request, response);
-         cmd.postIds = postsPassedList;
-         cmd.module = forumsModule;
-         cmd.destinationForumId = new Integer(toForumId);
-         cmd.newSubject = request.getParameters().get("subject", "default");
-         cmd.topicId = new Integer(tid);
-         cmd.userId = request.getUser().getId().toString();
-         cmd.splitAfter = true;
-
-         Result result = forumsModule.invoke(cmd);
-         ResultType type = result.getType();
-         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addErrorMessage(response, "moderate", "ERR_INTERNAL");
-
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOPIC_SPLITED)
-         {
-            response.setRenderParameter(getOperationName(), OP_MAIN);
-            addSuccessMessage(response, "moderate", "SUCC_TOPIC_SPLITTED");
-
-            return;
-         }
-
-
-         return;
-      }
-
-
-   }
-
-   public void preferences(JBossActionRequest request, JBossActionResponse response)
-      throws CommandException
-   {
-
-      try
-      {
-         PortletPreferences pp = request.getPreferences();
-         PropertyMap upm = request.getUser().getProperties();
-         if (!pp.isReadOnly("notifyreply"))
-         {
-            pp.setValue("notifyreply", request.getParameter("notifyreply"));
-         }
-         /*if (!pp.isReadOnly("attachsig"))
-            pp.setValue("attachsig", request.getParameter("attachsig"));*/
-         if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
-         {
-            upm.put(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY, request.getParameter("attachsig"));
-         }
-         //TODO: BBCode disable should be implemented
-         /*if (!pp.isReadOnly("allowbbcode"))
-             pp.setValue("allowbbcode", request.getParameter("allowbbcode"));*/
-         if (!pp.isReadOnly("allowhtml"))
-         {
-            pp.setValue("allowhtml", request.getParameter("allowhtml"));
-         }
-         if (!pp.isReadOnly("postorder"))
-         {
-            pp.setValue("postorder", request.getParameter("postorder"));
-         }
-         if (!pp.isReadOnly("topicsperforum"))
-         {
-            pp.setValue("topicsperforum", request.getParameter("topicsperforum"));
-         }
-         if (!pp.isReadOnly("postspertopic"))
-         {
-            pp.setValue("postspertopic", request.getParameter("postspertopic"));
-         }
-         if (!pp.isReadOnly("dateformat"))
-         {
-            if (request.getParameter("dateformat") != null)
-            {
-               try
-               {
-                  new SimpleDateFormat(request.getParameter("dateformat"));
-                  pp.setValue("dateformat", request.getParameter("dateformat"));
-               }
-               catch (IllegalArgumentException e)
-               {
-                  System.out.println("Illegal date format");
-                  pp.setValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
-               }
-            }
-            else
-            {
-               pp.setValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
-            }
-
-         }
-         /*if (!pp.isReadOnly("signature"))
-         {
-            pp.setValue("signature", request.getParameter("signature"));
-         }*/
-         if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
-         {
-            upm.put(ForumsConstants.USER_SIGNATURE_PROPERTY, request.getParameter("signature"));
-         }
-
-         String summarymode = request.getParameter("summarymode");
-         String limit = request.getParameter("summarytopiclimit");
-         String days = request.getParameter("summarytopicdays");
-         String replies = request.getParameter("summarytopicreplies");
-         // we do simple validation of integers in fields
-
-         if (!pp.isReadOnly("summarymode"))
-         {
-            new Integer(summarymode);
-            pp.setValue("summarymode", request.getParameter("summarymode"));
-         }
-
-         try
-         {
-            if (!pp.isReadOnly("summarytopiclimit"))
-            {
-               Integer.parseInt(limit);
-               pp.setValue("summarytopiclimit", request.getParameter("summarytopiclimit"));
-            }
-         }
-         catch (IllegalArgumentException e)
-         {
-            //e.printStackTrace();
-            if (!pp.isReadOnly("summarytopiclimit"))
-            {
-               pp.setValue("summarytopiclimit", "6");
-            }
-            addErrorMessage(response, "posting", "Illegal format in: Topic Summary Limit");
-         }
-
-         try
-         {
-            if (!pp.isReadOnly("summarytopicdays"))
-            {
-               new Integer(days);
-               pp.setValue("summarytopicdays", request.getParameter("summarytopicdays"));
-            }
-         }
-         catch (IllegalArgumentException e)
-         {
-            //e.printStackTrace();
-            if (!pp.isReadOnly("summarytopicdays"))
-            {
-               pp.setValue("summarytopicdays", "20");
-            }
-            addErrorMessage(response, "posting", "Illegal format in: Topic Summary Days");
-         }
-
-         try
-         {
-            if (!pp.isReadOnly("summarytopicreplies"))
-            {
-               new Integer(replies);
-               pp.setValue("summarytopicreplies", request.getParameter("summarytopicreplies"));
-            }
-         }
-         catch (IllegalArgumentException e)
-         {
-            //e.printStackTrace();
-            if (!pp.isReadOnly("summarytopicreplies"))
-            {
-               pp.setValue("summarytopicreplies", "15");
-            }
-            addErrorMessage(response, "posting", "Illegal format in: Topic Summary Replies");
-         }
-         pp.store();
-      }
-      catch (Exception e)
-      {
-         System.out.println("Some Exception while storing portlet prefs....");
-         addErrorMessage(response, "posting", "Some Exception while storing portlet prefs....");
-         e.printStackTrace();
-      }
-   }
-
-
-   /**
-    * posting operation
-    *
-    * @param request  JBoss action request
-    * @param response JBoss action response
-    * @throws CommandException
-    * @throws CommandException DOCUMENT_ME
-    */
-   public void posting(JBossActionRequest request, JBossActionResponse response)
-      throws CommandException
-   {
-
-      //for debug
-      /*System.out.println("@@@@@@@@@@@@@@@@@@@@@@");
-      System.out.println("in posting();");
-      *///For more debug puproses uncomment lines in Contex.update()
-
-      ResourceBundle bundle = getResourceBundle(request.getLocale());
-
-      Context ctx = new Context();
-      ctx.setForumsModule(forumsModule);
-      ctx.update(request, response);
-
-      //Cancel button
-      String cancelVal = request.getParameters().get("cancel_posting", "none");
-      boolean cancelbtn = !cancelVal.equals("none");
-      if (cancelbtn)
-      {
-         switch (ctx.p_mode)
-         {
-            case ForumsConstants.PMODE_NEW_TOPIC:
-            {
-               response.setRenderParameter("op", OP_SHOWFORUM);
-               response.setRenderParameter("f", "" + ctx.p_forum_id);
-               return;
-            }
-            case ForumsConstants.PMODE_REPLY:
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("t", "" + ctx.p_post_parent_topic_id);
-               return;
-            }
-            case ForumsConstants.PMODE_EDIT_POST:
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("p", "" + ctx.p_post_id);
-               return;
-            }
-         }
-
-      }
-
-      //Set info that posting was processed so if new topic page will be displayed it will be postback
-      response.setRenderParameter(ForumsConstants.POSTING_POSTBACK_FLAG, "true");
-
-      /*
-      // Was cancel pressed? If so then redirect to the appropriate page
-      if (ctx.p_cancel)
-      {
-      if (ctx.p_post_id != -1)
-      {
-      response.sendRedirect("index.html?module=bb&op=viewtopic&p="
-      + ctx.p_post_id + "#" + ctx.p_post_id);
-      }
-      else if (ctx.p_topic_id != -1)
-      {
-      response.sendRedirect("index.html?module=bb&op=viewtopic&t="
-      + ctx.p_topic_id);
-      }
-      else if (ctx.p_forum_id != -1)
-      {
-      response.sendRedirect("index.html?module=bb&op=viewforum&f="
-      + ctx.p_forum_id);
-      }
-      else
-      {
-      response.sendRedirect("index.html?module=bb");
-      }
-      return;
-      }
-      */
-
-      // If the variable mode is empty we don't go farther in the process
-      if (ctx.p_mode == PMODE_NO_MODE)
-      {
-         addErrorMessage(response, "posting",
-            "Unexpected error: No mode defined");
-         return;
-      }
-
-      //If there were poll delete confirmation "No" button pressed
-      if ((ctx.p_mode == ForumsConstants.PMODE_POLL_DELETE) &&
-         (request.getParameter("cancel") != null) &&
-         (request.getParameter("cancel").equals("No")))
-      {
-         if (ctx.p_post_id != -1)
-         {
-            response.setRenderParameter("op", OP_SHOWTOPIC);
-            response.setRenderParameter("p", "" + ctx.p_post_id);
-         }
-         else if (ctx.p_topic_id != -1)
-         {
-            response.setRenderParameter("op", OP_SHOWTOPIC);
-            response.setRenderParameter("t", "" + ctx.p_topic_id);
-         }
-         else if (ctx.p_forum_id != -1)
-         {
-            response.setRenderParameter("op", OP_SHOWFORUM);
-            response.setRenderParameter("f", "" + ctx.p_forum_id);
-         }
-         return;
-
-      }
-
-      if (ctx.c_refresh)
-      {
-         response.setRenderParameter("mode", request.getParameter("mode"));
-
-      }
-
-      if (ctx.p_mode == PMODE_EDIT_POST)
-      {
-         if (ctx.p_topic_first_post)
-         {
-            response.setRenderParameter("firstTopicPost", "" + ctx.p_topic_first_post);
-         }
-         response.setRenderParameter("topictype", "" + ctx.p_topic_type);
-         //return;
-      }
-      /*
-      // If the mode is set to topic review then output that review
-      switch (ctx.p_mode)
-      {
-      case PMODE_TOPIC_REVIEW:
-      //         display(theme.TPL_THEME_POSTING_TOPIC_REVIEW, topicReview(ctx.p_topic_id), page);
-      return;
-      case PMODE_SMILIES:
-      // generate_smilies('window', PAGE_POSTING);
-      // exit;
-      return;
-      }
-      */
-
-      // Output the confirm message in no confirm variable is found when we delete something
-      if ((((ctx.p_mode == PMODE_EDIT_POST) && ctx.p_poll_delete) || (ctx.p_mode == PMODE_DELETE))
-         && !ctx.p_confirm)
-      {
-         response.setRenderParameter("MESSAGE_TITLE", bundle
-            .getString("Information"));
-         response.setRenderParameter("MESSAGE_TEXT",
-            (ctx.p_mode == PMODE_DELETE) ? bundle
-               .getString("Confirm_delete") : bundle
-               .getString("Confirm_delete_poll"));
-         response
-            .setRenderParameter("S_HIDDEN_FIELDS",
-               "<input type=\"hidden\" name=\"p\" value=\""
-                  + ctx.p_post_id
-                  + "\"/>"
-                  + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
-                  + "<input type=\"hidden\" name=\"op\" value=\"posting\"/>"
-                  + ((ctx.p_mode == PMODE_DELETE) ? "<input type=\"hidden\" name=\"mode\" value=\"delete\"/>"
-                  : "<input type=\"hidden\" name=\"mode\" value=\"poll_delete\"/>"));
-
-         //         display(theme.TPL_THEME_CONFIRM_BODY, temp, page);
-         response.setRenderParameter("op", OP_CONFIRM);
-         return;
-      }
-
-      // Get user informations
-      User currentUser = request.getUser();
-
-      //
-      Action action = ctx.action(request, response);
-
-      if (action instanceof ProcessCommandAction)
-      {
-         // Get the encapsulated command
-         ForumCommand cmd = ((ProcessCommandAction)action).getCommand();
-
-         // Set the current user on it
-         cmd.setCurrentUser(currentUser);
-
-         // Execute it
-         // Finish the command configuration
-         cmd.setModule(forumsModule);
-
-         // Execute the command
-         Result result = forumsModule.invoke(cmd);
-
-         // Switch on the result
-         ResultType type = result.getType();
-
-         /*
-          if (type == CommandConstants.TYPE_ALREADY_VOTED)
-          {
-          //            Die.exit(GENERAL_MESSAGE,
-          //                  "${bb.Already_voted}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
-          //                  ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
-          }
-          else if (type == CommandConstants.TYPE_CANNOT_INSERT_VOTE)
-          {
-          //            Die.rollback(GENERAL_ERROR, "Could not insert user_id for poll");
-          }
-          else if (type == CommandConstants.TYPE_CANNOT_OBTAIN_USER_DATA)
-          {
-          //            Die.exit(GENERAL_ERROR, "Could not obtain user vote data for this topic");
-          }
-          else if (type == CommandConstants.TYPE_VOTE_CAST)
-          {
-          //            Die.exit(GENERAL_MESSAGE,
-          //                  "${bb.Vote_cast}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
-          //                  ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
-          }
-          else if (type == CommandConstants.TYPE_NO_VOTE_OPTION)
-          {
-          //            Die.exit(GENERAL_MESSAGE,
-          //                  "${bb.No_vote_option}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
-          //                  ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
-          }
-          else if (type == CommandConstants.TYPE_COULD_NOT_OBTAIN_VOTE_DATA)
-          {
-          //            Die.exit(GENERAL_ERROR, "Could not obtain vote data for this topic");
-          }
-          else if (type == CommandConstants.TYPE_REDIRECT)
-          {
-          response.sendRedirect("index.html?module=bb&op=viewtopic&t=" + ((VoteTopicCommand) cmd).topic.getId());
-          }
-          else
-          */
-         if (type == CommandConstants.TYPE_ERROR_IN_POSTING)
-         {
-            addErrorMessage(response, "postingfailed", "Error in posting");
-            return;
-         }
-         else if ((type == CommandConstants.TYPE_NEW_TOPIC_POSTED)
-            || (type == CommandConstants.TYPE_EDIT_POST_POSTED)
-            || (type == CommandConstants.TYPE_REPLY_POSTED)
-            )
-         {
-            Post post = null;
-            if (cmd instanceof NewTopicCommand)
-            {
-               post = ((NewTopicCommand)cmd).post;
-            }
-            else if (cmd instanceof EditPostCommand)
-            {
-               post = ((EditPostCommand)cmd).post;
-            }
-            else
-            {
-               post = ((ReplyCommand)cmd).newPost;
-            }
-
-            //removed according JBPORTAL-403
-            //addSuccessMessage(response, "posting", "Stored");
-            if (ctx.p_post_id != -1)
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("p", "" + ctx.p_post_id);
-            }
-            else if (ctx.p_topic_id != -1)
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("t", "" + ctx.p_topic_id);
-            }
-            else if (ctx.p_forum_id != -1)
-            {
-               response.setRenderParameter("op", OP_SHOWFORUM);
-               response.setRenderParameter("f", "" + ctx.p_forum_id);
-            }
-
-
-            return;
-         }
-         else if (type == CommandConstants.TYPE_VOTE_POSTED)
-         {
-            addSuccessMessage(response, "posting", "Voted Successfully");
-            if (ctx.p_post_id != -1)
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("p", "" + ctx.p_post_id);
-            }
-            else if (ctx.p_topic_id != -1)
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("t", "" + ctx.p_topic_id);
-            }
-            else if (ctx.p_forum_id != -1)
-            {
-               response.setRenderParameter("op", OP_SHOWFORUM);
-               response.setRenderParameter("f", "" + ctx.p_forum_id);
-            }
-
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NOT_SELECTED_VOTE)
-         {
-            addErrorMessage(response, "posting", "Cannot vote because no option selected");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_POST)
-         {
-            addErrorMessage(response, "posting", "Error in deleting post");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_POLL)
-         {
-            addErrorMessage(response, "posting", "Error in deleting poll");
-            return;
-         }
-         else if ((type == CommandConstants.TYPE_POLL_DELETED)
-            || (type == CommandConstants.TYPE_POST_DELETED))
-         {
-            //            Die.exit(GENERAL_MESSAGE,
-            //                  "<br/><br/>${bb.Click_return_forum_0}<a href=\"index.html?module=bb&op=viewforum&f=" +
-            //                  cmd.forum.getId() + "\">${bb.Click_return_forum_1}</a>" +
-            //                  "${bb.Click_return_forum_2}");
-            if (ctx.p_post_id != -1 && (type != CommandConstants.TYPE_POST_DELETED))
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("p", "" + ctx.p_post_id);
-            }
-            else if (ctx.p_topic_id != -1 &&
-               (cmd instanceof DeletePostCommand) &&
-               !(((DeletePostCommand)cmd).pd_first_post && ((DeletePostCommand)cmd).pd_last_post))
-            {
-               response.setRenderParameter("op", OP_SHOWTOPIC);
-               response.setRenderParameter("t", "" + ctx.p_topic_id);
-
-            }
-            else if (ctx.p_forum_id != -1)
-            {
-               response.setRenderParameter("op", OP_SHOWFORUM);
-               response.setRenderParameter("f", "" + ctx.p_forum_id);
-            }
-            else
-            {
-               response.setRenderParameter("op", OP_MAIN);
-            }
-
-            return;
-         }
-         else if (type == CommandConstants.TYPE_FORUM_LOCKED)
-         {
-            addErrorMessage(response, "postingfailed", "Forum_locked");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOPIC_IS_LOCKED)
-         {
-            addErrorMessage(response, "postingfailed", "Topic_locked");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NOT_AUTHORIZED)
-         {
-            //if (isUserLoggedIn(currentUser))
-            if (request.getRemoteUser() != null)
-            {
-               //               Die.exit(GENERAL_MESSAGE, "${bb." + AUTH_TYPE_TO_MESSAGE[cmd.authType()] + "0}" +
-               //                     "todo" + // $is_auth[$is_auth_type . "_type"]
-               //                     "${bb." + AUTH_TYPE_TO_MESSAGE[cmd.authType()] + "1}");
-               return;
-            }
-            else
-            {
-               if (cmd instanceof EditPostCommand)
-               {
-                  // redirect after = index.html?module=bb&op=posting&mode=quote& + POST_POST_URL + = post_id
-               }
-               else if (cmd instanceof NewTopicCommand)
-               {
-                  // redirect after = index.html?module=bb&op=posting&mode=newtopic& + POST_FORUM_URL + = forum_id
-               }
-               else if (cmd instanceof ReplyCommand)
-               {
-                  //                  if (((ReplyCommand)cmd).quote)
-                  //                  {
-                  //                     // redirect after = index.html?module=bb&op=posting&mode=quote& + POST_POST_URL + = post_id
-                  //                  }
-                  //                  else
-                  //                  {
-                  //                     // beware mode=reply switched from topic to topic.lastPost
-                  //                     // redirect after = index.html?module=bb&op=posting&mode=reply& + POST_TOPIC_URL + = topic_id
-                  //                  }
-               }
-               else
-               {
-                  if (ctx.p_post_id != -1)
-                  {
-                     response.setRenderParameter("op", OP_SHOWTOPIC);
-                     response.setRenderParameter("p", "" + ctx.p_post_id);
-                  }
-                  else if (ctx.p_topic_id != -1)
-                  {
-                     response.setRenderParameter("op", OP_SHOWTOPIC);
-                     response.setRenderParameter("t", "" + ctx.p_topic_id);
-                  }
-                  else if (ctx.p_forum_id != -1)
-                  {
-                     response.setRenderParameter("op", OP_SHOWFORUM);
-                     response.setRenderParameter("f", "" + ctx.p_forum_id);
-                  }
-               }
-
-               //   response.sendRedirect("index.html?module=user&op=getlogin");
-            }
-         }
-         else if (type == CommandConstants.TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR)
-         {
-            //            Die.exit(GENERAL_MESSAGE, (cmd instanceof DeletePollCommand || cmd instanceof DeletePostCommand) ?
-            //                                      "${bb.Delete_own_posts}" : "${bb.Edit_own_posts}" +
-            //                  "<br/><br/>${bb.Click_return_topic_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
-            //                  ((TopicCommand)cmd).topic.getId() +
-            //                  "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}");
-         }
-         else if (type == CommandConstants.TYPE_CANNOT_DELETE_REPLIED)
-         {
-            addErrorMessage(response, "postingfailed", "Cannot_delete_replied");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_CANNOT_DELETE_POLL)
-         {
-            addErrorMessage(response, "postingfailed", "Cannot_delete_poll");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NO_SUCH_POST)
-         {
-            addErrorMessage(response, "postingfailed", "No_such_Post");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
-         {
-            addErrorMessage(response, "postingfailed", "No_topic_id");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
-         {
-            addErrorMessage(response, "postingfailed", "Forum_not_exist");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_CANNOT_QUERY)
-         {
-            addErrorMessage(response, "postingfailed",
-               "Could not query forum/topic/post information");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_INVALID_POST_SUBJECT)
-         {
-            addErrorMessage(response, "postingfailed", "Empty_subject");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_INVALID_POST_MESSAGE)
-         {
-            addErrorMessage(response, "postingfailed", "Empty_message");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOO_MANY_POLL_OPTION)
-         {
-            addErrorMessage(response, "postingfailed", "To_many_poll_options");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_INVALID_POLL_OPTION)
-         {
-            addErrorMessage(response, "postingfailed", "Empty_poll_option");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_INVALID_POLL_TITLE)
-         {
-            addErrorMessage(response, "postingfailed", "Empty_poll_title");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_TOO_FEW_POLL_OPTION)
-         {
-            addErrorMessage(response, "postingfailed", "To_few_poll_options");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_REPOSTED)
-         {
-            addErrorMessage(response, "postingfailed", "Reposted");
-            return;
-
-            //            Die.exit(GENERAL_MESSAGE,
-            //                  "${bb.Reposted}<br/><br/>" +
-            //                  "${bb.Click_view_message_0}" +
-            //                  "<a href=\"index.html?module=bb&op=viewtopic&t=" +
-            //                  ((RepostCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
-         }
-         else if (type == CommandConstants.TYPE_FLOODING_CANNOT_CREATE)
-         {
-            addErrorMessage(response, "postingfailed", "Flood_Error");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_CANNOT_ADD_ATTACHMENT)
-         {
-            addErrorMessage(response, "postingfailed",
-               "You are not authorized to add an attachment");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_CANNOT_DELETE_ATTACHMENT)
-         {
-            addErrorMessage(response, "postingfailed",
-               "You are not authorized to delete an attachment");
-            return;
-         }
-         else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_ATTACHMENT)
-         {
-            addErrorMessage(response, "postingfailed",
-               "Problem when deleting an attachment");
-            return;
-         }
-         else
-         {
-            throw new RuntimeException("This statement should not be reached");
-         }
-      }
-      else
-      {
-         ForumAction faction = (ForumAction)action;
-
-         faction.init();
-
-         Forum forum = faction.getForum();
-         Category category = forum.getCategory();
-         Message msg = faction.getMessage();
-         Poster poster = faction.getPoster();
-
-         //         Level level = secGetLevel(category.getTitle() + ":" + forum.getName() + ":", currentUser);
-         //boolean loggedIn = isUserLoggedIn(currentUser);
-         boolean loggedIn = request.getRemoteUser() != null;
-         /*int[] types = new int[]{AuthType.READ, AuthType.DELETE,
-            AuthType.STICKY, AuthType.ANNOUNCE, AuthType.POLL,
-            AuthType.ATTACH};*/
-
-         //         boolean[] auths = forum.getAuth().can(types, loggedIn, level);
-         //         boolean isAuthRead = auths[0];
-         //         boolean isAuthDelete = auths[1];
-         //         boolean isAuthSticky = auths[2];
-         //         boolean isAuthAnnounce = auths[3];
-         //         boolean isAuthPollCreate = auths[4];
-         //         boolean isAuthAttachments = auths[5];
-         //         boolean isAuthMod = Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
-         // We are sure to have forumEJB not null and we always target a forum
-         int forum_id = forum.getId().intValue();
-         String forum_name = forum.getName();
-         Integer topic_id = (faction instanceof TopicAction) ? ((TopicAction)faction)
-            .getTopic().getId()
-            : new Integer(-1);
-
-         // julien : is it utile ?
-         //          if (topic_id.intValue() > -1 && (cmd instanceof NewTopicCommand || cmd instanceof ReplyCommand))
-         //          {
-         //             Map trackingTopics = getTrackingTopics(page);
-         //             trackingTopics.put(topic_id, new Date());
-         //          }
-         //      if (!"".equals(error_msg))
-         //      {
-         //         DelegateContext temp = provider.instantiate(TPL_THEME_ERROR_BODY);
-         //         temp.put("ERROR_MESSAGE", error_msg);
-         //         errorBox = temp.render();
-         //      }
-         String previewBox = "";
-         String errorBox = "";
-
-         if (ctx.p_preview)
-         {
-            PropertyMap upm = request.getUser().getProperties();
-            String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
-            String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
-            String preview_message = "";
-            if ((addsign != null) && (sign != null) && addsign.equals("1"))
-            {
-               //preview_message = formatMessage(request, msg.getText() + "\n\n" + sign, msg.getBBCodeEnabled(), msg.getHTMLEnabled());
-               preview_message = formatMessage(request, msg.getText() + "\n\n" + sign, msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
-            }
-            else
-            {
-               //preview_message = formatMessage(request, msg.getText(), msg.getBBCodeEnabled(), msg.getHTMLEnabled());
-               preview_message = formatMessage(request, msg.getText(), msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
-            }
-            /*String preview_message = formatMessage(msg.getText(), msg
-                    .getBBCodeEnabled(), msg.getHTMLEnabled());*/
-            //if ((currentUser != null) && msg.getSignatureEnabled())
-            //{
-            //String signature = currentUser.getSignature();
-            String signature = request.getPreferences().getValue("signature", "");
-            if (!ForumsTools.isNullOrBlank(signature))
-            {
-               //preview_message += formatSignature(request, signature, msg.getBBCodeEnabled(), msg.getHTMLEnabled());
-               preview_message += formatSignature(request, signature, msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
-            }
-            //}
-
-            String preview_subject = formatTitle(request, msg.getSubject());
-            String preview_username = formatUserName(poster.getUser());
-
-            //
-            // Date formater
-            //
-            SimpleDateFormat sdf = getSDF(request);
-
-            //            PortletURL postingURL = response.createRenderURL();
-            //            postingURL.setParameter("op", OP_POSTING);
-            response.setRenderParameter("op", OP_POSTING);
-            response.setRenderParameter("preview", "true");
-            if (request.getParameters().getParameterExists("f"))
-            {
-               response.setRenderParameter("f", request.getParameter("f"));
-            }
-
-            if (request.getParameters().getParameterExists("p"))
-            {
-               response.setRenderParameter("p", request.getParameter("p"));
-            }
-
-            response.setRenderParameter("mode", request.getParameter("mode"));
-            response.setRenderParameter("TOPIC_TITLE", preview_subject);
-            response.setRenderParameter("POST_SUBJECT", msg.getSubject());
-            response.setRenderParameter("PREVIEW_SUBJECT", preview_subject);
-            response.setRenderParameter("POSTER_NAME", preview_username);
-            response.setRenderParameter("POST_DATE", sdf.format(new Date()));
-            response.setRenderParameter("MESSAGE", msg.getText());
-            response.setRenderParameter("PREVIEW_MESSAGE", preview_message);
-
-            //            response.sendRedirect(postingURL.toString());
-
-         }
-
-         if ((ctx.p_mode == ForumsConstants.PMODE_EDIT_POST) &&
-            (ctx.p_topic_first_post == true))
-         {
-            response.setRenderParameter("editPoll", "true");
-            Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
-            if (request.getParameter("editPostInit") != null && (ctx.p_post_id != -1))
-            {
-               try
-               {
-                  Post p = forumsModule.findPostById(new Integer(ctx.p_post_id));
-                  Topic t = forumsModule.findTopicById(p.getTopic().getId());
-                  if (t.getPoll() != null)
-                  {
-                     poll = t.getPoll();
-                  }
-               }
-               catch (ModuleException e)
-               {
-                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-               }
-            }
-            DelegateContext temp = new DelegateContext();
-            response.setRenderParameter("POLL_TITLE", poll.getTitle());
-            response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));
-            if (action instanceof EditPostAction)
-            {
-               response.setRenderParameter("switch_poll_delete_toggle", "true");
-               //root.next("switch_poll_delete_toggle");
-            }
-            int index = 0;
-            for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
-            {
-               String text = ((PollOption)iterator.next()).getQuestion();
-               //String text = (String)iterator.next();
-               String param = "poll_option_text[" + index + "]";
-               response.setRenderParameter(param, text);
-               index++;
-            }
-         }
-
-         //DelegateContext root = new DelegateContext();
-
-         /*
-          if (htmlEnabled)
-          {
-          root.next("switch_html_checkbox");
-          root.put("HTML_STATUS", "${bb.HTML_is_ON}");
-          }
-          else
-          {
-          root.put("HTML_STATUS", "${bb.HTML_is_OFF}");
-          }
-          if (codeEnabled)
-          {
-          root.next("switch_bbcode_checkbox");
-          root.put("BBCODE_STATUS", "${bb.BBCode_is_ON_0}<a href=\"index.html?module=bb&op=faq\" " +
-          "target=\"_phpbbcode\">" +
-          "${bb.BBCode_is_ON_1}</a>${bb.BBCode_is_ON_2}");
-          }
-          else
-          {
-          root.put("BBCODE_STATUS", "${bb.BBCode_is_OFF_0}<a href=\"index.html?module=bb&op=faq\"" +
-          "target=\"_phpbbcode\">" +
-          "${bb.BBCode_is_OFF_1}</a>${bb.BBCode_is_OFF_2}");
-          }
-          if (smiliesEnabled)
-          {
-          root.next("switch_smilies_checkbox");
-          root.put("SMILIES_STATUS", "${bb.Smilies_are_ON}");
-          }
-          else
-          {
-          root.put("SMILIES_STATUS", "${bb.Smilies_are_OFF}");
-          }
-          */
-         /*if ((currentUser == null)
-            || (faction instanceof EditPostAction && (((EditPostAction)faction)
-            .getPost().getPoster().getUser() == null)))
-         {
-            root.next("switch_username_select");
-         }*/
-
-         // Set the notify toggle on the template
-         /* if (currentUser != null)
-        {
-           root.next("switch_notify_checkbox");
-           boolean notify = ctx.p_notify;
-           if ((faction instanceof EditPostAction && (faction.getMode() == ForumAction.INIT))
-              || (faction instanceof ReplyAction && (faction.getMode() == ForumAction.INIT)))
-           {
-         */     /*
-                try
-                {
-                homesRW.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(currentUser.getId(), ((TopicAction)faction).getTopic().getId()));
-                notify = true;
-                }
-                catch (ObjectNotFoundException e)
-                {
-                // no watch
-                }
-                catch (FinderException e)
-                {
-                Die.exit(GENERAL_ERROR, "Could not obtain watch information", e);
-                }
-                */
-         /*   }
-
-            root.put("S_NOTIFY_CHECKED", notify ? "checked=\"checked\"" : "");
-         }*/
-
-         // Set the signature toggle on the template
-         /*if (currentUser != null)
-         {
-            root.next("switch_signature_checkbox");
-         }*/
-
-         // BLAH todo
-         // Set set delete toggle on the template
-         //          if (action instanceof EditPostAction && (isAuthMod || isAuthDelete))
-         //          {
-         //             EditPostAction epa = (EditPostAction)action;
-         //             if (epc.pd_last_post && (!epc.topic.getVote() || epc.pd_edit_poll))
-         //             {
-         //                root.next("switch_delete_checkbox");
-         //             }
-         //          }
-         // Topic type selection
-         if (faction instanceof NewTopicAction
-            || (faction instanceof EditPostAction && ((EditPostAction)faction)
-            .isFirstPost()))
-         {
-            int topic_type = ctx.p_topic_type;
-
-            // If we edit the post we override the topic type with the one loaded from the DB
-            if (faction instanceof EditPostAction
-               && (faction.getMode() == EditPostAction.INIT))
-            {
-               topic_type = ((EditPostAction)faction).getTopic().getType();
-            }
-             switch (topic_type) 
-             {
-               case 1:
-                 {
-                   response.setRenderParameter("topictype",Integer.toString(1));
-                 }
-                 break;
-               
-               case 2:
-                 {
-                   response.setRenderParameter("topictype",Integer.toString(2));
-                 }
-                 break;
-               
-             
-               default:
-                 {
-                   response.setRenderParameter("topictype",Integer.toString(0));
-                 }
-                 break;
-             }
-            /*
-             // Create the topic type selected
-             if (isAuthSticky || isAuthAnnounce)
-             {
-             StringBuffer selector = new StringBuffer("${bb.Post_topic_as}:");
-             BBTools.radioButton(selector, "topictype", "" + POST_NORMAL, topic_type == POST_NORMAL);
-             selector.append("${bb.Post_Normal}&nbsp;&nbsp;");
-             if (isAuthSticky)
-             {
-             BBTools.radioButton(selector, "topictype", "" + POST_STICKY, topic_type == POST_STICKY);
-             selector.append("${bb.Post_Sticky}&nbsp;&nbsp;");
-             }
-             if (isAuthAnnounce)
-             {
-             BBTools.radioButton(selector, "topictype", "" + POST_ANNOUNCE, topic_type == POST_ANNOUNCE);
-             selector.append("${bb.Post_Announcement}&nbsp;&nbsp;");
-             }
-             root.next("switch_type_toggle");
-             root.put("S_TYPE_TOGGLE", selector.toString());
-             }
-             */
-         }
-
-         // Hidden form fields
-         StringBuffer hidden_form_fields = new StringBuffer();
-         hidden_form_fields.append("<input type=\"hidden\" name=\"mode\" value=\"").append(ModeDecoder.encodePosting(ctx.p_mode)).append("\"/>").append("<input type=\"hidden\" name=\"op\" value=\"posting\"/>");
-         if (faction instanceof NewTopicAction)
-         {
-            hidden_form_fields.append("<input type=\"hidden\" name=\"f\" value=\"")
-               .append(forum_id).append("\"/>");
-         }
-         else if (faction instanceof ReplyAction
-            || faction instanceof EditPostAction)
-         {
-            hidden_form_fields.append("<input type=\"hidden\" name=\"p\" value=\"").append(((PostAction)faction).getPost().getId()).append("\"/>");
-         }
-
-         //System.out.println("I'm here :) - so refreshing page or doing sth else");
-         //System.out.println("Number of polls opts: " + ctx.p_poll.getOptions().size() + " plus poll lenght: " + ctx.p_poll.getLength());
-
-         String pollBox = "";
-         boolean canCreatePoll = false;
-         /*if (action instanceof EditPostAction)
-         {
-
-         switch (((EditPostAction)faction).getTopic().getPollLevel())
-         {
-         case TopicEJB.POLL_LEVEL_EMPTY:
-         canCreatePoll = isAuthPollCreate || isAuthMod;
-         break;
-         case TopicEJB.POLL_LEVEL_NO_POLL:
-         canCreatePoll = isAuthPollCreate || isAuthMod;
-         break;
-         case TopicEJB.POLL_LEVEL_NON_EMPTY:
-         canCreatePoll = isAuthMod;
-         break;
-         default:
-         throw new RuntimeException();
-         }
-
-         }
-         else*/
-         //{
-         canCreatePoll = (action instanceof NewTopicAction);
-
-         canCreatePoll &= ForumsTools.hasPermission(request, "AddPollInPost");
-         //}
-         if (canCreatePoll)
-         {
-            Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
-            DelegateContext temp = new DelegateContext();
-            response.setRenderParameter("POLL_TITLE", poll.getTitle());
-            response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));
-            if (action instanceof EditPostAction)
-            {
-               response.setRenderParameter("switch_poll_delete_toggle", "true");
-               //root.next("switch_poll_delete_toggle");
-            }
-            int index = 0;
-            for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
-            {
-               String text = ((PollOption)iterator.next()).getQuestion();
-               //String text = (String)iterator.next();
-               String param = "poll_option_text[" + index + "]";
-               response.setRenderParameter(param, text);
-               index++;
-            }
-         }
-
-         boolean canAttach = false;
-         if ((action instanceof NewTopicAction) ||
-            (action instanceof EditPostAction) ||
-            (action instanceof ReplyAction))
-         {
-            String[] testArray = new String[]{category.getTitle(), forum.getName()};
-            canAttach = ForumsTools.hasPermission(request, testArray, "AddAttachmentInPost");
-         }
-
-         //We must pass attachments data through response to creation of NewTopic view
-         if (canAttach)
-         {
-            List uploadedAttachments = ctx.p_session_attachments;
-            //index to count id of all attachments passd to view. needed to generate proper render params
-            int index = 0;
-            //if its edit we must pass already stored attachments minus those deleted by user
-            if (ctx.p_mode == ForumsConstants.PMODE_EDIT_POST)
-            {
-               Post p = null;
-               try
-               {
-                  p = forumsModule.findPostById(new Integer(ctx.p_post_id));
-               }
-               catch (ModuleException e)
-               {
-                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-                  //TODO:Some nice error message...
-               }
-               List storedAttachments = null;
-               if (p != null && (storedAttachments = p.getAttachments()) != null)
-               {
-                  storedAttachments:
-                  for (Iterator i = storedAttachments.iterator(); i.hasNext();)
-                  {
-                     Attachment attachment = (Attachment)i.next();
-                     String updatedComment = null;
-                     //check if attachment id is on deleted list;
-                     for (Iterator j = ctx.p_deleted_attachments.iterator(); j.hasNext();)
-                     {
-                        Integer deletedIndex = (Integer)j.next();
-                        if (deletedIndex.intValue() == attachment.getId().intValue())
-                        {
-                           //Attachment id on deleted list so continueing without displaying it
-                           continue storedAttachments;
-                        }
-                     }
-                     for (Iterator j = ctx.p_updated_attachments.keySet().iterator(); j.hasNext();)
-                     {
-                        Integer updatedIndex = (Integer)j.next();
-                        if (updatedIndex.intValue() == attachment.getId().intValue())
-                        {
-                           //Attachment id on updated list so we retrieve updated comment
-                           updatedComment = (String)ctx.p_updated_attachments.get(updatedIndex);
-                           break;
-                        }
-                     }
-                     response.setRenderParameter("ATTACHMENT[" + index + "]_NAME", attachment.getFile().getName());
-                     response.setRenderParameter("ATTACHMENT[" + index + "]_ID", "stored_attach_" + attachment.getId());
-                     response.setRenderParameter("ATTACHMENT[" + index + "]_COMMENT", (updatedComment != null) ? updatedComment : attachment.getComment());
-                     index++;
-                  }
-               }
-            }
-            //and now pass newly uploaded ones
-            for (Iterator i = uploadedAttachments.iterator(); i.hasNext(); index++)
-            {
-               FileBinding fb = (FileBinding)i.next();
-               response.setRenderParameter("ATTACHMENT[" + index + "]_NAME", fb.getFileName());
-               response.setRenderParameter("ATTACHMENT[" + index + "]_ID", fb.getFileId());
-               response.setRenderParameter("ATTACHMENT[" + index + "]_COMMENT", fb.getComment());
-            }
-         }
-
-         // generate smilies listing for page output
-         // generate_smilies('inline', PAGE_POSTING);
-         /*
-          String pollBox = "";
-          boolean canCreatePoll = false;
-          if (action instanceof EditPostAction)
-          {
-
-          switch (((EditPostAction)faction).getTopic().getPollLevel())
-          {
-          case TopicEJB.POLL_LEVEL_EMPTY:
-          canCreatePoll = isAuthPollCreate || isAuthMod;
-          break;
-          case TopicEJB.POLL_LEVEL_NO_POLL:
-          canCreatePoll = isAuthPollCreate || isAuthMod;
-          break;
-          case TopicEJB.POLL_LEVEL_NON_EMPTY:
-          canCreatePoll = isAuthMod;
-          break;
-          default:
-          throw new RuntimeException();
-          }
-
-          }
-          else
-          {
-          canCreatePoll = action instanceof NewTopicAction;
-          }
-          if (canCreatePoll)
-          {
-          Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
-          DelegateContext temp = new DelegateContext();
-          temp.put("POLL_TITLE", poll.getTitle());
-          temp.put("POLL_LENGTH", Integer.toString(poll.getLength()));
-          if (action instanceof EditPostAction)
-          {
-          temp.next("switch_poll_delete_toggle");
-          }
-          int index = 0;
-          for (Iterator iterator = poll.getOptions().iterator();iterator.hasNext();)
-          {
-          String text = (String)iterator.next();
-          if (text != null)
-          {
-          DelegateContext poll_option_rows = temp.next("poll_option_rows");
-          poll_option_rows.put("POLL_OPTION", text);
-          poll_option_rows.put("S_POLL_OPTION_NUM", "" + index++);
-          }
-          }
-          pollBox = theme.TPL_THEME_POSTING_POLL_BODY.render(temp);
-          }
-          */
-         // attachBox
-         // get HTMLCode for attachment form
-         // TODO: Check the if condition for attachBox
-         //        String attachBox = "";
-         //        if (/*(action instanceof NewTopicAction || action instanceof EditPostAction) && */isAuthAttachments)
-         /*        {
-          DelegateContext temp = new DelegateContext();
-          if (showApcp)
-          {
-          temp.next("show_apcp");
-          temp.next("switch_posted_attachments");
-          }
-          String addAttachmentBox = "";
-          if (ctx.p_attach_box || !showApcp)
-          {
-          root.put("S_FORM_ENCTYPE", " enctype=\"multipart/form-data\"");
-          DelegateContext addAttachmentCtx = new DelegateContext();
-          addAttachmentBox = theme.TPL_THEME_ADD_ATTACHMENT_BODY.render(addAttachmentCtx);
-          DelegateContext hidden_row = temp.next("hidden_row");
-          hidden_row.put("S_HIDDEN", "<input type=\"hidden\" name=\"add_attachment_box_flag\" value=\"1\"/>\n");
-          temp.put("ADD_ATTACHMENT_BODY", addAttachmentBox);
-          }
-          String postedAttachmentsBox = "";
-          if ((ctx.p_posted_attach) || (!showApcp))
-          {
-          DelegateContext postedAttachmentsCtx = new DelegateContext();
-          if (faction instanceof EditPostAction)
-          {
-          EditPostAction epa = (EditPostAction)faction;
-          PostEJBLocal post = epa.getPost();
-          for (Iterator i = post.getAttachments().iterator();i.hasNext();)
-          {
-          AttachmentEJBLocal attachmentEJB = (AttachmentEJBLocal)i.next();
-          if (!ctx.p_deleted_attachments.contains(attachmentEJB.getId()))
-          {
-          DelegateContext attachRowContext = postedAttachmentsCtx.next("attach_row");
-          attachRowContext.put("FILE_NAME", attachmentEJB.getRealFilename());
-          attachRowContext.put("FILE_COMMENT", attachmentEJB.getComment());
-          attachRowContext.put("ATTACH_FILENAME", "" + attachmentEJB.getId());
-          attachRowContext.put("ATTACH_ID", "" + attachmentEJB.getId());
-          }
-          //attachRowContext.next("switch_update_attachment");
-          }
-          }
-          for (IndexIterator i = IndexIterator.wrap(faction.getAttachments().iterator(), -1);i.hasNext();)
-          {
-          UploadedFile attachment = (UploadedFile)i.next();
-          DelegateContext attachRowContext = postedAttachmentsCtx.next("attach_row");
-          attachRowContext.put("FILE_NAME", attachment.getFile().getName());
-          attachRowContext.put("FILE_COMMENT", attachment.getComment());
-          attachRowContext.put("ATTACH_FILENAME", "session_" + i.getIndex());
-          attachRowContext.put("ATTACH_ID", "session_" + i);
-          //attachRowContext.next("switch_update_attachment");
-          //attachRowContext.next("switch_thumbnail");
-          }
-          DelegateContext hidden_row = temp.next("hidden_row");
-          hidden_row.put("S_HIDDEN", "<input type=\"hidden\" name=\"posted_attachments_flag\" value=\"1\"/>\n");
-          postedAttachmentsBox = theme.TPL_THEME_POSTED_ATTACHMENTS_BODY.render(postedAttachmentsCtx);
-          temp.put("POSTED_ATTACHMENTS_BODY", postedAttachmentsBox);
-          }
-
-          //     if (ctx.p_attach)
-          //    {
-          //        UploadedFileImpl webFile = page.getParameterAsFile("fileupload");
-          //        if (webFile != null)
-          //        {
-          //           // Create the command
-          //   return new StoreAttachmentCommand(
-          //        context.getFileHome(),
-          //        id,
-          //        fileId,
-          //        webFile.getContentType(),
-          //        webFile.getContent(),
-          //        user,
-          //        makeProd);
-          //Die.exit(GENERAL_ERROR, webFile.getContentType());
-          }
-          }
-          attachBox = theme.TPL_THEME_POSTING_ATTACH_BODY.render(temp);
-          }
-          // end attachBox
-          */
-         //String topicReviewBox = "";
-         /*
-          if (isAuthRead && faction instanceof ReplyAction)
-          {
-          DelegateContext sub = topicReview(((ReplyAction)faction).getTopic());
-          // sub.next("switch_inline_mode");
-          //            topicReviewBox = theme.TPL_THEME_POSTING_TOPIC_REVIEW.render(sub);
-          }
-          */
-         // We don't handle PM for now
-         /*
-          root.next("switch_not_privmsg");
-          // Output the data to the template
-          root.put("FORUM_NAME", forum_name);
-          root.put("CATEGORY_NAME",
-          category.getTitle());
-          root.put("L_POST_A", ""); // not used, this is for the page title
-          root.put("U_VIEW_CATEGORY", "index.html?module=bb&op=main&c=" + category.getId().toString());
-          root.put("U_VIEW_FORUM", "index.html?module=bb&op=viewforum&f=" + forum_id);
-          root.put("USERNAME",
-          poster.getUserName());
-          root.put("L_EMOTICONS", ""); // todo
-          root.put("U_VIEWTOPIC",
-          (ctx.p_mode == PMODE_REPLY)
-          ? ("index.html?module=bb&op=viewtopic&t=" + topic_id + "&postorder=desc") : "");
-          root.put("U_REVIEW_TOPIC",
-          (ctx.p_mode == PMODE_REPLY) ? ("index.html?module=bb&op=posting&mode=topicreview&t=" + topic_id)
-          : "");
-          root.put("S_HTML_CHECKED", msg.getHTMLEnabled() ? "" : "checked=\"checked\"");
-          root.put("S_BBCODE_CHECKED", msg.getBBCodeEnabled() ? "" : "checked=\"checked\"");
-          root.put("S_SMILIES_CHECKED", msg.getSmiliesEnabled() ? "" : "checked=\"checked\"");
-          root.put("S_SIGNATURE_CHECKED", msg.getSignatureEnabled() ? "checked=\"checked\"" : "");
-          root.put("S_TOPIC_ID",
-          topic_id.toString());
-          //         root.put("JUMPBOX", makeJumpBox("viewforum", currentUser != null));
-          root.put("ERROR_BOX", errorBox);
-          root.put("POST_PREVIEW_BOX", previewBox);
-          //         root.put("POLLBOX", pollBox);
-          //         root.put("ATTACHBOX", attachBox);
-          root.put("TOPIC_REVIEW_BOX", topicReviewBox);
-          */
-         response.setRenderParameter("S_HIDDEN_FORM_FIELDS", hidden_form_fields
-            .toString());
-         response.setRenderParameter("op", OP_POSTING);
-         if (request.getParameters().getParameterExists("f"))
-         {
-            response.setRenderParameter("f", request.getParameter("f"));
-         }
-
-         if (request.getParameters().getParameterExists("p"))
-         {
-            response.setRenderParameter("p", request.getParameter("p"));
-         }
-         response.setRenderParameter("SUBJECT", msg.getSubject());
-
-         if (ctx.p_mode == PMODE_QUOTE)
-         {
-            Post post;
-            try
-            {
-               post = forumsModule.findPostById(new Integer(ctx.p_post_id));
-               msg.setText("[quote=" + post.getPoster().getUser().getUserName() + "]" + post.getMessage().getText() + "[/quote]");
-            }
-            catch (ModuleException e1)
-            {
-               // TODO Auto-generated catch block
-               e1.printStackTrace();
-            }
-         }
-         else if (ctx.p_mode == PMODE_EDIT_POST)
-         {
-            Post post;
-            try
-            {
-               post = forumsModule.findPostById(new Integer(ctx.p_post_id));
-               msg.setText(post.getMessage().getText());
-            }
-            catch (ModuleException e1)
-            {
-               // TODO Auto-generated catch block
-               e1.printStackTrace();
-            }
-         }
-         response.setRenderParameter("MESSAGE", msg.getText());
-      }
-   }
-
-   /**
-    * admin_forums operation
-    *
-    * @param req  JBoss Action Request
-    * @param resp JBoss Action Response
-    */
-   public void admin_forums(JBossActionRequest req, JBossActionResponse resp)
-   {
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-      //Use this to do debug
-      /*System.out.println("in admin_forums(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
-      for (Iterator i=req.getParameterMap().keySet().iterator(); i.hasNext();)
-      {
-         String key = (String)i.next();
-         System.out.println("param key: " + key + " param val: " + req.getParameter(key));
-      }*/
-      String mode = req.getParameters().get("mode", "");
-      boolean addCategory = req.getParameter("addcategory") != null;
-      Category addforum = null;
-
-      try
-      {
-         for (Iterator i = forumsModule.findCategories().iterator(); i
-            .hasNext();)
-         {
-            Category category = (Category)i.next();
-            if (req.getParameter("addforum_" + category.getId()) != null)
-            {
-               addforum = category;
-               break;
-            }
-         }
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-         addErrorMessage(resp, "admin", "Cannot process command");
-         return;
-      }
-
-      if ((addforum != null) || addCategory)
-      {
-         if (addforum != null)
-         {
-            mode = "addforum";
-         }
-         else
-         {
-            mode = "addcat";
-         }
-      }
-
-      if ("addforum".equals(mode) || "editforum".equals(mode))
-      {
-
-         /*PortletURL addOrEditForumURL = resp.createRenderURL();
-         addOrEditForumURL.setParameters(req.getParameterMap());
-         addOrEditForumURL.setParameter("mode", mode);
-         addOrEditForumURL.setParameter("op", OP_SHOWADDEDITFORUM);*/
-         resp.setRenderParameters(req.getParameterMap());
-         resp.setRenderParameter("mode", mode);
-         resp.setRenderParameter("op", OP_SHOWADDEDITFORUM);
-
-         if ("addforum".equals(mode))
-         {
-            //addOrEditForumURL.setParameter("c",  "" + addforum.getID());
-            resp.setRenderParameter("c", "" + addforum.getId());
-         }
-
-         /*try
-         {
-            resp.sendRedirect(addOrEditForumURL.toString());
-         }
-         catch (IOException e1)
-         {
-            // TODO Auto-generated catch block
-            e1.printStackTrace();
-         }*/
-      }
-      else if ("cat_order".equals(mode))
-      {
-         try
-         {
-            Category category = forumsModule.findCategoryById(req
-               .getParameters().getIntObject(POST_CAT_URL));
-            String[] test = new String[]{category.getTitle()};
-            if (ForumsTools.hasPermission(req, test, "AdminCategory"))
-            {
-               OrderCategoryCommand cmd = new OrderCategoryCommand(req, resp);
-               cmd.move = req.getParameters().getInt("move", 0);
-               cmd.category = category;
-               cmd.module = forumsModule;
-               Result result = forumsModule.invoke(cmd);
-               ResultType type = result.getType();
-               if (type == CommandConstants.TYPE_CATEGORIES_ORDERED)
-               {
-                  addSuccessMessage(resp, "catorder", "Forums_updated");
-                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CANNOT_ORDER_CATEGORIES)
-               {
-                  addErrorMessage(resp, "catorder",
-                     "Can't change category order");
-                  return;
-               }
-            }
-            else
-            {
-               addErrorMessage(resp, "catorder",
-                  "Not authorized to change the category order");
-               return;
-            }
-         }
-         catch (Exception e)
-         {
-            e.printStackTrace();
-            addErrorMessage(resp, "catorder", "Couldn't order categories");
-            return;
-         }
-      }
-      else if ("addcat".equals(mode))
-      {
-         if (ForumsTools.hasPermission(req, "Admin"))
-         {
-            CreateCategoryCommand cmd = new CreateCategoryCommand(req, resp);
-            cmd.name = req.getParameters().get("categoryname", "").trim();
-            cmd.module = forumsModule;
-            Result result;
-            try
-            {
-               result = forumsModule.invoke(cmd);
-               ResultType type = result.getType();
-               if (type == CommandConstants.TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME)
-               {
-                  addErrorMessage(resp, "addcat",
-                     "Can't create a category without a name");
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED)
-               {
-                  addErrorMessage(resp, "addcat",
-                     "Couldn't insert row in categories table");
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CATEGORY_CREATED)
-               {
-                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                  addSuccessMessage(resp, "addcat", "Forums_updated");
-               }
-            }
-            catch (CommandException e1)
-            {
-               e1.printStackTrace();
-            }
-         }
-         else
-         {
-            addErrorMessage(resp, "addcat", "Not authorized to add a category");
-            return;
-         }
-      }
-      else if ("createforum".equals(mode))
-      {
-         try
-         {
-            Category category = forumsModule.findCategoryById(req
-               .getParameters().getIntObject(POST_CAT_URL));
-            String[] test = new String[]{category.getTitle()};
-            if (ForumsTools.hasPermission(req, test, "AdminCategory"))
-            {
-               CreateForumCommand cmd = new CreateForumCommand(req, resp);
-               cmd.name = req.getParameters().get("forumname", "");
-               cmd.description = req.getParameters().get("forumdesc", "")
-                  .trim();
-               cmd.category = category;
-               cmd.module = forumsModule;
-
-               Result result = forumsModule.invoke(cmd);
-               ResultType type = result.getType();
-
-               if (type == CommandConstants.TYPE_FORUM_CREATED)
-               {
-                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                  addSuccessMessage(resp, "addforum", "Forums_updated");
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INVALID_NAME)
-               {
-                  addErrorMessage(resp, "addforum", "Forum_missing_name");
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY)
-               {
-                  addErrorMessage(resp, "addforum", "Forum_missing_category");
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED)
-               {
-                  addErrorMessage(resp, "addforum", "Forum_failed");
-                  return;
-               }
-            }
-            else
-            {
-               addErrorMessage(resp, "addforum", "Forum_not_authorized");
-               return;
-            }
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();
-
-            //               Die.exit(GENERAL_ERROR, "Couldn't get order number from forums table", e);
-         }
-
-         //               if( $HTTP_POST_VARS['prune_enable'] )
-         //               {
-         //                  if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "")
-         //                  {
-         //                     message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
-         //                  }
-         //                  $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
-         //                     VALUES('" . $next_id . "', " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
-         //                  if( !$result = $db->sql_query($sql) )
-         //                  {
-         //                     message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql);
-         //                  }
-         //               }
-         catch (CommandException e)
-         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-      }
-      else if ("forum_order".equals(mode))
-      {
-         try
-         {
-            Forum forum = forumsModule.findForumById(req.getParameters()
-               .getIntObject("f"));
-            String[] test = new String[]{forum.getCategory().getTitle()};
-            if (ForumsTools.hasPermission(req, test, "AdminCategory"))
-            {
-               OrderForumCommand cmd = new OrderForumCommand(req, resp);
-               cmd.module = forumsModule;
-               cmd.forum = forum;
-               cmd.move = req.getParameters().getIntObject("move", 0)
-                  .intValue();
-               Result result = forumsModule.invoke(cmd);
-               ResultType type = result.getType();
-               if (type == CommandConstants.TYPE_FORUMS_ORDERED)
-               {
-                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                  addSuccessMessage(resp, "ordersuccess", "Forums_updated");
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CANNOT_ORDER_FORUMS)
-               {
-                  addErrorMessage(resp, "orderfailed",
-                     "Couldn't change category order");
-                  return;
-               }
-            }
-            else
-            {
-               addErrorMessage(resp, "forum",
-                  "Not authorized to change order in this category");
-               return;
-            }
-         }
-         catch (Exception e)
-         {
-            addErrorMessage(resp, "orderfailed",
-               "Couldn't change category order");
-            return;
-         }
-      }
-      else if ("forum_sync".equals(mode))
-      {
-         //               sync('forum', intval($HTTP_GET_VARS[POST_FORUM_URL]));
-         //               $show_index = TRUE;
-      }
-      else if ("deletecat".equals(mode))
-      {
-         try
-         {
-            Integer catId = req.getParameters().getIntObject(POST_CAT_URL);
-            Category category = forumsModule.findCategoryById(catId);
-            String selectTo = "";
-            if (forumsModule.findCategories().size() == 1)
-            {
-               if (forumsModule.findForumsByCategoryId(catId).size() > 0)
-               {
-                  addErrorMessage(resp, "deletecat", "Must_delete_forums");
-                  return;
-               }
-               else
-               {
-                  selectTo = bundle.getString("Nowhere_to_move");
-               }
-            }
-            else
-            {
-               selectTo = "<select name=\"to_id\">"
-                  + ForumsTools.listCategories(forumsModule.findCategories(), catId.intValue())
-                  + "</select>";
-            }
-
-            resp.setRenderParameter("op", OP_SHOWDELETEFORUM);
-            resp.setRenderParameter("NAME", category.getTitle());
-            resp.setRenderParameter("S_SELECT_TO", selectTo);
-            resp
-               .setRenderParameter("S_HIDDEN_FIELDS",
-                  "<input type=\"hidden\" name=\"mode\" value=\"movedelcat\"/>"
-                     + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
-                     + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>"
-                     + "<input type=\"hidden\" name=\"from_id\" value=\""
-                     + catId + "\"/>");
-
-            /*
-             DelegateContext root = new DelegateContext();
-             root.put("NAME", category.getTitle());
-             root.put("S_SELECT_TO", selectTo);
-             root.put("S_HIDDEN_FIELDS", "<input type=\"hidden\" name=\"mode\" value=\"movedelcat\"/>" +
-             "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
-             "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>" +
-             "<input type=\"hidden\" name=\"from_id\" value=\"" + catId + "\"/>");
-             display(theme.TPL_THEME_ADMIN_FORUM_DELETE_BODY, root, page);
-             */
-         }
-         catch (ModuleException e)
-         {
-            addErrorMessage(resp, "deletefailed", "Couldn't get Forum info");
-            return;
-         }
-      }
-      else if ("movedelcat".equals(mode))
-      {
-         try
-         {
-            Category fromCategory = forumsModule.findCategoryById(req
-               .getParameters().getIntObject("from_id"));
-            Category toCategory = forumsModule.findCategoryById(req
-               .getParameters().getIntObject("to_id"));
-            if (req.getParameters().getIntObject("from_id").equals(req.getParameters().getIntObject("to_id")))
-            {
-               addErrorMessage(resp, "deletecat", "cant_move_to_same_category");
-               return;
-            }
-            String[] test1 = new String[]{fromCategory.getTitle()};
-            String[] test2 = new String[]{toCategory.getTitle()};
-            if ((ForumsTools.hasPermission(req, test1, "DeleteForumInCategory"))
-               && (ForumsTools.hasPermission(req, test2, "AddForumInCategory")))
-            {
-               DeleteMoveCategoryCommand cmd = new DeleteMoveCategoryCommand(req, resp);
-               cmd.source = fromCategory;
-               cmd.target = toCategory; //null
-               cmd.module = forumsModule;
-               Result result = forumsModule.invoke(cmd);
-               ResultType type = result.getType();
-               if (type == CommandConstants.TYPE_CANNOT_REMOVE_CATEGORY)
-               {
-                  addErrorMessage(resp, "deletecategory",
-                     "Couldn't delete category");
-                  return;
-               }
-               else if (type == CommandConstants.TYPE_CATEGORY_REMOVED)
-               {
-                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                  addSuccessMessage(resp, "deletecategory", "Forums_updated");
-                  return;
-               }
-            }
-            else
-            {
-               addErrorMessage(resp, "deletecategory",
-                  "You can't delete and move this category");
-               return;
-            }
-         }
-         catch (Exception e)
-         {
-            addErrorMessage(resp, "deletefailed", "Couldn't delete category");
-            e.printStackTrace();
-            return;
-         }
-      }
-      else if ("deleteforum".equals(mode))
-      {
-         try
-         {
-            Integer forumId = req.getParameters().getIntObject("f");
-            Forum forum = forumsModule.findForumById(forumId);
-            resp.setRenderParameter("op", OP_SHOWDELETEFORUM);
-            resp.setRenderParameter("NAME", forum.getName());
-            resp
-               .setRenderParameter("S_HIDDEN_FIELDS",
-                  "<input type=\"hidden\" name=\"mode\" value=\"movedelforum\"/>"
-                     + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
-                     + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>"
-                     + "<input type=\"hidden\" name=\"from_id\" value=\""
-                     + forum.getId() + "\"/>");
-            resp.setRenderParameter("S_SELECT_TO",
-               "<select name=\"to_id\"><option value=\"-1\">"
-                  + bundle.getString("Delete_all_posts")
-                  + "</option>\n" // $s
-                  + ForumsTools.listForums(forumsModule.findForums(),
-                  forumId.intValue()) + "</select>");
-
-            //            display(theme.TPL_THEME_ADMIN_FORUM_DELETE_BODY, root, page);
-         }
-         catch (ModuleException e)
-         {
-            addErrorMessage(resp, "deletefailed",
-               "Could not obtain forum information");
-            e.printStackTrace();
-            return;
-         }
-      }
-      else if ("movedelforum".equals(mode))
-      {
-         // int deleteOld = page.getParameterAsInt("delete_old", -1);
-         try
-         {
-            Integer fromId = req.getParameters().getIntObject("from_id", -1);
-            Forum fromForum = forumsModule.findForumById(fromId);
-            Integer toId = req.getParameters().getIntObject("to_id", -1);
-            if ((toId.intValue() < 0) && (fromId.intValue() >= 0))
-            {
-               String[] test = new String[]{
-                  fromForum.getCategory().getTitle(), fromForum.getName()};
-               if (ForumsTools.hasPermission(req, test, "DeletePostInForum"))
-               {
-                  //resp.setRenderParameter("op","" + OP_SHOWFORUM);
-                  DeleteForumCommand cmd = new DeleteForumCommand(req, resp);
-                  cmd.forum = fromForum;
-                  cmd.module = forumsModule;
-                  Result result = forumsModule.invoke(cmd);
-                  ResultType type = result.getType();
-                  if (type == CommandConstants.TYPE_FORUM_REMOVED)
-                  {
-                     resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                     addSuccessMessage(resp, "delete", "Forums_updated");
-                     return;
-                  }
-                  else if (type == CommandConstants.TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED)
-                  {
-                     addErrorMessage(resp, "delete", "Could not delete forum");
-                  }
-               }
-            }
-            else if (!fromId.equals(toId) && (fromId.intValue() >= 0)
-               && (toId.intValue() >= 0))
-            {
-               Forum toForum = forumsModule.findForumById(toId);
-               String[] test1 = new String[]{
-                  fromForum.getCategory().getTitle(), fromForum.getName()};
-               String[] test2 = new String[]{
-                  toForum.getCategory().getTitle(), toForum.getName()};
-               if ((ForumsTools.hasPermission(req, test1, "DeletePostInForum"))
-                  && (ForumsTools.hasPermission(req, test2, "AddPostInForum")))
-               {
-                  DeleteMoveForumCommand cmd = new DeleteMoveForumCommand(req, resp);
-                  cmd.source = fromForum;
-                  cmd.target = toForum;
-                  cmd.module = forumsModule;
-                  Result result = forumsModule.invoke(cmd);
-                  ResultType type = result.getType();
-                  if (type == CommandConstants.TYPE_FORUM_MOVED_AND_REMOVED)
-                  {
-                     resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                     addSuccessMessage(resp, "delete", "Forums_updated");
-                     return;
-                  }
-                  else if (type == CommandConstants.TYPE_CANNOT_MOVE_AND_REMOVE_FORUM)
-                  {
-                     addErrorMessage(resp, "delete", "Could not delete forum");
-                     return;
-                  }
-
-                  /*
-                   cmd.sourceId = fromId;
-                   cmd.targetId = toId;
-                   cmd.topicDataSource = topicDataSource;
-                   cmd.topicTableName = topicTableName;
-                   cmd.topicForumFKColumnName = topicForumRelationColumnName;
-                   cmd.postDataSource = postDataSource;
-                   cmd.postTableName = postTableName;
-                   cmd.postForumFKColumnName = postForumRelationColumnName;
-                   cmd.forumHome = homesRW.forum;
-                   cmd.postHome = homesRW.post;
-                   cmd.topicHome = homesRW.topic;
-                   Result result = forumsModule.invoke(req, resp, cmd);
-                   */
-               }
-            }
-            else
-            {
-               addErrorMessage(resp, "delete", "Sorry but forums weren't updated... Check options you choose and try again");
-            }
-         }
-         catch (Exception e)
-         {
-            addErrorMessage(resp, "delete", "Could not delete forum");
-            e.printStackTrace();
-            return;
-         }
-      }
-      else if ("editcat".equals(mode))
-      {
-         try
-         {
-            Integer catId = req.getParameters().getIntObject(POST_CAT_URL);
-            Category category = forumsModule.findCategoryById(catId);
-            String hiddenFields = "<input type=\"hidden\" name=\"mode\" value=\"modcat\"/>"
-               + "<input type=\"hidden\" name=\""
-               + POST_CAT_URL
-               + "\" value=\""
-               + category.getId()
-               + "\"/>"
-               + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
-               + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>";
-            resp.setRenderParameter("op", OP_SHOWEDITCATEGORY);
-            resp.setRenderParameter("c", "" + category.getId());
-            resp.setRenderParameter("CAT_TITLE", category.getTitle());
-            resp.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields);
-
-            //               display(theme.TPL_THEME_ADMIN_CATEGORY_EDIT_BODY, root, page);
-         }
-         catch (ModuleException e)
-         {
-            addErrorMessage(resp, "deletefailed", "Cannot edit category");
-            e.printStackTrace();
-            return;
-         }
-      }
-      else if ("modcat".equals(mode))
-      {
-         try
-         {
-            Category category = forumsModule.findCategoryById(req
-               .getParameters().getIntObject(POST_CAT_URL));
-            String[] test = new String[]{category.getTitle()};
-            if (ForumsTools.hasPermission(req, test, "EditCategory"))
-            {
-               UpdateCategoryCommand cmd = new UpdateCategoryCommand(req, resp);
-               cmd.title = req.getParameters().get("cat_title", "").trim();
-               cmd.category = category;
-               Result result = forumsModule.invoke(cmd);
-               ResultType type = result.getType();
-               if (type == CommandConstants.TYPE_CATEGORY_UPDATED)
-               {
-                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                  addSuccessMessage(resp, "update", "Forums_updated");
-                  return;
-               }
-            }
-         }
-         catch (Exception e)
-         {
-            addErrorMessage(resp, "update", "Cannot update category");
-            e.printStackTrace();
-            return;
-         }
-      }
-      else if ("modforum".equals(mode))
-      {
-         //                  if( isset($HTTP_POST_VARS['prune_enable']))
-         //                  {
-         //                     if( $HTTP_POST_VARS['prune_enable'] != 1 )
-         //                     {
-         //                        $HTTP_POST_VARS['prune_enable'] = 0;
-         //                     }
-         //                  }
-         try
-         {
-            Category category = forumsModule.findCategoryById(req
-               .getParameters().getIntObject(POST_CAT_URL));
-            Forum forum = forumsModule.findForumById(req.getParameters()
-               .getIntObject("f"));
-            String[] test1 = new String[]{category.getTitle(),};
-            String[] test2 = new String[]{forum.getCategory().getTitle(),};
-            if ((ForumsTools.hasPermission(req, test1, "AddForumInCategory"))
-               && (ForumsTools.hasPermission(req, test2, "EditForumInCategory")))
-            {
-               UpdateForumCommand cmd = new UpdateForumCommand(req, resp);
-               cmd.name = req.getParameters().get("forumname", "");
-               cmd.description = req.getParameters().get("forumdesc", "");
-               cmd.category = category;
-               cmd.forum = forum;
-               Result result = forumsModule.invoke(cmd);
-               ResultType type = result.getType();
-               if (type == CommandConstants.TYPE_FORUM_UPDATED)
-               {
-                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
-                  addSuccessMessage(resp, "edit", "Forums_updated");
-                  return;
-               }
-            }
-            addErrorMessage(resp, "edit", "Cannot update forums");
-
-            // forum_status = intval($HTTP_POST_VARS['forumstatus'])
-            // prune_enable = intval($HTTP_POST_VARS['prune_enable']
-         }
-         catch (Exception e)
-         {
-            addErrorMessage(resp, "edit", "Couldn't update forum information");
-            e.printStackTrace();
-            return;
-         }
-
-         //                  if( $HTTP_POST_VARS['prune_enable'] == 1 )
-         //                  {
-         //                     if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "" )
-         //                     {
-         //                        message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
-         //                     }
-         //                     $sql = "SELECT *
-         //                        FROM " . PRUNE_TABLE . "
-         //                        WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
-         //                     if( !$result = $db->sql_query($sql) )
-         //                     {
-         //                        message_die(GENERAL_ERROR, "Couldn't get forum Prune Information","",__LINE__, __FILE__, $sql);
-         //                     }
-         //                     if( $db->sql_numrows($result) > 0 )
-         //                     {
-         //                        $sql = "UPDATE " . PRUNE_TABLE . "
-         //                           SET   prune_days = " . intval($HTTP_POST_VARS['prune_days']) . ",   prune_freq = " . intval($HTTP_POST_VARS['prune_freq']) . "
-         //                            WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
-         //                     }
-         //                     else
-         //                     {
-         //                        $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
-         //                           VALUES(" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
-         //                     }
-         //                     if( !$result = $db->sql_query($sql) )
-         //                     {
-         //                        message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql);
-         //                     }
-         //                  }
-         //            Die.exit(GENERAL_MESSAGE, "${bb.Forums_updated}<br/><br/>${bb.Click_return_forumadmin_0}<a href=\"" +
-         //                  "index.html?module=bb&op=admin_forums\">${bb.Click_return_forumadmin_1}</a>" +
-         //                  "${bb.Click_return_forumadmin_2}<br/><br/>${bb.Click_return_admin_index_0}" +
-         //                  "<a href=\"index.html?module=bb&pane=right\">${bb.Click_return_admin_index_1}</a>" +
-         //                  "${bb.Click_return_admin_index_2}");
-      }
-   }
-
-   private DelegateContext fillShowIndexContext(JBossRenderRequest req,
-                                                JBossRenderResponse resp, DelegateContext root)
-   {
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-
-      Integer c = req.getParameters().getIntObject("c", -1);
-      try
-      {
-         if (c.intValue() != -1)
-         {
-            Category category = forumsModule.findCategoryById(c);
-            fillShowCategoryContext(req, resp, root, category);
-         }
-         else
-         {
-            // Fill context with categories
-            Iterator iterator = forumsModule.findCategories().iterator();
-            while (iterator.hasNext())
-            {
-               Category currentCategory = (Category)iterator.next();
-
-               fillShowCategoryContext(req, resp, root, currentCategory);
-            }
-         }
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-      return root;
-   }
-
-   private DelegateContext fillShowCategoryContext(JBossRenderRequest req,
-                                                   JBossRenderResponse resp, DelegateContext root, Category category)
-   {
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-      try
-      {
-         String[] testArray = new String[]{category.getTitle()};
-
-         boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadCategory");
-
-         if (authRead)
-         {
-            DelegateContext catrow = root.next("catrow");
-            catrow.put("CAT_DESC", category.getTitle());
-            PortletURL viewCatURL = resp.createRenderURL();
-            viewCatURL.setParameter("op", OP_MAIN);
-            viewCatURL.setParameter("c", "" + category.getId());
-            catrow.put("U_VIEWCAT", viewCatURL.toString());
-
-            // Fill context with forums
-            Iterator forumsIterator = forumsModule.findForumsByCategoryId(category.getId()).iterator();
-            while (forumsIterator.hasNext())
-            {
-               Forum currentForum = (Forum)forumsIterator.next();
-               Integer currentCategoryId = category.getId();
-               String currentCategoryTitle = category.getTitle();
-               String currentForumName = currentForum.getName();
-               testArray = new String[]{currentCategoryTitle,
-                  currentForumName};
-
-               authRead = ForumsTools.hasPermission(req, testArray, "ReadForum");
-               boolean authView = authRead;
-
-               // We display the forum only if needed
-               if (authView)
-               {
-                  // Get forum data
-                  int currentForumStatus = currentForum.getStatus();
-                  Integer currentForumId = currentForum.getId();
-                  Post lastPost = currentForum.getLastPost();
-                  String currentForumDescription = currentForum
-                     .getDescription();
-                  int currentForumPostSize = currentForum.getPostCount();
-                  int currentForumTopicSize = currentForum.getTopicCount();
-                  String folderImage = theme.resourceForumURL;
-                  String folderAlt = bundle.getString("No_new_posts");
-                  if (currentForumStatus == FORUM_LOCKED)
-                  {
-                     folderImage = theme.resourceForumLockedURL;
-                     folderAlt = bundle.getString("Forum_locked");
-                  }
-
-                  /*
-                   else
-                   {
-                   Date when1 = (Date)dates.get(currentForumId);
-                   Date when2 = (Date)trackingForums.get(currentForumId);
-                   if ((Time.compare(when1, when2) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0)
-                   {
-                   folderImage = theme.resourceForumNewBigURL;
-                   folderAlt = "${bb.New_posts}";
-                   }
-                   }
-                   */
-
-                  // Get the last post text
-                  String lastPostText = bundle.getString("No_Posts");
-                  if (lastPost != null)
-                  {
-                     Integer lastPostId = lastPost.getId();
-                     StringBuffer temp = new StringBuffer();
-                     Date lastPostDate = lastPost.getCreateDate();
-
-                     // temp.append(dateFormatPool.formatDate(lastPostDate)).append("<br/>");
-                     // temp.append(lastPost.getPoster().getAuthor(true));
-                     SimpleDateFormat sdf = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
-                     //temp.append(lastPostDate).append("<br/>");
-                     temp.append(sdf.format(lastPostDate)).append("<br/>");
-                     if ((req.getRemoteUser() != null))
-                     {
-                        PortletURL userProfileURL = resp.createRenderURL();
-                        userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
-                        userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
-                        temp.append("<a href=\"" + userProfileURL.toString() + "\">" + lastPost.getPoster().getUser().getUserName() + "</a>");
-                     }
-                     else
-                     {
-                        temp.append(lastPost.getPoster().getUser().getUserName());
-                     }
-                     PortletURL postURL = resp.createRenderURL();
-                     postURL.setParameter("op", OP_SHOWTOPIC);
-                     postURL.setParameter("p", "" + lastPostId);
-                     temp.append("<a href=\"").append(postURL.toString())
-                        .append("\"><img src=\"").append(theme.resourceIconLatestReplyURL).append("\" border=\"0\" alt=\""
-                        + bundle.getString("View_latest_post")
-                        + "\" title=\""
-                        + bundle.getString("View_latest_post")
-                        + "\"/></a>");
-                     lastPostText = temp.toString();
-                  }
-
-                  // Fetch the moderator list
-                  String moderatorList = "&nbsp";
-                  String moderatorsMessage = "&nbsp;";
-
-                  /*
-                   Set moderators = moderators(currentCategoryTitle, currentForumName);
-                   if (moderators.size() > 0)
-                   {
-                   StringBuffer temp = new StringBuffer();
-                   for (Iterator j = moderators.iterator();j.hasNext();temp.append(j.hasNext() ? "," : ""))
-                   {
-                   temp.append(j.next());
-                   }
-                   moderatorList = temp.toString();
-                   moderatorsMessage = moderators.size() == 1 ? "${bb.Moderator}" : "${bb.Moderators}";
-                   }
-                   */
-
-                  // Build the template
-                  DelegateContext forumrow = catrow.next("forumrow");
-
-                  /*                     forumrow.put("ROW_COLOR", theme.getProperty(i.getIndex() % 2 == 0 ? "td_color1" : "td_color2"));
-                   forumrow.put("ROW_CLASS", theme.getProperty(i.getIndex() % 2 == 0 ? "td_class1" : "td_class2"));
-                   */
-                  forumrow.put("FORUM_FOLDER_IMG", folderImage);
-                  forumrow.put("FORUM_NAME", currentForumName);
-                  forumrow.put("FORUM_DESC", currentForumDescription);
-                  forumrow.put("POSTS", "" + currentForumPostSize);
-                  forumrow.put("TOPICS", "" + currentForumTopicSize);
-                  forumrow.put("LAST_POST", lastPostText);
-                  forumrow.put("MODERATORS", moderatorList);
-                  forumrow.put("L_MODERATOR", moderatorsMessage);
-                  forumrow.put("L_FORUM_FOLDER_ALT", folderAlt);
-                  PortletURL viewForumURL = resp.createRenderURL();
-                  viewForumURL.setParameter("op", OP_SHOWFORUM);
-                  viewForumURL.setParameter("f", currentForumId.toString());
-                  forumrow.put("U_VIEWFORUM", viewForumURL.toString());
-               }
-            }
-         }
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-
-      return root;
-   }
-
-   private DelegateContext fillShowForumContext(JBossRenderRequest req,
-                                                JBossRenderResponse resp, DelegateContext root)
-   {
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-
-      //      JBossPortletPreferences prefs =
-      //         new JBossPortletPreferences(null,
-      //                                     req.getUser().getPreferenceStore().get(new FQN("org.jboss.portlet.forums")),
-      //                                     null, PortletPreferencesImpl.RENDER, proxyInfo);
-      //      PreferencesProxy        proxy = (PreferencesProxy) prefs.getProxy();
-
-      /*int topicsPerPage = 10;*/
-      int topicsPerPage = Integer.parseInt(req.getPreferences().getValue("topicsperforum", "10"));
-      int hotThreshold = 10;
-      /*int postsPerPage = 10;*/
-      int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
-
-
-      Integer forumId = req.getParameters().getIntObject("f", -1);
-      int start = req.getParameters().getInt("start", 0);
-
-      //      String markRead = page.getParameter("mark", "");
-      int topicDays = req.getParameters().getInt("topicdays", 0);
-
-      Forum forum = null;
-      try
-      {
-         forum = forumsModule.findForumById(forumId);
-      }
-      catch (ModuleException e1)
-      {
-         // TODO Auto-generated catch block
-         e1.printStackTrace();
-      }
-
-      Category category = forum.getCategory();
-      User user = req.getUser();
-      //boolean loggedIn = isUserLoggedIn(user);
-      boolean loggedIn = req.getRemoteUser() != null;
-      Date lastVisit = loggedIn ? user.getLastVisitDate() : null;
-      String categoryTitle = category.getTitle();
-      String forumName = forum.getName();
-
-      //      Level level = secGetLevel(categoryTitle + ":" + forumName + ":");
-      //      Auth auth = forum.getAuth();
-      //TODO: add security here
-      String[] testArray = new String[]{categoryTitle, forumName};
-      boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadForum"); //auth.can(Auth.TYPE_READ, loggedIn, level);
-      boolean authView = ForumsTools.hasPermission(req, testArray, "ReadForum"); //auth.can(Auth.TYPE_VIEW, loggedIn, level);
-      boolean authPost = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
-      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum"); //Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
-
-      if (authPost)
-      {
-         root.next("AUTH_POST");
-      }
-
-      if (!authRead || !authView)
-      {
-         System.out.println("You are not authorized to see this forum");
-         return root;
-
-         /*
-          if (!loggedIn)
-          {
-          //  $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
-          //  redirect(append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
-          //            page.sendRedirect("index.html?module=user&op=getlogin");
-          //            return root;
-          }
-          Die.exit(GENERAL_MESSAGE, !authView ? "${bb.Forum_not_exist}" : "sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type'])");
-          */
-      }
-
-      /*
-       if ("topics".equals(markRead) && loggedIn)
-       {
-       PostEJBLocal lastPost = forum.getLastPost();
-       if (lastPost != null)
-       {
-       if (lastPost.getPostDate().after(lastVisit))
-       {
-       getTrackingForums(page).put(forumId, new Date());
-       }
-       }
-       Die.exit(GENERAL_MESSAGE, "${bb.Topics_marked_read}<br/><br/>" +
-       "${bb.Click_return_forum_0}<a href=\"index.html?module=bb&op=viewforum&f=" +
-       forumId + "\">${bb.Click_return_forum_1}</a>" +
-       "${bb.Click_return_forum_2}");
-       }
-       if (authMod && pruneEnable)
-       {
-       //   if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
-       //   {
-       //      include($phpbb_root_path . 'includes/prune.'.$phpEx);
-       //      require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
-       //      auto_prune($forum_id);
-       //   }
-       }
-       // todo put that in statistics
-       Set moderators = moderators(categoryTitle, forumName);
-       String moderatorMessage = "${bb.Moderators}";
-       String moderatorList = "${bb.None}";
-       if (moderators.size() > 0)
-       {
-       StringBuffer temp = new StringBuffer();
-       if (moderators.size() == 1)
-       {
-       moderatorMessage = "${bb.Moderator}";
-       }
-       for (Iterator iterator = moderators.iterator();iterator.hasNext();)
-       {
-       temp.append((String)iterator.next());
-       if (iterator.hasNext())
-       {
-       temp.append(", ");
-       }
-       }
-       moderatorList = temp.toString();
-       }
-       //      int topicCount = 0;
-       */
-      Date minTopicTime = null;
-      if (topicDays > 0)
-      {
-         Calendar c = Calendar.getInstance();
-         c.add(Calendar.DATE, -topicDays);
-         minTopicTime = c.getTime();
-
-         //         Collection temp = null;
-         //         try
-         //         {
-         //            temp = homes.topic.selectGeneric("SELECT t.id FROM topic AS t WHERE t.forum=?1 AND t.lastPost.postDate>=?2",
-         //                                             new Object[]{forum, minTopicTime});
-         //         }
-         //         catch(FinderException e)
-         //         {
-         //            Die.exit(GENERAL_ERROR, "Could not obtain limited topics count information");
-         //         }
-         //         topicCount = temp.size();
-      }
-      else
-      {
-         //         topicCount = forum.getTopicSize();
-         topicDays = 0;
-      }
-
-      List announcements = null;
-      List topics = null;
-
-      try
-      {
-         announcements = forumsModule.findAnnouncements(forum);
-         topics = (minTopicTime == null) ? forumsModule.findTopicsDesc(forum,
-            POST_ANNOUNCE, start, topicsPerPage) : forumsModule
-            .findTopicsBefore(forum, POST_ANNOUNCE, start, topicsPerPage,
-               minTopicTime);
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-
-      int totalAnnoucements = announcements.size();
-      int totalTopicsAndStickies = forum.getTopicCount();
-      int totalTopics = totalTopicsAndStickies; // + totalAnnoucements;
-
-      StringBuffer authCan = new StringBuffer();
-      //Prapare permission info
-      //authCan.append(authMod ? bundle.getString("Rules_moderate_0") : bundle.getString("Rules_moderate_0"));
-
-      //authCan = new StringBuffer();
-
-      //generate "You can..." forum permissions description
-      ForumsTools.authCan(authCan, req, testArray, bundle);
-      //Moderator permission is described separately
-      PortletURL moderateURL = resp.createRenderURL();
-      moderateURL.setParameter(getOperationName(), OP_SHOWMODERATEFORUM);
-      moderateURL.setParameter("f", "" + forumId);
-      if (authMod)
-      {
-         authCan.append(bundle.getString("Rules_moderate_0")).
-            append("<a href=\"" + moderateURL.toString() + "\">").
-            append(bundle.getString("Rules_moderate_2")).
-            append("</a><br/>");
-      }
-      else
-      {
-         authCan.append(bundle.getString("Rules_moderate_1")).
-            append(bundle.getString("Rules_moderate_2")).
-            append("<b/>");
-      }
-
-      Iterator ci = new CompoundIterator(new Iterator[]{
-         announcements.iterator(), topics.iterator()});
-
-      /*
-       if (!ci.hasNext())
-       {
-       }
-       */
-
-      //      if
-      //	No topics
-      //	$no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
-      //	$template->assign_vars(array(
-      //	'L_NO_TOPICS' => $no_topics_msg)
-      /*
-       Map trackingForums = getTrackingForums(page);
-       Map trackingTopics = getTrackingTopics(page);
-       Date trackingAllForums = (Date)page.getSession().getAttribute(cookieName + "_f_all");
-       */
-      PortletURL gotoURL = resp.createRenderURL();
-      gotoURL.setParameter("op", OP_SHOWTOPIC);
-      Goto toPost = new Goto(postsPerPage, bundle.getString("Goto_page"), gotoURL.toString());
-      toPost.setImgUrl(theme.resourceIconGotopostURL);
-
-      for (IndexIterator iterator = IndexIterator.wrap(ci, -1); iterator
-         .hasNext();)
-      {
-         Topic topic = (Topic)iterator.next();
-
-         int replies = topic.getReplies();
-         int status = topic.getStatus();
-         /*Integer topicId = (status == TOPIC_MOVED) ? topic.getTarget().getID()
-                 : topic.getID();*/
-         Integer topicId = topic.getId();
-         String type = bundle.getString("Topic_Moved");
-         String folderImage = theme.resourceFolderURL;
-         String folderAlt = bundle.getString("Topic_Moved");
-         String newestPostImg = "";
-         Date topicLastPostDate = (topic.getLastPost() != null) ? topic.getLastPost().getCreateDate() : null;
-         Post firstPost = topic.getFirstPost();
-         Post lastPost = topic.getLastPost();
-         Poster lastPostUser = lastPost.getPoster();
-         Poster poster = topic.getPoster();
-
-         if (status != TOPIC_MOVED)
-         {
-            FolderType folderType = theme.getFolderType(topic.getType(),
-               status, replies >= hotThreshold);
-            boolean newest = loggedIn; /* &&
-                     ((Time.compare(topicLastPostDate, lastVisit) & Time.LEFT_AFTER) != 0) &&
-                     ((Time.compare(topicLastPostDate, trackingAllForums) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0) &&
-                     ((Time.compare(topicLastPostDate, (Date)trackingTopics.get(topicId)) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0) &&
-                     ((Time.compare(topicLastPostDate, (Date)trackingForums.get(forumId)) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0);
-                     */
-
-            if (newest)
-            {
-               folderImage = folderType.folderNew;
-               folderAlt = (status == TOPIC_LOCKED) ? bundle
-                  .getString("Topic_locked") : bundle.getString("New_posts");
-               newestPostImg = "<a href=\"index.html?module=bb&op=viewtopic&t="
-                  + topicId + "&view=newest\"><img src=\""
-                  + theme.resourceIconNewestReplyURL + "\" alt=\""
-                  + bundle.getString("View_newest_post") + "\" title=\""
-                  + bundle.getString("View_newest_post")
-                  + "\" border=\"0\"/></a>";
-            }
-            else
-            {
-               folderImage = folderType.folder;
-               folderAlt = (status == TOPIC_LOCKED) ? bundle
-                  .getString("Topic_locked") : bundle
-                  .getString("No_new_posts");
-               newestPostImg = "";
-            }
-
-            try
-            {
-               type = bundle.getString(folderType.type);
-            }
-            catch (java.util.MissingResourceException e)
-            {
-               type = "";
-            }
-
-            /*
-             if (topic.getVote())
-             {
-             type += "${bb.Topic_Poll} ";
-             }
-             */
-         }
-
-         toPost.setPostSize(replies);
-         toPost.setTopicId(topicId.intValue());
-         String gotoPage = toPost.generate();
-         String rowColor = theme
-            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_color1"
-               : "td_color2");
-         String rowClass = theme
-            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_class1"
-               : "td_class2");
-         String topicAuthor = firstPost.getPoster().getUser().getUserName();
-         String lastPostAuthor = lastPost.getPoster().getUser().getUserName();
-
-         PortletURL lastPostURL = resp.createRenderURL();
-         lastPostURL.setParameter("op", OP_SHOWTOPIC);
-         lastPostURL.setParameter("p", "" + lastPost.getId());
-
-         String lastPostUrl = "<a href=\"" + lastPostURL.toString() + "\">"
-            + "<img src=\"" + theme.resourceIconLatestReplyURL + "\" alt=\""
-            + bundle.getString("View_latest_post") + "\" title=\""
-            + bundle.getString("View_latest_post") + "\" border=\"0\"/></a>";
-
-         DelegateContext topicrow = root.next("topicrow");
-         topicrow.put("ROW_COLOR", rowColor);
-         topicrow.put("ROW_CLASS", rowClass);
-         topicrow.put("FORUM_ID", forumId.toString());
-         topicrow.put("TOPIC_ID", topicId.toString());
-         topicrow.put("TOPIC_FOLDER_IMG", folderImage);
-         topicrow.put("TOPIC_AUTHOR", topicAuthor);
-         topicrow.put("GOTO_PAGE", gotoPage);
-         topicrow.put("REPLIES", "" + replies);
-         //topicrow.put("NEWEST_POST_IMG", newestPostImg);
-         topicrow.put("NEWEST_POST_IMG", lastPostUrl);
-         topicrow.put("TOPIC_TITLE", formatTitle(req, topic.getSubject()));
-         topicrow.put("TOPIC_TYPE", type);
-         topicrow.put("VIEWS", "" + topic.getViewCount());
-
-         //         topicrow.put("FIRST_POST_TIME", dateFormatPool.formatDate(topic.getCreationDate()));
-         /*topicrow.put("LAST_POST_TIME", topic.getLastPostDate().toString());*/
-         SimpleDateFormat sdfp = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
-         topicrow.put("LAST_POST_TIME", sdfp.format(topic.getLastPostDate()));
-         if ((req.getRemoteUser() != null))
-         {
-            PortletURL userProfileURL = resp.createRenderURL();
-            userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
-            userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
-            topicrow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
-         }
-         topicrow.put("LAST_POST_AUTHOR", lastPostAuthor);
-         topicrow.put("LAST_POST_IMG", lastPostUrl);
-         topicrow.put("L_TOPIC_FOLDER_ALT", folderAlt);
-         PortletURL viewTopicURL = resp.createRenderURL();
-         viewTopicURL.setParameter("op", OP_SHOWTOPIC);
-         viewTopicURL.setParameter("t", "" + topicId);
-         topicrow.put("U_VIEW_TOPIC", viewTopicURL.toString());
-      }
-
-      PortletURL pageNavigationURL = resp.createRenderURL();
-      pageNavigationURL.setParameter("op", OP_SHOWFORUM);
-      pageNavigationURL.setParameter("f", "" + forumId);
-      pageNavigationURL.setParameter("topicDays", "" + topicDays);
-
-      GotoWithOffset toTopic = new GotoWithOffset(totalTopicsAndStickies,
-         start, topicsPerPage, pageNavigationURL + "&start=", bundle
-         .getString("Goto_page"), bundle.getString("Previous"), bundle
-         .getString("Next"));
-
-      String pageNumber = bundle.getString("Page_of_0")
-         + ((int)Math.floor((double)start / topicsPerPage) + 1)
-         + bundle.getString("Page_of_1")
-         + ((int)Math.ceil((double)totalTopicsAndStickies / topicsPerPage));
-
-      PortletURL postNewURL = resp.createRenderURL();
-      postNewURL.setParameter("op", OP_POSTING);
-      postNewURL.setParameter("f", "" + forumId);
-      postNewURL.setParameter("mode", "newtopic");
-      root.put("U_POST_NEW_TOPIC", postNewURL.toString());
-
-      //      root.put("S_SELECT_TOPIC_DAYS", BBTools.selectDays("topicdays", topicDays));
-      root.put("S_POST_DAYS_ACTION", "index.html?module=bb&op=viewforum&f="
-         + forumId + "&start=" + start);
-      root.put("FORUM_ID", forum.getId().toString());
-      root.put("FORUM_NAME", forum.getName());
-      root.put("CATEGORY_NAME", categoryTitle);
-
-      //      root.put("MODERATORS", moderatorList);
-      root.put("POST_IMG",
-         (forum.getStatus() == FORUM_LOCKED) ? theme.resourcePostLockedURL
-            : theme.resourcePostNewURL);
-      root.put("FOLDER_IMG", theme.resourceFolderURL);
-      root.put("FOLDER_NEW_IMG", theme.resourceFolderNewURL);
-      root.put("FOLDER_HOT_IMG", theme.resourceFolderHotURL);
-      root.put("FOLDER_HOT_NEW_IMG", theme.resourceFolderHotNewURL);
-      root.put("FOLDER_LOCKED_IMG", theme.resourceFolderLockedURL);
-      root.put("FOLDER_LOCKED_NEW_IMG", theme.resourceFolderLockedNewURL);
-      root.put("FOLDER_STICKY_IMG", theme.resourceFolderStickyURL);
-      root.put("FOLDER_STICKY_NEW_IMG", theme.resourceFolderStickyNewURL);
-      root.put("FOLDER_ANNOUNCE_IMG", theme.resourceFolderAnnounceURL);
-      root.put("FOLDER_ANNOUNCE_NEW_IMG", theme.resourceFolderAnnounceNewURL);
-
-      //      root.put("L_MODERATOR", moderatorMessage);
-      root.put("L_POST_NEW_TOPIC", (forum.getStatus() == FORUM_LOCKED) ? bundle
-         .getString("Forum_locked") : bundle.getString("Post_new_topic"));
-
-      root.put("S_AUTH_LIST", authCan.toString());
-      PortletURL viewMainPageURL = resp.createRenderURL();
-      viewMainPageURL.setParameter("op", OP_MAIN);
-      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
-      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
-      PortletURL viewCategoryURL = resp.createRenderURL();
-      viewCategoryURL.setParameter("op", OP_MAIN);
-      viewCategoryURL.setParameter("c", "" + category.getId());
-      root.put("U_VIEW_CATEGORY", viewCategoryURL.toString());
-      PortletURL viewForumURL = resp.createRenderURL();
-      viewForumURL.setParameter("op", OP_SHOWFORUM);
-      viewForumURL.setParameter("f", "" + forumId);
-      root.put("U_VIEW_FORUM", viewForumURL.toString());
-      root.put("U_MARK_READ", "index.html?module=bb&op=viewforum&f=" + forumId
-         + "&mark=topics");
-      root.put("PAGE_NUMBER", pageNumber.toString());
-      root.put("PAGINATION", toTopic.generate());
-
-      //      root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
-      return root;
-   }
-
-   private DelegateContext fillShowPreferencesContext(JBossRenderRequest req,
-                                                      JBossRenderResponse resp, DelegateContext root)
-   {
-      try
-      {
-         PortletURL preferencesSubmitURL = resp.createActionURL();
-         preferencesSubmitURL.setParameter("op", "preferences");
-         //Go into view mode after submit
-         preferencesSubmitURL.setPortletMode(PortletMode.VIEW);
-         //process portlet.preferences() method on Submit
-         root.put("S_PROFILE_ACTION", preferencesSubmitURL.toString());
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace();
-      }
-
-      PortletPreferences pp = req.getPreferences();
-      PropertyMap upm = req.getUser().getProperties();
-      if (pp.getValue("notifyreply", "0").equals("1"))
-      {
-         root.put("NOTIFY_REPLY_YES", "CHECKED");
-      }
-      else
-      {
-         root.put("NOTIFY_REPLY_NO", "CHECKED");
-      }
-      /*if (pp.getValue("attachsig", "0").equals("1"))
-      {
-         root.put("ALWAYS_ADD_SIGNATURE_YES", "CHECKED");
-      }
-      else
-      {
-         root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
-      }*/
-      String attachsig = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
-      if ((attachsig != null) && attachsig.equals("1"))
-      {
-         root.put("ALWAYS_ADD_SIGNATURE_YES", "CHECKED");
-      }
-      else if ((attachsig != null))
-      {
-         root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
-      }
-      else if ((attachsig == null))
-      {
-         root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
-      }
-
-      //TODO:Disable BBCode need to be implemented in ToHTMLRenderer --> BBCodeParser
-      /*if (pp.getValue("allowbbcode", "0").equals("1")) {
-          root.put("ALWAYS_ALLOW_BBCODE_YES", "CHECKED");
-      } else {
-          root.put("ALWAYS_ALLOW_BBCODE_NO", "CHECKED");
-      }*/
-      if (pp.getValue("allowhtml", "0").equals("1"))
-      {
-         root.put("ALWAYS_ALLOW_HTML_YES", "CHECKED");
-      }
-      else
-      {
-         root.put("ALWAYS_ALLOW_HTML_NO", "CHECKED");
-      }
-      if (pp.getValue("postorder", "ascending").equals("ascending"))
-      {
-         root.put("POST_ORDER_ASCENDING", "CHECKED");
-      }
-      else
-      {
-         root.put("POST_ORDER_DESCENDING", "CHECKED");
-      }
-      /*root.put("TOPICS_PER_FORUM", pp.getValue("topicsperforum", "10"));*/
-      int topics = Integer.parseInt(pp.getValue("topicsperforum", "10"));
-      switch (topics)
-      {
-         case 5:
-            root.put("TOPICS_PER_FORUM_N5", "CHECKED");
-            break;
-         case 10:
-            root.put("TOPICS_PER_FORUM_N10", "CHECKED");
-            break;
-         case 15:
-            root.put("TOPICS_PER_FORUM_N15", "CHECKED");
-            break;
-         case 20:
-            root.put("TOPICS_PER_FORUM_N20", "CHECKED");
-            break;
-         case 25:
-            root.put("TOPICS_PER_FORUM_N25", "CHECKED");
-            break;
-         case 30:
-            root.put("TOPICS_PER_FORUM_N30", "CHECKED");
-            break;
-      }
-
-      /*root.put("POSTS_PER_TOPIC", pp.getValue("postspertopic", "15"));*/
-      int posts = Integer.parseInt(pp.getValue("postspertopic", "10"));
-      switch (posts)
-      {
-         case 5:
-            root.put("POSTS_PER_TOPIC_N5", "CHECKED");
-            break;
-         case 10:
-            root.put("POSTS_PER_TOPIC_N10", "CHECKED");
-            break;
-         case 15:
-            root.put("POSTS_PER_TOPIC_N15", "CHECKED");
-            break;
-         case 20:
-            root.put("POSTS_PER_TOPIC_N20", "CHECKED");
-            break;
-         case 25:
-            root.put("POSTS_PER_TOPIC_N25", "CHECKED");
-            break;
-         case 30:
-            root.put("POSTS_PER_TOPIC_N30", "CHECKED");
-            break;
-      }
-
-      root.put("DATE_FORMAT", pp.getValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN));
-      //root.put("SIGNATURE", pp.getValue("signature", ""));
-      String sig = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
-      root.put("SIGNATURE", (sig != null) ? sig : "");
-
-      if (pp.isReadOnly("notifyreply"))
-      {
-         root.put("NOTIFY_ON_REPLY_DISABLED", "DISABLED");
-      }
-      /*if (pp.isReadOnly("attachsig"))
-         root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");*/
-      if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
-      {
-         root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");
-      }
-      /*if (pp.isReadOnly("allowbbcode"))
-     root.put("ALWAYS_ALLOW_BBCODE_DISABLED", "DISABLED");*/
-      if (pp.isReadOnly("allowhtml"))
-      {
-         root.put("ALWAYS_ALLOW_HTML_DISABLED", "DISABLED");
-      }
-      if (pp.isReadOnly("postorder"))
-      {
-         root.put("POST_ORDER_DISABLED", "DISABLED");
-      }
-      if (pp.isReadOnly("topicsperforum"))
-      {
-         root.put("TOPICS_PER_FORUM_DISABLED", "DISABLED");
-      }
-      if (pp.isReadOnly("postspertopic"))
-      {
-         root.put("POSTS_PER_TOPIC_DISABLED", "DISABLED");
-      }
-      if (pp.isReadOnly("dateformat"))
-      {
-         root.put("DATE_FORMAT_DISABLED", "DISABLED");
-      }
-      /*if (pp.isReadOnly("signature"))
-         root.put("SIGNATURE_DISABLED", "DISABLED");*/
-      if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
-      {
-         root.put("SIGNATURE_DISABLED", "DISABLED");
-      }
-
-      int summarymode = Integer.parseInt(pp.getValue("summarymode", "0"));
-      switch (summarymode)
-      {
-         case 0:
-            root.put("TOPIC_SUMMARY_MODE_LATEST_POSTS", "SELECTED");
-            break;
-         case 1:
-            root.put("TOPIC_SUMMARY_MODE_HOT", "SELECTED");
-            break;
-         case 2:
-            root.put("TOPIC_SUMMARY_MODE_HOTTEST", "SELECTED");
-            break;
-         case 3:
-            root.put("TOPIC_SUMMARY_MODE_MOST_VIEWED", "SELECTED");
-            break;
-      }
-      if (pp.isReadOnly("summarymode"))
-      {
-         root.put("MODE_CHOOSE_DISABLED", "DISABLED");
-      }
-      if (pp.isReadOnly("summarytopiclimit"))
-      {
-         root.put("TOPIC_SUMMARY_LIMIT_DISABLED", "DISABLED");
-      }
-      if (pp.isReadOnly("summarytopicdays"))
-      {
-         root.put("TOPIC_SUMMARY_DAYS_DISABLED", "DISABLED");
-      }
-      if (pp.isReadOnly("summarytopicreplies"))
-      {
-         root.put("TOPIC_SUMMARY_REPLIES_DISABLED", "DISABLED");
-      }
-      root.put("TOPIC_SUMMARY_LIMIT", pp.getValue("summarytopiclimit", "6"));
-      root.put("TOPIC_SUMMARY_DAYS", pp.getValue("summarytopicdays", "20"));
-      root.put("TOPIC_SUMMARY_REPLIES", pp.getValue("summarytopicreplies", "5"));
-      return root;
-   }
-
-
-   private DelegateContext fillShowUserProfileContext(JBossRenderRequest req,
-                                                      JBossRenderResponse resp, DelegateContext root)
-   {
-      User user = null;
-      Poster poster = null;
-      try
-      {
-         poster = forumsModule.findPosterByUserId(req.getParameters().get("uid", "-1"));
-         user = poster.getUser();
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         return root;
-      }
-
-      PortletURL viewMainPageURL = resp.createRenderURL();
-      viewMainPageURL.setParameter("op", OP_MAIN);
-      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
-      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
-      root.put("USERNAME", user.getGivenName());
-
-      //root.put("EMAIL_IMG", user.getFakeEmail());
-      //String homepage = (String)(user.getProperties().get(CoreConstants.INFO_USER_HOMEPAGE));
-      //root.put("WWW", "<a href=\"" + homepage + "\">"+ homepage + "</a>");
-      root.put("LOCATION", (String)(user.getProperties().get(User.INFO_USER_LOCATION)));
-      root.put("OCCUPATION", (String)(user.getProperties().get(User.INFO_USER_OCCUPATION)));
-      root.put("INTERESTS", (String)(user.getProperties().get(User.INFO_USER_INTERESTS)));
-
-      //root.put("ICQ_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_ICQ)));
-      //root.put("AIM_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_AIM)));
-      //root.put("YIM_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_YIM)));
-      root.put("MSN_IMG", (String)(user.getProperties().get(User.INFO_USER_IM_MSNM)));
-      root.put("SKYPE_IMG", (String)(user.getProperties().get(User.INFO_USER_IM_SKYPE)));
-
-      root.put("JOINED", "" + user.getRegistrationDate());
-      root.put("POSTS", "" + poster.getPostCount());
-
-
-      String fakeEmail = user.getFakeEmail();
-      String homepage = (String)(user.getProperties().get(User.INFO_USER_HOMEPAGE));
-      String icqAddr = (String)(user.getProperties().get(User.INFO_USER_IM_ICQ));
-      String aimAddr = (String)(user.getProperties().get(User.INFO_USER_IM_AIM));
-      String yimAddr = (String)(user.getProperties().get(User.INFO_USER_IM_YIM));
-
-
-      if (fakeEmail != null && fakeEmail.length() > 0)
-      {
-         String emailImgLnk = ForumsTools.createImageLink("mailto:" + fakeEmail, theme.resourceIconEmailURL, "");
-         root.put("EMAIL_IMG", emailImgLnk);
-      }
-      if (homepage != null && homepage.length() > 0)
-      {
-         String wwwImgLnk = ForumsTools.createImageLink(homepage, theme.resourceIconWWWURL, "");
-         root.put("WWW", wwwImgLnk);
-      }
-      String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + icqAddr;
-      if (icqAddr != null && icqAddr.length() > 0)
-      {
-         String icqImgLnk = ForumsTools.createImageLink(icqUrl, theme.resourceIconICQURL, "");
-         root.put("ICQ_IMG", icqImgLnk);
-      }
-      String aimUrl = "aim:goim?screenname=" + aimAddr + "&message=Hello+Are+you+there?";
-      if (aimAddr != null && aimAddr.length() > 0)
-      {
-         String aimImgLnk = ForumsTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "");
-         root.put("AIM_IMG", aimImgLnk);
-      }
-      String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + yimAddr + "&src=pg";
-      if (yimAddr != null && yimAddr.length() > 0)
-      {
-         String yimImgLnk = ForumsTools.createImageLink(yimUrl.toString(), theme.resourceIconYIMURL, "");
-         root.put("YIM_IMG", yimAddr);
-      }
-
-      return root;
-   }
-
-
-   private DelegateContext fillShowBlockTopicsContext(JBossRenderRequest req,
-                                                      JBossRenderResponse resp, DelegateContext root)
-   {
-      //System.out.println("in fillShowNewTopicContext(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-      PortletPreferences pp = req.getPreferences();
-      //int mode = ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS;
-      PortletURL viewMainPageURL = resp.createRenderURL();
-      viewMainPageURL.setParameter("op", OP_MAIN);
-      try
-      {
-         viewMainPageURL.setWindowState(WindowState.MAXIMIZED);
-      }
-      catch (WindowStateException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
-      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
-      int mode = ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS;
-      int limit = 6;
-      int replies = 15;
-      int days = 20;
-      try
-      {
-         mode = new Integer(pp.getValue("summarymode", "0")).intValue();
-         limit = new Integer(pp.getValue("summarytopiclimit", "6")).intValue();
-         days = new Integer(pp.getValue("summarytopicdays", "20")).intValue();
-         replies = new Integer(pp.getValue("summarytopicreplies", "5")).intValue();
-      }
-      catch (IllegalArgumentException e)
-      {
-         System.out.println("ERROR -- Illegal value of summary topic properties");
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-      Calendar after = Calendar.getInstance();
-      after.add(Calendar.DATE, - days);
-      Collection topics = new LinkedList();
-      Date time = after.getTime();
-
-      try
-      {
-         switch (mode)
-         {
-            case ForumsConstants.BLOCK_TOPICS_MODE_HOT_TOPICS:
-               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_HOT_TOPICS"));
-               topics = forumsModule.findTopicsHot(replies, limit);
-               break;
-            case ForumsConstants.BLOCK_TOPICS_MODE_HOTTEST_TOPICS:
-               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_HOTTEST_TOPICS"));
-               topics = forumsModule.findTopicsHottest(time, limit);
-               break;
-            case ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS:
-               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_LATEST_POSTS"));
-               topics = forumsModule.findTopicsByLatestPosts(limit);
-               break;
-            case ForumsConstants.BLOCK_TOPICS_MODE_MOST_VIEWED:
-               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_MOST_VIEWED"));
-               topics = forumsModule.findTopicsMostViewed(time, limit);
-               break;
-         }
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-      //DelegateContext root = new DelegateContext();
-      root.next("switch_no_topics").put("L_NO_TOPICS", topics.size() + " " + bundle.getString("L_TOPICS_FOUND"));
-
-      if (topics.size() > 0)
-      {
-         for (Iterator i = topics.iterator(); i.hasNext();)
-         {
-            //TopicEJBLocal topic = (TopicEJBLocal)i.next();
-            Topic topic = (Topic)i.next();
-            DelegateContext topicrow = root.next("topicrow");
-            topicrow.put("TOPIC_TITLE", topic.getSubject());
-            PortletURL topicViewURL = resp.createRenderURL();
-            try
-            {
-               topicViewURL.setWindowState(WindowState.MAXIMIZED);
-            }
-            catch (WindowStateException e)
-            {
-               e.printStackTrace();
-            }
-            topicViewURL.setParameter("op", "showTopic");
-            topicViewURL.setParameter("t", "" + topic.getId());
-            topicrow.put("U_VIEW_TOPIC", topicViewURL.toString());
-         }
-      }
-      /*else
-      {
-         root.next("switch_no_topics");
-      }*/
-
-      /*root.put("BLOCK_TOPICS_TYPE","Newest topics");
-      for (int i = 0; i<4; i++){
-         DelegateContext topicrow = root.next("topicrow");
-         topicrow.put("TOPIC_TITLE", "topic name " + i);
-      }*/
-
-
-
-
-      return root;
-   }
-
-
-   private DelegateContext fillShowNewTopicContext(JBossRenderRequest req,
-                                                   JBossRenderResponse resp, DelegateContext root)
-   {
-      //System.out.println("in fillShowNewTopicContext(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
-      PortletURL topicSubmitURL = resp.createActionURL();
-      topicSubmitURL.setParameter("op", "posting");
-      String forumId = req.getParameter("f");
-      if (forumId != null)
-      {
-         topicSubmitURL.setParameter("f", forumId);
-      }
-      String postId = req.getParameter("p");
-      if (postId != null)
-      {
-         topicSubmitURL.setParameter("p", postId);
-      }
-
-      boolean isPostBack = false;
-      //check if we display for the first time or if it's postback
-      //postback flag is set in posting() method so we can deal with first display of this view.
-      if (req.getParameter(ForumsConstants.POSTING_POSTBACK_FLAG) != null)
-      {
-         isPostBack = true;
-      }
-      else
-      {
-         //clear stored files from session
-         req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, null);
-      }
-
-
-      if (req.getParameter("S_HIDDEN_FORM_FIELDS") != null)
-      {
-         root.put("S_HIDDEN_FORM_FIELDS", req
-            .getParameter("S_HIDDEN_FORM_FIELDS"));
-      }
-      else
-      {
-         root.put("S_HIDDEN_FORM_FIELDS",
-            "<input type=\"hidden\" name=\"mode\" value=\""
-               + req.getParameter("mode") + "\" />"
-               + "<input type=\"hidden\" name=\"iteratingtest\" value=\"val1\" /><input type=\"hidden\" name=\"iteratingtest\" value=\"val2\" /><input type=\"hidden\" name=\"iteratingtest\" value=\"val3\" />");
-      }
-
-
-      root.put("U_FORM_SUBMIT", topicSubmitURL.toString());
-      root.put("S_FORM_ENCTYPE", "enctype=\"multipart/form-data\"");
-
-      String instantReplyHiddenFormFields = "<input type=\"hidden\" name=\"attach_sig\" value=\"-1\"/>\n";
-      root.put("S_INSTANT_REPLY_HIDDEN_FORM_FIELDS",
-         instantReplyHiddenFormFields);
-
-      if (req.getParameters().getParameterExists("preview"))
-      {
-         PropertyMap upm = req.getUser().getProperties();
-         String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
-         String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
-
-         DelegateContext preview = root.next("preview");
-         preview.put("PREVIEW_SUBJECT", req.getParameter("PREVIEW_SUBJECT"));
-         preview.put("TOPIC_TITLE", req.getParameter("TOPIC_TITLE"));
-         preview.put("POSTER_NAME", req.getParameter("POSTER_NAME"));
-         preview.put("POST_DATE", req.getParameter("POST_DATE"));
-         preview.put("PREVIEW_MESSAGE", req.getParameter("PREVIEW_MESSAGE"));
-      }
-
-      root.put("SUBJECT", req.getParameter("SUBJECT"));
-      root.put("MESSAGE", req.getParameter("MESSAGE"));
-      //root.next("switch_notify_checkbox");
-      //root.put("S_NOTIFY_CHECKED", "checked");
-
-      Forum forum = null;
-      try
-      {
-         Integer tmp = req.getParameters().getIntObject("f");
-         forum = forumsModule.findForumById(tmp);
-      }
-      catch (ModuleException e1)
-      {
-         // TODO Auto-generated catch block
-         e1.printStackTrace();
-      }
-      Category category = forum.getCategory();
-      String forumName = forum.getName();
-      String[] testArray = new String[]{category.getTitle(), forum.getName()};
-      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum"); //Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
-      boolean authAddAttach = ForumsTools.hasPermission(req, testArray, "AddAttachmentInPost");
-      boolean authAddPoll = ForumsTools.hasPermission(req, testArray, "AddPollInPost");
-      boolean authEditPoll = ForumsTools.hasPermission(req, testArray, "EditPollInPost");
-
-      if (authMod)
-      {
-         root.next("auth_mod");
-
-      }
-
-      /*if (authAddAttach)
-      {
-         root.next("attachmentsEnabled");
-      }*/
-
-      //System.out.println("title from req: " + req.getParameter("POLL_TITLE"));
-      /*if (ForumsTools.hasPermission(req,"AddPollInPost"))
-      {
-         System.out.println("Enabling poll body");
-         DelegateContext poll = root.next("pollEnabled");
-         poll.put("POLL_TITLE", req.getParameter("POLL_TITLE"));
-
-      }
-      */
-      boolean newTopic = false;
-      if ((req.getParameter("mode") != null) && req.getParameter("mode").equals("newtopic"))
-      {
-         newTopic = true;
-      }
-      boolean firstTopicPost = false;
-      if ((req.getParameter("firstTopicPost") != null) && req.getParameter("firstTopicPost").equals("true"))
-      {
-         firstTopicPost = true;
-      }
-
-
-      if (authMod && (newTopic || firstTopicPost))
-      {
-         DelegateContext tt = root.next("switch_type_toggle");
-         String type = req.getParameter("topictype");
-         if (type != null)
-         {
-            if (type.equals("0"))
-            {
-               root.put("TOPIC_TYPE_NORMAL", "CHECKED");
-            }
-            else if (type.equals("1"))
-            {
-               root.put("TOPIC_TYPE_STICKY", "CHECKED");
-            }
-            else if (type.equals("2"))
-            {
-               root.put("TOPIC_TYPE_ANNOUNCEMENT", "CHECKED");
-            }
-
-         }
-         else
-         {
-            root.put("TOPIC_TYPE_NORMAL", "CHECKED");
-         }
-      }
-
-      if ((ForumsTools.hasPermission(req, "AddPollInPost") && newTopic) ||
-         (ForumsTools.hasPermission(req, "EditPollInPost") && (req.getParameter("editPoll") != null) &&
-            req.getParameter("editPoll").equals("true")))
-      {
-         DelegateContext poll = root.next("pollEnabled");
-         poll.put("POLL_TITLE", req.getParameter("POLL_TITLE"));
-         poll.put("POLL_LENGTH", req.getParameter("POLL_LENGTH"));
-         if (ForumsTools.hasPermission(req, "EditPostInForum") &&
-            (req.getParameter("switch_poll_delete_toggle") != null)
-            )
-         {
-            poll.next("switch_poll_delete_toggle");
-         }
-         /*response.setRenderParameter("POLL_TITLE", poll.getTitle());
-        response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));*/
-         /*if (action instanceof EditPostAction)
-         {
-            response.setRenderParameter("switch_poll_delete_toggle", "true");
-            //root.next("switch_poll_delete_toggle");
-         }*/
-         /*int index = 0;
-         for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
-         {
-            String text = (String) iterator.next();
-            if (text != null)
-            {
-               DelegateContext poll_option_rows = root.next("poll_option_rows");
-               poll_option_rows.put("POLL_OPTION", text);
-               poll_option_rows.put("S_POLL_OPTION_NUM", "" + index++);
-            }
-         }*/
-         //boolean option_deleted = false;
-
-         for (int index = 0; true; index++)
-         {
-            String param = "poll_option_text[" + index + "]";
-            String value = req.getParameter(param);
-            if (value != null)
-            {
-               DelegateContext poll_option_rows = poll.next("poll_option_rows");
-               poll_option_rows.put("POLL_OPTION", value);
-               poll_option_rows.put("S_POLL_OPTION_NUM", "" + index);
-            }
-            else
-            {
-               break;
-            }
-
-            /* boolean deleted = req.getParameter("del_poll_option[" + index + "]") != null;
-          option_deleted |= deleted;*/
-            /*if(value != null)
-            {
-               p_poll.getOptions().add(deleted ? null : value);
-            }
-            else
-            {
-               break;
-            }*/
-         }
-         //pollBox = theme.TPL_THEME_POSTING_POLL_BODY.render(temp);
-      }
-
-      if (authAddAttach)
-      {
-         DelegateContext attach = root.next("attachmentsEnabled");
-
-         for (int i = 0; ; i++)
-         {
-
-            String name = req.getParameter("ATTACHMENT[" + i + "]_NAME");
-            String id = req.getParameter("ATTACHMENT[" + i + "]_ID");
-            String comment = req.getParameter("ATTACHMENT[" + i + "]_COMMENT");
-            if ((name != null) && (id != null))
-            {
-               DelegateContext row = attach.next("attach_row");
-               row.put("ATTACH_FILENAME", name);
-               row.put("ATTACH_ID", id);
-               row.put("FILE_COMMENT", comment);
-            }
-            else
-            {
-               break;
-            }
-         }
-      }
-
-
-      return root;
-   }
-
-   private DelegateContext fillShowSplitTopicContext(JBossRenderRequest req,
-                                                     JBossRenderResponse resp, DelegateContext root)
-   {
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-
-      Integer topicId = req.getParameters().getIntObject("t", -1);
-      Integer forumId = req.getParameters().getIntObject("f", -1);
-
-      /*resp.setProperty("t", "" + topicId);
-      resp.setProperty("f", "" + forumId);*/
-      if (topicId.intValue() == -1)
-      {
-         return root;
-      }
-      //TODO: index on top of page is not used now...
-      Topic topic = null;
-      List posts = null;
-      try
-      {
-         topic = forumsModule.findTopicById(topicId);
-         posts = forumsModule.findPostsByTopicId(topicId);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         //TODO:some nice error message
-         return root;
-      }
-
-      // form action
-      PortletURL actionURL = resp.createActionURL();
-      actionURL.setParameter(getOperationName(), "moderate_forum");
-      actionURL.setParameter("t", "" + topicId);
-      actionURL.setParameter("f", "" + forumId);
-      root.put("S_SPLIT_ACTION", actionURL.toString());
-
-      //Main index link
-      PortletURL indexURL = resp.createActionURL();
-      indexURL.setParameter(getOperationName(), OP_MAIN);
-      root.put("U_INDEX", indexURL.toString());
-
-      //This topics forum index
-      PortletURL forumURL = resp.createActionURL();
-      forumURL.setParameter(getOperationName(), OP_SHOWFORUM);
-      forumURL.setParameter("f", "" + topic.getForum().getId());
-      root.put("U_VIEW_FORUM", forumURL.toString());
-      root.put("FORUM_NAME", topic.getForum().getName());
-
-
-      int rowindex = 0;
-      for (IndexIterator pi = IndexIterator.wrap(posts.iterator(), -1); pi.hasNext(); rowindex++)
-      {
-         Post post = (Post)pi.next();
-         String rowColor = theme
-            .getProperty(((pi.getIndex() % 2) == 0) ? "td_color1"
-               : "td_color2");
-         String rowClass = theme
-            .getProperty(((pi.getIndex() % 2) == 0) ? "td_class1"
-               : "td_class2");
-
-         DelegateContext postRow = root.next("postrow");
-
-         postRow.put("ROW_COLOR", rowColor);
-         postRow.put("ROW_CLASS", rowClass);
-         postRow.put("POSTER_NAME", post.getPoster().getUser().getUserName());
-         postRow.put("POST_DATE", getSDF(req).format(post.getCreateDate()));
-         postRow.put("POST_SUBJECT", post.getMessage().getSubject());
-         String message = post.getMessage().getText();
-         PropertyMap upm = post.getPoster().getUser().getProperties();
-         String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
-         String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
-         if ((addsign != null) && (sign != null) && addsign.equals("1"))
-         {
-            message += "\n\n" + sign;
-         }
-         postRow.put("MESSAGE", formatMessage(req, message, true, true));
-         postRow.put("POST_ROW_INDEX", "" + rowindex);
-         postRow.put("POST_ID", post.getId());
-         postRow.put("IMG_MINIPOST", theme.resourceIconMinipostURL);
-         //TODO:this spacer link is corrupted
-         postRow.put("IMG_SPACER", theme.resourceIconSpacerURL);
-      }
-
-      try
-      {
-         String selectTo = new StringBuffer().
-            append("<select name=\"forum_to_id\">").
-            append("<option value=\"-1\"").
-            append(" selected=\"selected\">").
-            append("Select destination forum").append("</option>\n").
-            append(ForumsTools.listForums(forumsModule.findForums(), -1)).
-            append("</select>").toString();
-         root.put("S_FORUM_SELECT", selectTo);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-
-
-      return root;
-   }
-
-   private DelegateContext fillShowTopicContext(JBossRenderRequest req,
-                                                JBossRenderResponse resp, DelegateContext root)
-   {
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-
-      Integer topicId = req.getParameters().getIntObject("t", -1);
-      Integer postId = req.getParameters().getIntObject("p", -1);
-      int start = req.getParameters().getInt("start", 0);
-      String view = req.getParameter("view");
-      int postDays = req.getParameters().getInt("postdays", 0);
-      String vote = req.getParameter("vote");
-
-      if ((topicId.intValue() == -1) && (postId.intValue() == -1))
-      {
-         //         Die.exit(GENERAL_MESSAGE, "${bb.Topic_post_not_exist}");
-      }
-
-      Topic topic = null;
-      Forum forum = null;
-      Category category = null;
-      User user = req.getUser();
-      //boolean loggedIn = isUserLoggedIn(user);
-      boolean loggedIn = req.getRemoteUser() != null;
-
-      //      try
-      //      {
-      if (postId.intValue() == -1)
-      {
-         if (view != null)
-         {
-            if ("newest".equals(view))
-            {
-               //if (isUserLoggedIn(user))
-               if (req.getRemoteUser() != null)
-               {
-                  //                     Date lastVisit = user.getPreviousLastVisitDate();
-                  Date lastVisit = user.getLastVisitDate();
-                  try
-                  {
-                     topic = forumsModule.findTopicById(topicId);
-                     Post post = topic.getLastPost();
-
-                     // homesRO.post.findLatestPost(lastVisit, topic);
-                     // resp. sendRedirect("index.html?module=bb&op=viewtopic&p=" + post.getID() + "#" + post.getID());
-                     return null;
-                  }
-                  catch (ModuleException e)
-                  {
-                     //                        Die.exit(GENERAL_MESSAGE, "${No_new_posts_last_visit}");
-                  }
-               }
-               else
-               {
-                  //                     page.sendRedirect("index.html?module=bb&op=viewtopic&t=" + topicId);
-                  //                     return;
-               }
-            }
-            else if ("next".equals(view))
-            {
-               /*
-                try
-                {
-                topic = (TopicEJBLocal)BBTools.head(homesRO.topic.findNext(topicId));
-                }
-                catch (FinderException e)
-                {
-                Die.exit(GENERAL_ERROR, "Could not obtain newer/older topic information", e);
-                }
-                */
-            }
-            else if ("previous".equals(view))
-            {
-               /*
-                try
-                {
-                topic = (TopicEJBLocal)BBTools.head(homesRO.topic.findPrevious(topicId));
-                }
-                catch (FinderException e)
-                {
-                Die.exit(GENERAL_ERROR, "Could not obtain newer/older topic information", e);
-                }
-                */
-            }
-
-            /*
-             if (topic == null)
-             {
-             Die.exit(GENERAL_MESSAGE, "next".equals(view) ? "${bb.No_newer_topics}" : "${bb.No_older_topics}");
-             }
-             topicId = topic.getId();
-             forum = topic.getForum();
-             category = forum.getCategory();
-             */
-         }
-         else
-         // Common use case, showing the topic with topicID as is, no postId defined
-         {
-            try
-            {
-               topic = forumsModule.findTopicById(topicId);
-               forum = topic.getForum();
-               category = forum.getCategory();
-            }
-            catch (ModuleException e)
-            {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
-            }
-         }
-      }
-      else
-      {
-         Post post;
-         try
-         {
-            post = forumsModule.findPostById(postId);
-            topic = post.getTopic();
-            forum = topic.getForum();
-            category = forum.getCategory();
-
-            //               start = (int)(Math.floor(((double)(size.intValue() - 1) / postPerPage)) * postPerPage);
-            topicId = topic.getId();
-         }
-         catch (ModuleException e1)
-         {
-            // TODO Auto-generated catch block
-            e1.printStackTrace();
-         }
-
-         //            Long size = homesRO.post.countPostsBefore(post);
-      }
-      //      }
-      //      catch (ObjectNotFoundException e)
-      //      {
-      //         Die.exit(GENERAL_MESSAGE, "${bb.Topic_post_not_exist}");
-      //      }
-      //      catch (FinderException e)
-      //      {
-      //         Die.exit(GENERAL_ERROR, "Could not obtain topic information", e);
-      //      }
-      String[] testArray = {category.getTitle(), forum.getName()};
-      boolean authView = ForumsTools.hasPermission(req, testArray, "ReadForum");
-      boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadForum");
-      boolean authDelete = ForumsTools.hasPermission(req, testArray, "DeletePostInForum");
-      boolean authPost = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
-      boolean authVote = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
-      boolean authEdit = ForumsTools.hasPermission(req, testArray, "EditPostInForum");
-      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum");
-
-      if (authPost)
-      {
-         root.next("DISPLAY_REPLY_BOX");
-      }
-
-      //      if (!authView || !authRead)
-      //      {
-      if (loggedIn)
-      {
-         //            $redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
-         //            $redirect .= ( isset($start) ) ? "&start=$start" : '';
-         //            redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
-         //            page.sendRedirect("index.html?module=user&=getlogin");
-         //            return;
-      }
-
-      //         Die.exit(GENERAL_MESSAGE, !authView ? "${bb.Topic_post_not_exist}" : "${bb.Sorry_auth_read_0}TODO:$is_auth['auth_read_type']${bb.Sorry_auth_read_1}");
-      //      }
-      Integer forumId = forum.getId();
-      int forumStatus = forum.getStatus();
-      int topicStatus = topic.getStatus();
-      String forumName = forum.getName();
-      String topicTitle = topic.getSubject();
-
-      // Is user watching this thread ?
-      boolean isWatching = false;
-      boolean canWatch = false;
-      if (loggedIn)
-      {
-         //       try
-         //       {
-         canWatch = true;
-
-         /*
-          try
-          {
-          TopicWatchEJBPK key = new TopicWatchEJBPK(user.getId(), topic.getId());
-          TopicWatchEJBLocal watch = homesRO.topicWatch.findByPrimaryKey(key);
-          String unwatch = page.getParameter("unwatch");
-          if (unwatch != null)
-          {
-          if ("topic".equals(unwatch))
-          {
-          isWatching = false;
-          watch.remove();
-          }
-          Die.exit(GENERAL_MESSAGE, "${bb.No_longer_watching}<br/><br/>${bb.Click_return_topic_0}" +
-          "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
-          "&start=" + start + "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}");
-          }
-          else
-          {
-          isWatching = true;
-          }
-          }
-          catch (ObjectNotFoundException e)
-          {
-          String watch = page.getParameter("watch");
-          if (watch != null)
-          {
-          if ("topic".equals(watch))
-          {
-          homesRO.topicWatch.create(user, topic);
-          isWatching = true;
-          }
-          String message = "${bb.You_are_watching}<br/><br/>${bb.Click_return_topic_0}" +
-          "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
-          "&start=" + start + "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}";
-          Die.exit(GENERAL_MESSAGE, message);
-          }
-          else
-          {
-          isWatching = false;
-          }
-          }
-          }
-          catch (RemoveException e)
-          {
-          Die.rollback(GENERAL_ERROR, "Could not delete topic watch information", e);
-          }
-          catch (CreateException ce)
-          {
-          Die.rollback(GENERAL_ERROR, "Could not insert topic watch information", ce);
-          }
-          catch (FinderException e)
-          {
-          Die.exit(GENERAL_ERROR, "Could not obtain topic watch information", e);
-          }*/
-      }
-      else
-      {
-         /*
-          if ("topic".equals(page.getParameter("unwatch")))
-          {
-          //               redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
-          //            page.sendRedirect("index.html?module=user&op=getlogin");
-          //            return;
-          }
-          else
-          {
-          canWatch = false;
-          isWatching = false;
-          }
-          */
-      }
-      int totalReplies = 0;
-      Date minPostDate = null;
-      if (postDays > 0)
-      {
-         Calendar c = Calendar.getInstance();
-         c.add(Calendar.DATE, -postDays);
-         minPostDate = c.getTime();
-
-         /*
-          try
-          {
-          Collection result = homesRO.post.selectGeneric("SELECT p.id FROM post AS p WHERE p.topic=?1 AND p.postDate>=?2",
-          new Object[]{topic, minPostDate});
-          totalReplies = result.size();
-          }
-          catch (FinderException e)
-          {
-          Die.exit(GENERAL_ERROR, "Could not obtain limited topics count information", e);
-          }
-          */
-
-         // if ( !empty($HTTP_POST_VARS['postdays']))
-         // {
-         //   $start = 0;
-         // }
-      }
-      else
-      {
-         totalReplies = topic.getReplies();
-         postDays = 0;
-      }
-
-      //      String selectPostDays = BBTools.selectDays("postdays", postDays);
-      /*boolean postOrderAsc = true;*/
-      boolean postOrderAsc = true;
-      if (req.getPreferences().getValue("postorder", "ascending").equals("ascending"))
-      {
-         //System.out.println("Show posts ascending");
-         postOrderAsc = true;
-      }
-      else
-      {
-         //System.out.println("Show posts descending");
-         postOrderAsc = false;
-      }
-
-      //      String asc = req.getParameter("postorder");
-      //      boolean postOrderAsc = asc != null ? "asc".equals(asc) : user == null ? true : !user.getSortOrderDescending();
-      // Decide how to order the post display
-      //      String selectPostOrder = "<select name=\"postorder\"><option value=\"asc\">" +
-      //            "${bb.Oldest_First}</option><option value=\"desc\" selected=\"selected\">" +
-      //            "${bb.Newest_First}</option></select>";
-
-      /*      if (postOrderAsc)
-       {
-       selectPostOrder = "<select name=\"postorder\"><option value=\"asc\" selected=\"selected\">" +
-       "${bb.Oldest_First}</option><option value=\"desc\">" +
-       "${bb.Newest_First}</option></select>";
-       }
-       */
-
-      List posts = null;
-      int totalPosts = 0;
-      //int allTopicPostsNum = 0;
-
-      /*int postsPerPage = 10;*/
-      int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
-      try
-      {
-         /*
-          posts = postOrderAsc ?
-          (minPostDate != null ?
-          homesRO.post.findByTopicBeforeAsc(topic, minPostDate, start, postPerPage) :
-          homesRO.post.findByTopicAsc(topic, start, postPerPage)) :
-          (minPostDate != null ?
-          homesRO.post.findByTopicBeforeDesc(topic, minPostDate, start, postPerPage) :
-          homesRO.post.findByTopicDesc(topic, start, postPerPage));
-          */
-
-         //To get proper pagination when jump to latest post
-         if (postId.intValue() != -1)
-         {
-            if (postOrderAsc)
-            {
-               posts = forumsModule.findPostsByTopicIdAsc(topicId, 0, 0);
-            }
-            else
-            {
-               posts = forumsModule.findPostsByTopicIdDesc(topicId, 0, 0);
-            }
-            int page = 0;
-            int postposition = 1;
-            for (Iterator i = posts.iterator(); i.hasNext(); postposition++)
-            {
-               if (postposition > ((page + 1) * postsPerPage))
-               {
-                  page++;
-               }
-               if (((Post)i.next()).getId().intValue() == postId.intValue())
-               {
-                  break;
-               }
-            }
-            start = page * postsPerPage;
-         }
-         //else
-         //{
-         if (postOrderAsc)
-         {
-            posts = forumsModule.findPostsByTopicIdAsc(topicId, start,
-               postsPerPage);
-         }
-         else
-         {
-            posts = forumsModule.findPostsByTopicIdDesc(topicId, start,
-               postsPerPage);
-         }
-         totalPosts = posts.size();
-         //}
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-
-         //Die.exit(GENERAL_ERROR, "Could not obtain post/user information.", e);
-      }
-      if (totalPosts == 0)
-      {
-         //         Die.exit(GENERAL_MESSAGE, "${bb.No_posts_topic}");
-      }
-
-      //      $sql = "SELECT *
-      //         FROM " . RANKS_TABLE . "
-      //         ORDER BY rank_special, rank_min";
-      //      if ( !($result = $db->sql_query($sql)) )
-      //      {
-      //         message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
-      //      }
-      //
-      //      $ranksrow = array();
-      //      while ( $row = $db->sql_fetchrow($result) )
-      //      {
-      //         $ranksrow[] = $row;
-      //      }
-      //      $db->sql_freeresult($result);
-      //
-      ////
-      topicTitle = formatTitle(req, topicTitle);
-
-      //
-      ////
-      //// Was a highlight request part of the URI?
-      ////
-      //      $highlight_match = $highlight = '';
-      //      if (isset($HTTP_GET_VARS['highlight']))
-      //      {
-      //         // Split words and phrases
-      //         $words = explode(' ', trim(htmlspecialchars(urldecode($HTTP_GET_VARS['highlight']))));
-      //
-      //         for($i = 0; $i < sizeof($words); $i++)
-      //         {
-      //            if (trim($words[$i]) != '')
-      //            {
-      //               $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
-      //            }
-      //         }
-      //         unset($words);
-      //
-      //         $highlight = urlencode($HTTP_GET_VARS['highlight']);
-      //      }
-      PortletURL newTopicURL;
-      newTopicURL = resp.createRenderURL();
-      newTopicURL.setParameter("op", OP_POSTING);
-      newTopicURL.setParameter("f", "" + forumId);
-      newTopicURL.setParameter("mode", "newtopic");
-
-      /*
-       PortletURL replyTopicURL;
-       replyTopicURL = resp.createRenderURL();
-       replyTopicURL.setParameter("op", OP_POSTING);
-       replyTopicURL.setParameter("mode", "reply");
-       replyTopicURL.setParameter("p", "" + topic.getLastPost().getID());
-       */
-      PortletURL replyTopicURL;
-      replyTopicURL = resp.createActionURL();
-      replyTopicURL.setParameter("op", "posting");
-      replyTopicURL.setParameter("mode", "reply");
-      replyTopicURL.setParameter("p", "" + topic.getLastPost().getId());
-      replyTopicURL.setParameter("f", "" + forumId);
-
-      //      replyTopicURL.setParameter("f", "" + forumId);
-      //      String replyTopicUrl = "index.html?module=bb&op=posting&mode=reply&p=" + topic.getLastPost().getID();
-      PortletURL viewForumURL = resp.createRenderURL();
-      viewForumURL.setParameter("op", OP_SHOWFORUM);
-      viewForumURL.setParameter("f", "" + forumId);
-      PortletURL viewCategoryURL = resp.createRenderURL();
-      viewCategoryURL.setParameter("op", OP_MAIN);
-      viewCategoryURL.setParameter("c", "" + category.getId());
-      PortletURL replySubmitURL = resp.createActionURL();
-      replySubmitURL.setParameter("op", "posting");
-
-      String viewPrevTopicUrl = "index.html?module=bb&op=viewtopic&t="
-         + topicId + "&view=previous";
-      String viewNextTopicUrl = "index.html?module=bb&op=viewtopic&t="
-         + topicId + "&view=next";
-
-      String replyImg = theme.resourceReplyNewURL;
-      String replyAlt = bundle.getString("Reply_to_topic");
-      String postImg = theme.resourcePostNewURL;
-      String postAlt = bundle.getString("Post_new_topic");
-      if (forumStatus == FORUM_LOCKED)
-      {
-         replyImg = theme.resourceReplyLockedURL;
-         replyAlt = bundle.getString("Topic_locked");
-         postImg = theme.resourcePostLockedURL;
-         postAlt = bundle.getString("Forum_locked");
-      }
-      else if (topicStatus == TOPIC_LOCKED)
-      {
-         replyImg = theme.resourceReplyLockedURL;
-         replyAlt = bundle.getString("Topic_locked");
-      }
-      DelegateContext auth = null;
-      if (authPost)
-      {
-         auth = root.next("AUTH_POST");
-      }
-      //disable <a href=> for posting when topic is locked
-      if (authPost && !(topic.getStatus() == TOPIC_LOCKED))
-      {
-         auth.next("UNLOCKED");
-      }
-
-      if (loggedIn)
-      {
-         //         Map trackingTopics = getTrackingTopics(page);
-         //         Map trackingForums = getTrackingForums(page);
-         //         Date topicDate = (Date)trackingTopics.get(topicId);
-         //         Date forumDate = (Date)trackingForums.get(forumId);
-
-         /*
-          Date topicLastRead = null;
-          if (topicDate != null && forumDate != null)
-          {
-          topicLastRead = topicDate.after(forumDate) ? topicDate : forumDate;
-          }
-          else if (topicDate != null || forumDate != null)
-          {
-          topicLastRead = topicDate != null ? topicDate : forumDate;
-          }
-          else
-          {
-          //            topicLastRead = user.getPreviousLastVisitDate();
-          topicLastRead = user.getLastVisitDate();
-          }
-          //         if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
-          //         {
-          //            asort($tracking_topics);
-          //            unset($tracking_topics[key($tracking_topics)]);
-          //         }
-          trackingTopics.put(topicId, new Date());
-          */
-      }
-
-      StringBuffer authCan = new StringBuffer();
-
-      //      BBTools.authCan(authCan, forum, loggedIn, level);
-      String topicMod = "";
-
-
-      if (authMod)
-      {
-         /*authCan.append(bundle.getString("Rules_moderate_0") + "<a href=\"index.html?module=bb&op=modcp&f=")
-       .append(forumId).append("\">" + bundle.getString("Rules_moderate_1") + "</a>"
-       + bundle.getString("Rules_moderate_2")); */
-         PortletURL deleteTopicURL = resp.createActionURL();
-         deleteTopicURL.setParameter(getOperationName(), "moderate_forum");
-         deleteTopicURL.setParameter("delete", "delete");
-         deleteTopicURL.setParameter("f", "" + topic.getForum().getId());
-         deleteTopicURL.setParameter("t", "" + topic.getId());
-         PortletURL moveTopicURL = resp.createActionURL();
-         moveTopicURL.setParameter(getOperationName(), "moderate_forum");
-         moveTopicURL.setParameter("move", "move");
-         moveTopicURL.setParameter("f", "" + topic.getForum().getId());
-         moveTopicURL.setParameter("t", "" + topic.getId());
-         PortletURL lockTopicURL = resp.createActionURL();
-         lockTopicURL.setParameter(getOperationName(), "moderate_forum");
-         lockTopicURL.setParameter("lock", "lock");
-         lockTopicURL.setParameter("f", "" + topic.getForum().getId());
-         lockTopicURL.setParameter("t", "" + topic.getId());
-         PortletURL unlockTopicURL = resp.createActionURL();
-         unlockTopicURL.setParameter(getOperationName(), "moderate_forum");
-         unlockTopicURL.setParameter("unlock", "unlock");
-         unlockTopicURL.setParameter("f", "" + topic.getForum().getId());
-         unlockTopicURL.setParameter("t", "" + topic.getId());
-         PortletURL splitTopicURL = resp.createActionURL();
-         splitTopicURL.setParameter(getOperationName(), "moderate_forum");
-         splitTopicURL.setParameter("split", "split");
-         splitTopicURL.setParameter("f", "" + topic.getForum().getId());
-         splitTopicURL.setParameter("t", "" + topic.getId());
-
-         topicMod =
-            "<a href=\"" + deleteTopicURL.toString() + "\">" + "<img src=\""
-               + theme.resourceTopicModeDeleteURL + "\" alt=\"" + bundle.getString("Delete_topic") + "\" title=\""
-               + bundle.getString("Delete_topic") + "\" " + "border=\"0\"/></a>&nbsp;"
-               + "<a href=\"" + moveTopicURL.toString() + "\">" + "<img src=\""
-               + theme.resourceTopicModMoveURL + "\" alt=" + bundle.getString("Move_topic") + "\" " + "title=\""
-               + bundle.getString("Move_topic") + "\" border=\"0\"/></a>&nbsp;"
-               + ((topicStatus == TOPIC_UNLOCKED)
-               ? ("<a href=\"" + lockTopicURL.toString() + "\">" + "<img src=\""
-               + theme.resourceTopicModLockURL + "\" alt=\"" + bundle.getString("Lock_topic") + "\" " + "title=\""
-               + bundle.getString("Lock_topic") + "\" border=\"0\" /></a>&nbsp;")
-               : ("<a href=\"" + unlockTopicURL.toString() + "\">" + "<img src=\""
-               + theme.resourceTopicModUnlockURL + "\" alt=\"" + bundle.getString("Unlock_topic") + "\" "
-               + "title=\"" + bundle.getString("Unlock_topic") + "\" border=\"0\"/></a>&nbsp;"))
-               + "<a href=\"" + splitTopicURL.toString() + "\">" + "<img src=\""
-               + theme.resourceTopicModSplitURL + "\" " + "alt=\"" + bundle.getString("Split_topic") + "\" title=\""
-               + bundle.getString("Split_topic") + "\" border=\"0\"/></a>&nbsp;";
-      }
-
-      String watchingTopic = "";
-      String watchingTopicImg = "";
-
-      /*
-       if (canWatch)
-       {
-       if (isWatching)
-       {
-       watchingTopic = "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
-       "&unwatch=topic&start=" + start + "\">${bb.Stop_watching_topic}</a>";
-       String url = theme.resourceTopicUnWatchURL;
-       watchingTopicImg = "".equals(url) ? "" : "<a href=\"index.html?module=bb&op=viewtopic&t=" +
-       topicId + "&unwatch=topic&start=" + start + "\"><img src=\"" + url +
-       "\" alt=\"" + bundle.getString("Stop_watching_topic") + "\" title=\"" + bundle.getString("Stop_watching_topic") + "\" border=\"0\"></a>";
-       }
-       else
-       {
-       watchingTopic = "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
-       "&watch=topic&start=" + start + "\">${bb.Start_watching_topic}</a>";
-       String url = theme.resourceTopicWatchURL;
-       watchingTopicImg = "".equals(url) ? "" : "<a href=\"index.html?module=bb&op=viewtopic&t=" +
-       topicId + "&watch=topic&start=" + start + "\"><img src=\"" + url +
-       "\" alt=\"" + bundle.getString("Start_watching_topic") + "\" title=\"" + bundle.getString("Start_watching_topic") + "\" border=\"0\"></a>";
-       }
-       }
-       */
-
-      // $pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : ;
-      /*int postPerPage = 10;*/
-      int postPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
-
-      PortletURL gotoURL = resp.createRenderURL();
-      gotoURL.setParameter("op", OP_SHOWTOPIC);
-      gotoURL.setParameter("t", "" + topicId);
-      gotoURL.setParameter("postDays", "" + postDays);
-      gotoURL.setParameter("postorder", (postOrderAsc ? "asc" : "desc"));
-      GotoWithOffset toPost = new GotoWithOffset(1 + totalReplies, start,
-         postPerPage, gotoURL.toString() + "&start=", bundle
-         .getString("Goto_page"), bundle.getString("Previous"), bundle
-         .getString("Next"));
-
-      String pageNumber = bundle.getString("Page_of_0")
-         + ((int)Math.floor((double)start / (postPerPage)) + 1)
-         + bundle.getString("Page_of_1")
-         + ((int)Math.ceil((double)(totalReplies + 1) / postPerPage))
-         + bundle.getString("Page_of_2");
-
-      String instantReplyHiddenFormFields = "<input type=\"hidden\" name=\"attach_sig\" value=\"-1\"/>\n"
-         + "<input type=\"hidden\" name=\"mode\" value=\"reply\"/>\n"
-         + "<input type=\"hidden\" name=\"subject\" value=\"Re: "
-         + topic.getSubject()
-         + "\"/>\n"
-         + "<input type=\"hidden\" name=\"p\" value=\""
-         + topic.getLastPost().getId() + "\"/>\n";
-      replySubmitURL.setParameter("attach_sig", "-1");
-      replySubmitURL.setParameter("mode", "reply");
-      replySubmitURL.setParameter("subject", "Re: " + topic.getSubject());
-      replySubmitURL.setParameter("t", "" + topic.getId());
-      replySubmitURL.setParameter("f", "" + topic.getForum().getId());
-      replySubmitURL.setParameter("p", "" + topic.getLastPost().getId());
-      // "<input type=\"hidden\" name=\"notify\" value=\"" + "checked" + "\"/>\n";
-      //      DelegateContext root = new DelegateContext();
-      root.put("S_INSTANT_REPLY_HIDDEN_FORM_FIELDS",
-         instantReplyHiddenFormFields);
-      root.put("FORUM_ID", forumId.toString());
-      root.put("FORUM_NAME", forumName);
-      root.put("CATEGORY_NAME", category.getTitle());
-      root.put("TOPIC_ID", topicId.toString());
-      root.put("TOPIC_TITLE", topicTitle);
-      root.put("PAGINATION", toPost.generate());
-      root.put("PAGE_NUMBER", pageNumber);
-      root.put("POST_IMG", postImg);
-      root.put("REPLY_IMG", replyImg);
-      root.put("L_POST_NEW_TOPIC", postAlt);
-      root.put("L_POST_REPLY_TOPIC", replyAlt);
-      root.put("S_TOPIC_LINK", "t");
-
-      //      root.put("S_SELECT_POST_DAYS", selectPostDays);
-      //     root.put("S_SELECT_POST_ORDER", selectPostOrder);
-      root.put("S_POST_DAYS_ACTION", "index.html?module=bb&op=viewtopic&t="
-         + topicId + "&start=" + start);
-      root.put("S_AUTH_LIST", authCan.toString());
-      root.put("S_TOPIC_ADMIN", topicMod);
-      root.put("S_WATCH_TOPIC", watchingTopic);
-      root.put("S_WATCH_TOPIC_IMG", watchingTopicImg);
-      root.put("U_VIEW_FORUM", viewForumURL.toString());
-      root.put("U_VIEW_OLDER_TOPIC", viewPrevTopicUrl);
-      root.put("U_VIEW_NEWER_TOPIC", viewNextTopicUrl);
-      root.put("U_POST_NEW_TOPIC", newTopicURL.toString());
-      root.put("U_POST_REPLY_TOPIC", replyTopicURL.toString());
-
-      //      root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
-      PortletURL viewMainPageURL = resp.createRenderURL();
-      viewMainPageURL.setParameter("op", OP_MAIN);
-      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
-      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
-      root.put("U_VIEW_CATEGORY", viewCategoryURL.toString());
-      root.put("U_VIEW_TOPIC", "index.html?module=bb&op=viewtopic&t=" + topicId
-         + "&start=" + start + "&postdays=" + "postDays" + "&postorder="
-         + "postOrder" + "&highlight=" + "highlight");
-      root.put("U_REPLY_SUBMIT", replySubmitURL.toString());
-
-
-      Poll poll = topic.getPoll();
-      boolean isPoll = poll != null;
-      if (isPoll && poll.getOptions().size() == 0)
-      {
-         isPoll = false;
-      }
-      boolean pollVoted = false;
-      boolean canVote = ForumsTools.hasPermission(req, "VotePollInPost");
-      boolean pollExpired = false;
-      //boolean pollEnded = poll.getIsEnded();
-      boolean pollViewResultsMode = false;
-      if (req.getParameter("poll_results_view_enable") != null &&
-         req.getParameter("poll_results_view_enable").equals("true"))
-      {
-         pollViewResultsMode = true;
-      }
-      if (loggedIn && isPoll)
-      {
-         for (Iterator i = poll.getVoted().iterator(); i.hasNext();)
-         {
-            Integer userId = (Integer)i.next();
-            pollVoted |= user.getId().equals(userId);
-         }
-      }
-      if (isPoll)
-      {
-         Calendar c = Calendar.getInstance();
-         c.setTime(poll.getCreationDate());
-         c.add(Calendar.DATE, poll.getLength());
-         pollExpired = c.before(new Date());
-
-      }
-      if (isPoll && !pollVoted && loggedIn && !pollViewResultsMode && !pollExpired && canVote)
-      {
-         PortletURL voteSubmitURL = resp.createActionURL();
-         voteSubmitURL.setParameter("op", "posting");
-         voteSubmitURL.setParameter("mode", "vote");
-         voteSubmitURL.setParameter("t", "" + topic.getId());
-         voteSubmitURL.setParameter("f", "" + topic.getForum().getId());
-         DelegateContext poll_ballot = root.next("poll_ballot_display");
-         poll_ballot.put("POLL_QUESTION", poll.getTitle());
-         Iterator i = poll.getOptions().iterator();
-         int index = 0;
-         while (i.hasNext())
-         {
-            PollOption po = (PollOption)i.next();
-            DelegateContext poll_ballot_option = poll_ballot.next("poll_option");
-            poll_ballot_option.put("POLL_OPTION_ID", "" + index);
-            poll_ballot_option.put("POLL_OPTION_CAPTION", po.getQuestion());
-            index++;
-         }
-
-         PortletURL viewPollResultsURL = resp.createRenderURL();
-         viewPollResultsURL.setParameter("op", "showTopic");
-         viewPollResultsURL.setParameter("t", "" + topic.getId());
-         viewPollResultsURL.setParameter("poll_results_view_enable", "true");
-         poll_ballot.put("U_VIEW_RESULTS", viewPollResultsURL.toString());
-         //pollRoot.put("U_VIEW_RESULTS", "index.html?module=bb&op=viewtopic&t=" + topicId +
-         //"&postdays=" + postDays + "&postorder=" + (postOrderAsc ? "asc" : "desc") +
-         //"&vote=viewresult");
-         String hiddenFields = "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
-            "<input type=\"hidden\" name=\"op\" value=\"posting\"/>" +
-            "<input type=\"hidden\" name=\"t\" value=\"" + topicId +
-            "\"/><input type=\"hidden\" name=\"mode\" value=\"vote\"/>";
-
-         //            pollRoot.put("POLL_QUESTION", formatVoteTitle(voteTitle));
-         poll_ballot.put("S_HIDDEN_FIELDS", hiddenFields);
-         poll_ballot.put("VOTE_FORM_SUBMIT", voteSubmitURL.toString());
-      }
-      else if (isPoll)
-      {
-         DelegateContext poll_result = root.next("poll_result_display");
-         poll_result.put("POLL_QUESTION", poll.getTitle());
-         poll_result.put("TOTAL_VOTES", "" + poll.getVotesSum());
-         float voteResultsSum = 0;
-         for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
-         {
-            PollOption po = (PollOption)iterator.next();
-            voteResultsSum += po.getVotes();
-         }
-
-         Iterator i = poll.getOptions().iterator();
-         int numOfOpts = poll.getOptions().size();
-         //int index = 0;
-         while (i.hasNext())
-         {
-            PollOption po = (PollOption)i.next();
-            DelegateContext poll_result_option = poll_result.next("poll_option");
-            //poll_result_option.put("POLL_OPTION_ID", "" + index);
-            poll_result_option.put("POLL_OPTION_CAPTION", po.getQuestion());
-            poll_result_option.put("POLL_OPTION_L_IMG", "" + theme.resourcePollVotingLBar);
-            poll_result_option.put("POLL_OPTION_R_IMG", "" + theme.resourcePollVotingRBar);
-            poll_result_option.put("POLL_OPTION_IMG", "" + theme.resourcePollVotingBar);
-
-            float votePercent = voteResultsSum > 0 ? po.getVotes() / voteResultsSum : 0f;
-            int voteGraphicLength = Math.round(votePercent * 205); // 205 == voteGraphicLength
-            //String voteGraphicImg = theme.resourcePollVotingBar  //theme.getResourceURL("voting_graphic_" + voteGraphic);
-
-            //optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
-            poll_result_option.put("POLL_OPTION_RESULT", "" + po.getVotes());
-            poll_result_option.put("POLL_OPTION_PERCENT", "" + votePercent); // sprintf("%.1d%%", ($vote_percent * 100))
-            //optionRoot.put("POLL_OPTION_IMG",);
-            poll_result_option.put("POLL_OPTION_IMG_WIDTH", "" + voteGraphicLength);
-            //index++;
-         }
-
-
-      }
-
-      /*
-      PollEJBLocal poll = topic.getPoll();
-      String pollBox = "";
-      if (poll != null)
-      {
-      int voteOptions = -1;
-      Collection options = null;
-      try
-      {
-      options = homesRO.option.findByPoll(poll);
-      voteOptions = options.size();
-      }
-      catch (FinderException e)
-      {
-      Die.exit(GENERAL_ERROR, "Could not obtain vote data for this topic", e);
-      }
-      String hiddenFields = "";
-      if (voteOptions > 0)
-      {
-      String voteTitle = poll.getText();
-      boolean userVoted = false;
-      if (user != null)
-      {
-      try
-      {
-      userVoted = true;
-      homesRO.vote.findByPollAndUser(poll, user);
-      }
-      catch (ObjectNotFoundException e)
-      {
-      userVoted = false;
-      }
-      catch (FinderException e)
-      {
-      Die.exit(GENERAL_ERROR, "Could not obtain user vote data for this topic", e);
-      }
-      }
-      Template pollTpl = null;
-      DelegateContext pollRoot = new DelegateContext();
-      boolean viewResult = "viewresult".equals(vote);
-      Calendar c = Calendar.getInstance();
-      c.setTime(poll.getCreationDate());
-      c.add(Calendar.DATE, poll.getLength());
-      boolean pollExpired = c.before(new Date());
-      if (userVoted || viewResult || pollExpired || !authVote || topic.getStatus() == TOPIC_LOCKED)
-      {
-      pollTpl = theme.TPL_THEME_VIEWTOPIC_POLL_RESULT;
-      float voteResultsSum = 0;
-      for (Iterator iterator = options.iterator();iterator.hasNext();)
-      {
-      OptionEJBLocal option = (OptionEJBLocal)iterator.next();
-      voteResultsSum += option.getResult();
-      }
-      int voteGraphic = 0;
-      for (Iterator iterator = options.iterator();iterator.hasNext();)
-      {
-      OptionEJBLocal option = (OptionEJBLocal)iterator.next();
-      float votePercent = voteResultsSum > 0 ? option.getResult() / voteResultsSum : 0f;
-      int voteGraphicLength = Math.round(votePercent * 205); // 205 == voteGraphicLength
-      String voteGraphicImg = theme.getResourceURL("voting_graphic_" + voteGraphic);
-      if ("".equals(voteGraphicImg))
-      {
-      voteGraphicImg = theme.getResourceURL("voting_graphic_0");
-      voteGraphic = 0;
-      }
-      else
-      {
-      voteGraphic++;
-      }
-      DelegateContext optionRoot = pollRoot.next("poll_option");
-      optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
-      optionRoot.put("POLL_OPTION_RESULT", "" + option.getResult());
-      optionRoot.put("POLL_OPTION_PERCENT", "" + votePercent); // sprintf("%.1d%%", ($vote_percent * 100))
-      optionRoot.put("POLL_OPTION_IMG", voteGraphicImg);
-      optionRoot.put("POLL_OPTION_IMG_WIDTH", "" + voteGraphicLength);
-      }
-      pollRoot.put("TOTAL_VOTES", "" + voteResultsSum);
-      }
-      else
-      {
-      pollTpl = theme.TPL_THEME_VIEWTOPIC_POLL_BALLOT;
-      for (Iterator iterator = options.iterator();iterator.hasNext();)
-      {
-      Option option = (Option)iterator.next();
-      DelegateContext optionRoot = pollRoot.next("poll_option");
-      optionRoot.put("POLL_OPTION_ID", option.getId().toString());
-      optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
-      }
-      pollRoot.put("U_VIEW_RESULTS", "index.html?module=bb&op=viewtopic&t=" + topicId +
-      "&postdays=" + postDays + "&postorder=" + (postOrderAsc ? "asc" : "desc") +
-      "&vote=viewresult");
-      hiddenFields += "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
-      "<input type=\"hidden\" name=\"op\" value=\"posting\"/>" +
-      "<input type=\"hidden\" name=\"t\" value=\"" + topicId +
-      "\"/><input type=\"hidden\" name=\"mode\" value=\"vote\"/>";
-      }
-      //            pollRoot.put("POLL_QUESTION", formatVoteTitle(voteTitle));
-      pollRoot.put("S_HIDDEN_FIELDS", hiddenFields);
-      pollBox = pollTpl.render(pollRoot);
-      }
-      }
-      root.put("POLL_DISPLAY", pollBox);
-      */
-      topic.setViewCount(topic.getViewCount() + 1);
-
-      for (IndexIterator iterator = IndexIterator.wrap(posts.iterator(), -1); iterator
-         .hasNext();)
-      {
-         Post post = (Post)iterator.next();
-         User poster = post.getPoster().getUser();
-
-         //below where " req.getRemoteUser() != null" was earlier "poster != null"
-
-         String posterId = req.getRemoteUser() != null ? poster.getId().toString() : "0";
-         /*String postDate = post.getCreateDate().toString();*/
-         SimpleDateFormat sdf = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
-         String postDate = sdf.format(post.getCreateDate());
-         String posterPosts = req.getRemoteUser() != null ? (bundle.getString("Posts")
-            + ":" + poster.getUserName()) : "";
-         String location = (String)poster.getProperties().get("LOCATION");
-         String posterFrom = (req.getRemoteUser() != null && (location != null)) ? (bundle
-            .getString("Location")
-            + ":" + location) : "";
-         /*String posterJoined = (poster != null) ? (bundle.getString("Joined")
-            + ":" + poster.getRegistrationDate()) : "";*/
-         String posterJoined = req.getRemoteUser() != null ? (bundle.getString("Joined")
-            + ":" + sdf.format(poster.getRegistrationDate())) : "";
-
-         //         String posterAvatar = "";
-         //         $poster_avatar = '';
-         //         if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] )
-         //         {
-         //            switch( $postrow[$i]['user_avatar_type'] )
-         //            {
-         //               case USER_AVATAR_UPLOAD:
-         //                  $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
-         //                  break;
-         //               case USER_AVATAR_REMOTE:
-         //                  $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
-         //                  break;
-         //               case USER_AVATAR_GALLERY:
-         //                  $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
-         //                  break;
-         //            }
-         //         }
-         String miniPostImg = theme.resourceIconMinipostURL;
-         String miniPostAlt = bundle.getString("Post");
-         if (loggedIn && false) // $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read
-         {
-            miniPostImg = theme.resourceIconMinipostNewURL;
-            miniPostAlt = bundle.getString("New_post");
-         }
-
-         //        String miniPostUrl = "index.html?module=bb&op=viewtopic&p=" + post.getID() + "#" + postImg;
-         //         //
-         //         // Generate ranks, set them to empty string initially.
-         //         //
-         //         $poster_rank = '';
-         //         $rank_image = '';
-         //         if ( $postrow[$i]['user_id'] == ANONYMOUS )
-         //         {
-         //         }
-         //         else if ( $postrow[$i]['user_rank'] )
-         //         {
-         //            for($j = 0; $j < count($ranksrow); $j++)
-         //            {
-         //               if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
-         //               {
-         //                  $poster_rank = $ranksrow[$j]['rank_title'];
-         //                  $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
-         //               }
-         //            }
-         //         }
-         //         else
-         //         {
-         //            for($j = 0; $j < count($ranksrow); $j++)
-         //            {
-         //               if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
-         //               {
-         //                  $poster_rank = $ranksrow[$j]['rank_title'];
-         //                  $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
-         //               }
-         //            }
-         //         }
-         //
-         // compute the displayed poster name
-         String posterName = post.getPoster().getUser().getUserName();
-         String profileImgLnk = "";
-         String profileLnk = "";
-         String pmImgLnk = "";
-         String pmLnk = "";
-         String emailImgLnk = "";
-         String emailLnk = "";
-         String wwwImgLnk = "";
-         String wwwLnk = "";
-         String icqStatusImgLnk = "";
-         String icqImgLnk = "";
-         String icqLnk = "";
-         String aimImgLnk = "";
-         String aimLnk = "";
-         String msnImgLnk = "";
-         String msnLnk = "";
-         String yimImgLnk = "";
-         String yimLnk = "";
-         String skypeImgLnk = "";
-         String skypeImg = "";
-         String editImgLnk = "";
-         String editLnk = "";
-         String repostImgLnk = "";
-         String repostLnk = "";
-         String ipImgLnk = "";
-         String ipLnk = "";
-
-         //theme
-         PortletURL userProfileURL = resp.createRenderURL();
-         userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
-         userProfileURL.setParameter("uid", "" + poster.getId().toString());
-         if ((req.getRemoteUser() != null))
-         {
-            //user.getPreferenceStore().
-            String fakeEmail = poster.getFakeEmail();
-            String homepage = (String)(poster.getProperties().get(User.INFO_USER_HOMEPAGE));
-            String icqAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_ICQ));
-            String aimAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_AIM));
-            String msnmAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_MSNM));
-            String yimAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_YIM));
-            String skypeAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_SKYPE));
-
-            profileImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconProfileURL, "");
-            if (fakeEmail != null && fakeEmail.length() > 0)
-            {
-               emailImgLnk = ForumsTools.createImageLink("mailto:" + fakeEmail, theme.resourceIconEmailURL, "");
-            }
-            if (homepage != null && homepage.length() > 0)
-            {
-               wwwImgLnk = ForumsTools.createImageLink(homepage, theme.resourceIconWWWURL, "");
-            }
-            String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + icqAddr;
-            if (icqAddr != null && icqAddr.length() > 0)
-            {
-               icqImgLnk = ForumsTools.createImageLink(icqUrl, theme.resourceIconICQURL, "");
-            }
-            String aimUrl = "aim:goim?screenname=" + aimAddr + "&message=Hello+Are+you+there?";
-            if (aimAddr != null && aimAddr.length() > 0)
-            {
-               aimImgLnk = ForumsTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "");
-            }
-            if (msnmAddr != null && msnmAddr.length() > 0)
-            {
-               msnImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconMSNMURL, "");
-            }
-            if (skypeAddr != null && skypeAddr.length() > 0)
-            {
-               skypeImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconSkypeURL, "");
-            }
-            String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + yimAddr + "&src=pg";
-            if (yimAddr != null && yimAddr.length() > 0)
-            {
-               yimImgLnk = ForumsTools.createImageLink(yimUrl.toString(), theme.resourceIconYIMURL, "");
-            }
-         }
-
-         /*
-         if (poster != null)
-         {
-         String posterIcq = poster.getMessengerICQ();
-         String posterAim = poster.getMessengerAIM();
-         String posterMsn = poster.getMessengerMSNM();
-         String posterYim = poster.getMessengerYIM();
-         String profileUrl = "index.html?module=user&op=userinfo&uid=" + posterId;
-         profileImgLnk = BBTools.createImageLink(profileUrl, theme.resourceIconProfileURL, "${bb.Read_profile}");
-         profileLnk = BBTools.createLink(profileUrl, "${bb.Read_profile}");
-         //            String pmUrl = "privmsg.php?mode=post&u=" + posterId;
-         String pmUrl = ""; // todo private message
-         pmImgLnk = BBTools.createImageLink(pmUrl, theme.resourceIconPMURL, "${bb.Send_private_message}");
-         pmLnk = BBTools.createLink(pmUrl, "${bb.Send_private_message}");
-         if (!poster.getViewEmail() || authMod)
-         {
-         String emailUrl = emailForm ? "index.html?module=user&op=userinfo&uid=" + posterId :
-         "mailto:" + poster.getEmail();
-         emailImgLnk = BBTools.createImageLink(emailUrl, theme.resourceIconEmailURL, "${bb.Send_email}");
-         emailLnk = BBTools.createLink(emailUrl, "${bb.Send_email}");
-         }
-         String websiteUrl = poster.getURL();
-         if (websiteUrl != null && websiteUrl.length() > 0)
-         {
-         wwwImgLnk = BBTools.createImageLink(websiteUrl, "userwww", theme.resourceIconWWWURL, "${bb.Visit_website}", "${bb.Visit_website}");
-         wwwLnk = BBTools.createLink(websiteUrl, "userwww", "${bb.Visit_website}");
-         }
-         if (posterIcq != null && posterIcq.length() > 0)
-         {
-         icqStatusImgLnk = "<a href=\"http://wwp.icq.com/" + posterIcq + "#pager\">" +
-         "<img src=\"http://web.icq.com/" +
-         "whitepages/online?icq=\"" + posterIcq +
-         "&img=5\" width=\"18\" height=\"18\" border=\"0\"/></a>";
-         String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + posterIcq;
-         icqImgLnk = BBTools.createImageLink(icqUrl, theme.resourceIconICQURL, "${bb.ICQ}");
-         icqLnk = BBTools.createLink(icqUrl, "${bb.ICQ}");
-         }
-         if (posterAim != null && posterAim.length() > 0)
-         {
-         String aimUrl = "aim:goim?screenname=\"" + posterAim + "&message=Hello+Are+you+there?";
-         aimImgLnk = BBTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "${bb.AIM}");
-         aimLnk = BBTools.createLink(aimUrl, "${bb.AIM}");
-         }
-         if (posterMsn != null && posterMsn.length() > 0)
-         {
-         String msnUrl = "index.html?module=user&op=userinfo&uid=" + posterId;
-         msnImgLnk = BBTools.createImageLink(msnUrl, theme.resourceIconMSNMURL, "${bb.MSNM}");
-         msnLnk = BBTools.createLink(msnUrl, "${bb.MSNM}");
-         }
-         if (posterYim != null && posterYim.length() > 0)
-         {
-         String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + posterYim + "&src=pg";
-         yimImgLnk = BBTools.createImageLink(yimUrl, theme.resourceIconYIMURL, "${bb.YIM}");
-         yimLnk = BBTools.createLink(yimUrl, "${bb.YIM}");
-         }
-         }
-         */
-         /*
-          String searchUrl = "index.html?module=bb&op=search&search_authors=${encodeurl:" + post.getPoster().getAuthor(false) + "}" + "&showresults=posts";
-          String searchImg = BBTools.createImageLink(searchUrl, theme.resourceIconSearchURL, "${bb.Search_user_posts}");
-          String search = BBTools.createLink(searchUrl, "${bb.Search_user_posts}");
-          if ((EJB.areIdentical(user, poster) && authEdit) || authMod)
-          {
-          String editUrl = "index.html?module=bb&op=posting&mode=editpost&p=" + post.getId();
-          editImgLnk = "<a href=\"" + editUrl + "\"><img src=\"" + theme.resourceIconEditURL +
-          "\" alt=\"${bb.Edit_delete_post}\" title=\"${bb.Edit_delete_post}\" border=\"0\"/></a>";
-          editLnk = "<a href=\"" + editUrl + "\">${bb.Edit_delete_post}</a>";
-          String repostUrl = "index.html?module=bb&op=posting&mode=repost&p=" + post.getId();
-          repostImgLnk = "<a href=\"" + repostUrl + "\"><img src=\"" + theme.resourceIconRepostURL +
-          "\" alt=\"${bb.Repost_post}\" title=\"${bb.Repost_post}\" border=\"0\"/></a>";
-          repostLnk = "<a href=\"" + repostUrl + "\">${bb.Repost_post}</a>";
-          }
-          */
-
-
-
-         boolean canDelete = false;
-         boolean canIP = false;
-
-         if (authMod)
-         {
-            canDelete = true;
-            canIP = true;
-         }
-         else
-         {
-            canDelete = authDelete
-               && poster.getUserName().equals(user.getUserName())
-               && topic.getLastPost().getId().equals(post.getId());
-         }
-
-         // only moderators can use the IP function on a given topic
-         if (canIP)
-         {
-            String url = "index.html?module=bb&op=modcp&mode=ip&p="
-               + post.getId() + "&t=" + topicId;
-
-            //            ipImgLnk = BBTools.createImageLink(url, theme.resourceIconIPURL, "${bb.View_IP}");
-            //            ipLnk = BBTools.createLink(url, "${bb.View_IP}");
-         }
-
-         Message message = post.getMessage();
-         String postSubject = message.getSubject();
-         if (postSubject == null)
-         {
-            postSubject = "";
-         }
-         String text = "";
-         if (message.getText() != null)
-         {
-            text = new String(message.getText());
-         }
-
-         PropertyMap upm = post.getPoster().getUser().getProperties();
-         String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
-         String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
-         if ((addsign != null) && (sign != null) && addsign.equals("1"))
-         {
-            text += "\n\n" + sign;
-         }
-
-         String signature = "";
-
-         /*
-         if (message.getSignatureEnabled() && signatureEnabled)
-         {
-         signature = poster.getSignature();
-         if (!BBTools.isNullOrBlank(signature))
-         {
-         signature = formatSignature(signature, message.getBBCodeEnabled(), message.getHTMLEnabled());
-         }
-         }
-         */
-         PortletPreferences pp = req.getPreferences();
-         //text = formatMessage(req, text, message.getBBCodeEnabled(), message.getHTMLEnabled());
-         text = formatMessage(req, text, message.getBBCodeEnabled(), pp.getValue("allowhtml", "1").equals("1"));
-         postSubject = formatTitle(req, postSubject);
-
-         //         //
-         //         // Highlight active words (primarily for search)
-         //         //
-         //         if ($highlight_match)
-         //         {
-         //            // This was shamelessly 'borrowed' from volker at multiartstudio dot de
-         //            // via php.net's annotated manual
-         //            $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
-         //         }
-         int editCount = post.getEditCount();
-         String editedBy = "";
-         if (editCount > 0)
-         {
-            //check is it one or more and prepare nice sentence
-            String[] ett = (editCount == 1) ? new String[]{
-               bundle.getString("Edited_time_total_0"),
-               bundle.getString("Edited_time_total_1"),
-               bundle.getString("Edited_time_total_2"),
-               bundle.getString("Edited_time_total_3")} : new String[]{
-               bundle.getString("Edited_times_total_0"),
-               bundle.getString("Edited_times_total_1"),
-               bundle.getString("Edited_times_total_2"),
-               bundle.getString("Edited_times_total_3")};
-
-            editedBy = "<br/><br/>" + ett[0] + poster.getUserName() + ett[1] + sdf.format(post.getEditDate()) + ett[2] + editCount + ett[3];
-         }
-
-         String rowColor = theme
-            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_color1"
-               : "td_color2");
-         String rowClass = theme
-            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_class1"
-               : "td_class2");
-
-         DelegateContext postRow = root.next("postrow");
-
-         postRow.put("ROW_COLOR", rowColor);
-         postRow.put("ROW_CLASS", rowClass);
-         postRow.put("POSTER_NAME", posterName);
-         if ((req.getRemoteUser() != null))
-         {
-            postRow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
-         }
-         postRow.put("POSTER_RANK", ""); // $poster_rank
-         postRow.put("RANK_IMAGE", ""); // $rank_image
-         postRow.put("POSTER_JOINED", posterJoined);
-
-         //         postRow.put("POSTER_POSTS", posterPosts);
-         postRow.put("POSTER_FROM", posterFrom);
-         postRow.put("POSTER_AVATAR", ""); // $poster_avatar
-         postRow.put("POST_DATE", postDate);
-         postRow.put("POST_SUBJECT", postSubject);
-         postRow.put("MESSAGE", text);
-         postRow.put("SIGNATURE", signature);
-         postRow.put("EDITED_MESSAGE", editedBy);
-         postRow.put("MINI_POST_IMG", miniPostImg);
-
-         postRow.put("PROFILE_IMG", profileImgLnk);
-         postRow.put("PROFILE", profileLnk);
-
-         //         postRow.put("SEARCH_IMG", searchImg);
-         //         postRow.put("SEARCH", search);
-         postRow.put("PM_IMG", pmImgLnk);
-         postRow.put("PM", pmLnk);
-         postRow.put("EMAIL_IMG", emailImgLnk);
-         postRow.put("EMAIL", emailLnk);
-         postRow.put("WWW_IMG", wwwImgLnk);
-         postRow.put("WWW", wwwLnk);
-         postRow.put("ICQ_STATUS_IMG", icqStatusImgLnk);
-         postRow.put("ICQ_IMG", icqImgLnk);
-         postRow.put("ICQ", icqLnk);
-         postRow.put("AIM_IMG", aimImgLnk);
-         postRow.put("AIM", aimLnk);
-         postRow.put("MSN_IMG", msnImgLnk);
-         postRow.put("MSN", msnLnk);
-         postRow.put("SKYPE_IMG", skypeImgLnk);
-         postRow.put("YIM_IMG", yimImgLnk);
-         postRow.put("YIM", yimLnk);
-         //postRow.put("EDIT_IMG", editImgLnk);
-         //postRow.put("EDIT", editLnk);
-         postRow.put("REPOST_IMG", repostImgLnk);
-         postRow.put("REPOST", repostLnk);
-
-         if (authPost)
-         {
-            PortletURL quoteURL = resp.createActionURL();
-            quoteURL.setParameter("mode", "quote");
-            quoteURL.setParameter("op", "posting");
-            quoteURL.setParameter("p", String.valueOf(post.getId()));
-            quoteURL.setParameter("f", String.valueOf(forum.getId()));
-
-            //String quoteUrl = "index.html?module=bb&op=posting&mode=quote&p=" + post.getID();
-            String quoteImg = ForumsTools.createImageLink(quoteURL.toString(),
-               theme.resourceIconQuoteURL, bundle
-               .getString("Reply_with_quote"));
-            String quote = ForumsTools.createLink(quoteURL.toString(), bundle
-               .getString("Reply_with_quote"));
-            postRow.put("QUOTE_IMG", quoteImg);
-            postRow.put("QUOTE", quote);
-         }
-
-         if (authMod)
-         {
-            PortletURL editURL = resp.createActionURL();
-            editURL.setParameter("mode", "editpost");
-            editURL.setParameter("op", "posting");
-            editURL.setParameter("p", String.valueOf(post.getId()));
-            editURL.setParameter("f", String.valueOf(forum.getId()));
-            //Set this param to inform posting() that it will be it's first call
-            editURL.setParameter("editPostInit", "true");
-            boolean firstTopicPost = false;
-            firstTopicPost |= post.getTopic().getFirstPost().getId().equals(post.getId());
-            editURL.setParameter("firstTopicPost", "" + firstTopicPost);
-            if (firstTopicPost)
-            {
-               editURL.setParameter("topictype", "" + post.getTopic().getType());
-            }
-            editURL.setParameter("subject", post.getMessage().getSubject());
-
-            String editImg = ForumsTools.createImageLink(editURL.toString(),
-               theme.resourceIconEditURL, bundle
-               .getString("Edit_Post"));
-            String edit = ForumsTools.createLink(editURL.toString(), bundle
-               .getString("Edit_Post"));
-            postRow.put("EDIT_IMG", editImg);
-            postRow.put("EDIT", edit);
-         }
-
-
-         postRow.put("IP_IMG", ipImgLnk);
-         postRow.put("IP", ipLnk);
-
-         // only moderators can delete all messages from a given topic
-         // if a user has the delete privilege on a forum that means he
-         // in this forum can delete his own posts
-         if (canDelete)
-         {
-            PortletURL deleteURL = resp.createActionURL();
-            deleteURL.setParameter("mode", "delete");
-            deleteURL.setParameter("op", "posting");
-            deleteURL.setParameter("p", "" + post.getId());
-
-            String delPostImgLnk = ForumsTools.createImageLink(deleteURL
-               .toString(), theme.resourceIconDelpostURL, bundle
-               .getString("Delete_post"));
-            String delPostLnk = ForumsTools.createLink(deleteURL.toString(),
-               bundle.getString("Delete_post"));
-            postRow.put("DELETE_IMG", delPostImgLnk);
-            postRow.put("DELETE", delPostLnk);
-         }
-
-         postRow.put("L_MINI_POST_ALT", miniPostAlt);
-
-         //         postRow.put("U_MINI_POST", miniPostUrl);
-         postRow.put("U_POST_ID", post.getId().toString());
-
-         //Here we display post attachments
-         List attachments = post.getAttachments();
-         DelegateContext attachDisplayCtx = null;
-         DelegateContext attachContext = null;
-         if (attachments.size() > 0)
-         {
-            attachDisplayCtx = postRow.next("attachments_display");
-            attachContext = attachDisplayCtx.next("attach");
-         }
-         //For every attachment we must create Token and place it in the AttachmentTokenManager
-         //to pass to DownloadServlet aggrement to download each.
-         AttachmentTokenManager atm = getAttachmentManager(req);
-         //Generate url to servlet
-         String hostURL = ((req.isSecure()) ? "https" : "http")
-            + "://"
-            + req.getServerName()
-            + ((req.getServerPort() == 80) ? "" : ":"
-            + req.getServerPort());
-         String servletURL = hostURL + req.getContextPath() + "/files?tokenId=";
-         for (Iterator i = attachments.iterator(); i.hasNext();)
-         {
-            Attachment attach = (Attachment)i.next();
-            //TODO:BD set some nice expire date (maybe in config)
-            Calendar c = Calendar.getInstance();
-            //15 minutes for downloading?
-            c.add(Calendar.MINUTE, 15);
-
-            AttachmentToken token = atm.createNewToken(attach.getId(), c.getTime());
-            atm.addToken(token);
-
-            if (attach.getFile().getContentType().startsWith("image/"))
-            {
-               //Date expireDate = newDate();
-               //expireDate.
-               DelegateContext catImagesContext = attachContext.next("cat_images");
-               catImagesContext.put("COMMENT", attach.getComment());
-               catImagesContext.put("DOWNLOAD_NAME", attach.getFile().getName());
-               catImagesContext.put("IMG_SRC", servletURL + token.getId());
-               catImagesContext.put("FILSIZE", "" + attach.getFile().getSize() / 1024 + "kB");
-               //catImagesContext.put("SIZE_VAR", "${bb.Bytes}");
-            }
-            else
-            {
-               DelegateContext attachRowContext = attachContext.next("attachrow");
-               attachRowContext.put("COMMENT", attach.getComment());
-               attachRowContext.put("DOWNLOAD_NAME", attach.getFile().getName());
-               attachRowContext.put("U_DOWNLOAD_LINK", servletURL + token.getId());
-               attachRowContext.put("FILESIZE", "" + attach.getFile().getSize() / 1024 + "kB");
-            }
-         }
-         //}
-         //attachments = theme.TPL_THEME_VIEWTOPIC_ATTACH_BODY.render(attachmentsContext);
-         //postRow.put("ATTACHMENTS", attachments);
-
-         //try
-         //{
-
-         /*File tmp = File.createTempFile(attach.getFile().getName(),"");
-     Blob blob = (Blob) attach.getFile().getContent();*/
-/*               OutputStream out = blob.();
-String fileName = "oraclejdbc.jar";
-File f = new File(fileName);
-FileInputStream fin = new FileInputStream(f);
-int count = -1, total = 0;
-byte[] data = new byte[(int)fin.available()];
-fin.read(data);
-out.write(data);
-fin.close();
-out.close();*/
-         // Get the image Blob from the database
-
-         /*InputStream in = null;
-         try
-         {
-            in = blob.getBinaryStream();
-                           BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(tmp) );
-
-byte by[] = new byte[ 32768 ];
-int index = in.read( by, 0, 32768 );
-while ( index != -1 )
-{
-out.write( by, 0, index );
-index = in.read( by, 0, 32768 );
-}
-out.flush();
-            System.out.println("Stored attachment into: " + tmp.getAbsolutePath());
-         }
-         catch (SQLException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         }*/
-
-         /*}
-         catch (IOException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         }*/
-         //}
-         /*
-         Collection attachmentsCollection = post.getAttachments();
-         String attachments = "";
-         DelegateContext attachmentsContext = new DelegateContext();
-         DelegateContext attachContext = attachmentsContext.next("attach");
-         Iterator i = attachmentsCollection.iterator();
-         AttachmentEJBLocal attachment = null;
-         while (i.hasNext())
-         {
-         attachment = (AttachmentEJBLocal)i.next();
-         if (attachment.getMimetype().startsWith("image/"))
-         {
-         DelegateContext catImagesContext = attachContext.next("cat_images");
-         catImagesContext.put("COMMENT", attachment.getComment());
-         catImagesContext.put("DOWNLOAD_NAME", attachment.getRealFilename());
-         catImagesContext.put("IMG_SRC", "modules/bb/attach?id=" + attachment.getId());
-         catImagesContext.put("FILESIZE", "" + attachment.getFilesize());
-         catImagesContext.put("SIZE_VAR", "${bb.Bytes}");
-         }
-         else
-         {
-         DelegateContext attachRowContext = attachContext.next("attachrow");
-         attachRowContext.put("COMMENT", attachment.getComment());
-         attachRowContext.put("DOWNLOAD_NAME", attachment.getRealFilename());
-         attachRowContext.put("U_DOWNLOAD_LINK", "modules/bb/attach?id=" + attachment.getId());
-         attachRowContext.put("FILESIZE", attachment.getFilesize() + " ${bb.Bytes}");
-         }
-         }
-         attachments = theme.TPL_THEME_VIEWTOPIC_ATTACH_BODY.render(attachmentsContext);
-         postRow.put("ATTACHMENTS", attachments);
-         */
-      }
-
-      return root;
-   }
-
-   private DelegateContext fillShowAddEditForumContext(JBossRenderRequest req,
-                                                       JBossRenderResponse resp, DelegateContext root)
-   {
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-
-      String mode = req.getParameters().get("mode", "");
-
-      // default values for addforum case, miss only the forum name which is calculated under
-      String title = bundle.getString("Create_forum");
-      String newMode = "createforum";
-      String buttonValue = bundle.getString("Create_forum");
-      String forumName = "";
-      String forumDesc = "";
-      int forumStatus = FORUM_UNLOCKED;
-      int forumId = -1;
-      int categoryId = -1;
-      String pruneEnabled = "";
-
-      if ("editforum".equals(mode))
-      {
-         // if edit forum, we override the addforum values
-         title = bundle.getString("Edit_forum");
-         newMode = "modforum";
-         buttonValue = bundle.getString("Update");
-         try
-         {
-            Forum forum = forumsModule.findForumById(req.getParameters()
-               .getIntObject("f"));
-            forumId = forum.getId().intValue();
-            categoryId = forum.getCategory().getId().intValue();
-            forumName = forum.getName();
-            forumDesc = forum.getDescription();
-            forumStatus = forum.getStatus();
-
-            /*
-             if (forum.getPruneEnable())
-             {
-             pruneEnabled = "checked=\"checked\"";
-             //                  $sql = "SELECT *
-             //                           FROM " . PRUNE_TABLE . "
-             //                           WHERE forum_id = $forum_id";
-             //                  if(!$pr_result = $db->sql_query($sql))
-             //                  {
-             //                      message_die(GENERAL_ERROR, "Auto-Prune: Couldn't read auto_prune table.", __LINE__, __FILE__);
-             //                    }
-             //                  $pr_row = $db->sql_fetchrow($pr_result);
-             }
-             */
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();
-
-            //            Die.exit(GENERAL_ERROR, "Couldn't get Forum/Category information", e);
-         }
-      }
-      else
-      {
-         categoryId = req.getParameters().getInt("c", -1);
-
-         // for the addforum mode we setup the forum name
-         forumName = req.getParameter("forumname_" + categoryId);
-      }
-
-      String forumLocked = "";
-      String forumUnlocked = "selected=\"selected\"";
-      if (forumStatus == FORUM_LOCKED)
-      {
-         forumLocked = forumUnlocked;
-         forumUnlocked = "";
-      }
-
-      String catList;
-      try
-      {
-         catList = ForumsTools.listCategories(forumsModule.findCategories(),
-            categoryId);
-         root.put("S_CAT_LIST", catList);
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-
-      String statusList = "<option value=\"" + FORUM_UNLOCKED + "\" "
-         + forumUnlocked + ">" + bundle.getString("Status_unlocked")
-         + "</option>\n" + "<option value=\"" + FORUM_LOCKED + "\" "
-         + forumLocked + ">" + bundle.getString("Status_locked")
-         + "</option>\n";
-      String hiddenFields = "<input type=\"hidden\" name=\"mode\" value=\""
-         + newMode + "\"/>" + "<input type=\"hidden\" name=\"f\" value=\""
-         + forumId + "\"/>"
-         + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
-         + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>";
-
-      PortletURL postURL = resp.createActionURL();
-      root.put("POST_URL", postURL.toString());
-      root.put("S_HIDDEN_FIELDS", hiddenFields);
-      root.put("S_SUBMIT_VALUE", buttonValue);
-      root.put("S_STATUS_LIST", statusList);
-      root.put("S_PRUNE_ENABLED", pruneEnabled);
-      root.put("L_FORUM_TITLE", title);
-      root.put("PRUNE_DAYS", "TODO_PRUNE_DAYS"); // ( isset($pr_row['prune_days']) ) ? $pr_row['prune_days'] : 7
-      root.put("PRUNE_FREQ", "TODO_PRUNE_FREQ"); // ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1
-      root.put("FORUM_NAME", forumName);
-      root.put("DESCRIPTION", forumDesc);
-
-      return root;
-   }
-
-   private DelegateContext fillShowAdminForumsContext(JBossRenderRequest req,
-                                                      JBossRenderResponse resp, DelegateContext root)
-   {
-      String mode = req.getParameters().get("mode", "");
-      boolean addCategory = req.getParameter("addcategory") != null;
-      Category addforum = null;
-
-      try
-      {
-         for (Iterator i = forumsModule.findCategories().iterator(); i
-            .hasNext();)
-         {
-            Category category = (Category)i.next();
-            if (req.getParameter("addforum_" + category.getId()) != null)
-            {
-               addforum = category;
-               break;
-            }
-         }
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-
-         //            Die.exit(GENERAL_ERROR, "Cannot process command", e);
-      }
-
-      if ((addforum != null) || addCategory)
-      {
-         if (addforum != null)
-         {
-            mode = "addforum";
-         }
-         else
-         {
-            mode = "addcat";
-         }
-      }
-
-      try
-      {
-         PortletURL postURL = resp.createActionURL();
-         postURL.setParameters(req.getParameterMap());
-         postURL.setParameter("op", "admin_forums");
-         root.put("POST_URL", postURL.toString());
-         for (Iterator i = forumsModule.findCategories().iterator(); i
-            .hasNext();)
-         {
-            Category category = (Category)i.next();
-            Integer categoryId = category.getId();
-
-            DelegateContext catrow = root.next("catrow");
-            catrow.put("S_ADD_FORUM_SUBMIT", "addforum_" + categoryId);
-            catrow.put("S_ADD_FORUM_NAME", "forumname_" + categoryId);
-            catrow.put("CAT_ID", categoryId.toString());
-            catrow.put("CAT_DESC", category.getTitle());
-            PortletURL categoryEditURL = resp.createActionURL();
-            categoryEditURL.setParameter("op", "admin_forums");
-            categoryEditURL.setParameter("mode", "editcat");
-            categoryEditURL.setParameter("c", "" + categoryId);
-            categoryEditURL.setParameter(POST_CAT_URL, "" + categoryId);
-            catrow.put("U_CAT_EDIT", categoryEditURL.toString());
-            PortletURL categoryDeleteURL = resp.createActionURL();
-            categoryDeleteURL.setParameter("op", "admin_forums");
-            categoryDeleteURL.setParameter("mode", "deletecat");
-            categoryDeleteURL.setParameter(POST_CAT_URL, "" + categoryId);
-            catrow.put("U_CAT_DELETE", categoryDeleteURL.toString());
-            PortletURL catMoveUp = resp.createActionURL();
-            catMoveUp.setParameter("op", "admin_forums");
-            catMoveUp.setParameter("mode", "cat_order");
-            catMoveUp.setParameter("move", "-15");
-            catMoveUp.setParameter(POST_CAT_URL, "" + categoryId);
-            catrow.put("U_CAT_MOVE_UP", catMoveUp.toString());
-            PortletURL catMoveDown = resp.createActionURL();
-            catMoveDown.setParameter("op", "admin_forums");
-            catMoveDown.setParameter("mode", "cat_order");
-            catMoveDown.setParameter("move", "15");
-            catMoveDown.setParameter(POST_CAT_URL, "" + categoryId);
-            catrow.put("U_CAT_MOVE_DOWN", catMoveDown.toString());
-            PortletURL categoryViewURL = resp.createRenderURL();
-            categoryViewURL.setParameter("op", OP_MAIN);
-            categoryViewURL.setParameter(POST_CAT_URL, "" + categoryId);
-            catrow.put("U_VIEWCAT", categoryViewURL.toString());
-
-            for (Iterator j = forumsModule.findForumsByCategoryId(categoryId)
-               .iterator(); j.hasNext();)
-            {
-               Forum forum = (Forum)j.next();
-               Integer forumId = forum.getId();
-               DelegateContext forumrow = catrow.next("forumrow");
-               forumrow.put("FORUM_NAME", forum.getName());
-               forumrow.put("FORUM_DESC", forum.getDescription());
-               forumrow.put("ROW_COLOR'", "$row_color");
-               forumrow.put("NUM_TOPICS", "" + forum.getTopicCount());
-               forumrow.put("NUM_POSTS", "" + forum.getPostCount());
-               PortletURL viewForumURL = resp.createRenderURL();
-               viewForumURL.setParameter(getOperationName(), OP_SHOWFORUM);
-               viewForumURL.setParameter("f", "" + forumId);
-               forumrow.put("U_VIEWFORUM", viewForumURL.toString());
-               PortletURL forumEditURL = resp.createActionURL();
-               forumEditURL.setParameter("op", "admin_forums");
-               forumEditURL.setParameter("mode", "editforum");
-               forumEditURL.setParameter("f", "" + forumId);
-               forumrow.put("U_FORUM_EDIT", forumEditURL.toString());
-               PortletURL forumDeleteURL = resp.createActionURL();
-               forumDeleteURL.setParameter("op", "admin_forums");
-               forumDeleteURL.setParameter("mode", "deleteforum");
-               forumDeleteURL.setParameter("f", "" + forumId);
-               forumrow.put("U_FORUM_DELETE", forumDeleteURL.toString());
-               PortletURL forumMoveUpURL = resp.createActionURL();
-               forumMoveUpURL.setParameter("op", "admin_forums");
-               forumMoveUpURL.setParameter("mode", "forum_order");
-               forumMoveUpURL.setParameter("move", "-15");
-               forumMoveUpURL.setParameter("f", "" + forumId);
-               forumrow.put("U_FORUM_MOVE_UP", forumMoveUpURL.toString());
-               PortletURL forumMoveDownURL = resp.createActionURL();
-               forumMoveDownURL.setParameter("op", "admin_forums");
-               forumMoveDownURL.setParameter("mode", "forum_order");
-               forumMoveDownURL.setParameter("move", "15");
-               forumMoveDownURL.setParameter("f", "" + forumId);
-               forumrow.put("U_FORUM_MOVE_DOWN", forumMoveDownURL.toString());
-
-               /*
-                PortletURL forumResyncURL = resp.createActionURL();
-                forumResyncURL.setParameter("op", "admin_forums");
-                forumResyncURL.setParameter("mode", "forum_sync");
-                forumResyncURL.setParameter("f", "" + forumId);
-                forumrow.put("U_FORUM_RESYNC", forumResyncURL.toString());
-                */
-            }
-         }
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-
-         //            Die.exit(GENERAL_ERROR, "Could not query categories list");
-      }
-
-      //         display(theme.TPL_THEME_ADMIN_FORUM_ADMIN_BODY, root, page);
-      return root;
-   }
-
-   private DelegateContext fillShowModerateForumContext(JBossRenderRequest req,
-                                                        JBossRenderResponse resp, DelegateContext root)
-   {
-      //System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
-      //System.out.println("fillModerateForumContext()");
-      ResourceBundle bundle = getResourceBundle(req.getLocale());
-
-      int topicsPerPage = Integer.parseInt(req.getPreferences().getValue("topicsperforum", "10"));
-      int hotThreshold = 10;
-      int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
-      Integer forumId = req.getParameters().getIntObject("f", -1);
-      int start = req.getParameters().getInt("start", 0);
-
-      //      String markRead = page.getParameter("mark", "");
-      int topicDays = req.getParameters().getInt("topicdays", 0);
-
-      Forum forum = null;
-      try
-      {
-         forum = forumsModule.findForumById(forumId);
-      }
-      catch (ModuleException e1)
-      {
-         // TODO Auto-generated catch block
-         e1.printStackTrace();
-      }
-
-      Category category = forum.getCategory();
-      User user = req.getUser();
-      boolean loggedIn = req.getRemoteUser() != null;
-
-      String categoryTitle = category.getTitle();
-      String forumName = forum.getName();
-
-      String[] testArray = new String[]{categoryTitle, forumName};
-      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum");
-      if (!authMod)
-      {
-         System.out.println("You are not authorized to moderate this forum");
-         return root;
-      }
-
-      Date minTopicTime = null;
-      if (topicDays > 0)
-      {
-         Calendar c = Calendar.getInstance();
-         c.add(Calendar.DATE, -topicDays);
-         minTopicTime = c.getTime();
-      }
-      else
-      {
-         topicDays = 0;
-      }
-
-      List announcements = null;
-      List topics = null;
-
-      try
-      {
-         announcements = forumsModule.findAnnouncements(forum);
-         topics = (minTopicTime == null) ? forumsModule.findTopicsDesc(forum,
-            POST_ANNOUNCE, start, topicsPerPage) : forumsModule
-            .findTopicsBefore(forum, POST_ANNOUNCE, start, topicsPerPage,
-               minTopicTime);
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-
-      int totalTopicsAndStickies = forum.getTopicCount();
-
-
-      StringBuffer authCan = new StringBuffer();
-
-      Iterator ci = new CompoundIterator(new Iterator[]{
-         announcements.iterator(), topics.iterator()});
-
-
-      PortletURL gotoURL = resp.createRenderURL();
-      gotoURL.setParameter("op", OP_SHOWTOPIC);
-      Goto toPost = new Goto(postsPerPage, bundle.getString("Goto_page"), gotoURL.toString());
-      toPost.setImgUrl(theme.resourceIconGotopostURL);
-      int row_index = 0;
-      for (IndexIterator iterator = IndexIterator.wrap(ci, -1); iterator
-         .hasNext(); row_index++)
-      {
-
-         Topic topic = (Topic)iterator.next();
-
-         int replies = topic.getReplies();
-         int status = topic.getStatus();
-         /*Integer topicId = (status == TOPIC_MOVED) ? topic.getTarget().getID()
-                 : topic.getID();*/
-         Integer topicId = topic.getId();
-         String type = bundle.getString("Topic_Moved");
-         String folderImage = theme.resourceFolderURL;
-         String folderAlt = bundle.getString("Topic_Moved");
-         String newestPostImg = "";
-         /*Date topicLastPostDate = (topic.getLastPost()!=null) ? topic.getLastPost().getCreateDate() : null;*/
-         Post firstPost = topic.getFirstPost();
-         Post lastPost = topic.getLastPost();
-         /*Poster lastPostUser = lastPost.getPoster();
-         Poster poster = topic.getPoster();*/
-
-         if (status != TOPIC_MOVED)
-         {
-            FolderType folderType = theme.getFolderType(topic.getType(),
-               status, replies >= hotThreshold);
-            boolean newest = loggedIn;
-
-            if (newest)
-            {
-               folderImage = folderType.folderNew;
-               folderAlt = (status == TOPIC_LOCKED) ? bundle
-                  .getString("Topic_locked") : bundle.getString("New_posts");
-               /*newestPostImg = "<a href=\"index.html?module=bb&op=viewtopic&t="
-                       + topicId + "&view=newest\"><img src=\""
-                       + theme.resourceIconNewestReplyURL + "\" alt=\""
-                       + bundle.getString("View_newest_post") + "\" title=\""
-                       + bundle.getString("View_newest_post")
-                       + "\" border=\"0\"/></a>";*/
-            }
-            else
-            {
-               folderImage = folderType.folder;
-               folderAlt = (status == TOPIC_LOCKED) ? bundle
-                  .getString("Topic_locked") : bundle
-                  .getString("No_new_posts");
-               newestPostImg = "";
-            }
-
-            try
-            {
-               type = bundle.getString(folderType.type);
-            }
-            catch (java.util.MissingResourceException e)
-            {
-               type = "";
-            }
-
-         }
-
-         toPost.setPostSize(replies);
-         toPost.setTopicId(topicId.intValue());
-         String gotoPage = toPost.generate();
-         String topicAuthor = firstPost.getPoster().getUser().getUserName();
-         String lastPostAuthor = lastPost.getPoster().getUser().getUserName();
-
-         PortletURL lastPostURL = resp.createRenderURL();
-         lastPostURL.setParameter("op", OP_SHOWTOPIC);
-         lastPostURL.setParameter("p", "" + lastPost.getId());
-
-         String lastPostUrl = "<a href=\"" + lastPostURL.toString() + "\">"
-            + "<img src=\"" + theme.resourceIconLatestReplyURL + "\" alt=\""
-            + bundle.getString("View_latest_post") + "\" title=\""
-            + bundle.getString("View_latest_post") + "\" border=\"0\"/></a>";
-
-         DelegateContext topicrow = root.next("topicrow");
-         topicrow.put("TOPIC_ROW_INDEX", "" + row_index);
-         topicrow.put("FORUM_ID", forumId.toString());
-         topicrow.put("TOPIC_ID", topicId.toString());
-         topicrow.put("TOPIC_FOLDER_IMG", folderImage);
-         topicrow.put("TOPIC_AUTHOR", topicAuthor);
-         topicrow.put("GOTO_PAGE", gotoPage);
-         topicrow.put("REPLIES", "" + replies);
-         //topicrow.put("NEWEST_POST_IMG", newestPostImg);
-         topicrow.put("NEWEST_POST_IMG", lastPostUrl);
-         topicrow.put("TOPIC_TITLE", formatTitle(req, topic.getSubject()));
-         topicrow.put("TOPIC_TYPE", type);
-         SimpleDateFormat sdfp = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
-         topicrow.put("LAST_POST_TIME", sdfp.format(topic.getLastPostDate()));
-
-         if ((req.getRemoteUser() != null))
-         {
-            PortletURL userProfileURL = resp.createRenderURL();
-            userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
-            userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
-            topicrow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
-         }
-         topicrow.put("LAST_POST_AUTHOR", lastPostAuthor);
-         topicrow.put("LAST_POST_IMG", lastPostUrl);
-         topicrow.put("L_TOPIC_FOLDER_ALT", folderAlt);
-         PortletURL viewTopicURL = resp.createRenderURL();
-         viewTopicURL.setParameter("op", OP_SHOWTOPIC);
-         viewTopicURL.setParameter("t", "" + topicId);
-         topicrow.put("U_VIEW_TOPIC", viewTopicURL.toString());
-      }
-
-
-      PortletURL moderateActionURL = resp.createActionURL();
-      moderateActionURL.setParameter(getOperationName(), "moderate_forum");
-      moderateActionURL.setParameter("f", "" + forumId);
-      root.put("S_POST_DAYS_ACTION", moderateActionURL.toString());
-      //root.put("FORUM_ID", forum.getID().toString());
-
-      //forum link on top of view
-      root.put("FORUM_NAME", forum.getName());
-
-      PortletURL viewForumURL = resp.createRenderURL();
-      viewForumURL.setParameter("op", OP_SHOWFORUM);
-      viewForumURL.setParameter("f", "" + forumId);
-      root.put("U_VIEW_FORUM", viewForumURL.toString());
-
-      //URL to go to moderate forum with specific page
-      PortletURL pageNavigationURL = resp.createRenderURL();
-      pageNavigationURL.setParameter("op", OP_SHOWMODERATEFORUM);
-      pageNavigationURL.setParameter("f", "" + forumId);
-      pageNavigationURL.setParameter("topicDays", "" + topicDays);
-
-      //generate Page nav bar
-      GotoWithOffset toForum = new GotoWithOffset(totalTopicsAndStickies,
-         start, topicsPerPage, pageNavigationURL + "&start=", bundle
-         .getString("Goto_page"), bundle.getString("Previous"), bundle
-         .getString("Next"));
-
-      String pageNumber = bundle.getString("Page_of_0")
-         + ((int)Math.floor((double)start / topicsPerPage) + 1)
-         + bundle.getString("Page_of_1")
-         + ((int)Math.ceil((double)totalTopicsAndStickies / topicsPerPage));
-      //page nav bar
-      root.put("PAGE_NUMBER", pageNumber.toString());
-      root.put("PAGINATION", toForum.generate());
-
-      //      root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
-      return root;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param req  DOCUMENT_ME
-    * @param resp DOCUMENT_ME
-    */
-   public void forum_watches(JBossActionRequest req, JBossActionResponse resp)
-   {
-      try
-      {
-         if (req.getParameters().getParameterExists("watch"))
-         {
-            Integer id = req.getParameters().getIntObject("forum_id", -1);
-            boolean linked = "linked".equals(req.getParameter("watch_mode"));
-            Forum forum = forumsModule.findForumById(id);
-            Poster poster = forumsModule.findPosterByUserId(req.getUser()
-               .getId().toString());
-            String[] test = new String[]{forum.getCategory().getTitle(),
-               forum.getName()};
-            if (ForumsTools.hasPermission(req, test, "ReadForum"))
-            {
-               if (poster == null)
-               {
-                  poster = forumsModule.createPoster(req.getUser().getId().toString());
-               }
-               forumsModule.createWatch(poster, forum,
-                  linked ? ForumsConstants.WATCH_MODE_LINKED
-                     : ForumsConstants.WATCH_MODE_EMBEDED);
-            }
-         }
-         else if (req.getParameters().getParameterExists("update"))
-         {
-            Integer forumWatchId = req.getParameters().getIntObject("forumwatch_id", -1);
-            boolean linked = "linked".equals(req.getParameter("watch_mode"));
-            ForumWatch watch = forumsModule.findForumWatchById(forumWatchId);
-            watch.setMode(linked ? ForumsConstants.WATCH_MODE_LINKED
-               : ForumsConstants.WATCH_MODE_EMBEDED);
-         }
-         else if (req.getParameters().getParameterExists("unwatch"))
-         {
-            Integer forumWatchId = req.getParameters().getIntObject("forumwatch_id", -1);
-            ForumWatch watch = forumsModule.findForumWatchById(forumWatchId);
-            forumsModule.removeWatch(watch);
-         }
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param req  DOCUMENT_ME
-    * @param resp DOCUMENT_ME
-    */
-   public void topic_watches(JBossActionRequest req, JBossActionResponse resp)
-   {
-      try
-      {
-         Integer topicWatchId = req.getParameters().getIntObject("topicwatch_id", -1);
-         TopicWatch watch = forumsModule.findTopicWatchById(topicWatchId);
-         forumsModule.removeWatch(watch);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   private DelegateContext fillShowWatchedForums(JBossRenderRequest req,
-                                                 JBossRenderResponse resp, DelegateContext root)
-   {
-      Set forumIds = new HashSet();
-      Collection watches;
-      try
-      {
-         watches = forumsModule.findForumWatchByUser(req.getUser());
-         if (watches.size() > 0)
-         {
-            root.next("switch_watched_forums_block");
-            for (IndexIterator i = IndexIterator.wrap(watches.iterator()); i
-               .hasNext();)
-            {
-               ForumWatch watch = (ForumWatch)i.next();
-               Forum forum = watch.getForum();
-
-               // See if the user is authorized
-               Category category = forum.getCategory();
-               String[] test = new String[]{category.getTitle(),
-                  forum.getName()};
-               if (ForumsTools.hasPermission(req, test, "ReadForum"))
-               {
-                  boolean linked = watch.getMode() == ForumsConstants.WATCH_MODE_LINKED;
-                  Integer forumId = forum.getId();
-                  forumIds.add(forumId);
-                  String forumIdAsString = forumId.toString();
-                  PortletURL viewForumURL = resp.createRenderURL();
-                  viewForumURL.setParameter("op", OP_SHOWFORUM);
-                  viewForumURL.setParameter("f", forumIdAsString);
-                  root
-                     .next("forum_watch_row")
-                     .put("ROW_CLASS",
-                        theme
-                           .getProperty(((i.getIndex() & 1) == 0) ? "td_class1"
-                           : "td_class2")).put("U_FORUM_LINK",
-                     viewForumURL.toString()).put("FORUMWATCH_ID",
-                     watch.getId()).put("FORUM_ID", forumIdAsString)
-                     .put("S_FORUM_TITLE", forum.getName()).put("LINKED",
-                     linked ? "checked=\"checked\"" : "").put("EMBEDED", linked ? "" : "checked=\"checked\"");
-               }
-            }
-         }
-         else
-         {
-            root.next("switch_no_watched_forums");
-         }
-
-         StringBuffer select = new StringBuffer("<select name=\"forum_id\"><option value=\"\"></option>");
-         Collection forums = forumsModule.findForums();
-         for (Iterator i = forums.iterator(); i.hasNext();)
-         {
-            Forum forum = (Forum)i.next();
-
-            // Get the forum level
-            Category category = forum.getCategory();
-            String[] test = new String[]{category.getTitle(), forum.getName()};
-
-            // Display it only if the user is authorized
-            if (ForumsTools.hasPermission(req, test, "ReadForum"))
-            {
-               Integer forumid = forum.getId();
-               if (!forumIds.contains(forumid))
-               {
-                  select.append("<option value=\"").append(forum.getId())
-                     .append("\">").append(forum.getName()).append("</option>");
-               }
-            }
-         }
-
-         select.append("</select>");
-         root.put("S_FORUM_WATCH_SELECT", select.toString());
-
-         //         display(theme.TPL_THEME_WATCHED_FORUMS_BODY, root, page);
-         //      }
-         //      catch(Exception e)
-         //      {
-         //         Die.rollback(GENERAL_ERROR, "Could not obtain watch forum information");
-         //      }
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-
-      return root;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param text DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public String formatTitle(PortletRequest req, String text)
-   {
-      StringWriter stringWriter = new StringWriter();
-      getToHTMLRenderer(req).setWriter(stringWriter);
-
-      getToHTMLRenderer(req).render(text.toCharArray(), 0, text.length());
-      return stringWriter.toString();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param text        DOCUMENT_ME
-    * @param allowBBCode DOCUMENT_ME
-    * @param allowHTML   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public String formatMessage(PortletRequest req, String text, boolean allowBBCode, boolean allowHTML)
-   {
-      if (allowHTML)
-      {
-         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_ALWAYS_PRINT);
-         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
-      }
-      else
-      {
-         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_NEVER_PRINT);
-         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
-      }
-      return formatTitle(req, text);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param text        DOCUMENT_ME
-    * @param allowBBCode DOCUMENT_ME
-    * @param allowHTML   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public String formatSignature(PortletRequest req, String text, boolean allowBBCode, boolean allowHTML)
-   {
-      if (allowHTML)
-      {
-         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_ALWAYS_PRINT);
-         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
-      }
-      else
-      {
-         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_NEVER_PRINT);
-         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
-      }
-      return "<br/>_________________<br/>" + formatTitle(req, text);
-   }
-
-
-   /**
-    *
-    */
-   public String formatUserName(User user)
-   {
-      return user.getUserName();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param cmd DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws CommandException DOCUMENT_ME
-    */
-   public Result executeForumCommand(JBossActionRequest request,
-                                     JBossActionResponse response, ForumCommand cmd)
-      throws CommandException
-   {
-      // Finish the command configuration
-      cmd.setModule(forumsModule);
-
-      //      cmd.setHomes(homesRW);
-      // Execute the command
-      return forumsModule.invoke(cmd);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param resp  DOCUMENT_ME
-    * @param key   DOCUMENT_ME
-    * @param error DOCUMENT_ME
-    */
-   public void addErrorMessage(JBossActionResponse resp, String key,
-                               String error)
-   {
-      resp.setRenderParameter(key.toLowerCase() + "_error", error);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param resp    DOCUMENT_ME
-    * @param key     DOCUMENT_ME
-    * @param success DOCUMENT_ME
-    */
-   public void addSuccessMessage(JBossActionResponse resp, String key,
-                                 String success)
-   {
-      resp.setRenderParameter(key.toLowerCase() + "_success", success);
-   }
-
-   /**
-    * Get a <code>SimpleDateFormat</code> object from the session. The object is stored
-    * in the session because it is expensive to create and we want to reuse it as
-    * much as we can. Also it is configured with the date format taken from the preference
-    * of the user if it exists.
-    *
-    * @param req the request that maybe contains the format object
-    * @return the format object
-    */
-   public SimpleDateFormat getSDF(PortletRequest req)
-   {
-      // Get the pattern
-      String pattern = req.getPreferences().getValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
-
-      // Get the simple date format if it exists
-      SimpleDateFormat sdf = (SimpleDateFormat)req.getPortletSession().getAttribute("SDF");
-
-      // Do we have it ?
-      if (sdf == null)
-      {
-         // Create a new one
-         sdf = new SimpleDateFormat(pattern, req.getLocale());
-
-         // Put it in the session
-         req.getPortletSession().setAttribute("SDF", sdf);
-      }
-      else
-      {
-         // Check if config has not changed
-         if (!sdf.toPattern().equals(pattern))
-         {
-            sdf.applyPattern(pattern);
-         }
-      }
-      return sdf;
-   }
-
-   private ToHTMLRenderer getToHTMLRenderer(PortletRequest req)
-   {
-      ToHTMLRenderer renderer = (ToHTMLRenderer)req.getPortletSession().getAttribute("RENDERER");
-      if (renderer == null)
-      {
-         // Create the HTMLRenderer for BBCode
-         ToHTMLConfig config = new ToHTMLConfig();
-         config.setLoader(loader);
-         Locale locale = req.getLocale();
-         ResourceBundle bundle = getPortletConfig().getResourceBundle(locale);
-         renderer = new ToHTMLRenderer(config, bundle);
-         req.getPortletSession().setAttribute("RENDERER", renderer);
-      }
-      return renderer;
-   }
-
-   public AttachmentTokenManager getAttachmentManager(PortletRequest req)
-   {
-      // Get the simple date format if it exists
-      AttachmentTokenManager atm = (AttachmentTokenManager)req.getPortletSession().getAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER, PortletSession.APPLICATION_SCOPE);
-
-      // Do we have it ?
-      if (atm == null)
-      {
-         // Create a new one
-         atm = new AttachmentTokenManager();
-         // Put it in the session
-         req.getPortletSession().setAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER, atm, PortletSession.APPLICATION_SCOPE);
-      }
-      else
-      {
-         //what else?
-      }
-      return atm;
-   }
-
-
-
-
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums;
+
+
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.result.ResultType;
+import org.jboss.portal.common.context.DelegateContext;
+import org.jboss.portal.common.util.ProxyInfo;
+import org.jboss.portal.identity.PropertyMap;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.core.servlet.jsp.PortalJsp;
+import org.jboss.portal.format.render.bbcodehtml.ToHTMLConfig;
+import org.jboss.portal.format.render.bbcodehtml.ToHTMLRenderer;
+import org.jboss.portal.format.util.CLLoader;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portlet.JBossPortlet;
+import org.jboss.portlet.JBossRenderRequest;
+import org.jboss.portlet.JBossRenderResponse;
+import org.jboss.portlet.forums.action.Action;
+import org.jboss.portlet.forums.action.EditPostAction;
+import org.jboss.portlet.forums.action.ForumAction;
+import org.jboss.portlet.forums.action.NewTopicAction;
+import org.jboss.portlet.forums.action.PostAction;
+import org.jboss.portlet.forums.action.ProcessCommandAction;
+import org.jboss.portlet.forums.action.ReplyAction;
+import org.jboss.portlet.forums.action.TopicAction;
+import org.jboss.portlet.forums.commands.CommandConstants;
+import org.jboss.portlet.forums.commands.admin.CreateCategoryCommand;
+import org.jboss.portlet.forums.commands.admin.CreateForumCommand;
+import org.jboss.portlet.forums.commands.admin.DeleteForumCommand;
+import org.jboss.portlet.forums.commands.admin.DeleteMoveCategoryCommand;
+import org.jboss.portlet.forums.commands.admin.DeleteMoveForumCommand;
+import org.jboss.portlet.forums.commands.admin.OrderCategoryCommand;
+import org.jboss.portlet.forums.commands.admin.OrderForumCommand;
+import org.jboss.portlet.forums.commands.admin.UpdateCategoryCommand;
+import org.jboss.portlet.forums.commands.admin.UpdateForumCommand;
+import org.jboss.portlet.forums.commands.moderation.DeleteTopicCommand;
+import org.jboss.portlet.forums.commands.moderation.LockTopicCommand;
+import org.jboss.portlet.forums.commands.moderation.MoveTopicCommand;
+import org.jboss.portlet.forums.commands.moderation.SplitTopicCommand;
+import org.jboss.portlet.forums.commands.post.DeletePostCommand;
+import org.jboss.portlet.forums.commands.post.EditPostCommand;
+import org.jboss.portlet.forums.commands.post.ForumCommand;
+import org.jboss.portlet.forums.commands.post.NewTopicCommand;
+import org.jboss.portlet.forums.commands.post.ReplyCommand;
+import org.jboss.portlet.forums.helper.ForumsTools;
+import org.jboss.portlet.forums.helper.Goto;
+import org.jboss.portlet.forums.helper.GotoWithOffset;
+import org.jboss.portlet.forums.helper.IndexIterator;
+import org.jboss.portlet.forums.helper.FileBinding;
+import org.jboss.portlet.forums.helper.AttachmentTokenManager;
+import org.jboss.portlet.forums.helper.AttachmentToken;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.ForumWatch;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Poll;
+import org.jboss.portlet.forums.model.PollOption;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Poster;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.TopicWatch;
+import org.jboss.portlet.forums.model.Attachment;
+import org.jboss.portlet.forums.properties.TCCLXProperties;
+import org.jboss.portlet.forums.theme.FolderType;
+import org.jboss.portlet.forums.theme.ForumsTheme;
+import org.jboss.util.collection.CompoundIterator;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletURL;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import javax.portlet.PortletSession;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.37 $
+ */
+public class ForumsPortlet
+   extends JBossPortlet
+   implements ForumsConstants
+{
+   // private ForumsModule forumsModule;
+
+   private final String OP_MAIN = "main";
+
+   public static final String OP_SHOWFORUM = "showForum";
+
+   private final String OP_POSTING = "showPosting";
+
+   public final static String OP_SHOWTOPIC = "showTopic";
+
+   public static final String OP_SHOWADMINFORUMS = "showAdminForums";
+
+   public static final String OP_SHOWMODERATEFORUM = "showModerateForum";
+
+   public static final String OP_SHOWMOVETOPIC = "showMoveTopic";
+
+   public static final String OP_SHOWODELETETOPIC = "showDeleteTopic";
+
+   public static final String OP_SHOWSPLITTOPIC = "showSplitTopic";
+
+   public static final String OP_SHOWUSERPROFILE = "showUserProfile";
+
+   private final String OP_SHOWADDEDITFORUM = "showAddEditForum";
+
+   private final String OP_SHOWEDITCATEGORY = "showEditCategory";
+
+   private final String OP_SHOWDELETEFORUM = "showDeleteForum";
+
+   private final String OP_CONFIRM = "showConfirm";
+
+   private final String OP_SHOWWATCHEDTOPICS = "showWatchedTopics";
+
+   private final String OP_SHOWWATCHEDFORUMS = "showWatchedForums";
+
+   private ForumsTheme theme;
+
+   private ProxyInfo proxyInfo;
+
+   private CLLoader loader;
+
+   private ForumsModule forumsModule;
+
+   /**
+    * Initialization method of the portlet
+    *
+    * @throws PortletException DOCUMENT_ME
+    */
+   public void init() throws PortletException
+   {
+      super.init();
+
+      try
+      {
+         forumsModule = (ForumsModule)new InitialContext().lookup("java:portal/ForumsModule");
+         getPortletContext().setAttribute("forumsModule", forumsModule);
+      }
+      catch (NamingException e)
+      {
+         throw new PortletException(e);
+      }
+
+      /*
+       try
+       {
+       userModule = (UserModule) new InitialContext()
+       .lookup(ModuleConstants.USERMODULE_JNDINAME);
+       roleModule = (RoleModule) new InitialContext()
+       .lookup(ModuleConstants.ROLEMODULE_JNDINAME);
+       }
+       catch (NamingException e)
+       {
+       throw new PortletException(e);
+       }
+       */
+      // Start the theme
+      theme = new ForumsTheme();
+      try
+      {
+         // start theme
+         theme.setExtendedProperties(new TCCLXProperties(ForumsConstants.THEMENAME, "theme.properties"));
+         theme.start();
+      }
+      catch (IOException e)
+      {
+         throw new PortletException("Cannot start the forums theme, can't read template files", e);
+      }
+      catch (Exception e)
+      {
+         throw new PortletException("Cannot start the forums theme", e);
+      }
+
+      // Preferences proxy
+      /*
+       Class proxyClass = Proxy.getProxyClass(Thread.currentThread().getContextClassLoader(), new Class[]{PreferencesProxy.class});
+       try
+       {
+       proxyInfo = new ProxyInfo(proxyClass);
+       }
+       catch (Exception e1)
+       {
+       throw new PortletException();
+       }
+       */
+
+      // Loader that will load the resource from the war file
+      loader = new CLLoader("template");
+   }
+
+   public String getDefaultOperation()
+   {
+      return OP_MAIN;
+   }
+
+   /**
+    * doEdit Portlet method
+    *
+    * @param req  Portlet render request
+    * @param resp Portlet response request
+    * @throws PortletException For any unexpected exception
+    * @throws IOException      If cannot write HTML chunk
+    */
+   protected void doEdit(JBossRenderRequest req, JBossRenderResponse resp)
+      throws PortletException, IOException
+   {
+
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+      resp.setContentType("text/html");
+      PrintWriter writer = resp.getWriter();
+      writer.write("<div class=\"bb\">");
+      if (req.getWindowState() != WindowState.MAXIMIZED)
+      {
+         writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
+         writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
+         PortletURL showProfileURL = resp.createRenderURL();
+         showProfileURL.setWindowState(WindowState.MAXIMIZED);
+         showProfileURL.setPortletMode(PortletMode.EDIT);
+         writer.write("<a href=\"" + showProfileURL.toString() + "\">"
+            + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums.gif" + "\"><br>"
+            + bundle.getString("Preferences_edit") + "</a>");
+         writer.write("</td></tr></table>");
+      }
+      else
+      {
+         DelegateContext root = new DelegateContext();
+         if (!(req.getRemoteUser() != null))
+         {
+            writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
+            writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
+            writer.write("Sorry but you must login to change preferences");
+            writer.write("</td></tr></table>");
+            writer.write("</div>");
+            writer.close();
+            return;
+         }
+         else
+         {
+            resp.setTitle("Forums");
+            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowPreferencesContext(req, resp, root));
+            PortletRequestDispatcher rd = getPortletContext()
+               .getRequestDispatcher("/WEB-INF/subSilver/jsp/preferences_body.jsp");
+            rd.include(req, resp);
+         }
+      }
+      writer.write("</div>");
+      writer.close();
+   }
+
+   /**
+    * doView Portlet method
+    *
+    * @param req  Portlet render request
+    * @param resp Portlet response request
+    * @throws PortletException For any unexpected exception
+    * @throws IOException      If cannot write HTML chunk
+    */
+   protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
+      throws PortletException, IOException
+   {
+      //Use this to do debug
+      /*System.out.println("#####################");
+      System.out.println("in doView(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
+      for (Iterator i = req.getParameterMap().keySet().iterator(); i.hasNext();)
+      {
+         String key = (String)i.next();
+         System.out.println("param key: " + key + " ||param val: " + req.getParameter(key));
+      }*/
+
+
+
+
+
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+
+      resp.setContentType("text/html");
+      PrintWriter writer = resp.getWriter();
+      writer.write("<div class=\"bb\">");
+      String op = req.getParameters().get(getOperationName(),
+         getDefaultOperation());
+      if (req.getWindowState() != WindowState.MAXIMIZED)
+      {
+         DelegateContext root = new DelegateContext();
+         resp.setTitle("Forums");
+         req.setAttribute(PortalJsp.CTX_REQUEST, fillShowBlockTopicsContext(req, resp, root));
+         PortletRequestDispatcher rd = getPortletContext()
+            .getRequestDispatcher("/WEB-INF/subSilver/jsp/block/topics.jsp");
+         rd.include(req, resp);
+
+         /*writer.write("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\"><tr class=\"portlet-section-body\">");
+
+         // Window is is normal mode
+         // Check if the user is an administrator
+         boolean isAdmin = hasPermission(req,"Admin");
+         if (isAdmin)
+         {
+            writer.write("<td width=\"50%\" align=\"center\" class=\"portlet-menu-item\">");
+
+            // Create a link to the administration interface
+            PortletURL adminURL = resp.createRenderURL();
+            adminURL.setParameter("op", "" + OP_SHOWADMINFORUMS);
+            adminURL.setWindowState(WindowState.MAXIMIZED);
+            writer.write("<a href=\"" + adminURL.toString() + "\">"
+                    + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums_admin.gif\"><br>"
+                    + bundle.getString("Admin_panel") + "</a>");
+            writer.write("</td>");
+            writer.write("<td width=\"50%\" align=\"center\" class=\"portlet-menu-item\">");
+         }
+         else
+         {
+            writer.write("<td align=\"center\" class=\"portlet-menu-item\">");
+         }
+
+         //Create a link to the forum index
+         PortletURL showForumsURL = resp.createRenderURL();
+         showForumsURL.setWindowState(WindowState.MAXIMIZED);
+         showForumsURL.setParameter("op", "" + OP_MAIN);
+         writer.write("<a href=\"" + showForumsURL.toString() + "\">"
+                 + "<img border=\"0\" src=\"" + req.getContextPath() + "/subSilver/images/icon_forums.gif" + "\"><br>"
+                 + bundle.getString("Main_index") + "</a>");
+         writer.write("</td></tr></table>");*/
+
+
+      }
+      else
+      {
+         DelegateContext logged_in = null;
+         DelegateContext root = new DelegateContext();
+         if ((req.getRemoteUser() != null))
+         {
+            logged_in = root.next("switch_user_logged_in");
+         }
+         boolean isAdmin = ForumsTools.hasPermission(req, "Admin");
+         if (isAdmin && (req.getRemoteUser() != null))
+         {
+            // Create a link to the administration interface
+            PortletURL adminURL = resp.createRenderURL();
+            adminURL.setParameter("op", "" + OP_SHOWADMINFORUMS);
+            String adminLink = new String("<a id=\"adminPanel\" class=\"mainmenu\" href=\"" + adminURL.toString() + "\">"
+               + "<img src=\"" + req.getContextPath() + "/subSilver/images/icon_mini_admin.gif\"\n" +
+               "                               width=\"12\" height=\"13\" border=\"0\"\n" +
+               "                               hspace=\"3\"/>"
+               + bundle.getString("Admin_panel") + "</a><br/>");
+            logged_in.put("ADMIN_PANEL_LINK", adminLink);
+         }
+
+         req.setAttribute(PortalJsp.CTX_REQUEST, root);
+         PortletRequestDispatcher rdisp = getPortletContext()
+            .getRequestDispatcher("/WEB-INF/subSilver/jsp/small_header.jsp");
+         rdisp.include(req, resp);
+
+         if (OP_MAIN.equals(op))
+         {
+            // Forum index
+            resp.setTitle("Forums");
+            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowIndexContext(req,
+               resp, root));
+
+
+            PortletRequestDispatcher rd = getPortletContext()
+               .getRequestDispatcher("/WEB-INF/subSilver/jsp/index_body.jsp");
+            rd.include(req, resp);
+         }
+         else if (OP_SHOWFORUM.equals(op))
+         {
+            // Display topics of a forums
+            resp.setTitle("Forums");
+            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowForumContext(req,
+               resp, root));
+            PortletRequestDispatcher rd = getPortletContext()
+               .getRequestDispatcher("/WEB-INF/subSilver/jsp/viewforum_body.jsp");
+            rd.include(req, resp);
+         }
+         else if (OP_POSTING.equals(op))
+         {
+            // Display new post form
+            resp.setTitle("Forums");
+            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowNewTopicContext(req, resp, root));
+            PortletRequestDispatcher rd = getPortletContext()
+               .getRequestDispatcher("/WEB-INF/subSilver/jsp/posting_body.jsp");
+            rd.include(req, resp);
+         }
+         else if (OP_SHOWTOPIC.equals(op))
+         {
+            // Display a topic
+            resp.setTitle("Forums");
+            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowTopicContext(req,
+               resp, root));
+            PortletRequestDispatcher rd = getPortletContext()
+               .getRequestDispatcher("/WEB-INF/subSilver/jsp/viewtopic_body.jsp");
+            rd.include(req, resp);
+         }
+         else if (OP_SHOWADMINFORUMS.equals(op))
+         {
+            // Display administration interface
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "Admin");
+            if (auth)
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST,
+                  fillShowAdminForumsContext(req, resp, root));
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_admin_body.jsp");
+               rd.include(req, resp);
+            }
+         }
+         else if (OP_SHOWMODERATEFORUM.equals(op))
+         {
+            // Display administration interface
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
+            if (auth)
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST,
+                  fillShowModerateForumContext(req, resp, root));
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_body.jsp");
+               rd.include(req, resp);
+            }
+         }
+
+         else if (OP_SHOWUSERPROFILE.equals(op))
+         {
+            // Display administration interface
+            resp.setTitle("Forums");
+            if ((req.getRemoteUser() != null))
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST,
+                  fillShowUserProfileContext(req, resp, root));
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/profile_view_body.jsp");
+               rd.include(req, resp);
+            }
+         }
+
+         else if (OP_SHOWMOVETOPIC.equals(op))
+         {
+            // Display administration interface
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
+            if (auth)
+            {
+               /*req.setAttribute(PortalJsp.CTX_REQUEST,
+                       fillShowModerateForumContext(req, resp, root));*/
+               PortletURL forumGotoURL = resp.createActionURL();
+               forumGotoURL.setParameter(getOperationName(), OP_SHOWFORUM);
+               forumGotoURL.setParameter("f", "" + req.getParameters().get("U_INDEX_f", "-1"));
+               root.put("U_INDEX", forumGotoURL.toString());
+               root.put("L_INDEX", req.getParameters().get("L_INDEX", ""));
+               root.put("S_HIDDEN_FIELDS", req.getParameters().get("S_HIDDEN_FIELDS", ""));
+               root.put("S_FORUM_SELECT", req.getParameters().get("S_FORUM_SELECT", ""));
+               req.setAttribute(PortalJsp.CTX_REQUEST, root);
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_move.jsp");
+               rd.include(req, resp);
+            }
+         }
+         else if (OP_SHOWSPLITTOPIC.equals(op))
+         {
+            // Display administration interface
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "ModerateForum");
+            if (auth)
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST,
+                  fillShowSplitTopicContext(req, resp, root));
+               req.setAttribute(PortalJsp.CTX_REQUEST, root);
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/modcp_split.jsp");
+               rd.include(req, resp);
+            }
+         }
+         else if (OP_SHOWADDEDITFORUM.equals(op))
+         {
+            // Display new or edit a forum form
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "Admin");
+            if (auth)
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST,
+                  fillShowAddEditForumContext(req, resp, root));
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_edit_body.jsp");
+               rd.include(req, resp);
+            }
+         }
+         else if (OP_SHOWDELETEFORUM.equals(op))
+         {
+            // Show form to delete an exisiting forum
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "Admin");
+            if (auth)
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST, root);
+               root.put("NAME", req.getParameter("NAME"));
+               root.put("S_SELECT_TO", req.getParameter("S_SELECT_TO"));
+               root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
+               PortletURL postURL = resp.createActionURL();
+               root.put("POST_URL", postURL.toString());
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/forum_delete_body.jsp");
+               rd.include(req, resp);
+            }
+         }
+         else if (OP_SHOWEDITCATEGORY.equals(op))
+         {
+            // Show form to edit or create a category
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "Admin");
+            if (auth)
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST, root);
+               root.put("CAT_TITLE", req.getParameter("CAT_TITLE"));
+               root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
+               PortletURL postURL = resp.createActionURL();
+               root.put("POST_URL", postURL.toString());
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/admin/category_edit_body.jsp");
+               rd.include(req, resp);
+            }
+         }
+         else if (OP_CONFIRM.equals(op))
+         {
+            // Show form to edit or create a category
+            resp.setTitle("Forums");
+            boolean auth = ForumsTools.hasPermission(req, "Delete");
+            if (auth)
+            {
+               req.setAttribute(PortalJsp.CTX_REQUEST, root);
+               root.put("MESSAGE_TITLE", req.getParameter("MESSAGE_TITLE"));
+               root.put("MESSAGE_TEXT", req.getParameter("MESSAGE_TEXT"));
+               root.put("S_HIDDEN_FIELDS", req.getParameter("S_HIDDEN_FIELDS"));
+               PortletURL postURL = resp.createActionURL();
+               root.put("POST_URL", postURL.toString());
+               PortletRequestDispatcher rd = getPortletContext()
+                  .getRequestDispatcher("/WEB-INF/subSilver/jsp/confirm_body.jsp");
+               rd.include(req, resp);
+            }
+         }
+         else if (OP_SHOWWATCHEDFORUMS.equals(op))
+         {
+            resp.setTitle("Forums");
+            req.setAttribute(PortalJsp.CTX_REQUEST, fillShowWatchedForums(req,
+               resp, root));
+            PortletRequestDispatcher rd = getPortletContext()
+               .getRequestDispatcher("/WEB-INF/subSilver/jsp/watched_forums_body.jsp");
+            rd.include(req, resp);
+         }
+
+         /*NAVIGATION JUMP BOX*/
+         String selectTo = "";
+         selectTo = "<select name=\"nav_id\">"
+            + "<option value=\"main\">" + "All categories view" + "</option>\n";
+         selectTo += ForumsTools.listForumsCategories(forumsModule);
+         selectTo += "</select>";
+
+         PortletURL navigationActionURL = resp.createActionURL();
+         navigationActionURL.setParameter("op", "navigation");
+         root.put("S_JUMPBOX_ACTION", navigationActionURL.toString());
+         root.put("S_JUMPBOX_SELECT", selectTo);
+         req.setAttribute(PortalJsp.CTX_REQUEST, root);
+         PortletRequestDispatcher rdispend = getPortletContext()
+            .getRequestDispatcher("/WEB-INF/subSilver/jsp/jumpbox.jsp");
+         rdispend.include(req, resp);
+      }
+
+
+      writer.write("</div>");
+      writer.close();
+   }
+
+   public void navigation(JBossActionRequest request, JBossActionResponse response)
+      throws CommandException
+   {
+      //Use this to do debug
+      /*System.out.println("!@!@!@!@!@!@!@!@!@!@!@!@");
+      System.out.println("in navigation(); op: " + request.getParameter("op") + " and mode: " + request.getParameter("mode"));
+      for (Iterator i=request.getParameterMap().keySet().iterator(); i.hasNext();)
+      {
+         String key = (String)i.next();
+         System.out.println("param key: " + key + " ||param val: " + request.getParameter(key));
+      }*/
+      String nav = "main";
+      nav = request.getParameter("nav_id");
+      response.setRenderParameter(getOperationName(), OP_MAIN);
+      if (nav.equals("main"))
+      {
+         return;
+      }
+      else
+      {
+         String toGo[] = nav.split("x");
+         if (toGo.length == 2)
+         {
+            response.setRenderParameter(toGo[0], toGo[1]);
+            if (toGo[0].equals("f"))
+            {
+               response.setRenderParameter(getOperationName(), OP_SHOWFORUM);
+            }
+         }
+
+      }
+
+
+   }
+
+   /**
+    * Method do action processing for Moderator functions from moderator panel
+    * in forum view and moderator bar in topic view.
+    * <p/>
+    * This method <b>MUST</b> get both proper "f" (forum id) and "t" (topic id) params.
+    *
+    * @param request
+    * @param response
+    * @throws CommandException
+    */
+   public void moderate_forum(JBossActionRequest request, JBossActionResponse response)
+      throws CommandException
+   {
+      //Use this to do debug
+      /*System.out.println("!@!@!@!@!@!@!@!@!@!@!@!@");
+      System.out.println("in moderate_forum(); op: " + request.getParameter("op") + " and mode: " + request.getParameter("mode"));
+      for (Iterator i=request.getParameterMap().keySet().iterator(); i.hasNext();)
+      {
+         String key = (String)i.next();
+         System.out.println("param key: " + key + " ||param val: " + request.getParameter(key));
+      }*/
+
+      ResourceBundle bundle = getResourceBundle(request.getLocale());
+
+      //get all parameters passed
+      Map paramMap = request.getParameterMap();
+
+      //is this return from confirmation page?
+      boolean confirmed = paramMap.containsKey("comfirmPage");
+
+      //if no button was pressed let's jump to main view
+      if (paramMap.containsKey("cancel"))
+      {
+         response.setRenderParameter(getOperationName(), getDefaultOperation());
+         return;
+      }
+      //if its confirmed and it's not cancel button then it should be yes button
+
+      //type of action
+      String mode = request.getParameters().get("mode", "");
+
+      //forum id:
+      int fid = Integer.parseInt(request.getParameters().get("f", "-1"));
+      int tid = Integer.parseInt(request.getParameters().get("t", "-1"));
+
+      //get forum from fid
+      Forum forum = null;
+      try
+      {
+         //if (fid != -1)
+         //{
+         forum = forumsModule.findForumById(new Integer(fid));
+         //}
+      }
+      catch (ModuleException e)
+      {
+
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         //if no forum then goto main
+         response.setRenderParameter(getOperationName(), OP_MAIN);
+         addErrorMessage(response, "moderate", "ERR_INTERNAL");
+         return;
+      }
+
+      //Initial perrmisions check
+      String[] testArray = new String[]{forum.getCategory().getTitle(), forum.getName()};
+      boolean authMod = ForumsTools.hasPermission(request, testArray, "ModerateForum");
+      if (!authMod)
+      {
+         response.setRenderParameter(getOperationName(), OP_MAIN);
+         addErrorMessage(response, "moderate", "ERR_PERMISSION_VIOLATION");
+         return;
+      }
+
+      //if not specified jump to OP_MAIN at end
+      response.setRenderParameter(getOperationName(), OP_MAIN);
+
+      //let decode which button was pressed in moderator panel
+      //or what command is confirmed
+      if (paramMap.containsKey("delete"))
+      {
+
+         mode = "delete";
+      }
+      else if (paramMap.containsKey("move"))
+      {
+
+         mode = "move";
+      }
+      else if (paramMap.containsKey("lock"))
+      {
+
+         mode = "lock";
+      }
+      else if (paramMap.containsKey("unlock"))
+      {
+
+         mode = "unlock";
+      }
+      else if (paramMap.containsKey("split"))
+      {
+
+         mode = "split";
+      }
+
+      //list of passed topic number
+      List topicsPassedList = new LinkedList();
+
+      //we need to know how many topics could be passed in topic_id_list[N]= pattern
+      int topicsPerPage = Integer.parseInt(request.getPreferences().getValue("topicsperforum", "10"));
+
+      //let's get all passed topics
+      for (int i = 0; i <= topicsPerPage; i++)
+      {
+         String pattern = "topic_id_list[" + i + "]";
+         String topicNum = request.getParameters().get(pattern, "none");
+
+         if (!topicNum.equals("none"))
+         {
+
+            topicsPassedList.add(new Integer(topicNum));
+         }
+      }
+      //plus the one from "t" param
+      if (tid != -1)
+      {
+         topicsPassedList.add(new Integer(tid));
+      }
+
+      //process delete button
+      if (mode.equals("delete"))
+      {
+
+         //show confirmation page in doView()
+         response.setRenderParameter(getOperationName(), OP_CONFIRM);
+         //action url for the confirmation form
+
+         StringBuffer hiddenFields = new StringBuffer();
+         hiddenFields.append("<input type=\"hidden\" name=\"deleteConfirm\" value=\"yes\"/>").
+            append("<input type=\"hidden\" name=\"op\" value=\"moderate_forum\"/>").
+            append("<input type=\"hidden\" name=\"f\" value=\"" + fid + "\"/>");
+         int i = 0;
+         //we must passed all topics number in response
+         for (Iterator itp = topicsPassedList.iterator(); itp.hasNext(); i++)
+         {
+            hiddenFields.append("<input type=\"hidden\" name=\"topic_id_list[" + i + "]" + "\" value=\"" + ((Integer)itp.next()).toString() + "\"/>");
+         }
+         response.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields.toString());
+         response.setRenderParameter("MESSAGE_TITLE", bundle.getString("Topic_delete_confirm"));
+         response.setRenderParameter("MESSAGE_TEXT", bundle.getString("Topic_delete_message"));
+         return;
+      }
+      // proces deletion confirmation
+      else if (paramMap.containsKey("deleteConfirm"))
+      {
+
+
+         DeleteTopicCommand cmd = new DeleteTopicCommand(request, response);
+         cmd.topicIds = topicsPassedList;
+         cmd.module = forumsModule;
+         Result result = forumsModule.invoke(cmd);
+         ResultType type = result.getType();
+         if (type == CommandConstants.TYPE_CANNOT_REMOVE_TOPICS)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_CANNOT_REMOVE_TOPIC");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOPICS_REMOVED)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
+            response.setRenderParameter("f", "" + fid);
+            addSuccessMessage(response, "moderate", "SUCC_TOPIC_REMOVED");
+            return;
+         }
+         return;
+      }
+      // process move button
+      else if (mode.equals("move"))
+      {
+
+         /*response.setRenderParameter(getOperationName(), OP_SHOWMOVETOPIC);
+         //url for navigation link - show our forum
+         PortletURL forumGotoURL = response.createActionURL();
+         forumGotoURL.setParameter(getOperationName(), OP_SHOWFORUM);
+         forumGotoURL.setParameter("f", "" + fid);
+         //<a href=...
+         response
+         response.setRenderParameter("U_INDEX", forumGotoURL.toString());*/
+         //>forum name</a>
+         //ass render urls should be created from RenderResponse we pass it to doView
+         response.setRenderParameter("U_INDEX_f", "" + fid);
+         response.setRenderParameter("L_INDEX", forum.getName());
+
+         //hidden fields
+         StringBuffer hiddenFields = new StringBuffer();
+         hiddenFields.append("<input type=\"hidden\" name=\"moveConfirm\" value=\"yes\"/>").
+            append("<input type=\"hidden\" name=\"op\" value=\"moderate_forum\"/>").
+            append("<input type=\"hidden\" name=\"f\" value=\"" + fid + "\" />");
+         int i = 0;
+         //we must passed all topics number in response
+         for (Iterator itp = topicsPassedList.iterator(); itp.hasNext(); i++)
+         {
+            hiddenFields.append("<input type=\"hidden\" name=\"topic_id_list[" + i + "]" + "\" value=\"" + ((Integer)itp.next()).toString() + "\"/>");
+         }
+         response.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields.toString());
+
+
+         try
+         {
+            String selectTo = new StringBuffer().
+               append("<select name=\"forum_to_id\">").
+               append("<option value=\"-1\"").
+               append(" selected=\"selected\">").
+               append("Select destination forum").append("</option>\n").
+               append(ForumsTools.listForums(forumsModule.findForums(), -1)).
+               append("</select>").toString();
+            response.setRenderParameter("S_FORUM_SELECT", selectTo);
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+            return;
+         }
+         return;
+
+      }
+
+      //process move confirmation
+      else if (paramMap.containsKey("moveConfirm"))
+      {
+
+         int toForumId = request.getParameters().getInt("forum_to_id", -1);
+         if (toForumId == -1)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_NO_DEST_FORUM");
+            return;
+         }
+
+         MoveTopicCommand cmd = new MoveTopicCommand(request, response);
+         cmd.topicIds = topicsPassedList;
+         cmd.module = forumsModule;
+         cmd.destinationForumId = new Integer(toForumId);
+
+         Result result = forumsModule.invoke(cmd);
+         ResultType type = result.getType();
+         if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOPIC_MOVED)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
+            response.setRenderParameter("f", "" + fid);
+            addSuccessMessage(response, "moderate", "SUCC_TOPIC_MOVED");
+            return;
+         }
+         return;
+      }
+
+      //process lock button
+      else if (mode.equals("lock"))
+      {
+
+         LockTopicCommand cmd = new LockTopicCommand(request, response);
+         cmd.topicIds = topicsPassedList;
+         cmd.module = forumsModule;
+
+         Result result = forumsModule.invoke(cmd);
+         ResultType type = result.getType();
+         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOPIC_LOCKED)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
+            response.setRenderParameter("f", "" + fid);
+            addSuccessMessage(response, "moderate", "SUCC_TOPIC_LOCKED");
+            return;
+         }
+         return;
+
+
+      }
+      //process unlock button
+      else if (mode.equals("unlock"))
+      {
+
+         LockTopicCommand cmd = new LockTopicCommand(request, response);
+         cmd.topicIds = topicsPassedList;
+         cmd.module = forumsModule;
+         cmd.unlockAction = true;
+
+         Result result = forumsModule.invoke(cmd);
+         ResultType type = result.getType();
+         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOPIC_UNLOCKED)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWMODERATEFORUM);
+            response.setRenderParameter("f", "" + fid);
+            addSuccessMessage(response, "moderate", "SUCC_TOPIC_UNLOCKED");
+
+            return;
+         }
+         return;
+      }
+      //process split button
+      else if (mode.equals("split"))
+      {
+
+         response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+         response.setRenderParameter("t", "" + tid);
+         response.setRenderParameter("f", "" + fid);
+         return;
+      }
+      //process split all button
+      else if (paramMap.containsKey("split_type_all"))
+      {
+
+
+         Topic topic = null;
+         try
+         {
+            topic = forumsModule.findTopicById(new Integer(tid));
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+            return;
+         }
+         if (topic.getPosts().size() == 1)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            //response.setRenderParameter("t","" + tid);
+            addErrorMessage(response, "moderate", "ERR_SPLIT_ONE_POST_TOPIC");
+            return;
+         }
+
+         //first get all post numbers passed in request
+         List postsPassedList = new LinkedList();
+         for (int i = 0; i < topic.getPosts().size(); i++)
+         {
+            String pattern = "post_id_list[" + i + "]";
+            String postNum = request.getParameters().get(pattern, "none");
+
+            if (!postNum.equals("none"))
+            {
+
+               postsPassedList.add(new Integer(postNum));
+            }
+            else
+            {
+               //break;
+            }
+         }
+         //check if we don't want to move all posts from source topic
+         if (postsPassedList.size() == 0)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_NO_POST_SELECTED");
+            return;
+         }
+         else if ((topic.getPosts().size() - postsPassedList.size()) == 0)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_SPLIT_ALL");
+            return;
+         }
+
+         int toForumId = request.getParameters().getInt("forum_to_id", -1);
+         if (toForumId == -1)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_DEST_FORUM");
+            return;
+         }
+         SplitTopicCommand cmd = new SplitTopicCommand(request, response);
+         cmd.postIds = postsPassedList;
+         cmd.module = forumsModule;
+         cmd.destinationForumId = new Integer(toForumId);
+         cmd.newSubject = request.getParameters().get("subject", "default");
+         cmd.topicId = new Integer(tid);
+         cmd.userId = request.getUser().getId().toString();
+
+         Result result = forumsModule.invoke(cmd);
+         ResultType type = result.getType();
+         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOPIC_SPLITED)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addSuccessMessage(response, "moderate", "SUCC_TOPIC_SPLITTED");
+            ;
+            return;
+         }
+         return;
+      }
+      //process split after button
+      else if (paramMap.containsKey("split_type_beyond"))
+      {
+
+         if (topicsPassedList.size() > 1)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "Too_many_error");
+            return;
+         }
+
+         Topic topic = null;
+         try
+         {
+            topic = forumsModule.findTopicById(new Integer(tid));
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+
+            return;
+         }
+         if (topic.getPosts().size() == 1)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            //response.setRenderParameter("t","" + tid);
+            addErrorMessage(response, "moderate", "ERR_SPLIT_ONE_POST_TOPIC");
+            return;
+         }
+
+         //first get all post numbers passed in request
+         List postsPassedList = new LinkedList();
+         for (int i = 0; i < topic.getPosts().size(); i++)
+         {
+            String pattern = "post_id_list[" + i + "]";
+            String postNum = request.getParameters().get(pattern, "none");
+
+            if (!postNum.equals("none"))
+            {
+
+               postsPassedList.add(new Integer(postNum));
+            }
+            else
+            {
+               //break;
+            }
+         }
+         if (postsPassedList.size() == 0)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_NO_POST_SELECTED");
+            return;
+         }
+         else if (postsPassedList.size() != 1)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "Too_many_error");
+            return;
+         }
+         //check if user selected first post
+         else if (topic.getFirstPost().getId().equals((Integer)(postsPassedList.iterator()).next()))
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_SPLIT_ALL");
+            return;
+         }
+
+         int toForumId = request.getParameters().getInt("forum_to_id", -1);
+         if (toForumId == -1)
+         {
+            response.setRenderParameter(getOperationName(), OP_SHOWSPLITTOPIC);
+            response.setRenderParameter("t", "" + tid);
+            response.setRenderParameter("f", "" + fid);
+            addErrorMessage(response, "moderate", "ERR_DEST_FORUM");
+            return;
+         }
+         SplitTopicCommand cmd = new SplitTopicCommand(request, response);
+         cmd.postIds = postsPassedList;
+         cmd.module = forumsModule;
+         cmd.destinationForumId = new Integer(toForumId);
+         cmd.newSubject = request.getParameters().get("subject", "default");
+         cmd.topicId = new Integer(tid);
+         cmd.userId = request.getUser().getId().toString();
+         cmd.splitAfter = true;
+
+         Result result = forumsModule.invoke(cmd);
+         ResultType type = result.getType();
+         if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addErrorMessage(response, "moderate", "ERR_INTERNAL");
+
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOPIC_SPLITED)
+         {
+            response.setRenderParameter(getOperationName(), OP_MAIN);
+            addSuccessMessage(response, "moderate", "SUCC_TOPIC_SPLITTED");
+
+            return;
+         }
+
+
+         return;
+      }
+
+
+   }
+
+   public void preferences(JBossActionRequest request, JBossActionResponse response)
+      throws CommandException
+   {
+
+      try
+      {
+         PortletPreferences pp = request.getPreferences();
+         PropertyMap upm = request.getUser().getProperties();
+         if (!pp.isReadOnly("notifyreply"))
+         {
+            pp.setValue("notifyreply", request.getParameter("notifyreply"));
+         }
+         /*if (!pp.isReadOnly("attachsig"))
+            pp.setValue("attachsig", request.getParameter("attachsig"));*/
+         if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
+         {
+            upm.put(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY, request.getParameter("attachsig"));
+         }
+         //TODO: BBCode disable should be implemented
+         /*if (!pp.isReadOnly("allowbbcode"))
+             pp.setValue("allowbbcode", request.getParameter("allowbbcode"));*/
+         if (!pp.isReadOnly("allowhtml"))
+         {
+            pp.setValue("allowhtml", request.getParameter("allowhtml"));
+         }
+         if (!pp.isReadOnly("postorder"))
+         {
+            pp.setValue("postorder", request.getParameter("postorder"));
+         }
+         if (!pp.isReadOnly("topicsperforum"))
+         {
+            pp.setValue("topicsperforum", request.getParameter("topicsperforum"));
+         }
+         if (!pp.isReadOnly("postspertopic"))
+         {
+            pp.setValue("postspertopic", request.getParameter("postspertopic"));
+         }
+         if (!pp.isReadOnly("dateformat"))
+         {
+            if (request.getParameter("dateformat") != null)
+            {
+               try
+               {
+                  new SimpleDateFormat(request.getParameter("dateformat"));
+                  pp.setValue("dateformat", request.getParameter("dateformat"));
+               }
+               catch (IllegalArgumentException e)
+               {
+                  System.out.println("Illegal date format");
+                  pp.setValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
+               }
+            }
+            else
+            {
+               pp.setValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
+            }
+
+         }
+         /*if (!pp.isReadOnly("signature"))
+         {
+            pp.setValue("signature", request.getParameter("signature"));
+         }*/
+         if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
+         {
+            upm.put(ForumsConstants.USER_SIGNATURE_PROPERTY, request.getParameter("signature"));
+         }
+
+         String summarymode = request.getParameter("summarymode");
+         String limit = request.getParameter("summarytopiclimit");
+         String days = request.getParameter("summarytopicdays");
+         String replies = request.getParameter("summarytopicreplies");
+         // we do simple validation of integers in fields
+
+         if (!pp.isReadOnly("summarymode"))
+         {
+            new Integer(summarymode);
+            pp.setValue("summarymode", request.getParameter("summarymode"));
+         }
+
+         try
+         {
+            if (!pp.isReadOnly("summarytopiclimit"))
+            {
+               Integer.parseInt(limit);
+               pp.setValue("summarytopiclimit", request.getParameter("summarytopiclimit"));
+            }
+         }
+         catch (IllegalArgumentException e)
+         {
+            //e.printStackTrace();
+            if (!pp.isReadOnly("summarytopiclimit"))
+            {
+               pp.setValue("summarytopiclimit", "6");
+            }
+            addErrorMessage(response, "posting", "Illegal format in: Topic Summary Limit");
+         }
+
+         try
+         {
+            if (!pp.isReadOnly("summarytopicdays"))
+            {
+               new Integer(days);
+               pp.setValue("summarytopicdays", request.getParameter("summarytopicdays"));
+            }
+         }
+         catch (IllegalArgumentException e)
+         {
+            //e.printStackTrace();
+            if (!pp.isReadOnly("summarytopicdays"))
+            {
+               pp.setValue("summarytopicdays", "20");
+            }
+            addErrorMessage(response, "posting", "Illegal format in: Topic Summary Days");
+         }
+
+         try
+         {
+            if (!pp.isReadOnly("summarytopicreplies"))
+            {
+               new Integer(replies);
+               pp.setValue("summarytopicreplies", request.getParameter("summarytopicreplies"));
+            }
+         }
+         catch (IllegalArgumentException e)
+         {
+            //e.printStackTrace();
+            if (!pp.isReadOnly("summarytopicreplies"))
+            {
+               pp.setValue("summarytopicreplies", "15");
+            }
+            addErrorMessage(response, "posting", "Illegal format in: Topic Summary Replies");
+         }
+         pp.store();
+      }
+      catch (Exception e)
+      {
+         System.out.println("Some Exception while storing portlet prefs....");
+         addErrorMessage(response, "posting", "Some Exception while storing portlet prefs....");
+         e.printStackTrace();
+      }
+   }
+
+
+   /**
+    * posting operation
+    *
+    * @param request  JBoss action request
+    * @param response JBoss action response
+    * @throws CommandException
+    * @throws CommandException DOCUMENT_ME
+    */
+   public void posting(JBossActionRequest request, JBossActionResponse response)
+      throws CommandException
+   {
+
+      //for debug
+      /*System.out.println("@@@@@@@@@@@@@@@@@@@@@@");
+      System.out.println("in posting();");
+      *///For more debug puproses uncomment lines in Contex.update()
+
+      ResourceBundle bundle = getResourceBundle(request.getLocale());
+
+      Context ctx = new Context();
+      ctx.setForumsModule(forumsModule);
+      ctx.update(request, response);
+
+      //Cancel button
+      String cancelVal = request.getParameters().get("cancel_posting", "none");
+      boolean cancelbtn = !cancelVal.equals("none");
+      if (cancelbtn)
+      {
+         switch (ctx.p_mode)
+         {
+            case ForumsConstants.PMODE_NEW_TOPIC:
+            {
+               response.setRenderParameter("op", OP_SHOWFORUM);
+               response.setRenderParameter("f", "" + ctx.p_forum_id);
+               return;
+            }
+            case ForumsConstants.PMODE_REPLY:
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("t", "" + ctx.p_post_parent_topic_id);
+               return;
+            }
+            case ForumsConstants.PMODE_EDIT_POST:
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("p", "" + ctx.p_post_id);
+               return;
+            }
+         }
+
+      }
+
+      //Set info that posting was processed so if new topic page will be displayed it will be postback
+      response.setRenderParameter(ForumsConstants.POSTING_POSTBACK_FLAG, "true");
+
+      /*
+      // Was cancel pressed? If so then redirect to the appropriate page
+      if (ctx.p_cancel)
+      {
+      if (ctx.p_post_id != -1)
+      {
+      response.sendRedirect("index.html?module=bb&op=viewtopic&p="
+      + ctx.p_post_id + "#" + ctx.p_post_id);
+      }
+      else if (ctx.p_topic_id != -1)
+      {
+      response.sendRedirect("index.html?module=bb&op=viewtopic&t="
+      + ctx.p_topic_id);
+      }
+      else if (ctx.p_forum_id != -1)
+      {
+      response.sendRedirect("index.html?module=bb&op=viewforum&f="
+      + ctx.p_forum_id);
+      }
+      else
+      {
+      response.sendRedirect("index.html?module=bb");
+      }
+      return;
+      }
+      */
+
+      // If the variable mode is empty we don't go farther in the process
+      if (ctx.p_mode == PMODE_NO_MODE)
+      {
+         addErrorMessage(response, "posting",
+            "Unexpected error: No mode defined");
+         return;
+      }
+
+      //If there were poll delete confirmation "No" button pressed
+      if ((ctx.p_mode == ForumsConstants.PMODE_POLL_DELETE) &&
+         (request.getParameter("cancel") != null) &&
+         (request.getParameter("cancel").equals("No")))
+      {
+         if (ctx.p_post_id != -1)
+         {
+            response.setRenderParameter("op", OP_SHOWTOPIC);
+            response.setRenderParameter("p", "" + ctx.p_post_id);
+         }
+         else if (ctx.p_topic_id != -1)
+         {
+            response.setRenderParameter("op", OP_SHOWTOPIC);
+            response.setRenderParameter("t", "" + ctx.p_topic_id);
+         }
+         else if (ctx.p_forum_id != -1)
+         {
+            response.setRenderParameter("op", OP_SHOWFORUM);
+            response.setRenderParameter("f", "" + ctx.p_forum_id);
+         }
+         return;
+
+      }
+
+      if (ctx.c_refresh)
+      {
+         response.setRenderParameter("mode", request.getParameter("mode"));
+
+      }
+
+      if (ctx.p_mode == PMODE_EDIT_POST)
+      {
+         if (ctx.p_topic_first_post)
+         {
+            response.setRenderParameter("firstTopicPost", "" + ctx.p_topic_first_post);
+         }
+         response.setRenderParameter("topictype", "" + ctx.p_topic_type);
+         //return;
+      }
+      /*
+      // If the mode is set to topic review then output that review
+      switch (ctx.p_mode)
+      {
+      case PMODE_TOPIC_REVIEW:
+      //         display(theme.TPL_THEME_POSTING_TOPIC_REVIEW, topicReview(ctx.p_topic_id), page);
+      return;
+      case PMODE_SMILIES:
+      // generate_smilies('window', PAGE_POSTING);
+      // exit;
+      return;
+      }
+      */
+
+      // Output the confirm message in no confirm variable is found when we delete something
+      if ((((ctx.p_mode == PMODE_EDIT_POST) && ctx.p_poll_delete) || (ctx.p_mode == PMODE_DELETE))
+         && !ctx.p_confirm)
+      {
+         response.setRenderParameter("MESSAGE_TITLE", bundle
+            .getString("Information"));
+         response.setRenderParameter("MESSAGE_TEXT",
+            (ctx.p_mode == PMODE_DELETE) ? bundle
+               .getString("Confirm_delete") : bundle
+               .getString("Confirm_delete_poll"));
+         response
+            .setRenderParameter("S_HIDDEN_FIELDS",
+               "<input type=\"hidden\" name=\"p\" value=\""
+                  + ctx.p_post_id
+                  + "\"/>"
+                  + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
+                  + "<input type=\"hidden\" name=\"op\" value=\"posting\"/>"
+                  + ((ctx.p_mode == PMODE_DELETE) ? "<input type=\"hidden\" name=\"mode\" value=\"delete\"/>"
+                  : "<input type=\"hidden\" name=\"mode\" value=\"poll_delete\"/>"));
+
+         //         display(theme.TPL_THEME_CONFIRM_BODY, temp, page);
+         response.setRenderParameter("op", OP_CONFIRM);
+         return;
+      }
+
+      // Get user informations
+      User currentUser = request.getUser();
+
+      //
+      Action action = ctx.action(request, response);
+
+      if (action instanceof ProcessCommandAction)
+      {
+         // Get the encapsulated command
+         ForumCommand cmd = ((ProcessCommandAction)action).getCommand();
+
+         // Set the current user on it
+         cmd.setCurrentUser(currentUser);
+
+         // Execute it
+         // Finish the command configuration
+         cmd.setModule(forumsModule);
+
+         // Execute the command
+         Result result = forumsModule.invoke(cmd);
+
+         // Switch on the result
+         ResultType type = result.getType();
+
+         /*
+          if (type == CommandConstants.TYPE_ALREADY_VOTED)
+          {
+          //            Die.exit(GENERAL_MESSAGE,
+          //                  "${bb.Already_voted}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
+          //                  ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
+          }
+          else if (type == CommandConstants.TYPE_CANNOT_INSERT_VOTE)
+          {
+          //            Die.rollback(GENERAL_ERROR, "Could not insert user_id for poll");
+          }
+          else if (type == CommandConstants.TYPE_CANNOT_OBTAIN_USER_DATA)
+          {
+          //            Die.exit(GENERAL_ERROR, "Could not obtain user vote data for this topic");
+          }
+          else if (type == CommandConstants.TYPE_VOTE_CAST)
+          {
+          //            Die.exit(GENERAL_MESSAGE,
+          //                  "${bb.Vote_cast}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
+          //                  ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
+          }
+          else if (type == CommandConstants.TYPE_NO_VOTE_OPTION)
+          {
+          //            Die.exit(GENERAL_MESSAGE,
+          //                  "${bb.No_vote_option}<br/><br/>${bb.Click_view_message_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
+          //                  ((VoteTopicCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
+          }
+          else if (type == CommandConstants.TYPE_COULD_NOT_OBTAIN_VOTE_DATA)
+          {
+          //            Die.exit(GENERAL_ERROR, "Could not obtain vote data for this topic");
+          }
+          else if (type == CommandConstants.TYPE_REDIRECT)
+          {
+          response.sendRedirect("index.html?module=bb&op=viewtopic&t=" + ((VoteTopicCommand) cmd).topic.getId());
+          }
+          else
+          */
+         if (type == CommandConstants.TYPE_ERROR_IN_POSTING)
+         {
+            addErrorMessage(response, "postingfailed", "Error in posting");
+            return;
+         }
+         else if ((type == CommandConstants.TYPE_NEW_TOPIC_POSTED)
+            || (type == CommandConstants.TYPE_EDIT_POST_POSTED)
+            || (type == CommandConstants.TYPE_REPLY_POSTED)
+            )
+         {
+            Post post = null;
+            if (cmd instanceof NewTopicCommand)
+            {
+               post = ((NewTopicCommand)cmd).post;
+            }
+            else if (cmd instanceof EditPostCommand)
+            {
+               post = ((EditPostCommand)cmd).post;
+            }
+            else
+            {
+               post = ((ReplyCommand)cmd).newPost;
+            }
+
+            //removed according JBPORTAL-403
+            //addSuccessMessage(response, "posting", "Stored");
+            if (ctx.p_post_id != -1)
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("p", "" + ctx.p_post_id);
+            }
+            else if (ctx.p_topic_id != -1)
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("t", "" + ctx.p_topic_id);
+            }
+            else if (ctx.p_forum_id != -1)
+            {
+               response.setRenderParameter("op", OP_SHOWFORUM);
+               response.setRenderParameter("f", "" + ctx.p_forum_id);
+            }
+
+
+            return;
+         }
+         else if (type == CommandConstants.TYPE_VOTE_POSTED)
+         {
+            addSuccessMessage(response, "posting", "Voted Successfully");
+            if (ctx.p_post_id != -1)
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("p", "" + ctx.p_post_id);
+            }
+            else if (ctx.p_topic_id != -1)
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("t", "" + ctx.p_topic_id);
+            }
+            else if (ctx.p_forum_id != -1)
+            {
+               response.setRenderParameter("op", OP_SHOWFORUM);
+               response.setRenderParameter("f", "" + ctx.p_forum_id);
+            }
+
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NOT_SELECTED_VOTE)
+         {
+            addErrorMessage(response, "posting", "Cannot vote because no option selected");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_POST)
+         {
+            addErrorMessage(response, "posting", "Error in deleting post");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_POLL)
+         {
+            addErrorMessage(response, "posting", "Error in deleting poll");
+            return;
+         }
+         else if ((type == CommandConstants.TYPE_POLL_DELETED)
+            || (type == CommandConstants.TYPE_POST_DELETED))
+         {
+            //            Die.exit(GENERAL_MESSAGE,
+            //                  "<br/><br/>${bb.Click_return_forum_0}<a href=\"index.html?module=bb&op=viewforum&f=" +
+            //                  cmd.forum.getId() + "\">${bb.Click_return_forum_1}</a>" +
+            //                  "${bb.Click_return_forum_2}");
+            if (ctx.p_post_id != -1 && (type != CommandConstants.TYPE_POST_DELETED))
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("p", "" + ctx.p_post_id);
+            }
+            else if (ctx.p_topic_id != -1 &&
+               (cmd instanceof DeletePostCommand) &&
+               !(((DeletePostCommand)cmd).pd_first_post && ((DeletePostCommand)cmd).pd_last_post))
+            {
+               response.setRenderParameter("op", OP_SHOWTOPIC);
+               response.setRenderParameter("t", "" + ctx.p_topic_id);
+
+            }
+            else if (ctx.p_forum_id != -1)
+            {
+               response.setRenderParameter("op", OP_SHOWFORUM);
+               response.setRenderParameter("f", "" + ctx.p_forum_id);
+            }
+            else
+            {
+               response.setRenderParameter("op", OP_MAIN);
+            }
+
+            return;
+         }
+         else if (type == CommandConstants.TYPE_FORUM_LOCKED)
+         {
+            addErrorMessage(response, "postingfailed", "Forum_locked");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOPIC_IS_LOCKED)
+         {
+            addErrorMessage(response, "postingfailed", "Topic_locked");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NOT_AUTHORIZED)
+         {
+            //if (isUserLoggedIn(currentUser))
+            if (request.getRemoteUser() != null)
+            {
+               //               Die.exit(GENERAL_MESSAGE, "${bb." + AUTH_TYPE_TO_MESSAGE[cmd.authType()] + "0}" +
+               //                     "todo" + // $is_auth[$is_auth_type . "_type"]
+               //                     "${bb." + AUTH_TYPE_TO_MESSAGE[cmd.authType()] + "1}");
+               return;
+            }
+            else
+            {
+               if (cmd instanceof EditPostCommand)
+               {
+                  // redirect after = index.html?module=bb&op=posting&mode=quote& + POST_POST_URL + = post_id
+               }
+               else if (cmd instanceof NewTopicCommand)
+               {
+                  // redirect after = index.html?module=bb&op=posting&mode=newtopic& + POST_FORUM_URL + = forum_id
+               }
+               else if (cmd instanceof ReplyCommand)
+               {
+                  //                  if (((ReplyCommand)cmd).quote)
+                  //                  {
+                  //                     // redirect after = index.html?module=bb&op=posting&mode=quote& + POST_POST_URL + = post_id
+                  //                  }
+                  //                  else
+                  //                  {
+                  //                     // beware mode=reply switched from topic to topic.lastPost
+                  //                     // redirect after = index.html?module=bb&op=posting&mode=reply& + POST_TOPIC_URL + = topic_id
+                  //                  }
+               }
+               else
+               {
+                  if (ctx.p_post_id != -1)
+                  {
+                     response.setRenderParameter("op", OP_SHOWTOPIC);
+                     response.setRenderParameter("p", "" + ctx.p_post_id);
+                  }
+                  else if (ctx.p_topic_id != -1)
+                  {
+                     response.setRenderParameter("op", OP_SHOWTOPIC);
+                     response.setRenderParameter("t", "" + ctx.p_topic_id);
+                  }
+                  else if (ctx.p_forum_id != -1)
+                  {
+                     response.setRenderParameter("op", OP_SHOWFORUM);
+                     response.setRenderParameter("f", "" + ctx.p_forum_id);
+                  }
+               }
+
+               //   response.sendRedirect("index.html?module=user&op=getlogin");
+            }
+         }
+         else if (type == CommandConstants.TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR)
+         {
+            //            Die.exit(GENERAL_MESSAGE, (cmd instanceof DeletePollCommand || cmd instanceof DeletePostCommand) ?
+            //                                      "${bb.Delete_own_posts}" : "${bb.Edit_own_posts}" +
+            //                  "<br/><br/>${bb.Click_return_topic_0}<a href=\"index.html?module=bb&op=viewtopic&t=" +
+            //                  ((TopicCommand)cmd).topic.getId() +
+            //                  "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}");
+         }
+         else if (type == CommandConstants.TYPE_CANNOT_DELETE_REPLIED)
+         {
+            addErrorMessage(response, "postingfailed", "Cannot_delete_replied");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_CANNOT_DELETE_POLL)
+         {
+            addErrorMessage(response, "postingfailed", "Cannot_delete_poll");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NO_SUCH_POST)
+         {
+            addErrorMessage(response, "postingfailed", "No_such_Post");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NO_SUCH_TOPIC)
+         {
+            addErrorMessage(response, "postingfailed", "No_topic_id");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_NO_SUCH_FORUM)
+         {
+            addErrorMessage(response, "postingfailed", "Forum_not_exist");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_CANNOT_QUERY)
+         {
+            addErrorMessage(response, "postingfailed",
+               "Could not query forum/topic/post information");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_INVALID_POST_SUBJECT)
+         {
+            addErrorMessage(response, "postingfailed", "Empty_subject");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_INVALID_POST_MESSAGE)
+         {
+            addErrorMessage(response, "postingfailed", "Empty_message");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOO_MANY_POLL_OPTION)
+         {
+            addErrorMessage(response, "postingfailed", "To_many_poll_options");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_INVALID_POLL_OPTION)
+         {
+            addErrorMessage(response, "postingfailed", "Empty_poll_option");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_INVALID_POLL_TITLE)
+         {
+            addErrorMessage(response, "postingfailed", "Empty_poll_title");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_TOO_FEW_POLL_OPTION)
+         {
+            addErrorMessage(response, "postingfailed", "To_few_poll_options");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_REPOSTED)
+         {
+            addErrorMessage(response, "postingfailed", "Reposted");
+            return;
+
+            //            Die.exit(GENERAL_MESSAGE,
+            //                  "${bb.Reposted}<br/><br/>" +
+            //                  "${bb.Click_view_message_0}" +
+            //                  "<a href=\"index.html?module=bb&op=viewtopic&t=" +
+            //                  ((RepostCommand)cmd).topic.getId() + "\">${bb.Click_view_message_1}</a>${bb.Click_view_message_2}");
+         }
+         else if (type == CommandConstants.TYPE_FLOODING_CANNOT_CREATE)
+         {
+            addErrorMessage(response, "postingfailed", "Flood_Error");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_CANNOT_ADD_ATTACHMENT)
+         {
+            addErrorMessage(response, "postingfailed",
+               "You are not authorized to add an attachment");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_CANNOT_DELETE_ATTACHMENT)
+         {
+            addErrorMessage(response, "postingfailed",
+               "You are not authorized to delete an attachment");
+            return;
+         }
+         else if (type == CommandConstants.TYPE_ERROR_IN_DELETING_ATTACHMENT)
+         {
+            addErrorMessage(response, "postingfailed",
+               "Problem when deleting an attachment");
+            return;
+         }
+         else
+         {
+            throw new RuntimeException("This statement should not be reached");
+         }
+      }
+      else
+      {
+         ForumAction faction = (ForumAction)action;
+
+         faction.init();
+
+         Forum forum = faction.getForum();
+         Category category = forum.getCategory();
+         Message msg = faction.getMessage();
+         Poster poster = faction.getPoster();
+
+         //         Level level = secGetLevel(category.getTitle() + ":" + forum.getName() + ":", currentUser);
+         //boolean loggedIn = isUserLoggedIn(currentUser);
+         boolean loggedIn = request.getRemoteUser() != null;
+         /*int[] types = new int[]{AuthType.READ, AuthType.DELETE,
+            AuthType.STICKY, AuthType.ANNOUNCE, AuthType.POLL,
+            AuthType.ATTACH};*/
+
+         //         boolean[] auths = forum.getAuth().can(types, loggedIn, level);
+         //         boolean isAuthRead = auths[0];
+         //         boolean isAuthDelete = auths[1];
+         //         boolean isAuthSticky = auths[2];
+         //         boolean isAuthAnnounce = auths[3];
+         //         boolean isAuthPollCreate = auths[4];
+         //         boolean isAuthAttachments = auths[5];
+         //         boolean isAuthMod = Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
+         // We are sure to have forumEJB not null and we always target a forum
+         int forum_id = forum.getId().intValue();
+         String forum_name = forum.getName();
+         Integer topic_id = (faction instanceof TopicAction) ? ((TopicAction)faction)
+            .getTopic().getId()
+            : new Integer(-1);
+
+         // julien : is it utile ?
+         //          if (topic_id.intValue() > -1 && (cmd instanceof NewTopicCommand || cmd instanceof ReplyCommand))
+         //          {
+         //             Map trackingTopics = getTrackingTopics(page);
+         //             trackingTopics.put(topic_id, new Date());
+         //          }
+         //      if (!"".equals(error_msg))
+         //      {
+         //         DelegateContext temp = provider.instantiate(TPL_THEME_ERROR_BODY);
+         //         temp.put("ERROR_MESSAGE", error_msg);
+         //         errorBox = temp.render();
+         //      }
+         String previewBox = "";
+         String errorBox = "";
+
+         if (ctx.p_preview)
+         {
+            PropertyMap upm = request.getUser().getProperties();
+            String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
+            String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+            String preview_message = "";
+            if ((addsign != null) && (sign != null) && addsign.equals("1"))
+            {
+               //preview_message = formatMessage(request, msg.getText() + "\n\n" + sign, msg.getBBCodeEnabled(), msg.getHTMLEnabled());
+               preview_message = formatMessage(request, msg.getText() + "\n\n" + sign, msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
+            }
+            else
+            {
+               //preview_message = formatMessage(request, msg.getText(), msg.getBBCodeEnabled(), msg.getHTMLEnabled());
+               preview_message = formatMessage(request, msg.getText(), msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
+            }
+            /*String preview_message = formatMessage(msg.getText(), msg
+                    .getBBCodeEnabled(), msg.getHTMLEnabled());*/
+            //if ((currentUser != null) && msg.getSignatureEnabled())
+            //{
+            //String signature = currentUser.getSignature();
+            String signature = request.getPreferences().getValue("signature", "");
+            if (!ForumsTools.isNullOrBlank(signature))
+            {
+               //preview_message += formatSignature(request, signature, msg.getBBCodeEnabled(), msg.getHTMLEnabled());
+               preview_message += formatSignature(request, signature, msg.getBBCodeEnabled(), request.getPreferences().getValue("allowhtml", "1").equals("1"));
+            }
+            //}
+
+            String preview_subject = formatTitle(request, msg.getSubject());
+            String preview_username = formatUserName(poster.getUser());
+
+            //
+            // Date formater
+            //
+            SimpleDateFormat sdf = getSDF(request);
+
+            //            PortletURL postingURL = response.createRenderURL();
+            //            postingURL.setParameter("op", OP_POSTING);
+            response.setRenderParameter("op", OP_POSTING);
+            response.setRenderParameter("preview", "true");
+            if (request.getParameters().getParameterExists("f"))
+            {
+               response.setRenderParameter("f", request.getParameter("f"));
+            }
+
+            if (request.getParameters().getParameterExists("p"))
+            {
+               response.setRenderParameter("p", request.getParameter("p"));
+            }
+
+            response.setRenderParameter("mode", request.getParameter("mode"));
+            response.setRenderParameter("TOPIC_TITLE", preview_subject);
+            response.setRenderParameter("POST_SUBJECT", msg.getSubject());
+            response.setRenderParameter("PREVIEW_SUBJECT", preview_subject);
+            response.setRenderParameter("POSTER_NAME", preview_username);
+            response.setRenderParameter("POST_DATE", sdf.format(new Date()));
+            response.setRenderParameter("MESSAGE", msg.getText());
+            response.setRenderParameter("PREVIEW_MESSAGE", preview_message);
+
+            //            response.sendRedirect(postingURL.toString());
+
+         }
+
+         if ((ctx.p_mode == ForumsConstants.PMODE_EDIT_POST) &&
+            (ctx.p_topic_first_post == true))
+         {
+            response.setRenderParameter("editPoll", "true");
+            Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
+            if (request.getParameter("editPostInit") != null && (ctx.p_post_id != -1))
+            {
+               try
+               {
+                  Post p = forumsModule.findPostById(new Integer(ctx.p_post_id));
+                  Topic t = forumsModule.findTopicById(p.getTopic().getId());
+                  if (t.getPoll() != null)
+                  {
+                     poll = t.getPoll();
+                  }
+               }
+               catch (ModuleException e)
+               {
+                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+               }
+            }
+            DelegateContext temp = new DelegateContext();
+            response.setRenderParameter("POLL_TITLE", poll.getTitle());
+            response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));
+            if (action instanceof EditPostAction)
+            {
+               response.setRenderParameter("switch_poll_delete_toggle", "true");
+               //root.next("switch_poll_delete_toggle");
+            }
+            int index = 0;
+            for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
+            {
+               String text = ((PollOption)iterator.next()).getQuestion();
+               //String text = (String)iterator.next();
+               String param = "poll_option_text[" + index + "]";
+               response.setRenderParameter(param, text);
+               index++;
+            }
+         }
+
+         //DelegateContext root = new DelegateContext();
+
+         /*
+          if (htmlEnabled)
+          {
+          root.next("switch_html_checkbox");
+          root.put("HTML_STATUS", "${bb.HTML_is_ON}");
+          }
+          else
+          {
+          root.put("HTML_STATUS", "${bb.HTML_is_OFF}");
+          }
+          if (codeEnabled)
+          {
+          root.next("switch_bbcode_checkbox");
+          root.put("BBCODE_STATUS", "${bb.BBCode_is_ON_0}<a href=\"index.html?module=bb&op=faq\" " +
+          "target=\"_phpbbcode\">" +
+          "${bb.BBCode_is_ON_1}</a>${bb.BBCode_is_ON_2}");
+          }
+          else
+          {
+          root.put("BBCODE_STATUS", "${bb.BBCode_is_OFF_0}<a href=\"index.html?module=bb&op=faq\"" +
+          "target=\"_phpbbcode\">" +
+          "${bb.BBCode_is_OFF_1}</a>${bb.BBCode_is_OFF_2}");
+          }
+          if (smiliesEnabled)
+          {
+          root.next("switch_smilies_checkbox");
+          root.put("SMILIES_STATUS", "${bb.Smilies_are_ON}");
+          }
+          else
+          {
+          root.put("SMILIES_STATUS", "${bb.Smilies_are_OFF}");
+          }
+          */
+         /*if ((currentUser == null)
+            || (faction instanceof EditPostAction && (((EditPostAction)faction)
+            .getPost().getPoster().getUser() == null)))
+         {
+            root.next("switch_username_select");
+         }*/
+
+         // Set the notify toggle on the template
+         /* if (currentUser != null)
+        {
+           root.next("switch_notify_checkbox");
+           boolean notify = ctx.p_notify;
+           if ((faction instanceof EditPostAction && (faction.getMode() == ForumAction.INIT))
+              || (faction instanceof ReplyAction && (faction.getMode() == ForumAction.INIT)))
+           {
+         */     /*
+                try
+                {
+                homesRW.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(currentUser.getId(), ((TopicAction)faction).getTopic().getId()));
+                notify = true;
+                }
+                catch (ObjectNotFoundException e)
+                {
+                // no watch
+                }
+                catch (FinderException e)
+                {
+                Die.exit(GENERAL_ERROR, "Could not obtain watch information", e);
+                }
+                */
+         /*   }
+
+            root.put("S_NOTIFY_CHECKED", notify ? "checked=\"checked\"" : "");
+         }*/
+
+         // Set the signature toggle on the template
+         /*if (currentUser != null)
+         {
+            root.next("switch_signature_checkbox");
+         }*/
+
+         // BLAH todo
+         // Set set delete toggle on the template
+         //          if (action instanceof EditPostAction && (isAuthMod || isAuthDelete))
+         //          {
+         //             EditPostAction epa = (EditPostAction)action;
+         //             if (epc.pd_last_post && (!epc.topic.getVote() || epc.pd_edit_poll))
+         //             {
+         //                root.next("switch_delete_checkbox");
+         //             }
+         //          }
+         // Topic type selection
+         if (faction instanceof NewTopicAction
+            || (faction instanceof EditPostAction && ((EditPostAction)faction)
+            .isFirstPost()))
+         {
+            int topic_type = ctx.p_topic_type;
+
+            // If we edit the post we override the topic type with the one loaded from the DB
+            if (faction instanceof EditPostAction
+               && (faction.getMode() == EditPostAction.INIT))
+            {
+               topic_type = ((EditPostAction)faction).getTopic().getType();
+            }
+             switch (topic_type) 
+             {
+               case 1:
+                 {
+                   response.setRenderParameter("topictype",Integer.toString(1));
+                 }
+                 break;
+               
+               case 2:
+                 {
+                   response.setRenderParameter("topictype",Integer.toString(2));
+                 }
+                 break;
+               
+             
+               default:
+                 {
+                   response.setRenderParameter("topictype",Integer.toString(0));
+                 }
+                 break;
+             }
+            /*
+             // Create the topic type selected
+             if (isAuthSticky || isAuthAnnounce)
+             {
+             StringBuffer selector = new StringBuffer("${bb.Post_topic_as}:");
+             BBTools.radioButton(selector, "topictype", "" + POST_NORMAL, topic_type == POST_NORMAL);
+             selector.append("${bb.Post_Normal}&nbsp;&nbsp;");
+             if (isAuthSticky)
+             {
+             BBTools.radioButton(selector, "topictype", "" + POST_STICKY, topic_type == POST_STICKY);
+             selector.append("${bb.Post_Sticky}&nbsp;&nbsp;");
+             }
+             if (isAuthAnnounce)
+             {
+             BBTools.radioButton(selector, "topictype", "" + POST_ANNOUNCE, topic_type == POST_ANNOUNCE);
+             selector.append("${bb.Post_Announcement}&nbsp;&nbsp;");
+             }
+             root.next("switch_type_toggle");
+             root.put("S_TYPE_TOGGLE", selector.toString());
+             }
+             */
+         }
+
+         // Hidden form fields
+         StringBuffer hidden_form_fields = new StringBuffer();
+         hidden_form_fields.append("<input type=\"hidden\" name=\"mode\" value=\"").append(ModeDecoder.encodePosting(ctx.p_mode)).append("\"/>").append("<input type=\"hidden\" name=\"op\" value=\"posting\"/>");
+         if (faction instanceof NewTopicAction)
+         {
+            hidden_form_fields.append("<input type=\"hidden\" name=\"f\" value=\"")
+               .append(forum_id).append("\"/>");
+         }
+         else if (faction instanceof ReplyAction
+            || faction instanceof EditPostAction)
+         {
+            hidden_form_fields.append("<input type=\"hidden\" name=\"p\" value=\"").append(((PostAction)faction).getPost().getId()).append("\"/>");
+         }
+
+         //System.out.println("I'm here :) - so refreshing page or doing sth else");
+         //System.out.println("Number of polls opts: " + ctx.p_poll.getOptions().size() + " plus poll lenght: " + ctx.p_poll.getLength());
+
+         String pollBox = "";
+         boolean canCreatePoll = false;
+         /*if (action instanceof EditPostAction)
+         {
+
+         switch (((EditPostAction)faction).getTopic().getPollLevel())
+         {
+         case TopicEJB.POLL_LEVEL_EMPTY:
+         canCreatePoll = isAuthPollCreate || isAuthMod;
+         break;
+         case TopicEJB.POLL_LEVEL_NO_POLL:
+         canCreatePoll = isAuthPollCreate || isAuthMod;
+         break;
+         case TopicEJB.POLL_LEVEL_NON_EMPTY:
+         canCreatePoll = isAuthMod;
+         break;
+         default:
+         throw new RuntimeException();
+         }
+
+         }
+         else*/
+         //{
+         canCreatePoll = (action instanceof NewTopicAction);
+
+         canCreatePoll &= ForumsTools.hasPermission(request, "AddPollInPost");
+         //}
+         if (canCreatePoll)
+         {
+            Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
+            DelegateContext temp = new DelegateContext();
+            response.setRenderParameter("POLL_TITLE", poll.getTitle());
+            response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));
+            if (action instanceof EditPostAction)
+            {
+               response.setRenderParameter("switch_poll_delete_toggle", "true");
+               //root.next("switch_poll_delete_toggle");
+            }
+            int index = 0;
+            for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
+            {
+               String text = ((PollOption)iterator.next()).getQuestion();
+               //String text = (String)iterator.next();
+               String param = "poll_option_text[" + index + "]";
+               response.setRenderParameter(param, text);
+               index++;
+            }
+         }
+
+         boolean canAttach = false;
+         if ((action instanceof NewTopicAction) ||
+            (action instanceof EditPostAction) ||
+            (action instanceof ReplyAction))
+         {
+            String[] testArray = new String[]{category.getTitle(), forum.getName()};
+            canAttach = ForumsTools.hasPermission(request, testArray, "AddAttachmentInPost");
+         }
+
+         //We must pass attachments data through response to creation of NewTopic view
+         if (canAttach)
+         {
+            List uploadedAttachments = ctx.p_session_attachments;
+            //index to count id of all attachments passd to view. needed to generate proper render params
+            int index = 0;
+            //if its edit we must pass already stored attachments minus those deleted by user
+            if (ctx.p_mode == ForumsConstants.PMODE_EDIT_POST)
+            {
+               Post p = null;
+               try
+               {
+                  p = forumsModule.findPostById(new Integer(ctx.p_post_id));
+               }
+               catch (ModuleException e)
+               {
+                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                  //TODO:Some nice error message...
+               }
+               List storedAttachments = null;
+               if (p != null && (storedAttachments = p.getAttachments()) != null)
+               {
+                  storedAttachments:
+                  for (Iterator i = storedAttachments.iterator(); i.hasNext();)
+                  {
+                     Attachment attachment = (Attachment)i.next();
+                     String updatedComment = null;
+                     //check if attachment id is on deleted list;
+                     for (Iterator j = ctx.p_deleted_attachments.iterator(); j.hasNext();)
+                     {
+                        Integer deletedIndex = (Integer)j.next();
+                        if (deletedIndex.intValue() == attachment.getId().intValue())
+                        {
+                           //Attachment id on deleted list so continueing without displaying it
+                           continue storedAttachments;
+                        }
+                     }
+                     for (Iterator j = ctx.p_updated_attachments.keySet().iterator(); j.hasNext();)
+                     {
+                        Integer updatedIndex = (Integer)j.next();
+                        if (updatedIndex.intValue() == attachment.getId().intValue())
+                        {
+                           //Attachment id on updated list so we retrieve updated comment
+                           updatedComment = (String)ctx.p_updated_attachments.get(updatedIndex);
+                           break;
+                        }
+                     }
+                     response.setRenderParameter("ATTACHMENT[" + index + "]_NAME", attachment.getFile().getName());
+                     response.setRenderParameter("ATTACHMENT[" + index + "]_ID", "stored_attach_" + attachment.getId());
+                     response.setRenderParameter("ATTACHMENT[" + index + "]_COMMENT", (updatedComment != null) ? updatedComment : attachment.getComment());
+                     index++;
+                  }
+               }
+            }
+            //and now pass newly uploaded ones
+            for (Iterator i = uploadedAttachments.iterator(); i.hasNext(); index++)
+            {
+               FileBinding fb = (FileBinding)i.next();
+               response.setRenderParameter("ATTACHMENT[" + index + "]_NAME", fb.getFileName());
+               response.setRenderParameter("ATTACHMENT[" + index + "]_ID", fb.getFileId());
+               response.setRenderParameter("ATTACHMENT[" + index + "]_COMMENT", fb.getComment());
+            }
+         }
+
+         // generate smilies listing for page output
+         // generate_smilies('inline', PAGE_POSTING);
+         /*
+          String pollBox = "";
+          boolean canCreatePoll = false;
+          if (action instanceof EditPostAction)
+          {
+
+          switch (((EditPostAction)faction).getTopic().getPollLevel())
+          {
+          case TopicEJB.POLL_LEVEL_EMPTY:
+          canCreatePoll = isAuthPollCreate || isAuthMod;
+          break;
+          case TopicEJB.POLL_LEVEL_NO_POLL:
+          canCreatePoll = isAuthPollCreate || isAuthMod;
+          break;
+          case TopicEJB.POLL_LEVEL_NON_EMPTY:
+          canCreatePoll = isAuthMod;
+          break;
+          default:
+          throw new RuntimeException();
+          }
+
+          }
+          else
+          {
+          canCreatePoll = action instanceof NewTopicAction;
+          }
+          if (canCreatePoll)
+          {
+          Poll poll = action instanceof NewTopicAction ? ((NewTopicAction)faction).getPoll() : ((EditPostAction)faction).getPoll();
+          DelegateContext temp = new DelegateContext();
+          temp.put("POLL_TITLE", poll.getTitle());
+          temp.put("POLL_LENGTH", Integer.toString(poll.getLength()));
+          if (action instanceof EditPostAction)
+          {
+          temp.next("switch_poll_delete_toggle");
+          }
+          int index = 0;
+          for (Iterator iterator = poll.getOptions().iterator();iterator.hasNext();)
+          {
+          String text = (String)iterator.next();
+          if (text != null)
+          {
+          DelegateContext poll_option_rows = temp.next("poll_option_rows");
+          poll_option_rows.put("POLL_OPTION", text);
+          poll_option_rows.put("S_POLL_OPTION_NUM", "" + index++);
+          }
+          }
+          pollBox = theme.TPL_THEME_POSTING_POLL_BODY.render(temp);
+          }
+          */
+         // attachBox
+         // get HTMLCode for attachment form
+         // TODO: Check the if condition for attachBox
+         //        String attachBox = "";
+         //        if (/*(action instanceof NewTopicAction || action instanceof EditPostAction) && */isAuthAttachments)
+         /*        {
+          DelegateContext temp = new DelegateContext();
+          if (showApcp)
+          {
+          temp.next("show_apcp");
+          temp.next("switch_posted_attachments");
+          }
+          String addAttachmentBox = "";
+          if (ctx.p_attach_box || !showApcp)
+          {
+          root.put("S_FORM_ENCTYPE", " enctype=\"multipart/form-data\"");
+          DelegateContext addAttachmentCtx = new DelegateContext();
+          addAttachmentBox = theme.TPL_THEME_ADD_ATTACHMENT_BODY.render(addAttachmentCtx);
+          DelegateContext hidden_row = temp.next("hidden_row");
+          hidden_row.put("S_HIDDEN", "<input type=\"hidden\" name=\"add_attachment_box_flag\" value=\"1\"/>\n");
+          temp.put("ADD_ATTACHMENT_BODY", addAttachmentBox);
+          }
+          String postedAttachmentsBox = "";
+          if ((ctx.p_posted_attach) || (!showApcp))
+          {
+          DelegateContext postedAttachmentsCtx = new DelegateContext();
+          if (faction instanceof EditPostAction)
+          {
+          EditPostAction epa = (EditPostAction)faction;
+          PostEJBLocal post = epa.getPost();
+          for (Iterator i = post.getAttachments().iterator();i.hasNext();)
+          {
+          AttachmentEJBLocal attachmentEJB = (AttachmentEJBLocal)i.next();
+          if (!ctx.p_deleted_attachments.contains(attachmentEJB.getId()))
+          {
+          DelegateContext attachRowContext = postedAttachmentsCtx.next("attach_row");
+          attachRowContext.put("FILE_NAME", attachmentEJB.getRealFilename());
+          attachRowContext.put("FILE_COMMENT", attachmentEJB.getComment());
+          attachRowContext.put("ATTACH_FILENAME", "" + attachmentEJB.getId());
+          attachRowContext.put("ATTACH_ID", "" + attachmentEJB.getId());
+          }
+          //attachRowContext.next("switch_update_attachment");
+          }
+          }
+          for (IndexIterator i = IndexIterator.wrap(faction.getAttachments().iterator(), -1);i.hasNext();)
+          {
+          UploadedFile attachment = (UploadedFile)i.next();
+          DelegateContext attachRowContext = postedAttachmentsCtx.next("attach_row");
+          attachRowContext.put("FILE_NAME", attachment.getFile().getName());
+          attachRowContext.put("FILE_COMMENT", attachment.getComment());
+          attachRowContext.put("ATTACH_FILENAME", "session_" + i.getIndex());
+          attachRowContext.put("ATTACH_ID", "session_" + i);
+          //attachRowContext.next("switch_update_attachment");
+          //attachRowContext.next("switch_thumbnail");
+          }
+          DelegateContext hidden_row = temp.next("hidden_row");
+          hidden_row.put("S_HIDDEN", "<input type=\"hidden\" name=\"posted_attachments_flag\" value=\"1\"/>\n");
+          postedAttachmentsBox = theme.TPL_THEME_POSTED_ATTACHMENTS_BODY.render(postedAttachmentsCtx);
+          temp.put("POSTED_ATTACHMENTS_BODY", postedAttachmentsBox);
+          }
+
+          //     if (ctx.p_attach)
+          //    {
+          //        UploadedFileImpl webFile = page.getParameterAsFile("fileupload");
+          //        if (webFile != null)
+          //        {
+          //           // Create the command
+          //   return new StoreAttachmentCommand(
+          //        context.getFileHome(),
+          //        id,
+          //        fileId,
+          //        webFile.getContentType(),
+          //        webFile.getContent(),
+          //        user,
+          //        makeProd);
+          //Die.exit(GENERAL_ERROR, webFile.getContentType());
+          }
+          }
+          attachBox = theme.TPL_THEME_POSTING_ATTACH_BODY.render(temp);
+          }
+          // end attachBox
+          */
+         //String topicReviewBox = "";
+         /*
+          if (isAuthRead && faction instanceof ReplyAction)
+          {
+          DelegateContext sub = topicReview(((ReplyAction)faction).getTopic());
+          // sub.next("switch_inline_mode");
+          //            topicReviewBox = theme.TPL_THEME_POSTING_TOPIC_REVIEW.render(sub);
+          }
+          */
+         // We don't handle PM for now
+         /*
+          root.next("switch_not_privmsg");
+          // Output the data to the template
+          root.put("FORUM_NAME", forum_name);
+          root.put("CATEGORY_NAME",
+          category.getTitle());
+          root.put("L_POST_A", ""); // not used, this is for the page title
+          root.put("U_VIEW_CATEGORY", "index.html?module=bb&op=main&c=" + category.getId().toString());
+          root.put("U_VIEW_FORUM", "index.html?module=bb&op=viewforum&f=" + forum_id);
+          root.put("USERNAME",
+          poster.getUserName());
+          root.put("L_EMOTICONS", ""); // todo
+          root.put("U_VIEWTOPIC",
+          (ctx.p_mode == PMODE_REPLY)
+          ? ("index.html?module=bb&op=viewtopic&t=" + topic_id + "&postorder=desc") : "");
+          root.put("U_REVIEW_TOPIC",
+          (ctx.p_mode == PMODE_REPLY) ? ("index.html?module=bb&op=posting&mode=topicreview&t=" + topic_id)
+          : "");
+          root.put("S_HTML_CHECKED", msg.getHTMLEnabled() ? "" : "checked=\"checked\"");
+          root.put("S_BBCODE_CHECKED", msg.getBBCodeEnabled() ? "" : "checked=\"checked\"");
+          root.put("S_SMILIES_CHECKED", msg.getSmiliesEnabled() ? "" : "checked=\"checked\"");
+          root.put("S_SIGNATURE_CHECKED", msg.getSignatureEnabled() ? "checked=\"checked\"" : "");
+          root.put("S_TOPIC_ID",
+          topic_id.toString());
+          //         root.put("JUMPBOX", makeJumpBox("viewforum", currentUser != null));
+          root.put("ERROR_BOX", errorBox);
+          root.put("POST_PREVIEW_BOX", previewBox);
+          //         root.put("POLLBOX", pollBox);
+          //         root.put("ATTACHBOX", attachBox);
+          root.put("TOPIC_REVIEW_BOX", topicReviewBox);
+          */
+         response.setRenderParameter("S_HIDDEN_FORM_FIELDS", hidden_form_fields
+            .toString());
+         response.setRenderParameter("op", OP_POSTING);
+         if (request.getParameters().getParameterExists("f"))
+         {
+            response.setRenderParameter("f", request.getParameter("f"));
+         }
+
+         if (request.getParameters().getParameterExists("p"))
+         {
+            response.setRenderParameter("p", request.getParameter("p"));
+         }
+         response.setRenderParameter("SUBJECT", msg.getSubject());
+
+         if (ctx.p_mode == PMODE_QUOTE)
+         {
+            Post post;
+            try
+            {
+               post = forumsModule.findPostById(new Integer(ctx.p_post_id));
+               msg.setText("[quote=" + post.getPoster().getUser().getUserName() + "]" + post.getMessage().getText() + "[/quote]");
+            }
+            catch (ModuleException e1)
+            {
+               // TODO Auto-generated catch block
+               e1.printStackTrace();
+            }
+         }
+         else if (ctx.p_mode == PMODE_EDIT_POST)
+         {
+            Post post;
+            try
+            {
+               post = forumsModule.findPostById(new Integer(ctx.p_post_id));
+               msg.setText(post.getMessage().getText());
+            }
+            catch (ModuleException e1)
+            {
+               // TODO Auto-generated catch block
+               e1.printStackTrace();
+            }
+         }
+         response.setRenderParameter("MESSAGE", msg.getText());
+      }
+   }
+
+   /**
+    * admin_forums operation
+    *
+    * @param req  JBoss Action Request
+    * @param resp JBoss Action Response
+    */
+   public void admin_forums(JBossActionRequest req, JBossActionResponse resp)
+   {
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+      //Use this to do debug
+      /*System.out.println("in admin_forums(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
+      for (Iterator i=req.getParameterMap().keySet().iterator(); i.hasNext();)
+      {
+         String key = (String)i.next();
+         System.out.println("param key: " + key + " param val: " + req.getParameter(key));
+      }*/
+      String mode = req.getParameters().get("mode", "");
+      boolean addCategory = req.getParameter("addcategory") != null;
+      Category addforum = null;
+
+      try
+      {
+         for (Iterator i = forumsModule.findCategories().iterator(); i
+            .hasNext();)
+         {
+            Category category = (Category)i.next();
+            if (req.getParameter("addforum_" + category.getId()) != null)
+            {
+               addforum = category;
+               break;
+            }
+         }
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+         addErrorMessage(resp, "admin", "Cannot process command");
+         return;
+      }
+
+      if ((addforum != null) || addCategory)
+      {
+         if (addforum != null)
+         {
+            mode = "addforum";
+         }
+         else
+         {
+            mode = "addcat";
+         }
+      }
+
+      if ("addforum".equals(mode) || "editforum".equals(mode))
+      {
+
+         /*PortletURL addOrEditForumURL = resp.createRenderURL();
+         addOrEditForumURL.setParameters(req.getParameterMap());
+         addOrEditForumURL.setParameter("mode", mode);
+         addOrEditForumURL.setParameter("op", OP_SHOWADDEDITFORUM);*/
+         resp.setRenderParameters(req.getParameterMap());
+         resp.setRenderParameter("mode", mode);
+         resp.setRenderParameter("op", OP_SHOWADDEDITFORUM);
+
+         if ("addforum".equals(mode))
+         {
+            //addOrEditForumURL.setParameter("c",  "" + addforum.getID());
+            resp.setRenderParameter("c", "" + addforum.getId());
+         }
+
+         /*try
+         {
+            resp.sendRedirect(addOrEditForumURL.toString());
+         }
+         catch (IOException e1)
+         {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+         }*/
+      }
+      else if ("cat_order".equals(mode))
+      {
+         try
+         {
+            Category category = forumsModule.findCategoryById(req
+               .getParameters().getIntObject(POST_CAT_URL));
+            String[] test = new String[]{category.getTitle()};
+            if (ForumsTools.hasPermission(req, test, "AdminCategory"))
+            {
+               OrderCategoryCommand cmd = new OrderCategoryCommand(req, resp);
+               cmd.move = req.getParameters().getInt("move", 0);
+               cmd.category = category;
+               cmd.module = forumsModule;
+               Result result = forumsModule.invoke(cmd);
+               ResultType type = result.getType();
+               if (type == CommandConstants.TYPE_CATEGORIES_ORDERED)
+               {
+                  addSuccessMessage(resp, "catorder", "Forums_updated");
+                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CANNOT_ORDER_CATEGORIES)
+               {
+                  addErrorMessage(resp, "catorder",
+                     "Can't change category order");
+                  return;
+               }
+            }
+            else
+            {
+               addErrorMessage(resp, "catorder",
+                  "Not authorized to change the category order");
+               return;
+            }
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+            addErrorMessage(resp, "catorder", "Couldn't order categories");
+            return;
+         }
+      }
+      else if ("addcat".equals(mode))
+      {
+         if (ForumsTools.hasPermission(req, "Admin"))
+         {
+            CreateCategoryCommand cmd = new CreateCategoryCommand(req, resp);
+            cmd.name = req.getParameters().get("categoryname", "").trim();
+            cmd.module = forumsModule;
+            Result result;
+            try
+            {
+               result = forumsModule.invoke(cmd);
+               ResultType type = result.getType();
+               if (type == CommandConstants.TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME)
+               {
+                  addErrorMessage(resp, "addcat",
+                     "Can't create a category without a name");
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED)
+               {
+                  addErrorMessage(resp, "addcat",
+                     "Couldn't insert row in categories table");
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CATEGORY_CREATED)
+               {
+                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                  addSuccessMessage(resp, "addcat", "Forums_updated");
+               }
+            }
+            catch (CommandException e1)
+            {
+               e1.printStackTrace();
+            }
+         }
+         else
+         {
+            addErrorMessage(resp, "addcat", "Not authorized to add a category");
+            return;
+         }
+      }
+      else if ("createforum".equals(mode))
+      {
+         try
+         {
+            Category category = forumsModule.findCategoryById(req
+               .getParameters().getIntObject(POST_CAT_URL));
+            String[] test = new String[]{category.getTitle()};
+            if (ForumsTools.hasPermission(req, test, "AdminCategory"))
+            {
+               CreateForumCommand cmd = new CreateForumCommand(req, resp);
+               cmd.name = req.getParameters().get("forumname", "");
+               cmd.description = req.getParameters().get("forumdesc", "")
+                  .trim();
+               cmd.category = category;
+               cmd.module = forumsModule;
+
+               Result result = forumsModule.invoke(cmd);
+               ResultType type = result.getType();
+
+               if (type == CommandConstants.TYPE_FORUM_CREATED)
+               {
+                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                  addSuccessMessage(resp, "addforum", "Forums_updated");
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INVALID_NAME)
+               {
+                  addErrorMessage(resp, "addforum", "Forum_missing_name");
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY)
+               {
+                  addErrorMessage(resp, "addforum", "Forum_missing_category");
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED)
+               {
+                  addErrorMessage(resp, "addforum", "Forum_failed");
+                  return;
+               }
+            }
+            else
+            {
+               addErrorMessage(resp, "addforum", "Forum_not_authorized");
+               return;
+            }
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();
+
+            //               Die.exit(GENERAL_ERROR, "Couldn't get order number from forums table", e);
+         }
+
+         //               if( $HTTP_POST_VARS['prune_enable'] )
+         //               {
+         //                  if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "")
+         //                  {
+         //                     message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
+         //                  }
+         //                  $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
+         //                     VALUES('" . $next_id . "', " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
+         //                  if( !$result = $db->sql_query($sql) )
+         //                  {
+         //                     message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql);
+         //                  }
+         //               }
+         catch (CommandException e)
+         {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+         }
+      }
+      else if ("forum_order".equals(mode))
+      {
+         try
+         {
+            Forum forum = forumsModule.findForumById(req.getParameters()
+               .getIntObject("f"));
+            String[] test = new String[]{forum.getCategory().getTitle()};
+            if (ForumsTools.hasPermission(req, test, "AdminCategory"))
+            {
+               OrderForumCommand cmd = new OrderForumCommand(req, resp);
+               cmd.module = forumsModule;
+               cmd.forum = forum;
+               cmd.move = req.getParameters().getIntObject("move", 0)
+                  .intValue();
+               Result result = forumsModule.invoke(cmd);
+               ResultType type = result.getType();
+               if (type == CommandConstants.TYPE_FORUMS_ORDERED)
+               {
+                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                  addSuccessMessage(resp, "ordersuccess", "Forums_updated");
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CANNOT_ORDER_FORUMS)
+               {
+                  addErrorMessage(resp, "orderfailed",
+                     "Couldn't change category order");
+                  return;
+               }
+            }
+            else
+            {
+               addErrorMessage(resp, "forum",
+                  "Not authorized to change order in this category");
+               return;
+            }
+         }
+         catch (Exception e)
+         {
+            addErrorMessage(resp, "orderfailed",
+               "Couldn't change category order");
+            return;
+         }
+      }
+      else if ("forum_sync".equals(mode))
+      {
+         //               sync('forum', intval($HTTP_GET_VARS[POST_FORUM_URL]));
+         //               $show_index = TRUE;
+      }
+      else if ("deletecat".equals(mode))
+      {
+         try
+         {
+            Integer catId = req.getParameters().getIntObject(POST_CAT_URL);
+            Category category = forumsModule.findCategoryById(catId);
+            String selectTo = "";
+            if (forumsModule.findCategories().size() == 1)
+            {
+               if (forumsModule.findForumsByCategoryId(catId).size() > 0)
+               {
+                  addErrorMessage(resp, "deletecat", "Must_delete_forums");
+                  return;
+               }
+               else
+               {
+                  selectTo = bundle.getString("Nowhere_to_move");
+               }
+            }
+            else
+            {
+               selectTo = "<select name=\"to_id\">"
+                  + ForumsTools.listCategories(forumsModule.findCategories(), catId.intValue())
+                  + "</select>";
+            }
+
+            resp.setRenderParameter("op", OP_SHOWDELETEFORUM);
+            resp.setRenderParameter("NAME", category.getTitle());
+            resp.setRenderParameter("S_SELECT_TO", selectTo);
+            resp
+               .setRenderParameter("S_HIDDEN_FIELDS",
+                  "<input type=\"hidden\" name=\"mode\" value=\"movedelcat\"/>"
+                     + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
+                     + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>"
+                     + "<input type=\"hidden\" name=\"from_id\" value=\""
+                     + catId + "\"/>");
+
+            /*
+             DelegateContext root = new DelegateContext();
+             root.put("NAME", category.getTitle());
+             root.put("S_SELECT_TO", selectTo);
+             root.put("S_HIDDEN_FIELDS", "<input type=\"hidden\" name=\"mode\" value=\"movedelcat\"/>" +
+             "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
+             "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>" +
+             "<input type=\"hidden\" name=\"from_id\" value=\"" + catId + "\"/>");
+             display(theme.TPL_THEME_ADMIN_FORUM_DELETE_BODY, root, page);
+             */
+         }
+         catch (ModuleException e)
+         {
+            addErrorMessage(resp, "deletefailed", "Couldn't get Forum info");
+            return;
+         }
+      }
+      else if ("movedelcat".equals(mode))
+      {
+         try
+         {
+            Category fromCategory = forumsModule.findCategoryById(req
+               .getParameters().getIntObject("from_id"));
+            Category toCategory = forumsModule.findCategoryById(req
+               .getParameters().getIntObject("to_id"));
+            if (req.getParameters().getIntObject("from_id").equals(req.getParameters().getIntObject("to_id")))
+            {
+               addErrorMessage(resp, "deletecat", "cant_move_to_same_category");
+               return;
+            }
+            String[] test1 = new String[]{fromCategory.getTitle()};
+            String[] test2 = new String[]{toCategory.getTitle()};
+            if ((ForumsTools.hasPermission(req, test1, "DeleteForumInCategory"))
+               && (ForumsTools.hasPermission(req, test2, "AddForumInCategory")))
+            {
+               DeleteMoveCategoryCommand cmd = new DeleteMoveCategoryCommand(req, resp);
+               cmd.source = fromCategory;
+               cmd.target = toCategory; //null
+               cmd.module = forumsModule;
+               Result result = forumsModule.invoke(cmd);
+               ResultType type = result.getType();
+               if (type == CommandConstants.TYPE_CANNOT_REMOVE_CATEGORY)
+               {
+                  addErrorMessage(resp, "deletecategory",
+                     "Couldn't delete category");
+                  return;
+               }
+               else if (type == CommandConstants.TYPE_CATEGORY_REMOVED)
+               {
+                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                  addSuccessMessage(resp, "deletecategory", "Forums_updated");
+                  return;
+               }
+            }
+            else
+            {
+               addErrorMessage(resp, "deletecategory",
+                  "You can't delete and move this category");
+               return;
+            }
+         }
+         catch (Exception e)
+         {
+            addErrorMessage(resp, "deletefailed", "Couldn't delete category");
+            e.printStackTrace();
+            return;
+         }
+      }
+      else if ("deleteforum".equals(mode))
+      {
+         try
+         {
+            Integer forumId = req.getParameters().getIntObject("f");
+            Forum forum = forumsModule.findForumById(forumId);
+            resp.setRenderParameter("op", OP_SHOWDELETEFORUM);
+            resp.setRenderParameter("NAME", forum.getName());
+            resp
+               .setRenderParameter("S_HIDDEN_FIELDS",
+                  "<input type=\"hidden\" name=\"mode\" value=\"movedelforum\"/>"
+                     + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
+                     + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>"
+                     + "<input type=\"hidden\" name=\"from_id\" value=\""
+                     + forum.getId() + "\"/>");
+            resp.setRenderParameter("S_SELECT_TO",
+               "<select name=\"to_id\"><option value=\"-1\">"
+                  + bundle.getString("Delete_all_posts")
+                  + "</option>\n" // $s
+                  + ForumsTools.listForums(forumsModule.findForums(),
+                  forumId.intValue()) + "</select>");
+
+            //            display(theme.TPL_THEME_ADMIN_FORUM_DELETE_BODY, root, page);
+         }
+         catch (ModuleException e)
+         {
+            addErrorMessage(resp, "deletefailed",
+               "Could not obtain forum information");
+            e.printStackTrace();
+            return;
+         }
+      }
+      else if ("movedelforum".equals(mode))
+      {
+         // int deleteOld = page.getParameterAsInt("delete_old", -1);
+         try
+         {
+            Integer fromId = req.getParameters().getIntObject("from_id", -1);
+            Forum fromForum = forumsModule.findForumById(fromId);
+            Integer toId = req.getParameters().getIntObject("to_id", -1);
+            if ((toId.intValue() < 0) && (fromId.intValue() >= 0))
+            {
+               String[] test = new String[]{
+                  fromForum.getCategory().getTitle(), fromForum.getName()};
+               if (ForumsTools.hasPermission(req, test, "DeletePostInForum"))
+               {
+                  //resp.setRenderParameter("op","" + OP_SHOWFORUM);
+                  DeleteForumCommand cmd = new DeleteForumCommand(req, resp);
+                  cmd.forum = fromForum;
+                  cmd.module = forumsModule;
+                  Result result = forumsModule.invoke(cmd);
+                  ResultType type = result.getType();
+                  if (type == CommandConstants.TYPE_FORUM_REMOVED)
+                  {
+                     resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                     addSuccessMessage(resp, "delete", "Forums_updated");
+                     return;
+                  }
+                  else if (type == CommandConstants.TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED)
+                  {
+                     addErrorMessage(resp, "delete", "Could not delete forum");
+                  }
+               }
+            }
+            else if (!fromId.equals(toId) && (fromId.intValue() >= 0)
+               && (toId.intValue() >= 0))
+            {
+               Forum toForum = forumsModule.findForumById(toId);
+               String[] test1 = new String[]{
+                  fromForum.getCategory().getTitle(), fromForum.getName()};
+               String[] test2 = new String[]{
+                  toForum.getCategory().getTitle(), toForum.getName()};
+               if ((ForumsTools.hasPermission(req, test1, "DeletePostInForum"))
+                  && (ForumsTools.hasPermission(req, test2, "AddPostInForum")))
+               {
+                  DeleteMoveForumCommand cmd = new DeleteMoveForumCommand(req, resp);
+                  cmd.source = fromForum;
+                  cmd.target = toForum;
+                  cmd.module = forumsModule;
+                  Result result = forumsModule.invoke(cmd);
+                  ResultType type = result.getType();
+                  if (type == CommandConstants.TYPE_FORUM_MOVED_AND_REMOVED)
+                  {
+                     resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                     addSuccessMessage(resp, "delete", "Forums_updated");
+                     return;
+                  }
+                  else if (type == CommandConstants.TYPE_CANNOT_MOVE_AND_REMOVE_FORUM)
+                  {
+                     addErrorMessage(resp, "delete", "Could not delete forum");
+                     return;
+                  }
+
+                  /*
+                   cmd.sourceId = fromId;
+                   cmd.targetId = toId;
+                   cmd.topicDataSource = topicDataSource;
+                   cmd.topicTableName = topicTableName;
+                   cmd.topicForumFKColumnName = topicForumRelationColumnName;
+                   cmd.postDataSource = postDataSource;
+                   cmd.postTableName = postTableName;
+                   cmd.postForumFKColumnName = postForumRelationColumnName;
+                   cmd.forumHome = homesRW.forum;
+                   cmd.postHome = homesRW.post;
+                   cmd.topicHome = homesRW.topic;
+                   Result result = forumsModule.invoke(req, resp, cmd);
+                   */
+               }
+            }
+            else
+            {
+               addErrorMessage(resp, "delete", "Sorry but forums weren't updated... Check options you choose and try again");
+            }
+         }
+         catch (Exception e)
+         {
+            addErrorMessage(resp, "delete", "Could not delete forum");
+            e.printStackTrace();
+            return;
+         }
+      }
+      else if ("editcat".equals(mode))
+      {
+         try
+         {
+            Integer catId = req.getParameters().getIntObject(POST_CAT_URL);
+            Category category = forumsModule.findCategoryById(catId);
+            String hiddenFields = "<input type=\"hidden\" name=\"mode\" value=\"modcat\"/>"
+               + "<input type=\"hidden\" name=\""
+               + POST_CAT_URL
+               + "\" value=\""
+               + category.getId()
+               + "\"/>"
+               + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
+               + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>";
+            resp.setRenderParameter("op", OP_SHOWEDITCATEGORY);
+            resp.setRenderParameter("c", "" + category.getId());
+            resp.setRenderParameter("CAT_TITLE", category.getTitle());
+            resp.setRenderParameter("S_HIDDEN_FIELDS", hiddenFields);
+
+            //               display(theme.TPL_THEME_ADMIN_CATEGORY_EDIT_BODY, root, page);
+         }
+         catch (ModuleException e)
+         {
+            addErrorMessage(resp, "deletefailed", "Cannot edit category");
+            e.printStackTrace();
+            return;
+         }
+      }
+      else if ("modcat".equals(mode))
+      {
+         try
+         {
+            Category category = forumsModule.findCategoryById(req
+               .getParameters().getIntObject(POST_CAT_URL));
+            String[] test = new String[]{category.getTitle()};
+            if (ForumsTools.hasPermission(req, test, "EditCategory"))
+            {
+               UpdateCategoryCommand cmd = new UpdateCategoryCommand(req, resp);
+               cmd.title = req.getParameters().get("cat_title", "").trim();
+               cmd.category = category;
+               Result result = forumsModule.invoke(cmd);
+               ResultType type = result.getType();
+               if (type == CommandConstants.TYPE_CATEGORY_UPDATED)
+               {
+                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                  addSuccessMessage(resp, "update", "Forums_updated");
+                  return;
+               }
+            }
+         }
+         catch (Exception e)
+         {
+            addErrorMessage(resp, "update", "Cannot update category");
+            e.printStackTrace();
+            return;
+         }
+      }
+      else if ("modforum".equals(mode))
+      {
+         //                  if( isset($HTTP_POST_VARS['prune_enable']))
+         //                  {
+         //                     if( $HTTP_POST_VARS['prune_enable'] != 1 )
+         //                     {
+         //                        $HTTP_POST_VARS['prune_enable'] = 0;
+         //                     }
+         //                  }
+         try
+         {
+            Category category = forumsModule.findCategoryById(req
+               .getParameters().getIntObject(POST_CAT_URL));
+            Forum forum = forumsModule.findForumById(req.getParameters()
+               .getIntObject("f"));
+            String[] test1 = new String[]{category.getTitle(),};
+            String[] test2 = new String[]{forum.getCategory().getTitle(),};
+            if ((ForumsTools.hasPermission(req, test1, "AddForumInCategory"))
+               && (ForumsTools.hasPermission(req, test2, "EditForumInCategory")))
+            {
+               UpdateForumCommand cmd = new UpdateForumCommand(req, resp);
+               cmd.name = req.getParameters().get("forumname", "");
+               cmd.description = req.getParameters().get("forumdesc", "");
+               cmd.category = category;
+               cmd.forum = forum;
+               Result result = forumsModule.invoke(cmd);
+               ResultType type = result.getType();
+               if (type == CommandConstants.TYPE_FORUM_UPDATED)
+               {
+                  resp.setRenderParameter("op", OP_SHOWADMINFORUMS);
+                  addSuccessMessage(resp, "edit", "Forums_updated");
+                  return;
+               }
+            }
+            addErrorMessage(resp, "edit", "Cannot update forums");
+
+            // forum_status = intval($HTTP_POST_VARS['forumstatus'])
+            // prune_enable = intval($HTTP_POST_VARS['prune_enable']
+         }
+         catch (Exception e)
+         {
+            addErrorMessage(resp, "edit", "Couldn't update forum information");
+            e.printStackTrace();
+            return;
+         }
+
+         //                  if( $HTTP_POST_VARS['prune_enable'] == 1 )
+         //                  {
+         //                     if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "" )
+         //                     {
+         //                        message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
+         //                     }
+         //                     $sql = "SELECT *
+         //                        FROM " . PRUNE_TABLE . "
+         //                        WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
+         //                     if( !$result = $db->sql_query($sql) )
+         //                     {
+         //                        message_die(GENERAL_ERROR, "Couldn't get forum Prune Information","",__LINE__, __FILE__, $sql);
+         //                     }
+         //                     if( $db->sql_numrows($result) > 0 )
+         //                     {
+         //                        $sql = "UPDATE " . PRUNE_TABLE . "
+         //                           SET   prune_days = " . intval($HTTP_POST_VARS['prune_days']) . ",   prune_freq = " . intval($HTTP_POST_VARS['prune_freq']) . "
+         //                            WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
+         //                     }
+         //                     else
+         //                     {
+         //                        $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
+         //                           VALUES(" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
+         //                     }
+         //                     if( !$result = $db->sql_query($sql) )
+         //                     {
+         //                        message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql);
+         //                     }
+         //                  }
+         //            Die.exit(GENERAL_MESSAGE, "${bb.Forums_updated}<br/><br/>${bb.Click_return_forumadmin_0}<a href=\"" +
+         //                  "index.html?module=bb&op=admin_forums\">${bb.Click_return_forumadmin_1}</a>" +
+         //                  "${bb.Click_return_forumadmin_2}<br/><br/>${bb.Click_return_admin_index_0}" +
+         //                  "<a href=\"index.html?module=bb&pane=right\">${bb.Click_return_admin_index_1}</a>" +
+         //                  "${bb.Click_return_admin_index_2}");
+      }
+   }
+
+   private DelegateContext fillShowIndexContext(JBossRenderRequest req,
+                                                JBossRenderResponse resp, DelegateContext root)
+   {
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+
+      Integer c = req.getParameters().getIntObject("c", -1);
+      try
+      {
+         if (c.intValue() != -1)
+         {
+            Category category = forumsModule.findCategoryById(c);
+            fillShowCategoryContext(req, resp, root, category);
+         }
+         else
+         {
+            // Fill context with categories
+            Iterator iterator = forumsModule.findCategories().iterator();
+            while (iterator.hasNext())
+            {
+               Category currentCategory = (Category)iterator.next();
+
+               fillShowCategoryContext(req, resp, root, currentCategory);
+            }
+         }
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+      return root;
+   }
+
+   private DelegateContext fillShowCategoryContext(JBossRenderRequest req,
+                                                   JBossRenderResponse resp, DelegateContext root, Category category)
+   {
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+      try
+      {
+         String[] testArray = new String[]{category.getTitle()};
+
+         boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadCategory");
+
+         if (authRead)
+         {
+            DelegateContext catrow = root.next("catrow");
+            catrow.put("CAT_DESC", category.getTitle());
+            PortletURL viewCatURL = resp.createRenderURL();
+            viewCatURL.setParameter("op", OP_MAIN);
+            viewCatURL.setParameter("c", "" + category.getId());
+            catrow.put("U_VIEWCAT", viewCatURL.toString());
+
+            // Fill context with forums
+            Iterator forumsIterator = forumsModule.findForumsByCategoryId(category.getId()).iterator();
+            while (forumsIterator.hasNext())
+            {
+               Forum currentForum = (Forum)forumsIterator.next();
+               Integer currentCategoryId = category.getId();
+               String currentCategoryTitle = category.getTitle();
+               String currentForumName = currentForum.getName();
+               testArray = new String[]{currentCategoryTitle,
+                  currentForumName};
+
+               authRead = ForumsTools.hasPermission(req, testArray, "ReadForum");
+               boolean authView = authRead;
+
+               // We display the forum only if needed
+               if (authView)
+               {
+                  // Get forum data
+                  int currentForumStatus = currentForum.getStatus();
+                  Integer currentForumId = currentForum.getId();
+                  Post lastPost = currentForum.getLastPost();
+                  String currentForumDescription = currentForum
+                     .getDescription();
+                  int currentForumPostSize = currentForum.getPostCount();
+                  int currentForumTopicSize = currentForum.getTopicCount();
+                  String folderImage = theme.resourceForumURL;
+                  String folderAlt = bundle.getString("No_new_posts");
+                  if (currentForumStatus == FORUM_LOCKED)
+                  {
+                     folderImage = theme.resourceForumLockedURL;
+                     folderAlt = bundle.getString("Forum_locked");
+                  }
+
+                  /*
+                   else
+                   {
+                   Date when1 = (Date)dates.get(currentForumId);
+                   Date when2 = (Date)trackingForums.get(currentForumId);
+                   if ((Time.compare(when1, when2) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0)
+                   {
+                   folderImage = theme.resourceForumNewBigURL;
+                   folderAlt = "${bb.New_posts}";
+                   }
+                   }
+                   */
+
+                  // Get the last post text
+                  String lastPostText = bundle.getString("No_Posts");
+                  if (lastPost != null)
+                  {
+                     Integer lastPostId = lastPost.getId();
+                     StringBuffer temp = new StringBuffer();
+                     Date lastPostDate = lastPost.getCreateDate();
+
+                     // temp.append(dateFormatPool.formatDate(lastPostDate)).append("<br/>");
+                     // temp.append(lastPost.getPoster().getAuthor(true));
+                     SimpleDateFormat sdf = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
+                     //temp.append(lastPostDate).append("<br/>");
+                     temp.append(sdf.format(lastPostDate)).append("<br/>");
+                     if ((req.getRemoteUser() != null))
+                     {
+                        PortletURL userProfileURL = resp.createRenderURL();
+                        userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
+                        userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
+                        temp.append("<a href=\"" + userProfileURL.toString() + "\">" + lastPost.getPoster().getUser().getUserName() + "</a>");
+                     }
+                     else
+                     {
+                        temp.append(lastPost.getPoster().getUser().getUserName());
+                     }
+                     PortletURL postURL = resp.createRenderURL();
+                     postURL.setParameter("op", OP_SHOWTOPIC);
+                     postURL.setParameter("p", "" + lastPostId);
+                     temp.append("<a href=\"").append(postURL.toString())
+                        .append("\"><img src=\"").append(theme.resourceIconLatestReplyURL).append("\" border=\"0\" alt=\""
+                        + bundle.getString("View_latest_post")
+                        + "\" title=\""
+                        + bundle.getString("View_latest_post")
+                        + "\"/></a>");
+                     lastPostText = temp.toString();
+                  }
+
+                  // Fetch the moderator list
+                  String moderatorList = "&nbsp";
+                  String moderatorsMessage = "&nbsp;";
+
+                  /*
+                   Set moderators = moderators(currentCategoryTitle, currentForumName);
+                   if (moderators.size() > 0)
+                   {
+                   StringBuffer temp = new StringBuffer();
+                   for (Iterator j = moderators.iterator();j.hasNext();temp.append(j.hasNext() ? "," : ""))
+                   {
+                   temp.append(j.next());
+                   }
+                   moderatorList = temp.toString();
+                   moderatorsMessage = moderators.size() == 1 ? "${bb.Moderator}" : "${bb.Moderators}";
+                   }
+                   */
+
+                  // Build the template
+                  DelegateContext forumrow = catrow.next("forumrow");
+
+                  /*                     forumrow.put("ROW_COLOR", theme.getProperty(i.getIndex() % 2 == 0 ? "td_color1" : "td_color2"));
+                   forumrow.put("ROW_CLASS", theme.getProperty(i.getIndex() % 2 == 0 ? "td_class1" : "td_class2"));
+                   */
+                  forumrow.put("FORUM_FOLDER_IMG", folderImage);
+                  forumrow.put("FORUM_NAME", currentForumName);
+                  forumrow.put("FORUM_DESC", currentForumDescription);
+                  forumrow.put("POSTS", "" + currentForumPostSize);
+                  forumrow.put("TOPICS", "" + currentForumTopicSize);
+                  forumrow.put("LAST_POST", lastPostText);
+                  forumrow.put("MODERATORS", moderatorList);
+                  forumrow.put("L_MODERATOR", moderatorsMessage);
+                  forumrow.put("L_FORUM_FOLDER_ALT", folderAlt);
+                  PortletURL viewForumURL = resp.createRenderURL();
+                  viewForumURL.setParameter("op", OP_SHOWFORUM);
+                  viewForumURL.setParameter("f", currentForumId.toString());
+                  forumrow.put("U_VIEWFORUM", viewForumURL.toString());
+               }
+            }
+         }
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      return root;
+   }
+
+   private DelegateContext fillShowForumContext(JBossRenderRequest req,
+                                                JBossRenderResponse resp, DelegateContext root)
+   {
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+
+      //      JBossPortletPreferences prefs =
+      //         new JBossPortletPreferences(null,
+      //                                     req.getUser().getPreferenceStore().get(new FQN("org.jboss.portlet.forums")),
+      //                                     null, PortletPreferencesImpl.RENDER, proxyInfo);
+      //      PreferencesProxy        proxy = (PreferencesProxy) prefs.getProxy();
+
+      /*int topicsPerPage = 10;*/
+      int topicsPerPage = Integer.parseInt(req.getPreferences().getValue("topicsperforum", "10"));
+      int hotThreshold = 10;
+      /*int postsPerPage = 10;*/
+      int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
+
+
+      Integer forumId = req.getParameters().getIntObject("f", -1);
+      int start = req.getParameters().getInt("start", 0);
+
+      //      String markRead = page.getParameter("mark", "");
+      int topicDays = req.getParameters().getInt("topicdays", 0);
+
+      Forum forum = null;
+      try
+      {
+         forum = forumsModule.findForumById(forumId);
+      }
+      catch (ModuleException e1)
+      {
+         // TODO Auto-generated catch block
+         e1.printStackTrace();
+      }
+
+      Category category = forum.getCategory();
+      User user = req.getUser();
+      //boolean loggedIn = isUserLoggedIn(user);
+      boolean loggedIn = req.getRemoteUser() != null;
+      Date lastVisit = loggedIn ? user.getLastVisitDate() : null;
+      String categoryTitle = category.getTitle();
+      String forumName = forum.getName();
+
+      //      Level level = secGetLevel(categoryTitle + ":" + forumName + ":");
+      //      Auth auth = forum.getAuth();
+      //TODO: add security here
+      String[] testArray = new String[]{categoryTitle, forumName};
+      boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadForum"); //auth.can(Auth.TYPE_READ, loggedIn, level);
+      boolean authView = ForumsTools.hasPermission(req, testArray, "ReadForum"); //auth.can(Auth.TYPE_VIEW, loggedIn, level);
+      boolean authPost = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
+      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum"); //Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
+
+      if (authPost)
+      {
+         root.next("AUTH_POST");
+      }
+
+      if (!authRead || !authView)
+      {
+         System.out.println("You are not authorized to see this forum");
+         return root;
+
+         /*
+          if (!loggedIn)
+          {
+          //  $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
+          //  redirect(append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
+          //            page.sendRedirect("index.html?module=user&op=getlogin");
+          //            return root;
+          }
+          Die.exit(GENERAL_MESSAGE, !authView ? "${bb.Forum_not_exist}" : "sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type'])");
+          */
+      }
+
+      /*
+       if ("topics".equals(markRead) && loggedIn)
+       {
+       PostEJBLocal lastPost = forum.getLastPost();
+       if (lastPost != null)
+       {
+       if (lastPost.getPostDate().after(lastVisit))
+       {
+       getTrackingForums(page).put(forumId, new Date());
+       }
+       }
+       Die.exit(GENERAL_MESSAGE, "${bb.Topics_marked_read}<br/><br/>" +
+       "${bb.Click_return_forum_0}<a href=\"index.html?module=bb&op=viewforum&f=" +
+       forumId + "\">${bb.Click_return_forum_1}</a>" +
+       "${bb.Click_return_forum_2}");
+       }
+       if (authMod && pruneEnable)
+       {
+       //   if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
+       //   {
+       //      include($phpbb_root_path . 'includes/prune.'.$phpEx);
+       //      require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
+       //      auto_prune($forum_id);
+       //   }
+       }
+       // todo put that in statistics
+       Set moderators = moderators(categoryTitle, forumName);
+       String moderatorMessage = "${bb.Moderators}";
+       String moderatorList = "${bb.None}";
+       if (moderators.size() > 0)
+       {
+       StringBuffer temp = new StringBuffer();
+       if (moderators.size() == 1)
+       {
+       moderatorMessage = "${bb.Moderator}";
+       }
+       for (Iterator iterator = moderators.iterator();iterator.hasNext();)
+       {
+       temp.append((String)iterator.next());
+       if (iterator.hasNext())
+       {
+       temp.append(", ");
+       }
+       }
+       moderatorList = temp.toString();
+       }
+       //      int topicCount = 0;
+       */
+      Date minTopicTime = null;
+      if (topicDays > 0)
+      {
+         Calendar c = Calendar.getInstance();
+         c.add(Calendar.DATE, -topicDays);
+         minTopicTime = c.getTime();
+
+         //         Collection temp = null;
+         //         try
+         //         {
+         //            temp = homes.topic.selectGeneric("SELECT t.id FROM topic AS t WHERE t.forum=?1 AND t.lastPost.postDate>=?2",
+         //                                             new Object[]{forum, minTopicTime});
+         //         }
+         //         catch(FinderException e)
+         //         {
+         //            Die.exit(GENERAL_ERROR, "Could not obtain limited topics count information");
+         //         }
+         //         topicCount = temp.size();
+      }
+      else
+      {
+         //         topicCount = forum.getTopicSize();
+         topicDays = 0;
+      }
+
+      List announcements = null;
+      List topics = null;
+
+      try
+      {
+         announcements = forumsModule.findAnnouncements(forum);
+         topics = (minTopicTime == null) ? forumsModule.findTopicsDesc(forum,
+            POST_ANNOUNCE, start, topicsPerPage) : forumsModule
+            .findTopicsBefore(forum, POST_ANNOUNCE, start, topicsPerPage,
+               minTopicTime);
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      int totalAnnoucements = announcements.size();
+      int totalTopicsAndStickies = forum.getTopicCount();
+      int totalTopics = totalTopicsAndStickies; // + totalAnnoucements;
+
+      StringBuffer authCan = new StringBuffer();
+      //Prapare permission info
+      //authCan.append(authMod ? bundle.getString("Rules_moderate_0") : bundle.getString("Rules_moderate_0"));
+
+      //authCan = new StringBuffer();
+
+      //generate "You can..." forum permissions description
+      ForumsTools.authCan(authCan, req, testArray, bundle);
+      //Moderator permission is described separately
+      PortletURL moderateURL = resp.createRenderURL();
+      moderateURL.setParameter(getOperationName(), OP_SHOWMODERATEFORUM);
+      moderateURL.setParameter("f", "" + forumId);
+      if (authMod)
+      {
+         authCan.append(bundle.getString("Rules_moderate_0")).
+            append("<a href=\"" + moderateURL.toString() + "\">").
+            append(bundle.getString("Rules_moderate_2")).
+            append("</a><br/>");
+      }
+      else
+      {
+         authCan.append(bundle.getString("Rules_moderate_1")).
+            append(bundle.getString("Rules_moderate_2")).
+            append("<b/>");
+      }
+
+      Iterator ci = new CompoundIterator(new Iterator[]{
+         announcements.iterator(), topics.iterator()});
+
+      /*
+       if (!ci.hasNext())
+       {
+       }
+       */
+
+      //      if
+      //	No topics
+      //	$no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
+      //	$template->assign_vars(array(
+      //	'L_NO_TOPICS' => $no_topics_msg)
+      /*
+       Map trackingForums = getTrackingForums(page);
+       Map trackingTopics = getTrackingTopics(page);
+       Date trackingAllForums = (Date)page.getSession().getAttribute(cookieName + "_f_all");
+       */
+      PortletURL gotoURL = resp.createRenderURL();
+      gotoURL.setParameter("op", OP_SHOWTOPIC);
+      Goto toPost = new Goto(postsPerPage, bundle.getString("Goto_page"), gotoURL.toString());
+      toPost.setImgUrl(theme.resourceIconGotopostURL);
+
+      for (IndexIterator iterator = IndexIterator.wrap(ci, -1); iterator
+         .hasNext();)
+      {
+         Topic topic = (Topic)iterator.next();
+
+         int replies = topic.getReplies();
+         int status = topic.getStatus();
+         /*Integer topicId = (status == TOPIC_MOVED) ? topic.getTarget().getID()
+                 : topic.getID();*/
+         Integer topicId = topic.getId();
+         String type = bundle.getString("Topic_Moved");
+         String folderImage = theme.resourceFolderURL;
+         String folderAlt = bundle.getString("Topic_Moved");
+         String newestPostImg = "";
+         Date topicLastPostDate = (topic.getLastPost() != null) ? topic.getLastPost().getCreateDate() : null;
+         Post firstPost = topic.getFirstPost();
+         Post lastPost = topic.getLastPost();
+         Poster lastPostUser = lastPost.getPoster();
+         Poster poster = topic.getPoster();
+
+         if (status != TOPIC_MOVED)
+         {
+            FolderType folderType = theme.getFolderType(topic.getType(),
+               status, replies >= hotThreshold);
+            boolean newest = loggedIn; /* &&
+                     ((Time.compare(topicLastPostDate, lastVisit) & Time.LEFT_AFTER) != 0) &&
+                     ((Time.compare(topicLastPostDate, trackingAllForums) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0) &&
+                     ((Time.compare(topicLastPostDate, (Date)trackingTopics.get(topicId)) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0) &&
+                     ((Time.compare(topicLastPostDate, (Date)trackingForums.get(forumId)) & (Time.LEFT_AFTER | Time.RIGHT_NULL)) != 0);
+                     */
+
+            if (newest)
+            {
+               folderImage = folderType.folderNew;
+               folderAlt = (status == TOPIC_LOCKED) ? bundle
+                  .getString("Topic_locked") : bundle.getString("New_posts");
+               newestPostImg = "<a href=\"index.html?module=bb&op=viewtopic&t="
+                  + topicId + "&view=newest\"><img src=\""
+                  + theme.resourceIconNewestReplyURL + "\" alt=\""
+                  + bundle.getString("View_newest_post") + "\" title=\""
+                  + bundle.getString("View_newest_post")
+                  + "\" border=\"0\"/></a>";
+            }
+            else
+            {
+               folderImage = folderType.folder;
+               folderAlt = (status == TOPIC_LOCKED) ? bundle
+                  .getString("Topic_locked") : bundle
+                  .getString("No_new_posts");
+               newestPostImg = "";
+            }
+
+            try
+            {
+               type = bundle.getString(folderType.type);
+            }
+            catch (java.util.MissingResourceException e)
+            {
+               type = "";
+            }
+
+            /*
+             if (topic.getVote())
+             {
+             type += "${bb.Topic_Poll} ";
+             }
+             */
+         }
+
+         toPost.setPostSize(replies);
+         toPost.setTopicId(topicId.intValue());
+         String gotoPage = toPost.generate();
+         String rowColor = theme
+            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_color1"
+               : "td_color2");
+         String rowClass = theme
+            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_class1"
+               : "td_class2");
+         String topicAuthor = firstPost.getPoster().getUser().getUserName();
+         String lastPostAuthor = lastPost.getPoster().getUser().getUserName();
+
+         PortletURL lastPostURL = resp.createRenderURL();
+         lastPostURL.setParameter("op", OP_SHOWTOPIC);
+         lastPostURL.setParameter("p", "" + lastPost.getId());
+
+         String lastPostUrl = "<a href=\"" + lastPostURL.toString() + "\">"
+            + "<img src=\"" + theme.resourceIconLatestReplyURL + "\" alt=\""
+            + bundle.getString("View_latest_post") + "\" title=\""
+            + bundle.getString("View_latest_post") + "\" border=\"0\"/></a>";
+
+         DelegateContext topicrow = root.next("topicrow");
+         topicrow.put("ROW_COLOR", rowColor);
+         topicrow.put("ROW_CLASS", rowClass);
+         topicrow.put("FORUM_ID", forumId.toString());
+         topicrow.put("TOPIC_ID", topicId.toString());
+         topicrow.put("TOPIC_FOLDER_IMG", folderImage);
+         topicrow.put("TOPIC_AUTHOR", topicAuthor);
+         topicrow.put("GOTO_PAGE", gotoPage);
+         topicrow.put("REPLIES", "" + replies);
+         //topicrow.put("NEWEST_POST_IMG", newestPostImg);
+         topicrow.put("NEWEST_POST_IMG", lastPostUrl);
+         topicrow.put("TOPIC_TITLE", formatTitle(req, topic.getSubject()));
+         topicrow.put("TOPIC_TYPE", type);
+         topicrow.put("VIEWS", "" + topic.getViewCount());
+
+         //         topicrow.put("FIRST_POST_TIME", dateFormatPool.formatDate(topic.getCreationDate()));
+         /*topicrow.put("LAST_POST_TIME", topic.getLastPostDate().toString());*/
+         SimpleDateFormat sdfp = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
+         topicrow.put("LAST_POST_TIME", sdfp.format(topic.getLastPostDate()));
+         if ((req.getRemoteUser() != null))
+         {
+            PortletURL userProfileURL = resp.createRenderURL();
+            userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
+            userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
+            topicrow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
+         }
+         topicrow.put("LAST_POST_AUTHOR", lastPostAuthor);
+         topicrow.put("LAST_POST_IMG", lastPostUrl);
+         topicrow.put("L_TOPIC_FOLDER_ALT", folderAlt);
+         PortletURL viewTopicURL = resp.createRenderURL();
+         viewTopicURL.setParameter("op", OP_SHOWTOPIC);
+         viewTopicURL.setParameter("t", "" + topicId);
+         topicrow.put("U_VIEW_TOPIC", viewTopicURL.toString());
+      }
+
+      PortletURL pageNavigationURL = resp.createRenderURL();
+      pageNavigationURL.setParameter("op", OP_SHOWFORUM);
+      pageNavigationURL.setParameter("f", "" + forumId);
+      pageNavigationURL.setParameter("topicDays", "" + topicDays);
+
+      GotoWithOffset toTopic = new GotoWithOffset(totalTopicsAndStickies,
+         start, topicsPerPage, pageNavigationURL + "&start=", bundle
+         .getString("Goto_page"), bundle.getString("Previous"), bundle
+         .getString("Next"));
+
+      String pageNumber = bundle.getString("Page_of_0")
+         + ((int)Math.floor((double)start / topicsPerPage) + 1)
+         + bundle.getString("Page_of_1")
+         + ((int)Math.ceil((double)totalTopicsAndStickies / topicsPerPage));
+
+      PortletURL postNewURL = resp.createRenderURL();
+      postNewURL.setParameter("op", OP_POSTING);
+      postNewURL.setParameter("f", "" + forumId);
+      postNewURL.setParameter("mode", "newtopic");
+      root.put("U_POST_NEW_TOPIC", postNewURL.toString());
+
+      //      root.put("S_SELECT_TOPIC_DAYS", BBTools.selectDays("topicdays", topicDays));
+      root.put("S_POST_DAYS_ACTION", "index.html?module=bb&op=viewforum&f="
+         + forumId + "&start=" + start);
+      root.put("FORUM_ID", forum.getId().toString());
+      root.put("FORUM_NAME", forum.getName());
+      root.put("CATEGORY_NAME", categoryTitle);
+
+      //      root.put("MODERATORS", moderatorList);
+      root.put("POST_IMG",
+         (forum.getStatus() == FORUM_LOCKED) ? theme.resourcePostLockedURL
+            : theme.resourcePostNewURL);
+      root.put("FOLDER_IMG", theme.resourceFolderURL);
+      root.put("FOLDER_NEW_IMG", theme.resourceFolderNewURL);
+      root.put("FOLDER_HOT_IMG", theme.resourceFolderHotURL);
+      root.put("FOLDER_HOT_NEW_IMG", theme.resourceFolderHotNewURL);
+      root.put("FOLDER_LOCKED_IMG", theme.resourceFolderLockedURL);
+      root.put("FOLDER_LOCKED_NEW_IMG", theme.resourceFolderLockedNewURL);
+      root.put("FOLDER_STICKY_IMG", theme.resourceFolderStickyURL);
+      root.put("FOLDER_STICKY_NEW_IMG", theme.resourceFolderStickyNewURL);
+      root.put("FOLDER_ANNOUNCE_IMG", theme.resourceFolderAnnounceURL);
+      root.put("FOLDER_ANNOUNCE_NEW_IMG", theme.resourceFolderAnnounceNewURL);
+
+      //      root.put("L_MODERATOR", moderatorMessage);
+      root.put("L_POST_NEW_TOPIC", (forum.getStatus() == FORUM_LOCKED) ? bundle
+         .getString("Forum_locked") : bundle.getString("Post_new_topic"));
+
+      root.put("S_AUTH_LIST", authCan.toString());
+      PortletURL viewMainPageURL = resp.createRenderURL();
+      viewMainPageURL.setParameter("op", OP_MAIN);
+      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
+      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
+      PortletURL viewCategoryURL = resp.createRenderURL();
+      viewCategoryURL.setParameter("op", OP_MAIN);
+      viewCategoryURL.setParameter("c", "" + category.getId());
+      root.put("U_VIEW_CATEGORY", viewCategoryURL.toString());
+      PortletURL viewForumURL = resp.createRenderURL();
+      viewForumURL.setParameter("op", OP_SHOWFORUM);
+      viewForumURL.setParameter("f", "" + forumId);
+      root.put("U_VIEW_FORUM", viewForumURL.toString());
+      root.put("U_MARK_READ", "index.html?module=bb&op=viewforum&f=" + forumId
+         + "&mark=topics");
+      root.put("PAGE_NUMBER", pageNumber.toString());
+      root.put("PAGINATION", toTopic.generate());
+
+      //      root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
+      return root;
+   }
+
+   private DelegateContext fillShowPreferencesContext(JBossRenderRequest req,
+                                                      JBossRenderResponse resp, DelegateContext root)
+   {
+      try
+      {
+         PortletURL preferencesSubmitURL = resp.createActionURL();
+         preferencesSubmitURL.setParameter("op", "preferences");
+         //Go into view mode after submit
+         preferencesSubmitURL.setPortletMode(PortletMode.VIEW);
+         //process portlet.preferences() method on Submit
+         root.put("S_PROFILE_ACTION", preferencesSubmitURL.toString());
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+
+      PortletPreferences pp = req.getPreferences();
+      PropertyMap upm = req.getUser().getProperties();
+      if (pp.getValue("notifyreply", "0").equals("1"))
+      {
+         root.put("NOTIFY_REPLY_YES", "CHECKED");
+      }
+      else
+      {
+         root.put("NOTIFY_REPLY_NO", "CHECKED");
+      }
+      /*if (pp.getValue("attachsig", "0").equals("1"))
+      {
+         root.put("ALWAYS_ADD_SIGNATURE_YES", "CHECKED");
+      }
+      else
+      {
+         root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
+      }*/
+      String attachsig = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+      if ((attachsig != null) && attachsig.equals("1"))
+      {
+         root.put("ALWAYS_ADD_SIGNATURE_YES", "CHECKED");
+      }
+      else if ((attachsig != null))
+      {
+         root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
+      }
+      else if ((attachsig == null))
+      {
+         root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
+      }
+
+      //TODO:Disable BBCode need to be implemented in ToHTMLRenderer --> BBCodeParser
+      /*if (pp.getValue("allowbbcode", "0").equals("1")) {
+          root.put("ALWAYS_ALLOW_BBCODE_YES", "CHECKED");
+      } else {
+          root.put("ALWAYS_ALLOW_BBCODE_NO", "CHECKED");
+      }*/
+      if (pp.getValue("allowhtml", "0").equals("1"))
+      {
+         root.put("ALWAYS_ALLOW_HTML_YES", "CHECKED");
+      }
+      else
+      {
+         root.put("ALWAYS_ALLOW_HTML_NO", "CHECKED");
+      }
+      if (pp.getValue("postorder", "ascending").equals("ascending"))
+      {
+         root.put("POST_ORDER_ASCENDING", "CHECKED");
+      }
+      else
+      {
+         root.put("POST_ORDER_DESCENDING", "CHECKED");
+      }
+      /*root.put("TOPICS_PER_FORUM", pp.getValue("topicsperforum", "10"));*/
+      int topics = Integer.parseInt(pp.getValue("topicsperforum", "10"));
+      switch (topics)
+      {
+         case 5:
+            root.put("TOPICS_PER_FORUM_N5", "CHECKED");
+            break;
+         case 10:
+            root.put("TOPICS_PER_FORUM_N10", "CHECKED");
+            break;
+         case 15:
+            root.put("TOPICS_PER_FORUM_N15", "CHECKED");
+            break;
+         case 20:
+            root.put("TOPICS_PER_FORUM_N20", "CHECKED");
+            break;
+         case 25:
+            root.put("TOPICS_PER_FORUM_N25", "CHECKED");
+            break;
+         case 30:
+            root.put("TOPICS_PER_FORUM_N30", "CHECKED");
+            break;
+      }
+
+      /*root.put("POSTS_PER_TOPIC", pp.getValue("postspertopic", "15"));*/
+      int posts = Integer.parseInt(pp.getValue("postspertopic", "10"));
+      switch (posts)
+      {
+         case 5:
+            root.put("POSTS_PER_TOPIC_N5", "CHECKED");
+            break;
+         case 10:
+            root.put("POSTS_PER_TOPIC_N10", "CHECKED");
+            break;
+         case 15:
+            root.put("POSTS_PER_TOPIC_N15", "CHECKED");
+            break;
+         case 20:
+            root.put("POSTS_PER_TOPIC_N20", "CHECKED");
+            break;
+         case 25:
+            root.put("POSTS_PER_TOPIC_N25", "CHECKED");
+            break;
+         case 30:
+            root.put("POSTS_PER_TOPIC_N30", "CHECKED");
+            break;
+      }
+
+      root.put("DATE_FORMAT", pp.getValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN));
+      //root.put("SIGNATURE", pp.getValue("signature", ""));
+      String sig = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
+      root.put("SIGNATURE", (sig != null) ? sig : "");
+
+      if (pp.isReadOnly("notifyreply"))
+      {
+         root.put("NOTIFY_ON_REPLY_DISABLED", "DISABLED");
+      }
+      /*if (pp.isReadOnly("attachsig"))
+         root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");*/
+      if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
+      {
+         root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");
+      }
+      /*if (pp.isReadOnly("allowbbcode"))
+     root.put("ALWAYS_ALLOW_BBCODE_DISABLED", "DISABLED");*/
+      if (pp.isReadOnly("allowhtml"))
+      {
+         root.put("ALWAYS_ALLOW_HTML_DISABLED", "DISABLED");
+      }
+      if (pp.isReadOnly("postorder"))
+      {
+         root.put("POST_ORDER_DISABLED", "DISABLED");
+      }
+      if (pp.isReadOnly("topicsperforum"))
+      {
+         root.put("TOPICS_PER_FORUM_DISABLED", "DISABLED");
+      }
+      if (pp.isReadOnly("postspertopic"))
+      {
+         root.put("POSTS_PER_TOPIC_DISABLED", "DISABLED");
+      }
+      if (pp.isReadOnly("dateformat"))
+      {
+         root.put("DATE_FORMAT_DISABLED", "DISABLED");
+      }
+      /*if (pp.isReadOnly("signature"))
+         root.put("SIGNATURE_DISABLED", "DISABLED");*/
+      if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
+      {
+         root.put("SIGNATURE_DISABLED", "DISABLED");
+      }
+
+      int summarymode = Integer.parseInt(pp.getValue("summarymode", "0"));
+      switch (summarymode)
+      {
+         case 0:
+            root.put("TOPIC_SUMMARY_MODE_LATEST_POSTS", "SELECTED");
+            break;
+         case 1:
+            root.put("TOPIC_SUMMARY_MODE_HOT", "SELECTED");
+            break;
+         case 2:
+            root.put("TOPIC_SUMMARY_MODE_HOTTEST", "SELECTED");
+            break;
+         case 3:
+            root.put("TOPIC_SUMMARY_MODE_MOST_VIEWED", "SELECTED");
+            break;
+      }
+      if (pp.isReadOnly("summarymode"))
+      {
+         root.put("MODE_CHOOSE_DISABLED", "DISABLED");
+      }
+      if (pp.isReadOnly("summarytopiclimit"))
+      {
+         root.put("TOPIC_SUMMARY_LIMIT_DISABLED", "DISABLED");
+      }
+      if (pp.isReadOnly("summarytopicdays"))
+      {
+         root.put("TOPIC_SUMMARY_DAYS_DISABLED", "DISABLED");
+      }
+      if (pp.isReadOnly("summarytopicreplies"))
+      {
+         root.put("TOPIC_SUMMARY_REPLIES_DISABLED", "DISABLED");
+      }
+      root.put("TOPIC_SUMMARY_LIMIT", pp.getValue("summarytopiclimit", "6"));
+      root.put("TOPIC_SUMMARY_DAYS", pp.getValue("summarytopicdays", "20"));
+      root.put("TOPIC_SUMMARY_REPLIES", pp.getValue("summarytopicreplies", "5"));
+      return root;
+   }
+
+
+   private DelegateContext fillShowUserProfileContext(JBossRenderRequest req,
+                                                      JBossRenderResponse resp, DelegateContext root)
+   {
+      User user = null;
+      Poster poster = null;
+      try
+      {
+         poster = forumsModule.findPosterByUserId(req.getParameters().get("uid", "-1"));
+         user = poster.getUser();
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         return root;
+      }
+
+      PortletURL viewMainPageURL = resp.createRenderURL();
+      viewMainPageURL.setParameter("op", OP_MAIN);
+      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
+      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
+      root.put("USERNAME", user.getGivenName());
+
+      //root.put("EMAIL_IMG", user.getFakeEmail());
+      //String homepage = (String)(user.getProperties().get(CoreConstants.INFO_USER_HOMEPAGE));
+      //root.put("WWW", "<a href=\"" + homepage + "\">"+ homepage + "</a>");
+      root.put("LOCATION", (String)(user.getProperties().get(User.INFO_USER_LOCATION)));
+      root.put("OCCUPATION", (String)(user.getProperties().get(User.INFO_USER_OCCUPATION)));
+      root.put("INTERESTS", (String)(user.getProperties().get(User.INFO_USER_INTERESTS)));
+
+      //root.put("ICQ_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_ICQ)));
+      //root.put("AIM_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_AIM)));
+      //root.put("YIM_IMG", (String)(user.getProperties().get(CoreConstants.INFO_USER_IM_YIM)));
+      root.put("MSN_IMG", (String)(user.getProperties().get(User.INFO_USER_IM_MSNM)));
+      root.put("SKYPE_IMG", (String)(user.getProperties().get(User.INFO_USER_IM_SKYPE)));
+
+      root.put("JOINED", "" + user.getRegistrationDate());
+      root.put("POSTS", "" + poster.getPostCount());
+
+
+      String fakeEmail = user.getFakeEmail();
+      String homepage = (String)(user.getProperties().get(User.INFO_USER_HOMEPAGE));
+      String icqAddr = (String)(user.getProperties().get(User.INFO_USER_IM_ICQ));
+      String aimAddr = (String)(user.getProperties().get(User.INFO_USER_IM_AIM));
+      String yimAddr = (String)(user.getProperties().get(User.INFO_USER_IM_YIM));
+
+
+      if (fakeEmail != null && fakeEmail.length() > 0)
+      {
+         String emailImgLnk = ForumsTools.createImageLink("mailto:" + fakeEmail, theme.resourceIconEmailURL, "");
+         root.put("EMAIL_IMG", emailImgLnk);
+      }
+      if (homepage != null && homepage.length() > 0)
+      {
+         String wwwImgLnk = ForumsTools.createImageLink(homepage, theme.resourceIconWWWURL, "");
+         root.put("WWW", wwwImgLnk);
+      }
+      String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + icqAddr;
+      if (icqAddr != null && icqAddr.length() > 0)
+      {
+         String icqImgLnk = ForumsTools.createImageLink(icqUrl, theme.resourceIconICQURL, "");
+         root.put("ICQ_IMG", icqImgLnk);
+      }
+      String aimUrl = "aim:goim?screenname=" + aimAddr + "&message=Hello+Are+you+there?";
+      if (aimAddr != null && aimAddr.length() > 0)
+      {
+         String aimImgLnk = ForumsTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "");
+         root.put("AIM_IMG", aimImgLnk);
+      }
+      String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + yimAddr + "&src=pg";
+      if (yimAddr != null && yimAddr.length() > 0)
+      {
+         String yimImgLnk = ForumsTools.createImageLink(yimUrl.toString(), theme.resourceIconYIMURL, "");
+         root.put("YIM_IMG", yimAddr);
+      }
+
+      return root;
+   }
+
+
+   private DelegateContext fillShowBlockTopicsContext(JBossRenderRequest req,
+                                                      JBossRenderResponse resp, DelegateContext root)
+   {
+      //System.out.println("in fillShowNewTopicContext(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+      PortletPreferences pp = req.getPreferences();
+      //int mode = ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS;
+      PortletURL viewMainPageURL = resp.createRenderURL();
+      viewMainPageURL.setParameter("op", OP_MAIN);
+      try
+      {
+         viewMainPageURL.setWindowState(WindowState.MAXIMIZED);
+      }
+      catch (WindowStateException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
+      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
+      int mode = ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS;
+      int limit = 6;
+      int replies = 15;
+      int days = 20;
+      try
+      {
+         mode = new Integer(pp.getValue("summarymode", "0")).intValue();
+         limit = new Integer(pp.getValue("summarytopiclimit", "6")).intValue();
+         days = new Integer(pp.getValue("summarytopicdays", "20")).intValue();
+         replies = new Integer(pp.getValue("summarytopicreplies", "5")).intValue();
+      }
+      catch (IllegalArgumentException e)
+      {
+         System.out.println("ERROR -- Illegal value of summary topic properties");
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+      Calendar after = Calendar.getInstance();
+      after.add(Calendar.DATE, - days);
+      Collection topics = new LinkedList();
+      Date time = after.getTime();
+
+      try
+      {
+         switch (mode)
+         {
+            case ForumsConstants.BLOCK_TOPICS_MODE_HOT_TOPICS:
+               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_HOT_TOPICS"));
+               topics = forumsModule.findTopicsHot(replies, limit);
+               break;
+            case ForumsConstants.BLOCK_TOPICS_MODE_HOTTEST_TOPICS:
+               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_HOTTEST_TOPICS"));
+               topics = forumsModule.findTopicsHottest(time, limit);
+               break;
+            case ForumsConstants.BLOCK_TOPICS_MODE_LATEST_POSTS:
+               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_LATEST_POSTS"));
+               topics = forumsModule.findTopicsByLatestPosts(limit);
+               break;
+            case ForumsConstants.BLOCK_TOPICS_MODE_MOST_VIEWED:
+               root.put("BLOCK_TOPICS_TYPE", bundle.getString("L_MODE_MOST_VIEWED"));
+               topics = forumsModule.findTopicsMostViewed(time, limit);
+               break;
+         }
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+      //DelegateContext root = new DelegateContext();
+      root.next("switch_no_topics").put("L_NO_TOPICS", topics.size() + " " + bundle.getString("L_TOPICS_FOUND"));
+
+      if (topics.size() > 0)
+      {
+         for (Iterator i = topics.iterator(); i.hasNext();)
+         {
+            //TopicEJBLocal topic = (TopicEJBLocal)i.next();
+            Topic topic = (Topic)i.next();
+            DelegateContext topicrow = root.next("topicrow");
+            topicrow.put("TOPIC_TITLE", topic.getSubject());
+            PortletURL topicViewURL = resp.createRenderURL();
+            try
+            {
+               topicViewURL.setWindowState(WindowState.MAXIMIZED);
+            }
+            catch (WindowStateException e)
+            {
+               e.printStackTrace();
+            }
+            topicViewURL.setParameter("op", "showTopic");
+            topicViewURL.setParameter("t", "" + topic.getId());
+            topicrow.put("U_VIEW_TOPIC", topicViewURL.toString());
+         }
+      }
+      /*else
+      {
+         root.next("switch_no_topics");
+      }*/
+
+      /*root.put("BLOCK_TOPICS_TYPE","Newest topics");
+      for (int i = 0; i<4; i++){
+         DelegateContext topicrow = root.next("topicrow");
+         topicrow.put("TOPIC_TITLE", "topic name " + i);
+      }*/
+
+
+
+
+      return root;
+   }
+
+
+   private DelegateContext fillShowNewTopicContext(JBossRenderRequest req,
+                                                   JBossRenderResponse resp, DelegateContext root)
+   {
+      //System.out.println("in fillShowNewTopicContext(); op: " + req.getParameter("op") + " and mode: " + req.getParameter("mode"));
+      PortletURL topicSubmitURL = resp.createActionURL();
+      topicSubmitURL.setParameter("op", "posting");
+      String forumId = req.getParameter("f");
+      if (forumId != null)
+      {
+         topicSubmitURL.setParameter("f", forumId);
+      }
+      String postId = req.getParameter("p");
+      if (postId != null)
+      {
+         topicSubmitURL.setParameter("p", postId);
+      }
+
+      boolean isPostBack = false;
+      //check if we display for the first time or if it's postback
+      //postback flag is set in posting() method so we can deal with first display of this view.
+      if (req.getParameter(ForumsConstants.POSTING_POSTBACK_FLAG) != null)
+      {
+         isPostBack = true;
+      }
+      else
+      {
+         //clear stored files from session
+         req.getPortletSession().setAttribute(ForumsConstants.DISK_PERSISTED_ATTACHEMENTS, null);
+      }
+
+
+      if (req.getParameter("S_HIDDEN_FORM_FIELDS") != null)
+      {
+         root.put("S_HIDDEN_FORM_FIELDS", req
+            .getParameter("S_HIDDEN_FORM_FIELDS"));
+      }
+      else
+      {
+         root.put("S_HIDDEN_FORM_FIELDS",
+            "<input type=\"hidden\" name=\"mode\" value=\""
+               + req.getParameter("mode") + "\" />"
+               + "<input type=\"hidden\" name=\"iteratingtest\" value=\"val1\" /><input type=\"hidden\" name=\"iteratingtest\" value=\"val2\" /><input type=\"hidden\" name=\"iteratingtest\" value=\"val3\" />");
+      }
+
+
+      root.put("U_FORM_SUBMIT", topicSubmitURL.toString());
+      root.put("S_FORM_ENCTYPE", "enctype=\"multipart/form-data\"");
+
+      String instantReplyHiddenFormFields = "<input type=\"hidden\" name=\"attach_sig\" value=\"-1\"/>\n";
+      root.put("S_INSTANT_REPLY_HIDDEN_FORM_FIELDS",
+         instantReplyHiddenFormFields);
+
+      if (req.getParameters().getParameterExists("preview"))
+      {
+         PropertyMap upm = req.getUser().getProperties();
+         String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
+         String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+
+         DelegateContext preview = root.next("preview");
+         preview.put("PREVIEW_SUBJECT", req.getParameter("PREVIEW_SUBJECT"));
+         preview.put("TOPIC_TITLE", req.getParameter("TOPIC_TITLE"));
+         preview.put("POSTER_NAME", req.getParameter("POSTER_NAME"));
+         preview.put("POST_DATE", req.getParameter("POST_DATE"));
+         preview.put("PREVIEW_MESSAGE", req.getParameter("PREVIEW_MESSAGE"));
+      }
+
+      root.put("SUBJECT", req.getParameter("SUBJECT"));
+      root.put("MESSAGE", req.getParameter("MESSAGE"));
+      //root.next("switch_notify_checkbox");
+      //root.put("S_NOTIFY_CHECKED", "checked");
+
+      Forum forum = null;
+      try
+      {
+         Integer tmp = req.getParameters().getIntObject("f");
+         forum = forumsModule.findForumById(tmp);
+      }
+      catch (ModuleException e1)
+      {
+         // TODO Auto-generated catch block
+         e1.printStackTrace();
+      }
+      Category category = forum.getCategory();
+      String forumName = forum.getName();
+      String[] testArray = new String[]{category.getTitle(), forum.getName()};
+      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum"); //Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
+      boolean authAddAttach = ForumsTools.hasPermission(req, testArray, "AddAttachmentInPost");
+      boolean authAddPoll = ForumsTools.hasPermission(req, testArray, "AddPollInPost");
+      boolean authEditPoll = ForumsTools.hasPermission(req, testArray, "EditPollInPost");
+
+      if (authMod)
+      {
+         root.next("auth_mod");
+
+      }
+
+      /*if (authAddAttach)
+      {
+         root.next("attachmentsEnabled");
+      }*/
+
+      //System.out.println("title from req: " + req.getParameter("POLL_TITLE"));
+      /*if (ForumsTools.hasPermission(req,"AddPollInPost"))
+      {
+         System.out.println("Enabling poll body");
+         DelegateContext poll = root.next("pollEnabled");
+         poll.put("POLL_TITLE", req.getParameter("POLL_TITLE"));
+
+      }
+      */
+      boolean newTopic = false;
+      if ((req.getParameter("mode") != null) && req.getParameter("mode").equals("newtopic"))
+      {
+         newTopic = true;
+      }
+      boolean firstTopicPost = false;
+      if ((req.getParameter("firstTopicPost") != null) && req.getParameter("firstTopicPost").equals("true"))
+      {
+         firstTopicPost = true;
+      }
+
+
+      if (authMod && (newTopic || firstTopicPost))
+      {
+         DelegateContext tt = root.next("switch_type_toggle");
+         String type = req.getParameter("topictype");
+         if (type != null)
+         {
+            if (type.equals("0"))
+            {
+               root.put("TOPIC_TYPE_NORMAL", "CHECKED");
+            }
+            else if (type.equals("1"))
+            {
+               root.put("TOPIC_TYPE_STICKY", "CHECKED");
+            }
+            else if (type.equals("2"))
+            {
+               root.put("TOPIC_TYPE_ANNOUNCEMENT", "CHECKED");
+            }
+
+         }
+         else
+         {
+            root.put("TOPIC_TYPE_NORMAL", "CHECKED");
+         }
+      }
+
+      if ((ForumsTools.hasPermission(req, "AddPollInPost") && newTopic) ||
+         (ForumsTools.hasPermission(req, "EditPollInPost") && (req.getParameter("editPoll") != null) &&
+            req.getParameter("editPoll").equals("true")))
+      {
+         DelegateContext poll = root.next("pollEnabled");
+         poll.put("POLL_TITLE", req.getParameter("POLL_TITLE"));
+         poll.put("POLL_LENGTH", req.getParameter("POLL_LENGTH"));
+         if (ForumsTools.hasPermission(req, "EditPostInForum") &&
+            (req.getParameter("switch_poll_delete_toggle") != null)
+            )
+         {
+            poll.next("switch_poll_delete_toggle");
+         }
+         /*response.setRenderParameter("POLL_TITLE", poll.getTitle());
+        response.setRenderParameter("POLL_LENGTH", Integer.toString(poll.getLength()));*/
+         /*if (action instanceof EditPostAction)
+         {
+            response.setRenderParameter("switch_poll_delete_toggle", "true");
+            //root.next("switch_poll_delete_toggle");
+         }*/
+         /*int index = 0;
+         for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
+         {
+            String text = (String) iterator.next();
+            if (text != null)
+            {
+               DelegateContext poll_option_rows = root.next("poll_option_rows");
+               poll_option_rows.put("POLL_OPTION", text);
+               poll_option_rows.put("S_POLL_OPTION_NUM", "" + index++);
+            }
+         }*/
+         //boolean option_deleted = false;
+
+         for (int index = 0; true; index++)
+         {
+            String param = "poll_option_text[" + index + "]";
+            String value = req.getParameter(param);
+            if (value != null)
+            {
+               DelegateContext poll_option_rows = poll.next("poll_option_rows");
+               poll_option_rows.put("POLL_OPTION", value);
+               poll_option_rows.put("S_POLL_OPTION_NUM", "" + index);
+            }
+            else
+            {
+               break;
+            }
+
+            /* boolean deleted = req.getParameter("del_poll_option[" + index + "]") != null;
+          option_deleted |= deleted;*/
+            /*if(value != null)
+            {
+               p_poll.getOptions().add(deleted ? null : value);
+            }
+            else
+            {
+               break;
+            }*/
+         }
+         //pollBox = theme.TPL_THEME_POSTING_POLL_BODY.render(temp);
+      }
+
+      if (authAddAttach)
+      {
+         DelegateContext attach = root.next("attachmentsEnabled");
+
+         for (int i = 0; ; i++)
+         {
+
+            String name = req.getParameter("ATTACHMENT[" + i + "]_NAME");
+            String id = req.getParameter("ATTACHMENT[" + i + "]_ID");
+            String comment = req.getParameter("ATTACHMENT[" + i + "]_COMMENT");
+            if ((name != null) && (id != null))
+            {
+               DelegateContext row = attach.next("attach_row");
+               row.put("ATTACH_FILENAME", name);
+               row.put("ATTACH_ID", id);
+               row.put("FILE_COMMENT", comment);
+            }
+            else
+            {
+               break;
+            }
+         }
+      }
+
+
+      return root;
+   }
+
+   private DelegateContext fillShowSplitTopicContext(JBossRenderRequest req,
+                                                     JBossRenderResponse resp, DelegateContext root)
+   {
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+
+      Integer topicId = req.getParameters().getIntObject("t", -1);
+      Integer forumId = req.getParameters().getIntObject("f", -1);
+
+      /*resp.setProperty("t", "" + topicId);
+      resp.setProperty("f", "" + forumId);*/
+      if (topicId.intValue() == -1)
+      {
+         return root;
+      }
+      //TODO: index on top of page is not used now...
+      Topic topic = null;
+      List posts = null;
+      try
+      {
+         topic = forumsModule.findTopicById(topicId);
+         posts = forumsModule.findPostsByTopicId(topicId);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         //TODO:some nice error message
+         return root;
+      }
+
+      // form action
+      PortletURL actionURL = resp.createActionURL();
+      actionURL.setParameter(getOperationName(), "moderate_forum");
+      actionURL.setParameter("t", "" + topicId);
+      actionURL.setParameter("f", "" + forumId);
+      root.put("S_SPLIT_ACTION", actionURL.toString());
+
+      //Main index link
+      PortletURL indexURL = resp.createActionURL();
+      indexURL.setParameter(getOperationName(), OP_MAIN);
+      root.put("U_INDEX", indexURL.toString());
+
+      //This topics forum index
+      PortletURL forumURL = resp.createActionURL();
+      forumURL.setParameter(getOperationName(), OP_SHOWFORUM);
+      forumURL.setParameter("f", "" + topic.getForum().getId());
+      root.put("U_VIEW_FORUM", forumURL.toString());
+      root.put("FORUM_NAME", topic.getForum().getName());
+
+
+      int rowindex = 0;
+      for (IndexIterator pi = IndexIterator.wrap(posts.iterator(), -1); pi.hasNext(); rowindex++)
+      {
+         Post post = (Post)pi.next();
+         String rowColor = theme
+            .getProperty(((pi.getIndex() % 2) == 0) ? "td_color1"
+               : "td_color2");
+         String rowClass = theme
+            .getProperty(((pi.getIndex() % 2) == 0) ? "td_class1"
+               : "td_class2");
+
+         DelegateContext postRow = root.next("postrow");
+
+         postRow.put("ROW_COLOR", rowColor);
+         postRow.put("ROW_CLASS", rowClass);
+         postRow.put("POSTER_NAME", post.getPoster().getUser().getUserName());
+         postRow.put("POST_DATE", getSDF(req).format(post.getCreateDate()));
+         postRow.put("POST_SUBJECT", post.getMessage().getSubject());
+         String message = post.getMessage().getText();
+         PropertyMap upm = post.getPoster().getUser().getProperties();
+         String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
+         String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+         if ((addsign != null) && (sign != null) && addsign.equals("1"))
+         {
+            message += "\n\n" + sign;
+         }
+         postRow.put("MESSAGE", formatMessage(req, message, true, true));
+         postRow.put("POST_ROW_INDEX", "" + rowindex);
+         postRow.put("POST_ID", post.getId());
+         postRow.put("IMG_MINIPOST", theme.resourceIconMinipostURL);
+         //TODO:this spacer link is corrupted
+         postRow.put("IMG_SPACER", theme.resourceIconSpacerURL);
+      }
+
+      try
+      {
+         String selectTo = new StringBuffer().
+            append("<select name=\"forum_to_id\">").
+            append("<option value=\"-1\"").
+            append(" selected=\"selected\">").
+            append("Select destination forum").append("</option>\n").
+            append(ForumsTools.listForums(forumsModule.findForums(), -1)).
+            append("</select>").toString();
+         root.put("S_FORUM_SELECT", selectTo);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+
+
+      return root;
+   }
+
+   private DelegateContext fillShowTopicContext(JBossRenderRequest req,
+                                                JBossRenderResponse resp, DelegateContext root)
+   {
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+
+      Integer topicId = req.getParameters().getIntObject("t", -1);
+      Integer postId = req.getParameters().getIntObject("p", -1);
+      int start = req.getParameters().getInt("start", 0);
+      String view = req.getParameter("view");
+      int postDays = req.getParameters().getInt("postdays", 0);
+      String vote = req.getParameter("vote");
+
+      if ((topicId.intValue() == -1) && (postId.intValue() == -1))
+      {
+         //         Die.exit(GENERAL_MESSAGE, "${bb.Topic_post_not_exist}");
+      }
+
+      Topic topic = null;
+      Forum forum = null;
+      Category category = null;
+      User user = req.getUser();
+      //boolean loggedIn = isUserLoggedIn(user);
+      boolean loggedIn = req.getRemoteUser() != null;
+
+      //      try
+      //      {
+      if (postId.intValue() == -1)
+      {
+         if (view != null)
+         {
+            if ("newest".equals(view))
+            {
+               //if (isUserLoggedIn(user))
+               if (req.getRemoteUser() != null)
+               {
+                  //                     Date lastVisit = user.getPreviousLastVisitDate();
+                  Date lastVisit = user.getLastVisitDate();
+                  try
+                  {
+                     topic = forumsModule.findTopicById(topicId);
+                     Post post = topic.getLastPost();
+
+                     // homesRO.post.findLatestPost(lastVisit, topic);
+                     // resp. sendRedirect("index.html?module=bb&op=viewtopic&p=" + post.getID() + "#" + post.getID());
+                     return null;
+                  }
+                  catch (ModuleException e)
+                  {
+                     //                        Die.exit(GENERAL_MESSAGE, "${No_new_posts_last_visit}");
+                  }
+               }
+               else
+               {
+                  //                     page.sendRedirect("index.html?module=bb&op=viewtopic&t=" + topicId);
+                  //                     return;
+               }
+            }
+            else if ("next".equals(view))
+            {
+               /*
+                try
+                {
+                topic = (TopicEJBLocal)BBTools.head(homesRO.topic.findNext(topicId));
+                }
+                catch (FinderException e)
+                {
+                Die.exit(GENERAL_ERROR, "Could not obtain newer/older topic information", e);
+                }
+                */
+            }
+            else if ("previous".equals(view))
+            {
+               /*
+                try
+                {
+                topic = (TopicEJBLocal)BBTools.head(homesRO.topic.findPrevious(topicId));
+                }
+                catch (FinderException e)
+                {
+                Die.exit(GENERAL_ERROR, "Could not obtain newer/older topic information", e);
+                }
+                */
+            }
+
+            /*
+             if (topic == null)
+             {
+             Die.exit(GENERAL_MESSAGE, "next".equals(view) ? "${bb.No_newer_topics}" : "${bb.No_older_topics}");
+             }
+             topicId = topic.getId();
+             forum = topic.getForum();
+             category = forum.getCategory();
+             */
+         }
+         else
+         // Common use case, showing the topic with topicID as is, no postId defined
+         {
+            try
+            {
+               topic = forumsModule.findTopicById(topicId);
+               forum = topic.getForum();
+               category = forum.getCategory();
+            }
+            catch (ModuleException e)
+            {
+               // TODO Auto-generated catch block
+               e.printStackTrace();
+            }
+         }
+      }
+      else
+      {
+         Post post;
+         try
+         {
+            post = forumsModule.findPostById(postId);
+            topic = post.getTopic();
+            forum = topic.getForum();
+            category = forum.getCategory();
+
+            //               start = (int)(Math.floor(((double)(size.intValue() - 1) / postPerPage)) * postPerPage);
+            topicId = topic.getId();
+         }
+         catch (ModuleException e1)
+         {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+         }
+
+         //            Long size = homesRO.post.countPostsBefore(post);
+      }
+      //      }
+      //      catch (ObjectNotFoundException e)
+      //      {
+      //         Die.exit(GENERAL_MESSAGE, "${bb.Topic_post_not_exist}");
+      //      }
+      //      catch (FinderException e)
+      //      {
+      //         Die.exit(GENERAL_ERROR, "Could not obtain topic information", e);
+      //      }
+      String[] testArray = {category.getTitle(), forum.getName()};
+      boolean authView = ForumsTools.hasPermission(req, testArray, "ReadForum");
+      boolean authRead = ForumsTools.hasPermission(req, testArray, "ReadForum");
+      boolean authDelete = ForumsTools.hasPermission(req, testArray, "DeletePostInForum");
+      boolean authPost = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
+      boolean authVote = ForumsTools.hasPermission(req, testArray, "AddPostInForum");
+      boolean authEdit = ForumsTools.hasPermission(req, testArray, "EditPostInForum");
+      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum");
+
+      if (authPost)
+      {
+         root.next("DISPLAY_REPLY_BOX");
+      }
+
+      //      if (!authView || !authRead)
+      //      {
+      if (loggedIn)
+      {
+         //            $redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
+         //            $redirect .= ( isset($start) ) ? "&start=$start" : '';
+         //            redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
+         //            page.sendRedirect("index.html?module=user&=getlogin");
+         //            return;
+      }
+
+      //         Die.exit(GENERAL_MESSAGE, !authView ? "${bb.Topic_post_not_exist}" : "${bb.Sorry_auth_read_0}TODO:$is_auth['auth_read_type']${bb.Sorry_auth_read_1}");
+      //      }
+      Integer forumId = forum.getId();
+      int forumStatus = forum.getStatus();
+      int topicStatus = topic.getStatus();
+      String forumName = forum.getName();
+      String topicTitle = topic.getSubject();
+
+      // Is user watching this thread ?
+      boolean isWatching = false;
+      boolean canWatch = false;
+      if (loggedIn)
+      {
+         //       try
+         //       {
+         canWatch = true;
+
+         /*
+          try
+          {
+          TopicWatchEJBPK key = new TopicWatchEJBPK(user.getId(), topic.getId());
+          TopicWatchEJBLocal watch = homesRO.topicWatch.findByPrimaryKey(key);
+          String unwatch = page.getParameter("unwatch");
+          if (unwatch != null)
+          {
+          if ("topic".equals(unwatch))
+          {
+          isWatching = false;
+          watch.remove();
+          }
+          Die.exit(GENERAL_MESSAGE, "${bb.No_longer_watching}<br/><br/>${bb.Click_return_topic_0}" +
+          "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
+          "&start=" + start + "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}");
+          }
+          else
+          {
+          isWatching = true;
+          }
+          }
+          catch (ObjectNotFoundException e)
+          {
+          String watch = page.getParameter("watch");
+          if (watch != null)
+          {
+          if ("topic".equals(watch))
+          {
+          homesRO.topicWatch.create(user, topic);
+          isWatching = true;
+          }
+          String message = "${bb.You_are_watching}<br/><br/>${bb.Click_return_topic_0}" +
+          "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
+          "&start=" + start + "\">${bb.Click_return_topic_1}</a>${bb.Click_return_topic_2}";
+          Die.exit(GENERAL_MESSAGE, message);
+          }
+          else
+          {
+          isWatching = false;
+          }
+          }
+          }
+          catch (RemoveException e)
+          {
+          Die.rollback(GENERAL_ERROR, "Could not delete topic watch information", e);
+          }
+          catch (CreateException ce)
+          {
+          Die.rollback(GENERAL_ERROR, "Could not insert topic watch information", ce);
+          }
+          catch (FinderException e)
+          {
+          Die.exit(GENERAL_ERROR, "Could not obtain topic watch information", e);
+          }*/
+      }
+      else
+      {
+         /*
+          if ("topic".equals(page.getParameter("unwatch")))
+          {
+          //               redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
+          //            page.sendRedirect("index.html?module=user&op=getlogin");
+          //            return;
+          }
+          else
+          {
+          canWatch = false;
+          isWatching = false;
+          }
+          */
+      }
+      int totalReplies = 0;
+      Date minPostDate = null;
+      if (postDays > 0)
+      {
+         Calendar c = Calendar.getInstance();
+         c.add(Calendar.DATE, -postDays);
+         minPostDate = c.getTime();
+
+         /*
+          try
+          {
+          Collection result = homesRO.post.selectGeneric("SELECT p.id FROM post AS p WHERE p.topic=?1 AND p.postDate>=?2",
+          new Object[]{topic, minPostDate});
+          totalReplies = result.size();
+          }
+          catch (FinderException e)
+          {
+          Die.exit(GENERAL_ERROR, "Could not obtain limited topics count information", e);
+          }
+          */
+
+         // if ( !empty($HTTP_POST_VARS['postdays']))
+         // {
+         //   $start = 0;
+         // }
+      }
+      else
+      {
+         totalReplies = topic.getReplies();
+         postDays = 0;
+      }
+
+      //      String selectPostDays = BBTools.selectDays("postdays", postDays);
+      /*boolean postOrderAsc = true;*/
+      boolean postOrderAsc = true;
+      if (req.getPreferences().getValue("postorder", "ascending").equals("ascending"))
+      {
+         //System.out.println("Show posts ascending");
+         postOrderAsc = true;
+      }
+      else
+      {
+         //System.out.println("Show posts descending");
+         postOrderAsc = false;
+      }
+
+      //      String asc = req.getParameter("postorder");
+      //      boolean postOrderAsc = asc != null ? "asc".equals(asc) : user == null ? true : !user.getSortOrderDescending();
+      // Decide how to order the post display
+      //      String selectPostOrder = "<select name=\"postorder\"><option value=\"asc\">" +
+      //            "${bb.Oldest_First}</option><option value=\"desc\" selected=\"selected\">" +
+      //            "${bb.Newest_First}</option></select>";
+
+      /*      if (postOrderAsc)
+       {
+       selectPostOrder = "<select name=\"postorder\"><option value=\"asc\" selected=\"selected\">" +
+       "${bb.Oldest_First}</option><option value=\"desc\">" +
+       "${bb.Newest_First}</option></select>";
+       }
+       */
+
+      List posts = null;
+      int totalPosts = 0;
+      //int allTopicPostsNum = 0;
+
+      /*int postsPerPage = 10;*/
+      int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
+      try
+      {
+         /*
+          posts = postOrderAsc ?
+          (minPostDate != null ?
+          homesRO.post.findByTopicBeforeAsc(topic, minPostDate, start, postPerPage) :
+          homesRO.post.findByTopicAsc(topic, start, postPerPage)) :
+          (minPostDate != null ?
+          homesRO.post.findByTopicBeforeDesc(topic, minPostDate, start, postPerPage) :
+          homesRO.post.findByTopicDesc(topic, start, postPerPage));
+          */
+
+         //To get proper pagination when jump to latest post
+         if (postId.intValue() != -1)
+         {
+            if (postOrderAsc)
+            {
+               posts = forumsModule.findPostsByTopicIdAsc(topicId, 0, 0);
+            }
+            else
+            {
+               posts = forumsModule.findPostsByTopicIdDesc(topicId, 0, 0);
+            }
+            int page = 0;
+            int postposition = 1;
+            for (Iterator i = posts.iterator(); i.hasNext(); postposition++)
+            {
+               if (postposition > ((page + 1) * postsPerPage))
+               {
+                  page++;
+               }
+               if (((Post)i.next()).getId().intValue() == postId.intValue())
+               {
+                  break;
+               }
+            }
+            start = page * postsPerPage;
+         }
+         //else
+         //{
+         if (postOrderAsc)
+         {
+            posts = forumsModule.findPostsByTopicIdAsc(topicId, start,
+               postsPerPage);
+         }
+         else
+         {
+            posts = forumsModule.findPostsByTopicIdDesc(topicId, start,
+               postsPerPage);
+         }
+         totalPosts = posts.size();
+         //}
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+
+         //Die.exit(GENERAL_ERROR, "Could not obtain post/user information.", e);
+      }
+      if (totalPosts == 0)
+      {
+         //         Die.exit(GENERAL_MESSAGE, "${bb.No_posts_topic}");
+      }
+
+      //      $sql = "SELECT *
+      //         FROM " . RANKS_TABLE . "
+      //         ORDER BY rank_special, rank_min";
+      //      if ( !($result = $db->sql_query($sql)) )
+      //      {
+      //         message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
+      //      }
+      //
+      //      $ranksrow = array();
+      //      while ( $row = $db->sql_fetchrow($result) )
+      //      {
+      //         $ranksrow[] = $row;
+      //      }
+      //      $db->sql_freeresult($result);
+      //
+      ////
+      topicTitle = formatTitle(req, topicTitle);
+
+      //
+      ////
+      //// Was a highlight request part of the URI?
+      ////
+      //      $highlight_match = $highlight = '';
+      //      if (isset($HTTP_GET_VARS['highlight']))
+      //      {
+      //         // Split words and phrases
+      //         $words = explode(' ', trim(htmlspecialchars(urldecode($HTTP_GET_VARS['highlight']))));
+      //
+      //         for($i = 0; $i < sizeof($words); $i++)
+      //         {
+      //            if (trim($words[$i]) != '')
+      //            {
+      //               $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
+      //            }
+      //         }
+      //         unset($words);
+      //
+      //         $highlight = urlencode($HTTP_GET_VARS['highlight']);
+      //      }
+      PortletURL newTopicURL;
+      newTopicURL = resp.createRenderURL();
+      newTopicURL.setParameter("op", OP_POSTING);
+      newTopicURL.setParameter("f", "" + forumId);
+      newTopicURL.setParameter("mode", "newtopic");
+
+      /*
+       PortletURL replyTopicURL;
+       replyTopicURL = resp.createRenderURL();
+       replyTopicURL.setParameter("op", OP_POSTING);
+       replyTopicURL.setParameter("mode", "reply");
+       replyTopicURL.setParameter("p", "" + topic.getLastPost().getID());
+       */
+      PortletURL replyTopicURL;
+      replyTopicURL = resp.createActionURL();
+      replyTopicURL.setParameter("op", "posting");
+      replyTopicURL.setParameter("mode", "reply");
+      replyTopicURL.setParameter("p", "" + topic.getLastPost().getId());
+      replyTopicURL.setParameter("f", "" + forumId);
+
+      //      replyTopicURL.setParameter("f", "" + forumId);
+      //      String replyTopicUrl = "index.html?module=bb&op=posting&mode=reply&p=" + topic.getLastPost().getID();
+      PortletURL viewForumURL = resp.createRenderURL();
+      viewForumURL.setParameter("op", OP_SHOWFORUM);
+      viewForumURL.setParameter("f", "" + forumId);
+      PortletURL viewCategoryURL = resp.createRenderURL();
+      viewCategoryURL.setParameter("op", OP_MAIN);
+      viewCategoryURL.setParameter("c", "" + category.getId());
+      PortletURL replySubmitURL = resp.createActionURL();
+      replySubmitURL.setParameter("op", "posting");
+
+      String viewPrevTopicUrl = "index.html?module=bb&op=viewtopic&t="
+         + topicId + "&view=previous";
+      String viewNextTopicUrl = "index.html?module=bb&op=viewtopic&t="
+         + topicId + "&view=next";
+
+      String replyImg = theme.resourceReplyNewURL;
+      String replyAlt = bundle.getString("Reply_to_topic");
+      String postImg = theme.resourcePostNewURL;
+      String postAlt = bundle.getString("Post_new_topic");
+      if (forumStatus == FORUM_LOCKED)
+      {
+         replyImg = theme.resourceReplyLockedURL;
+         replyAlt = bundle.getString("Topic_locked");
+         postImg = theme.resourcePostLockedURL;
+         postAlt = bundle.getString("Forum_locked");
+      }
+      else if (topicStatus == TOPIC_LOCKED)
+      {
+         replyImg = theme.resourceReplyLockedURL;
+         replyAlt = bundle.getString("Topic_locked");
+      }
+      DelegateContext auth = null;
+      if (authPost)
+      {
+         auth = root.next("AUTH_POST");
+      }
+      //disable <a href=> for posting when topic is locked
+      if (authPost && !(topic.getStatus() == TOPIC_LOCKED))
+      {
+         auth.next("UNLOCKED");
+      }
+
+      if (loggedIn)
+      {
+         //         Map trackingTopics = getTrackingTopics(page);
+         //         Map trackingForums = getTrackingForums(page);
+         //         Date topicDate = (Date)trackingTopics.get(topicId);
+         //         Date forumDate = (Date)trackingForums.get(forumId);
+
+         /*
+          Date topicLastRead = null;
+          if (topicDate != null && forumDate != null)
+          {
+          topicLastRead = topicDate.after(forumDate) ? topicDate : forumDate;
+          }
+          else if (topicDate != null || forumDate != null)
+          {
+          topicLastRead = topicDate != null ? topicDate : forumDate;
+          }
+          else
+          {
+          //            topicLastRead = user.getPreviousLastVisitDate();
+          topicLastRead = user.getLastVisitDate();
+          }
+          //         if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
+          //         {
+          //            asort($tracking_topics);
+          //            unset($tracking_topics[key($tracking_topics)]);
+          //         }
+          trackingTopics.put(topicId, new Date());
+          */
+      }
+
+      StringBuffer authCan = new StringBuffer();
+
+      //      BBTools.authCan(authCan, forum, loggedIn, level);
+      String topicMod = "";
+
+
+      if (authMod)
+      {
+         /*authCan.append(bundle.getString("Rules_moderate_0") + "<a href=\"index.html?module=bb&op=modcp&f=")
+       .append(forumId).append("\">" + bundle.getString("Rules_moderate_1") + "</a>"
+       + bundle.getString("Rules_moderate_2")); */
+         PortletURL deleteTopicURL = resp.createActionURL();
+         deleteTopicURL.setParameter(getOperationName(), "moderate_forum");
+         deleteTopicURL.setParameter("delete", "delete");
+         deleteTopicURL.setParameter("f", "" + topic.getForum().getId());
+         deleteTopicURL.setParameter("t", "" + topic.getId());
+         PortletURL moveTopicURL = resp.createActionURL();
+         moveTopicURL.setParameter(getOperationName(), "moderate_forum");
+         moveTopicURL.setParameter("move", "move");
+         moveTopicURL.setParameter("f", "" + topic.getForum().getId());
+         moveTopicURL.setParameter("t", "" + topic.getId());
+         PortletURL lockTopicURL = resp.createActionURL();
+         lockTopicURL.setParameter(getOperationName(), "moderate_forum");
+         lockTopicURL.setParameter("lock", "lock");
+         lockTopicURL.setParameter("f", "" + topic.getForum().getId());
+         lockTopicURL.setParameter("t", "" + topic.getId());
+         PortletURL unlockTopicURL = resp.createActionURL();
+         unlockTopicURL.setParameter(getOperationName(), "moderate_forum");
+         unlockTopicURL.setParameter("unlock", "unlock");
+         unlockTopicURL.setParameter("f", "" + topic.getForum().getId());
+         unlockTopicURL.setParameter("t", "" + topic.getId());
+         PortletURL splitTopicURL = resp.createActionURL();
+         splitTopicURL.setParameter(getOperationName(), "moderate_forum");
+         splitTopicURL.setParameter("split", "split");
+         splitTopicURL.setParameter("f", "" + topic.getForum().getId());
+         splitTopicURL.setParameter("t", "" + topic.getId());
+
+         topicMod =
+            "<a href=\"" + deleteTopicURL.toString() + "\">" + "<img src=\""
+               + theme.resourceTopicModeDeleteURL + "\" alt=\"" + bundle.getString("Delete_topic") + "\" title=\""
+               + bundle.getString("Delete_topic") + "\" " + "border=\"0\"/></a>&nbsp;"
+               + "<a href=\"" + moveTopicURL.toString() + "\">" + "<img src=\""
+               + theme.resourceTopicModMoveURL + "\" alt=" + bundle.getString("Move_topic") + "\" " + "title=\""
+               + bundle.getString("Move_topic") + "\" border=\"0\"/></a>&nbsp;"
+               + ((topicStatus == TOPIC_UNLOCKED)
+               ? ("<a href=\"" + lockTopicURL.toString() + "\">" + "<img src=\""
+               + theme.resourceTopicModLockURL + "\" alt=\"" + bundle.getString("Lock_topic") + "\" " + "title=\""
+               + bundle.getString("Lock_topic") + "\" border=\"0\" /></a>&nbsp;")
+               : ("<a href=\"" + unlockTopicURL.toString() + "\">" + "<img src=\""
+               + theme.resourceTopicModUnlockURL + "\" alt=\"" + bundle.getString("Unlock_topic") + "\" "
+               + "title=\"" + bundle.getString("Unlock_topic") + "\" border=\"0\"/></a>&nbsp;"))
+               + "<a href=\"" + splitTopicURL.toString() + "\">" + "<img src=\""
+               + theme.resourceTopicModSplitURL + "\" " + "alt=\"" + bundle.getString("Split_topic") + "\" title=\""
+               + bundle.getString("Split_topic") + "\" border=\"0\"/></a>&nbsp;";
+      }
+
+      String watchingTopic = "";
+      String watchingTopicImg = "";
+
+      /*
+       if (canWatch)
+       {
+       if (isWatching)
+       {
+       watchingTopic = "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
+       "&unwatch=topic&start=" + start + "\">${bb.Stop_watching_topic}</a>";
+       String url = theme.resourceTopicUnWatchURL;
+       watchingTopicImg = "".equals(url) ? "" : "<a href=\"index.html?module=bb&op=viewtopic&t=" +
+       topicId + "&unwatch=topic&start=" + start + "\"><img src=\"" + url +
+       "\" alt=\"" + bundle.getString("Stop_watching_topic") + "\" title=\"" + bundle.getString("Stop_watching_topic") + "\" border=\"0\"></a>";
+       }
+       else
+       {
+       watchingTopic = "<a href=\"index.html?module=bb&op=viewtopic&t=" + topicId +
+       "&watch=topic&start=" + start + "\">${bb.Start_watching_topic}</a>";
+       String url = theme.resourceTopicWatchURL;
+       watchingTopicImg = "".equals(url) ? "" : "<a href=\"index.html?module=bb&op=viewtopic&t=" +
+       topicId + "&watch=topic&start=" + start + "\"><img src=\"" + url +
+       "\" alt=\"" + bundle.getString("Start_watching_topic") + "\" title=\"" + bundle.getString("Start_watching_topic") + "\" border=\"0\"></a>";
+       }
+       }
+       */
+
+      // $pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : ;
+      /*int postPerPage = 10;*/
+      int postPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
+
+      PortletURL gotoURL = resp.createRenderURL();
+      gotoURL.setParameter("op", OP_SHOWTOPIC);
+      gotoURL.setParameter("t", "" + topicId);
+      gotoURL.setParameter("postDays", "" + postDays);
+      gotoURL.setParameter("postorder", (postOrderAsc ? "asc" : "desc"));
+      GotoWithOffset toPost = new GotoWithOffset(1 + totalReplies, start,
+         postPerPage, gotoURL.toString() + "&start=", bundle
+         .getString("Goto_page"), bundle.getString("Previous"), bundle
+         .getString("Next"));
+
+      String pageNumber = bundle.getString("Page_of_0")
+         + ((int)Math.floor((double)start / (postPerPage)) + 1)
+         + bundle.getString("Page_of_1")
+         + ((int)Math.ceil((double)(totalReplies + 1) / postPerPage))
+         + bundle.getString("Page_of_2");
+
+      String instantReplyHiddenFormFields = "<input type=\"hidden\" name=\"attach_sig\" value=\"-1\"/>\n"
+         + "<input type=\"hidden\" name=\"mode\" value=\"reply\"/>\n"
+         + "<input type=\"hidden\" name=\"subject\" value=\"Re: "
+         + topic.getSubject()
+         + "\"/>\n"
+         + "<input type=\"hidden\" name=\"p\" value=\""
+         + topic.getLastPost().getId() + "\"/>\n";
+      replySubmitURL.setParameter("attach_sig", "-1");
+      replySubmitURL.setParameter("mode", "reply");
+      replySubmitURL.setParameter("subject", "Re: " + topic.getSubject());
+      replySubmitURL.setParameter("t", "" + topic.getId());
+      replySubmitURL.setParameter("f", "" + topic.getForum().getId());
+      replySubmitURL.setParameter("p", "" + topic.getLastPost().getId());
+      // "<input type=\"hidden\" name=\"notify\" value=\"" + "checked" + "\"/>\n";
+      //      DelegateContext root = new DelegateContext();
+      root.put("S_INSTANT_REPLY_HIDDEN_FORM_FIELDS",
+         instantReplyHiddenFormFields);
+      root.put("FORUM_ID", forumId.toString());
+      root.put("FORUM_NAME", forumName);
+      root.put("CATEGORY_NAME", category.getTitle());
+      root.put("TOPIC_ID", topicId.toString());
+      root.put("TOPIC_TITLE", topicTitle);
+      root.put("PAGINATION", toPost.generate());
+      root.put("PAGE_NUMBER", pageNumber);
+      root.put("POST_IMG", postImg);
+      root.put("REPLY_IMG", replyImg);
+      root.put("L_POST_NEW_TOPIC", postAlt);
+      root.put("L_POST_REPLY_TOPIC", replyAlt);
+      root.put("S_TOPIC_LINK", "t");
+
+      //      root.put("S_SELECT_POST_DAYS", selectPostDays);
+      //     root.put("S_SELECT_POST_ORDER", selectPostOrder);
+      root.put("S_POST_DAYS_ACTION", "index.html?module=bb&op=viewtopic&t="
+         + topicId + "&start=" + start);
+      root.put("S_AUTH_LIST", authCan.toString());
+      root.put("S_TOPIC_ADMIN", topicMod);
+      root.put("S_WATCH_TOPIC", watchingTopic);
+      root.put("S_WATCH_TOPIC_IMG", watchingTopicImg);
+      root.put("U_VIEW_FORUM", viewForumURL.toString());
+      root.put("U_VIEW_OLDER_TOPIC", viewPrevTopicUrl);
+      root.put("U_VIEW_NEWER_TOPIC", viewNextTopicUrl);
+      root.put("U_POST_NEW_TOPIC", newTopicURL.toString());
+      root.put("U_POST_REPLY_TOPIC", replyTopicURL.toString());
+
+      //      root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
+      PortletURL viewMainPageURL = resp.createRenderURL();
+      viewMainPageURL.setParameter("op", OP_MAIN);
+      root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
+      root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
+      root.put("U_VIEW_CATEGORY", viewCategoryURL.toString());
+      root.put("U_VIEW_TOPIC", "index.html?module=bb&op=viewtopic&t=" + topicId
+         + "&start=" + start + "&postdays=" + "postDays" + "&postorder="
+         + "postOrder" + "&highlight=" + "highlight");
+      root.put("U_REPLY_SUBMIT", replySubmitURL.toString());
+
+
+      Poll poll = topic.getPoll();
+      boolean isPoll = poll != null;
+      if (isPoll && poll.getOptions().size() == 0)
+      {
+         isPoll = false;
+      }
+      boolean pollVoted = false;
+      boolean canVote = ForumsTools.hasPermission(req, "VotePollInPost");
+      boolean pollExpired = false;
+      //boolean pollEnded = poll.getIsEnded();
+      boolean pollViewResultsMode = false;
+      if (req.getParameter("poll_results_view_enable") != null &&
+         req.getParameter("poll_results_view_enable").equals("true"))
+      {
+         pollViewResultsMode = true;
+      }
+      if (loggedIn && isPoll)
+      {
+         for (Iterator i = poll.getVoted().iterator(); i.hasNext();)
+         {
+            Integer userId = (Integer)i.next();
+            pollVoted |= user.getId().equals(userId);
+         }
+      }
+      if (isPoll)
+      {
+         Calendar c = Calendar.getInstance();
+         c.setTime(poll.getCreationDate());
+         c.add(Calendar.DATE, poll.getLength());
+         pollExpired = c.before(new Date());
+
+      }
+      if (isPoll && !pollVoted && loggedIn && !pollViewResultsMode && !pollExpired && canVote)
+      {
+         PortletURL voteSubmitURL = resp.createActionURL();
+         voteSubmitURL.setParameter("op", "posting");
+         voteSubmitURL.setParameter("mode", "vote");
+         voteSubmitURL.setParameter("t", "" + topic.getId());
+         voteSubmitURL.setParameter("f", "" + topic.getForum().getId());
+         DelegateContext poll_ballot = root.next("poll_ballot_display");
+         poll_ballot.put("POLL_QUESTION", poll.getTitle());
+         Iterator i = poll.getOptions().iterator();
+         int index = 0;
+         while (i.hasNext())
+         {
+            PollOption po = (PollOption)i.next();
+            DelegateContext poll_ballot_option = poll_ballot.next("poll_option");
+            poll_ballot_option.put("POLL_OPTION_ID", "" + index);
+            poll_ballot_option.put("POLL_OPTION_CAPTION", po.getQuestion());
+            index++;
+         }
+
+         PortletURL viewPollResultsURL = resp.createRenderURL();
+         viewPollResultsURL.setParameter("op", "showTopic");
+         viewPollResultsURL.setParameter("t", "" + topic.getId());
+         viewPollResultsURL.setParameter("poll_results_view_enable", "true");
+         poll_ballot.put("U_VIEW_RESULTS", viewPollResultsURL.toString());
+         //pollRoot.put("U_VIEW_RESULTS", "index.html?module=bb&op=viewtopic&t=" + topicId +
+         //"&postdays=" + postDays + "&postorder=" + (postOrderAsc ? "asc" : "desc") +
+         //"&vote=viewresult");
+         String hiddenFields = "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
+            "<input type=\"hidden\" name=\"op\" value=\"posting\"/>" +
+            "<input type=\"hidden\" name=\"t\" value=\"" + topicId +
+            "\"/><input type=\"hidden\" name=\"mode\" value=\"vote\"/>";
+
+         //            pollRoot.put("POLL_QUESTION", formatVoteTitle(voteTitle));
+         poll_ballot.put("S_HIDDEN_FIELDS", hiddenFields);
+         poll_ballot.put("VOTE_FORM_SUBMIT", voteSubmitURL.toString());
+      }
+      else if (isPoll)
+      {
+         DelegateContext poll_result = root.next("poll_result_display");
+         poll_result.put("POLL_QUESTION", poll.getTitle());
+         poll_result.put("TOTAL_VOTES", "" + poll.getVotesSum());
+         float voteResultsSum = 0;
+         for (Iterator iterator = poll.getOptions().iterator(); iterator.hasNext();)
+         {
+            PollOption po = (PollOption)iterator.next();
+            voteResultsSum += po.getVotes();
+         }
+
+         Iterator i = poll.getOptions().iterator();
+         int numOfOpts = poll.getOptions().size();
+         //int index = 0;
+         while (i.hasNext())
+         {
+            PollOption po = (PollOption)i.next();
+            DelegateContext poll_result_option = poll_result.next("poll_option");
+            //poll_result_option.put("POLL_OPTION_ID", "" + index);
+            poll_result_option.put("POLL_OPTION_CAPTION", po.getQuestion());
+            poll_result_option.put("POLL_OPTION_L_IMG", "" + theme.resourcePollVotingLBar);
+            poll_result_option.put("POLL_OPTION_R_IMG", "" + theme.resourcePollVotingRBar);
+            poll_result_option.put("POLL_OPTION_IMG", "" + theme.resourcePollVotingBar);
+
+            float votePercent = voteResultsSum > 0 ? po.getVotes() / voteResultsSum : 0f;
+            int voteGraphicLength = Math.round(votePercent * 205); // 205 == voteGraphicLength
+            //String voteGraphicImg = theme.resourcePollVotingBar  //theme.getResourceURL("voting_graphic_" + voteGraphic);
+
+            //optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
+            poll_result_option.put("POLL_OPTION_RESULT", "" + po.getVotes());
+            poll_result_option.put("POLL_OPTION_PERCENT", "" + votePercent); // sprintf("%.1d%%", ($vote_percent * 100))
+            //optionRoot.put("POLL_OPTION_IMG",);
+            poll_result_option.put("POLL_OPTION_IMG_WIDTH", "" + voteGraphicLength);
+            //index++;
+         }
+
+
+      }
+
+      /*
+      PollEJBLocal poll = topic.getPoll();
+      String pollBox = "";
+      if (poll != null)
+      {
+      int voteOptions = -1;
+      Collection options = null;
+      try
+      {
+      options = homesRO.option.findByPoll(poll);
+      voteOptions = options.size();
+      }
+      catch (FinderException e)
+      {
+      Die.exit(GENERAL_ERROR, "Could not obtain vote data for this topic", e);
+      }
+      String hiddenFields = "";
+      if (voteOptions > 0)
+      {
+      String voteTitle = poll.getText();
+      boolean userVoted = false;
+      if (user != null)
+      {
+      try
+      {
+      userVoted = true;
+      homesRO.vote.findByPollAndUser(poll, user);
+      }
+      catch (ObjectNotFoundException e)
+      {
+      userVoted = false;
+      }
+      catch (FinderException e)
+      {
+      Die.exit(GENERAL_ERROR, "Could not obtain user vote data for this topic", e);
+      }
+      }
+      Template pollTpl = null;
+      DelegateContext pollRoot = new DelegateContext();
+      boolean viewResult = "viewresult".equals(vote);
+      Calendar c = Calendar.getInstance();
+      c.setTime(poll.getCreationDate());
+      c.add(Calendar.DATE, poll.getLength());
+      boolean pollExpired = c.before(new Date());
+      if (userVoted || viewResult || pollExpired || !authVote || topic.getStatus() == TOPIC_LOCKED)
+      {
+      pollTpl = theme.TPL_THEME_VIEWTOPIC_POLL_RESULT;
+      float voteResultsSum = 0;
+      for (Iterator iterator = options.iterator();iterator.hasNext();)
+      {
+      OptionEJBLocal option = (OptionEJBLocal)iterator.next();
+      voteResultsSum += option.getResult();
+      }
+      int voteGraphic = 0;
+      for (Iterator iterator = options.iterator();iterator.hasNext();)
+      {
+      OptionEJBLocal option = (OptionEJBLocal)iterator.next();
+      float votePercent = voteResultsSum > 0 ? option.getResult() / voteResultsSum : 0f;
+      int voteGraphicLength = Math.round(votePercent * 205); // 205 == voteGraphicLength
+      String voteGraphicImg = theme.getResourceURL("voting_graphic_" + voteGraphic);
+      if ("".equals(voteGraphicImg))
+      {
+      voteGraphicImg = theme.getResourceURL("voting_graphic_0");
+      voteGraphic = 0;
+      }
+      else
+      {
+      voteGraphic++;
+      }
+      DelegateContext optionRoot = pollRoot.next("poll_option");
+      optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
+      optionRoot.put("POLL_OPTION_RESULT", "" + option.getResult());
+      optionRoot.put("POLL_OPTION_PERCENT", "" + votePercent); // sprintf("%.1d%%", ($vote_percent * 100))
+      optionRoot.put("POLL_OPTION_IMG", voteGraphicImg);
+      optionRoot.put("POLL_OPTION_IMG_WIDTH", "" + voteGraphicLength);
+      }
+      pollRoot.put("TOTAL_VOTES", "" + voteResultsSum);
+      }
+      else
+      {
+      pollTpl = theme.TPL_THEME_VIEWTOPIC_POLL_BALLOT;
+      for (Iterator iterator = options.iterator();iterator.hasNext();)
+      {
+      Option option = (Option)iterator.next();
+      DelegateContext optionRoot = pollRoot.next("poll_option");
+      optionRoot.put("POLL_OPTION_ID", option.getId().toString());
+      optionRoot.put("POLL_OPTION_CAPTION", formatVoteInfo(option.getText()));
+      }
+      pollRoot.put("U_VIEW_RESULTS", "index.html?module=bb&op=viewtopic&t=" + topicId +
+      "&postdays=" + postDays + "&postorder=" + (postOrderAsc ? "asc" : "desc") +
+      "&vote=viewresult");
+      hiddenFields += "<input type=\"hidden\" name=\"module\" value=\"bb\"/>" +
+      "<input type=\"hidden\" name=\"op\" value=\"posting\"/>" +
+      "<input type=\"hidden\" name=\"t\" value=\"" + topicId +
+      "\"/><input type=\"hidden\" name=\"mode\" value=\"vote\"/>";
+      }
+      //            pollRoot.put("POLL_QUESTION", formatVoteTitle(voteTitle));
+      pollRoot.put("S_HIDDEN_FIELDS", hiddenFields);
+      pollBox = pollTpl.render(pollRoot);
+      }
+      }
+      root.put("POLL_DISPLAY", pollBox);
+      */
+      topic.setViewCount(topic.getViewCount() + 1);
+
+      for (IndexIterator iterator = IndexIterator.wrap(posts.iterator(), -1); iterator
+         .hasNext();)
+      {
+         Post post = (Post)iterator.next();
+         User poster = post.getPoster().getUser();
+
+         //below where " req.getRemoteUser() != null" was earlier "poster != null"
+
+         String posterId = req.getRemoteUser() != null ? poster.getId().toString() : "0";
+         /*String postDate = post.getCreateDate().toString();*/
+         SimpleDateFormat sdf = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
+         String postDate = sdf.format(post.getCreateDate());
+         String posterPosts = req.getRemoteUser() != null ? (bundle.getString("Posts")
+            + ":" + poster.getUserName()) : "";
+         String location = (String)poster.getProperties().get("LOCATION");
+         String posterFrom = (req.getRemoteUser() != null && (location != null)) ? (bundle
+            .getString("Location")
+            + ":" + location) : "";
+         /*String posterJoined = (poster != null) ? (bundle.getString("Joined")
+            + ":" + poster.getRegistrationDate()) : "";*/
+         String posterJoined = req.getRemoteUser() != null ? (bundle.getString("Joined")
+            + ":" + sdf.format(poster.getRegistrationDate())) : "";
+
+         //         String posterAvatar = "";
+         //         $poster_avatar = '';
+         //         if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] )
+         //         {
+         //            switch( $postrow[$i]['user_avatar_type'] )
+         //            {
+         //               case USER_AVATAR_UPLOAD:
+         //                  $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
+         //                  break;
+         //               case USER_AVATAR_REMOTE:
+         //                  $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
+         //                  break;
+         //               case USER_AVATAR_GALLERY:
+         //                  $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
+         //                  break;
+         //            }
+         //         }
+         String miniPostImg = theme.resourceIconMinipostURL;
+         String miniPostAlt = bundle.getString("Post");
+         if (loggedIn && false) // $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read
+         {
+            miniPostImg = theme.resourceIconMinipostNewURL;
+            miniPostAlt = bundle.getString("New_post");
+         }
+
+         //        String miniPostUrl = "index.html?module=bb&op=viewtopic&p=" + post.getID() + "#" + postImg;
+         //         //
+         //         // Generate ranks, set them to empty string initially.
+         //         //
+         //         $poster_rank = '';
+         //         $rank_image = '';
+         //         if ( $postrow[$i]['user_id'] == ANONYMOUS )
+         //         {
+         //         }
+         //         else if ( $postrow[$i]['user_rank'] )
+         //         {
+         //            for($j = 0; $j < count($ranksrow); $j++)
+         //            {
+         //               if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
+         //               {
+         //                  $poster_rank = $ranksrow[$j]['rank_title'];
+         //                  $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
+         //               }
+         //            }
+         //         }
+         //         else
+         //         {
+         //            for($j = 0; $j < count($ranksrow); $j++)
+         //            {
+         //               if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
+         //               {
+         //                  $poster_rank = $ranksrow[$j]['rank_title'];
+         //                  $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
+         //               }
+         //            }
+         //         }
+         //
+         // compute the displayed poster name
+         String posterName = post.getPoster().getUser().getUserName();
+         String profileImgLnk = "";
+         String profileLnk = "";
+         String pmImgLnk = "";
+         String pmLnk = "";
+         String emailImgLnk = "";
+         String emailLnk = "";
+         String wwwImgLnk = "";
+         String wwwLnk = "";
+         String icqStatusImgLnk = "";
+         String icqImgLnk = "";
+         String icqLnk = "";
+         String aimImgLnk = "";
+         String aimLnk = "";
+         String msnImgLnk = "";
+         String msnLnk = "";
+         String yimImgLnk = "";
+         String yimLnk = "";
+         String skypeImgLnk = "";
+         String skypeImg = "";
+         String editImgLnk = "";
+         String editLnk = "";
+         String repostImgLnk = "";
+         String repostLnk = "";
+         String ipImgLnk = "";
+         String ipLnk = "";
+
+         //theme
+         PortletURL userProfileURL = resp.createRenderURL();
+         userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
+         userProfileURL.setParameter("uid", "" + poster.getId().toString());
+         if ((req.getRemoteUser() != null))
+         {
+            //user.getPreferenceStore().
+            String fakeEmail = poster.getFakeEmail();
+            String homepage = (String)(poster.getProperties().get(User.INFO_USER_HOMEPAGE));
+            String icqAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_ICQ));
+            String aimAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_AIM));
+            String msnmAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_MSNM));
+            String yimAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_YIM));
+            String skypeAddr = (String)(poster.getProperties().get(User.INFO_USER_IM_SKYPE));
+
+            profileImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconProfileURL, "");
+            if (fakeEmail != null && fakeEmail.length() > 0)
+            {
+               emailImgLnk = ForumsTools.createImageLink("mailto:" + fakeEmail, theme.resourceIconEmailURL, "");
+            }
+            if (homepage != null && homepage.length() > 0)
+            {
+               wwwImgLnk = ForumsTools.createImageLink(homepage, theme.resourceIconWWWURL, "");
+            }
+            String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + icqAddr;
+            if (icqAddr != null && icqAddr.length() > 0)
+            {
+               icqImgLnk = ForumsTools.createImageLink(icqUrl, theme.resourceIconICQURL, "");
+            }
+            String aimUrl = "aim:goim?screenname=" + aimAddr + "&message=Hello+Are+you+there?";
+            if (aimAddr != null && aimAddr.length() > 0)
+            {
+               aimImgLnk = ForumsTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "");
+            }
+            if (msnmAddr != null && msnmAddr.length() > 0)
+            {
+               msnImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconMSNMURL, "");
+            }
+            if (skypeAddr != null && skypeAddr.length() > 0)
+            {
+               skypeImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconSkypeURL, "");
+            }
+            String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + yimAddr + "&src=pg";
+            if (yimAddr != null && yimAddr.length() > 0)
+            {
+               yimImgLnk = ForumsTools.createImageLink(yimUrl.toString(), theme.resourceIconYIMURL, "");
+            }
+         }
+
+         /*
+         if (poster != null)
+         {
+         String posterIcq = poster.getMessengerICQ();
+         String posterAim = poster.getMessengerAIM();
+         String posterMsn = poster.getMessengerMSNM();
+         String posterYim = poster.getMessengerYIM();
+         String profileUrl = "index.html?module=user&op=userinfo&uid=" + posterId;
+         profileImgLnk = BBTools.createImageLink(profileUrl, theme.resourceIconProfileURL, "${bb.Read_profile}");
+         profileLnk = BBTools.createLink(profileUrl, "${bb.Read_profile}");
+         //            String pmUrl = "privmsg.php?mode=post&u=" + posterId;
+         String pmUrl = ""; // todo private message
+         pmImgLnk = BBTools.createImageLink(pmUrl, theme.resourceIconPMURL, "${bb.Send_private_message}");
+         pmLnk = BBTools.createLink(pmUrl, "${bb.Send_private_message}");
+         if (!poster.getViewEmail() || authMod)
+         {
+         String emailUrl = emailForm ? "index.html?module=user&op=userinfo&uid=" + posterId :
+         "mailto:" + poster.getEmail();
+         emailImgLnk = BBTools.createImageLink(emailUrl, theme.resourceIconEmailURL, "${bb.Send_email}");
+         emailLnk = BBTools.createLink(emailUrl, "${bb.Send_email}");
+         }
+         String websiteUrl = poster.getURL();
+         if (websiteUrl != null && websiteUrl.length() > 0)
+         {
+         wwwImgLnk = BBTools.createImageLink(websiteUrl, "userwww", theme.resourceIconWWWURL, "${bb.Visit_website}", "${bb.Visit_website}");
+         wwwLnk = BBTools.createLink(websiteUrl, "userwww", "${bb.Visit_website}");
+         }
+         if (posterIcq != null && posterIcq.length() > 0)
+         {
+         icqStatusImgLnk = "<a href=\"http://wwp.icq.com/" + posterIcq + "#pager\">" +
+         "<img src=\"http://web.icq.com/" +
+         "whitepages/online?icq=\"" + posterIcq +
+         "&img=5\" width=\"18\" height=\"18\" border=\"0\"/></a>";
+         String icqUrl = "http://wwp.icq.com/scripts/search.dll?to=" + posterIcq;
+         icqImgLnk = BBTools.createImageLink(icqUrl, theme.resourceIconICQURL, "${bb.ICQ}");
+         icqLnk = BBTools.createLink(icqUrl, "${bb.ICQ}");
+         }
+         if (posterAim != null && posterAim.length() > 0)
+         {
+         String aimUrl = "aim:goim?screenname=\"" + posterAim + "&message=Hello+Are+you+there?";
+         aimImgLnk = BBTools.createImageLink(aimUrl, theme.resourceIconAIMURL, "${bb.AIM}");
+         aimLnk = BBTools.createLink(aimUrl, "${bb.AIM}");
+         }
+         if (posterMsn != null && posterMsn.length() > 0)
+         {
+         String msnUrl = "index.html?module=user&op=userinfo&uid=" + posterId;
+         msnImgLnk = BBTools.createImageLink(msnUrl, theme.resourceIconMSNMURL, "${bb.MSNM}");
+         msnLnk = BBTools.createLink(msnUrl, "${bb.MSNM}");
+         }
+         if (posterYim != null && posterYim.length() > 0)
+         {
+         String yimUrl = "http://edit.yahoo.com/config/send_webmesg?.target=" + posterYim + "&src=pg";
+         yimImgLnk = BBTools.createImageLink(yimUrl, theme.resourceIconYIMURL, "${bb.YIM}");
+         yimLnk = BBTools.createLink(yimUrl, "${bb.YIM}");
+         }
+         }
+         */
+         /*
+          String searchUrl = "index.html?module=bb&op=search&search_authors=${encodeurl:" + post.getPoster().getAuthor(false) + "}" + "&showresults=posts";
+          String searchImg = BBTools.createImageLink(searchUrl, theme.resourceIconSearchURL, "${bb.Search_user_posts}");
+          String search = BBTools.createLink(searchUrl, "${bb.Search_user_posts}");
+          if ((EJB.areIdentical(user, poster) && authEdit) || authMod)
+          {
+          String editUrl = "index.html?module=bb&op=posting&mode=editpost&p=" + post.getId();
+          editImgLnk = "<a href=\"" + editUrl + "\"><img src=\"" + theme.resourceIconEditURL +
+          "\" alt=\"${bb.Edit_delete_post}\" title=\"${bb.Edit_delete_post}\" border=\"0\"/></a>";
+          editLnk = "<a href=\"" + editUrl + "\">${bb.Edit_delete_post}</a>";
+          String repostUrl = "index.html?module=bb&op=posting&mode=repost&p=" + post.getId();
+          repostImgLnk = "<a href=\"" + repostUrl + "\"><img src=\"" + theme.resourceIconRepostURL +
+          "\" alt=\"${bb.Repost_post}\" title=\"${bb.Repost_post}\" border=\"0\"/></a>";
+          repostLnk = "<a href=\"" + repostUrl + "\">${bb.Repost_post}</a>";
+          }
+          */
+
+
+
+         boolean canDelete = false;
+         boolean canIP = false;
+
+         if (authMod)
+         {
+            canDelete = true;
+            canIP = true;
+         }
+         else
+         {
+            canDelete = authDelete
+               && poster.getUserName().equals(user.getUserName())
+               && topic.getLastPost().getId().equals(post.getId());
+         }
+
+         // only moderators can use the IP function on a given topic
+         if (canIP)
+         {
+            String url = "index.html?module=bb&op=modcp&mode=ip&p="
+               + post.getId() + "&t=" + topicId;
+
+            //            ipImgLnk = BBTools.createImageLink(url, theme.resourceIconIPURL, "${bb.View_IP}");
+            //            ipLnk = BBTools.createLink(url, "${bb.View_IP}");
+         }
+
+         Message message = post.getMessage();
+         String postSubject = message.getSubject();
+         if (postSubject == null)
+         {
+            postSubject = "";
+         }
+         String text = "";
+         if (message.getText() != null)
+         {
+            text = new String(message.getText());
+         }
+
+         PropertyMap upm = post.getPoster().getUser().getProperties();
+         String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
+         String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+         if ((addsign != null) && (sign != null) && addsign.equals("1"))
+         {
+            text += "\n\n" + sign;
+         }
+
+         String signature = "";
+
+         /*
+         if (message.getSignatureEnabled() && signatureEnabled)
+         {
+         signature = poster.getSignature();
+         if (!BBTools.isNullOrBlank(signature))
+         {
+         signature = formatSignature(signature, message.getBBCodeEnabled(), message.getHTMLEnabled());
+         }
+         }
+         */
+         PortletPreferences pp = req.getPreferences();
+         //text = formatMessage(req, text, message.getBBCodeEnabled(), message.getHTMLEnabled());
+         text = formatMessage(req, text, message.getBBCodeEnabled(), pp.getValue("allowhtml", "1").equals("1"));
+         postSubject = formatTitle(req, postSubject);
+
+         //         //
+         //         // Highlight active words (primarily for search)
+         //         //
+         //         if ($highlight_match)
+         //         {
+         //            // This was shamelessly 'borrowed' from volker at multiartstudio dot de
+         //            // via php.net's annotated manual
+         //            $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
+         //         }
+         int editCount = post.getEditCount();
+         String editedBy = "";
+         if (editCount > 0)
+         {
+            //check is it one or more and prepare nice sentence
+            String[] ett = (editCount == 1) ? new String[]{
+               bundle.getString("Edited_time_total_0"),
+               bundle.getString("Edited_time_total_1"),
+               bundle.getString("Edited_time_total_2"),
+               bundle.getString("Edited_time_total_3")} : new String[]{
+               bundle.getString("Edited_times_total_0"),
+               bundle.getString("Edited_times_total_1"),
+               bundle.getString("Edited_times_total_2"),
+               bundle.getString("Edited_times_total_3")};
+
+            editedBy = "<br/><br/>" + ett[0] + poster.getUserName() + ett[1] + sdf.format(post.getEditDate()) + ett[2] + editCount + ett[3];
+         }
+
+         String rowColor = theme
+            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_color1"
+               : "td_color2");
+         String rowClass = theme
+            .getProperty(((iterator.getIndex() % 2) == 0) ? "td_class1"
+               : "td_class2");
+
+         DelegateContext postRow = root.next("postrow");
+
+         postRow.put("ROW_COLOR", rowColor);
+         postRow.put("ROW_CLASS", rowClass);
+         postRow.put("POSTER_NAME", posterName);
+         if ((req.getRemoteUser() != null))
+         {
+            postRow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
+         }
+         postRow.put("POSTER_RANK", ""); // $poster_rank
+         postRow.put("RANK_IMAGE", ""); // $rank_image
+         postRow.put("POSTER_JOINED", posterJoined);
+
+         //         postRow.put("POSTER_POSTS", posterPosts);
+         postRow.put("POSTER_FROM", posterFrom);
+         postRow.put("POSTER_AVATAR", ""); // $poster_avatar
+         postRow.put("POST_DATE", postDate);
+         postRow.put("POST_SUBJECT", postSubject);
+         postRow.put("MESSAGE", text);
+         postRow.put("SIGNATURE", signature);
+         postRow.put("EDITED_MESSAGE", editedBy);
+         postRow.put("MINI_POST_IMG", miniPostImg);
+
+         postRow.put("PROFILE_IMG", profileImgLnk);
+         postRow.put("PROFILE", profileLnk);
+
+         //         postRow.put("SEARCH_IMG", searchImg);
+         //         postRow.put("SEARCH", search);
+         postRow.put("PM_IMG", pmImgLnk);
+         postRow.put("PM", pmLnk);
+         postRow.put("EMAIL_IMG", emailImgLnk);
+         postRow.put("EMAIL", emailLnk);
+         postRow.put("WWW_IMG", wwwImgLnk);
+         postRow.put("WWW", wwwLnk);
+         postRow.put("ICQ_STATUS_IMG", icqStatusImgLnk);
+         postRow.put("ICQ_IMG", icqImgLnk);
+         postRow.put("ICQ", icqLnk);
+         postRow.put("AIM_IMG", aimImgLnk);
+         postRow.put("AIM", aimLnk);
+         postRow.put("MSN_IMG", msnImgLnk);
+         postRow.put("MSN", msnLnk);
+         postRow.put("SKYPE_IMG", skypeImgLnk);
+         postRow.put("YIM_IMG", yimImgLnk);
+         postRow.put("YIM", yimLnk);
+         //postRow.put("EDIT_IMG", editImgLnk);
+         //postRow.put("EDIT", editLnk);
+         postRow.put("REPOST_IMG", repostImgLnk);
+         postRow.put("REPOST", repostLnk);
+
+         if (authPost)
+         {
+            PortletURL quoteURL = resp.createActionURL();
+            quoteURL.setParameter("mode", "quote");
+            quoteURL.setParameter("op", "posting");
+            quoteURL.setParameter("p", String.valueOf(post.getId()));
+            quoteURL.setParameter("f", String.valueOf(forum.getId()));
+
+            //String quoteUrl = "index.html?module=bb&op=posting&mode=quote&p=" + post.getID();
+            String quoteImg = ForumsTools.createImageLink(quoteURL.toString(),
+               theme.resourceIconQuoteURL, bundle
+               .getString("Reply_with_quote"));
+            String quote = ForumsTools.createLink(quoteURL.toString(), bundle
+               .getString("Reply_with_quote"));
+            postRow.put("QUOTE_IMG", quoteImg);
+            postRow.put("QUOTE", quote);
+         }
+
+         if (authMod)
+         {
+            PortletURL editURL = resp.createActionURL();
+            editURL.setParameter("mode", "editpost");
+            editURL.setParameter("op", "posting");
+            editURL.setParameter("p", String.valueOf(post.getId()));
+            editURL.setParameter("f", String.valueOf(forum.getId()));
+            //Set this param to inform posting() that it will be it's first call
+            editURL.setParameter("editPostInit", "true");
+            boolean firstTopicPost = false;
+            firstTopicPost |= post.getTopic().getFirstPost().getId().equals(post.getId());
+            editURL.setParameter("firstTopicPost", "" + firstTopicPost);
+            if (firstTopicPost)
+            {
+               editURL.setParameter("topictype", "" + post.getTopic().getType());
+            }
+            editURL.setParameter("subject", post.getMessage().getSubject());
+
+            String editImg = ForumsTools.createImageLink(editURL.toString(),
+               theme.resourceIconEditURL, bundle
+               .getString("Edit_Post"));
+            String edit = ForumsTools.createLink(editURL.toString(), bundle
+               .getString("Edit_Post"));
+            postRow.put("EDIT_IMG", editImg);
+            postRow.put("EDIT", edit);
+         }
+
+
+         postRow.put("IP_IMG", ipImgLnk);
+         postRow.put("IP", ipLnk);
+
+         // only moderators can delete all messages from a given topic
+         // if a user has the delete privilege on a forum that means he
+         // in this forum can delete his own posts
+         if (canDelete)
+         {
+            PortletURL deleteURL = resp.createActionURL();
+            deleteURL.setParameter("mode", "delete");
+            deleteURL.setParameter("op", "posting");
+            deleteURL.setParameter("p", "" + post.getId());
+
+            String delPostImgLnk = ForumsTools.createImageLink(deleteURL
+               .toString(), theme.resourceIconDelpostURL, bundle
+               .getString("Delete_post"));
+            String delPostLnk = ForumsTools.createLink(deleteURL.toString(),
+               bundle.getString("Delete_post"));
+            postRow.put("DELETE_IMG", delPostImgLnk);
+            postRow.put("DELETE", delPostLnk);
+         }
+
+         postRow.put("L_MINI_POST_ALT", miniPostAlt);
+
+
+         PortletURL miniPostURL = resp.createRenderURL();
+         try
+         {
+             miniPostURL.setWindowState(WindowState.MAXIMIZED);
+         }
+         catch (WindowStateException e)
+         {
+             e.printStackTrace();
+         }
+         miniPostURL.setParameter("op", OP_SHOWTOPIC);
+         miniPostURL.setParameter("p", "" + post.getId());
+
+         String miniPostUrlString = miniPostURL.toString()+"#"+post.getId();
+         miniPostUrlString = miniPostUrlString.replaceFirst("/auth","");
+         postRow.put("U_MINI_POST", miniPostUrlString);
+         postRow.put("U_POST_ID", post.getId().toString());
+
+         //Here we display post attachments
+         List attachments = post.getAttachments();
+         DelegateContext attachDisplayCtx = null;
+         DelegateContext attachContext = null;
+         if (attachments.size() > 0)
+         {
+            attachDisplayCtx = postRow.next("attachments_display");
+            attachContext = attachDisplayCtx.next("attach");
+         }
+         //For every attachment we must create Token and place it in the AttachmentTokenManager
+         //to pass to DownloadServlet aggrement to download each.
+         AttachmentTokenManager atm = getAttachmentManager(req);
+         //Generate url to servlet
+         String hostURL = ((req.isSecure()) ? "https" : "http")
+            + "://"
+            + req.getServerName()
+            + ((req.getServerPort() == 80) ? "" : ":"
+            + req.getServerPort());
+         String servletURL = hostURL + req.getContextPath() + "/files?tokenId=";
+         for (Iterator i = attachments.iterator(); i.hasNext();)
+         {
+            Attachment attach = (Attachment)i.next();
+            //TODO:BD set some nice expire date (maybe in config)
+            Calendar c = Calendar.getInstance();
+            //15 minutes for downloading?
+            c.add(Calendar.MINUTE, 15);
+
+            AttachmentToken token = atm.createNewToken(attach.getId(), c.getTime());
+            atm.addToken(token);
+
+            if (attach.getFile().getContentType().startsWith("image/"))
+            {
+               //Date expireDate = newDate();
+               //expireDate.
+               DelegateContext catImagesContext = attachContext.next("cat_images");
+               catImagesContext.put("COMMENT", attach.getComment());
+               catImagesContext.put("DOWNLOAD_NAME", attach.getFile().getName());
+               catImagesContext.put("IMG_SRC", servletURL + token.getId());
+               catImagesContext.put("FILSIZE", "" + attach.getFile().getSize() / 1024 + "kB");
+               //catImagesContext.put("SIZE_VAR", "${bb.Bytes}");
+            }
+            else
+            {
+               DelegateContext attachRowContext = attachContext.next("attachrow");
+               attachRowContext.put("COMMENT", attach.getComment());
+               attachRowContext.put("DOWNLOAD_NAME", attach.getFile().getName());
+               attachRowContext.put("U_DOWNLOAD_LINK", servletURL + token.getId());
+               attachRowContext.put("FILESIZE", "" + attach.getFile().getSize() / 1024 + "kB");
+            }
+         }
+         //}
+         //attachments = theme.TPL_THEME_VIEWTOPIC_ATTACH_BODY.render(attachmentsContext);
+         //postRow.put("ATTACHMENTS", attachments);
+
+         //try
+         //{
+
+         /*File tmp = File.createTempFile(attach.getFile().getName(),"");
+     Blob blob = (Blob) attach.getFile().getContent();*/
+/*               OutputStream out = blob.();
+String fileName = "oraclejdbc.jar";
+File f = new File(fileName);
+FileInputStream fin = new FileInputStream(f);
+int count = -1, total = 0;
+byte[] data = new byte[(int)fin.available()];
+fin.read(data);
+out.write(data);
+fin.close();
+out.close();*/
+         // Get the image Blob from the database
+
+         /*InputStream in = null;
+         try
+         {
+            in = blob.getBinaryStream();
+                           BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(tmp) );
+
+byte by[] = new byte[ 32768 ];
+int index = in.read( by, 0, 32768 );
+while ( index != -1 )
+{
+out.write( by, 0, index );
+index = in.read( by, 0, 32768 );
+}
+out.flush();
+            System.out.println("Stored attachment into: " + tmp.getAbsolutePath());
+         }
+         catch (SQLException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         }*/
+
+         /*}
+         catch (IOException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         }*/
+         //}
+         /*
+         Collection attachmentsCollection = post.getAttachments();
+         String attachments = "";
+         DelegateContext attachmentsContext = new DelegateContext();
+         DelegateContext attachContext = attachmentsContext.next("attach");
+         Iterator i = attachmentsCollection.iterator();
+         AttachmentEJBLocal attachment = null;
+         while (i.hasNext())
+         {
+         attachment = (AttachmentEJBLocal)i.next();
+         if (attachment.getMimetype().startsWith("image/"))
+         {
+         DelegateContext catImagesContext = attachContext.next("cat_images");
+         catImagesContext.put("COMMENT", attachment.getComment());
+         catImagesContext.put("DOWNLOAD_NAME", attachment.getRealFilename());
+         catImagesContext.put("IMG_SRC", "modules/bb/attach?id=" + attachment.getId());
+         catImagesContext.put("FILESIZE", "" + attachment.getFilesize());
+         catImagesContext.put("SIZE_VAR", "${bb.Bytes}");
+         }
+         else
+         {
+         DelegateContext attachRowContext = attachContext.next("attachrow");
+         attachRowContext.put("COMMENT", attachment.getComment());
+         attachRowContext.put("DOWNLOAD_NAME", attachment.getRealFilename());
+         attachRowContext.put("U_DOWNLOAD_LINK", "modules/bb/attach?id=" + attachment.getId());
+         attachRowContext.put("FILESIZE", attachment.getFilesize() + " ${bb.Bytes}");
+         }
+         }
+         attachments = theme.TPL_THEME_VIEWTOPIC_ATTACH_BODY.render(attachmentsContext);
+         postRow.put("ATTACHMENTS", attachments);
+         */
+      }
+
+      return root;
+   }
+
+   private DelegateContext fillShowAddEditForumContext(JBossRenderRequest req,
+                                                       JBossRenderResponse resp, DelegateContext root)
+   {
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+
+      String mode = req.getParameters().get("mode", "");
+
+      // default values for addforum case, miss only the forum name which is calculated under
+      String title = bundle.getString("Create_forum");
+      String newMode = "createforum";
+      String buttonValue = bundle.getString("Create_forum");
+      String forumName = "";
+      String forumDesc = "";
+      int forumStatus = FORUM_UNLOCKED;
+      int forumId = -1;
+      int categoryId = -1;
+      String pruneEnabled = "";
+
+      if ("editforum".equals(mode))
+      {
+         // if edit forum, we override the addforum values
+         title = bundle.getString("Edit_forum");
+         newMode = "modforum";
+         buttonValue = bundle.getString("Update");
+         try
+         {
+            Forum forum = forumsModule.findForumById(req.getParameters()
+               .getIntObject("f"));
+            forumId = forum.getId().intValue();
+            categoryId = forum.getCategory().getId().intValue();
+            forumName = forum.getName();
+            forumDesc = forum.getDescription();
+            forumStatus = forum.getStatus();
+
+            /*
+             if (forum.getPruneEnable())
+             {
+             pruneEnabled = "checked=\"checked\"";
+             //                  $sql = "SELECT *
+             //                           FROM " . PRUNE_TABLE . "
+             //                           WHERE forum_id = $forum_id";
+             //                  if(!$pr_result = $db->sql_query($sql))
+             //                  {
+             //                      message_die(GENERAL_ERROR, "Auto-Prune: Couldn't read auto_prune table.", __LINE__, __FILE__);
+             //                    }
+             //                  $pr_row = $db->sql_fetchrow($pr_result);
+             }
+             */
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();
+
+            //            Die.exit(GENERAL_ERROR, "Couldn't get Forum/Category information", e);
+         }
+      }
+      else
+      {
+         categoryId = req.getParameters().getInt("c", -1);
+
+         // for the addforum mode we setup the forum name
+         forumName = req.getParameter("forumname_" + categoryId);
+      }
+
+      String forumLocked = "";
+      String forumUnlocked = "selected=\"selected\"";
+      if (forumStatus == FORUM_LOCKED)
+      {
+         forumLocked = forumUnlocked;
+         forumUnlocked = "";
+      }
+
+      String catList;
+      try
+      {
+         catList = ForumsTools.listCategories(forumsModule.findCategories(),
+            categoryId);
+         root.put("S_CAT_LIST", catList);
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      String statusList = "<option value=\"" + FORUM_UNLOCKED + "\" "
+         + forumUnlocked + ">" + bundle.getString("Status_unlocked")
+         + "</option>\n" + "<option value=\"" + FORUM_LOCKED + "\" "
+         + forumLocked + ">" + bundle.getString("Status_locked")
+         + "</option>\n";
+      String hiddenFields = "<input type=\"hidden\" name=\"mode\" value=\""
+         + newMode + "\"/>" + "<input type=\"hidden\" name=\"f\" value=\""
+         + forumId + "\"/>"
+         + "<input type=\"hidden\" name=\"module\" value=\"bb\"/>"
+         + "<input type=\"hidden\" name=\"op\" value=\"admin_forums\"/>";
+
+      PortletURL postURL = resp.createActionURL();
+      root.put("POST_URL", postURL.toString());
+      root.put("S_HIDDEN_FIELDS", hiddenFields);
+      root.put("S_SUBMIT_VALUE", buttonValue);
+      root.put("S_STATUS_LIST", statusList);
+      root.put("S_PRUNE_ENABLED", pruneEnabled);
+      root.put("L_FORUM_TITLE", title);
+      root.put("PRUNE_DAYS", "TODO_PRUNE_DAYS"); // ( isset($pr_row['prune_days']) ) ? $pr_row['prune_days'] : 7
+      root.put("PRUNE_FREQ", "TODO_PRUNE_FREQ"); // ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1
+      root.put("FORUM_NAME", forumName);
+      root.put("DESCRIPTION", forumDesc);
+
+      return root;
+   }
+
+   private DelegateContext fillShowAdminForumsContext(JBossRenderRequest req,
+                                                      JBossRenderResponse resp, DelegateContext root)
+   {
+      String mode = req.getParameters().get("mode", "");
+      boolean addCategory = req.getParameter("addcategory") != null;
+      Category addforum = null;
+
+      try
+      {
+         for (Iterator i = forumsModule.findCategories().iterator(); i
+            .hasNext();)
+         {
+            Category category = (Category)i.next();
+            if (req.getParameter("addforum_" + category.getId()) != null)
+            {
+               addforum = category;
+               break;
+            }
+         }
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+
+         //            Die.exit(GENERAL_ERROR, "Cannot process command", e);
+      }
+
+      if ((addforum != null) || addCategory)
+      {
+         if (addforum != null)
+         {
+            mode = "addforum";
+         }
+         else
+         {
+            mode = "addcat";
+         }
+      }
+
+      try
+      {
+         PortletURL postURL = resp.createActionURL();
+         postURL.setParameters(req.getParameterMap());
+         postURL.setParameter("op", "admin_forums");
+         root.put("POST_URL", postURL.toString());
+         for (Iterator i = forumsModule.findCategories().iterator(); i
+            .hasNext();)
+         {
+            Category category = (Category)i.next();
+            Integer categoryId = category.getId();
+
+            DelegateContext catrow = root.next("catrow");
+            catrow.put("S_ADD_FORUM_SUBMIT", "addforum_" + categoryId);
+            catrow.put("S_ADD_FORUM_NAME", "forumname_" + categoryId);
+            catrow.put("CAT_ID", categoryId.toString());
+            catrow.put("CAT_DESC", category.getTitle());
+            PortletURL categoryEditURL = resp.createActionURL();
+            categoryEditURL.setParameter("op", "admin_forums");
+            categoryEditURL.setParameter("mode", "editcat");
+            categoryEditURL.setParameter("c", "" + categoryId);
+            categoryEditURL.setParameter(POST_CAT_URL, "" + categoryId);
+            catrow.put("U_CAT_EDIT", categoryEditURL.toString());
+            PortletURL categoryDeleteURL = resp.createActionURL();
+            categoryDeleteURL.setParameter("op", "admin_forums");
+            categoryDeleteURL.setParameter("mode", "deletecat");
+            categoryDeleteURL.setParameter(POST_CAT_URL, "" + categoryId);
+            catrow.put("U_CAT_DELETE", categoryDeleteURL.toString());
+            PortletURL catMoveUp = resp.createActionURL();
+            catMoveUp.setParameter("op", "admin_forums");
+            catMoveUp.setParameter("mode", "cat_order");
+            catMoveUp.setParameter("move", "-15");
+            catMoveUp.setParameter(POST_CAT_URL, "" + categoryId);
+            catrow.put("U_CAT_MOVE_UP", catMoveUp.toString());
+            PortletURL catMoveDown = resp.createActionURL();
+            catMoveDown.setParameter("op", "admin_forums");
+            catMoveDown.setParameter("mode", "cat_order");
+            catMoveDown.setParameter("move", "15");
+            catMoveDown.setParameter(POST_CAT_URL, "" + categoryId);
+            catrow.put("U_CAT_MOVE_DOWN", catMoveDown.toString());
+            PortletURL categoryViewURL = resp.createRenderURL();
+            categoryViewURL.setParameter("op", OP_MAIN);
+            categoryViewURL.setParameter(POST_CAT_URL, "" + categoryId);
+            catrow.put("U_VIEWCAT", categoryViewURL.toString());
+
+            for (Iterator j = forumsModule.findForumsByCategoryId(categoryId)
+               .iterator(); j.hasNext();)
+            {
+               Forum forum = (Forum)j.next();
+               Integer forumId = forum.getId();
+               DelegateContext forumrow = catrow.next("forumrow");
+               forumrow.put("FORUM_NAME", forum.getName());
+               forumrow.put("FORUM_DESC", forum.getDescription());
+               forumrow.put("ROW_COLOR'", "$row_color");
+               forumrow.put("NUM_TOPICS", "" + forum.getTopicCount());
+               forumrow.put("NUM_POSTS", "" + forum.getPostCount());
+               PortletURL viewForumURL = resp.createRenderURL();
+               viewForumURL.setParameter(getOperationName(), OP_SHOWFORUM);
+               viewForumURL.setParameter("f", "" + forumId);
+               forumrow.put("U_VIEWFORUM", viewForumURL.toString());
+               PortletURL forumEditURL = resp.createActionURL();
+               forumEditURL.setParameter("op", "admin_forums");
+               forumEditURL.setParameter("mode", "editforum");
+               forumEditURL.setParameter("f", "" + forumId);
+               forumrow.put("U_FORUM_EDIT", forumEditURL.toString());
+               PortletURL forumDeleteURL = resp.createActionURL();
+               forumDeleteURL.setParameter("op", "admin_forums");
+               forumDeleteURL.setParameter("mode", "deleteforum");
+               forumDeleteURL.setParameter("f", "" + forumId);
+               forumrow.put("U_FORUM_DELETE", forumDeleteURL.toString());
+               PortletURL forumMoveUpURL = resp.createActionURL();
+               forumMoveUpURL.setParameter("op", "admin_forums");
+               forumMoveUpURL.setParameter("mode", "forum_order");
+               forumMoveUpURL.setParameter("move", "-15");
+               forumMoveUpURL.setParameter("f", "" + forumId);
+               forumrow.put("U_FORUM_MOVE_UP", forumMoveUpURL.toString());
+               PortletURL forumMoveDownURL = resp.createActionURL();
+               forumMoveDownURL.setParameter("op", "admin_forums");
+               forumMoveDownURL.setParameter("mode", "forum_order");
+               forumMoveDownURL.setParameter("move", "15");
+               forumMoveDownURL.setParameter("f", "" + forumId);
+               forumrow.put("U_FORUM_MOVE_DOWN", forumMoveDownURL.toString());
+
+               /*
+                PortletURL forumResyncURL = resp.createActionURL();
+                forumResyncURL.setParameter("op", "admin_forums");
+                forumResyncURL.setParameter("mode", "forum_sync");
+                forumResyncURL.setParameter("f", "" + forumId);
+                forumrow.put("U_FORUM_RESYNC", forumResyncURL.toString());
+                */
+            }
+         }
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+
+         //            Die.exit(GENERAL_ERROR, "Could not query categories list");
+      }
+
+      //         display(theme.TPL_THEME_ADMIN_FORUM_ADMIN_BODY, root, page);
+      return root;
+   }
+
+   private DelegateContext fillShowModerateForumContext(JBossRenderRequest req,
+                                                        JBossRenderResponse resp, DelegateContext root)
+   {
+      //System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
+      //System.out.println("fillModerateForumContext()");
+      ResourceBundle bundle = getResourceBundle(req.getLocale());
+
+      int topicsPerPage = Integer.parseInt(req.getPreferences().getValue("topicsperforum", "10"));
+      int hotThreshold = 10;
+      int postsPerPage = Integer.parseInt(req.getPreferences().getValue("postspertopic", "10"));
+      Integer forumId = req.getParameters().getIntObject("f", -1);
+      int start = req.getParameters().getInt("start", 0);
+
+      //      String markRead = page.getParameter("mark", "");
+      int topicDays = req.getParameters().getInt("topicdays", 0);
+
+      Forum forum = null;
+      try
+      {
+         forum = forumsModule.findForumById(forumId);
+      }
+      catch (ModuleException e1)
+      {
+         // TODO Auto-generated catch block
+         e1.printStackTrace();
+      }
+
+      Category category = forum.getCategory();
+      User user = req.getUser();
+      boolean loggedIn = req.getRemoteUser() != null;
+
+      String categoryTitle = category.getTitle();
+      String forumName = forum.getName();
+
+      String[] testArray = new String[]{categoryTitle, forumName};
+      boolean authMod = ForumsTools.hasPermission(req, testArray, "ModerateForum");
+      if (!authMod)
+      {
+         System.out.println("You are not authorized to moderate this forum");
+         return root;
+      }
+
+      Date minTopicTime = null;
+      if (topicDays > 0)
+      {
+         Calendar c = Calendar.getInstance();
+         c.add(Calendar.DATE, -topicDays);
+         minTopicTime = c.getTime();
+      }
+      else
+      {
+         topicDays = 0;
+      }
+
+      List announcements = null;
+      List topics = null;
+
+      try
+      {
+         announcements = forumsModule.findAnnouncements(forum);
+         topics = (minTopicTime == null) ? forumsModule.findTopicsDesc(forum,
+            POST_ANNOUNCE, start, topicsPerPage) : forumsModule
+            .findTopicsBefore(forum, POST_ANNOUNCE, start, topicsPerPage,
+               minTopicTime);
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      int totalTopicsAndStickies = forum.getTopicCount();
+
+
+      StringBuffer authCan = new StringBuffer();
+
+      Iterator ci = new CompoundIterator(new Iterator[]{
+         announcements.iterator(), topics.iterator()});
+
+
+      PortletURL gotoURL = resp.createRenderURL();
+      gotoURL.setParameter("op", OP_SHOWTOPIC);
+      Goto toPost = new Goto(postsPerPage, bundle.getString("Goto_page"), gotoURL.toString());
+      toPost.setImgUrl(theme.resourceIconGotopostURL);
+      int row_index = 0;
+      for (IndexIterator iterator = IndexIterator.wrap(ci, -1); iterator
+         .hasNext(); row_index++)
+      {
+
+         Topic topic = (Topic)iterator.next();
+
+         int replies = topic.getReplies();
+         int status = topic.getStatus();
+         /*Integer topicId = (status == TOPIC_MOVED) ? topic.getTarget().getID()
+                 : topic.getID();*/
+         Integer topicId = topic.getId();
+         String type = bundle.getString("Topic_Moved");
+         String folderImage = theme.resourceFolderURL;
+         String folderAlt = bundle.getString("Topic_Moved");
+         String newestPostImg = "";
+         /*Date topicLastPostDate = (topic.getLastPost()!=null) ? topic.getLastPost().getCreateDate() : null;*/
+         Post firstPost = topic.getFirstPost();
+         Post lastPost = topic.getLastPost();
+         /*Poster lastPostUser = lastPost.getPoster();
+         Poster poster = topic.getPoster();*/
+
+         if (status != TOPIC_MOVED)
+         {
+            FolderType folderType = theme.getFolderType(topic.getType(),
+               status, replies >= hotThreshold);
+            boolean newest = loggedIn;
+
+            if (newest)
+            {
+               folderImage = folderType.folderNew;
+               folderAlt = (status == TOPIC_LOCKED) ? bundle
+                  .getString("Topic_locked") : bundle.getString("New_posts");
+               /*newestPostImg = "<a href=\"index.html?module=bb&op=viewtopic&t="
+                       + topicId + "&view=newest\"><img src=\""
+                       + theme.resourceIconNewestReplyURL + "\" alt=\""
+                       + bundle.getString("View_newest_post") + "\" title=\""
+                       + bundle.getString("View_newest_post")
+                       + "\" border=\"0\"/></a>";*/
+            }
+            else
+            {
+               folderImage = folderType.folder;
+               folderAlt = (status == TOPIC_LOCKED) ? bundle
+                  .getString("Topic_locked") : bundle
+                  .getString("No_new_posts");
+               newestPostImg = "";
+            }
+
+            try
+            {
+               type = bundle.getString(folderType.type);
+            }
+            catch (java.util.MissingResourceException e)
+            {
+               type = "";
+            }
+
+         }
+
+         toPost.setPostSize(replies);
+         toPost.setTopicId(topicId.intValue());
+         String gotoPage = toPost.generate();
+         String topicAuthor = firstPost.getPoster().getUser().getUserName();
+         String lastPostAuthor = lastPost.getPoster().getUser().getUserName();
+
+         PortletURL lastPostURL = resp.createRenderURL();
+         lastPostURL.setParameter("op", OP_SHOWTOPIC);
+         lastPostURL.setParameter("p", "" + lastPost.getId());
+
+         String lastPostUrl = "<a href=\"" + lastPostURL.toString() + "\">"
+            + "<img src=\"" + theme.resourceIconLatestReplyURL + "\" alt=\""
+            + bundle.getString("View_latest_post") + "\" title=\""
+            + bundle.getString("View_latest_post") + "\" border=\"0\"/></a>";
+
+         DelegateContext topicrow = root.next("topicrow");
+         topicrow.put("TOPIC_ROW_INDEX", "" + row_index);
+         topicrow.put("FORUM_ID", forumId.toString());
+         topicrow.put("TOPIC_ID", topicId.toString());
+         topicrow.put("TOPIC_FOLDER_IMG", folderImage);
+         topicrow.put("TOPIC_AUTHOR", topicAuthor);
+         topicrow.put("GOTO_PAGE", gotoPage);
+         topicrow.put("REPLIES", "" + replies);
+         //topicrow.put("NEWEST_POST_IMG", newestPostImg);
+         topicrow.put("NEWEST_POST_IMG", lastPostUrl);
+         topicrow.put("TOPIC_TITLE", formatTitle(req, topic.getSubject()));
+         topicrow.put("TOPIC_TYPE", type);
+         SimpleDateFormat sdfp = new SimpleDateFormat(req.getPreferences().getValue("dateformat", new SimpleDateFormat().toPattern()));
+         topicrow.put("LAST_POST_TIME", sdfp.format(topic.getLastPostDate()));
+
+         if ((req.getRemoteUser() != null))
+         {
+            PortletURL userProfileURL = resp.createRenderURL();
+            userProfileURL.setParameter(getOperationName(), OP_SHOWUSERPROFILE);
+            userProfileURL.setParameter("uid", "" + lastPost.getPoster().getUser().getId().toString());
+            topicrow.next("user_auth").put("POSTER_INFO_LINK", userProfileURL.toString());
+         }
+         topicrow.put("LAST_POST_AUTHOR", lastPostAuthor);
+         topicrow.put("LAST_POST_IMG", lastPostUrl);
+         topicrow.put("L_TOPIC_FOLDER_ALT", folderAlt);
+         PortletURL viewTopicURL = resp.createRenderURL();
+         viewTopicURL.setParameter("op", OP_SHOWTOPIC);
+         viewTopicURL.setParameter("t", "" + topicId);
+         topicrow.put("U_VIEW_TOPIC", viewTopicURL.toString());
+      }
+
+
+      PortletURL moderateActionURL = resp.createActionURL();
+      moderateActionURL.setParameter(getOperationName(), "moderate_forum");
+      moderateActionURL.setParameter("f", "" + forumId);
+      root.put("S_POST_DAYS_ACTION", moderateActionURL.toString());
+      //root.put("FORUM_ID", forum.getID().toString());
+
+      //forum link on top of view
+      root.put("FORUM_NAME", forum.getName());
+
+      PortletURL viewForumURL = resp.createRenderURL();
+      viewForumURL.setParameter("op", OP_SHOWFORUM);
+      viewForumURL.setParameter("f", "" + forumId);
+      root.put("U_VIEW_FORUM", viewForumURL.toString());
+
+      //URL to go to moderate forum with specific page
+      PortletURL pageNavigationURL = resp.createRenderURL();
+      pageNavigationURL.setParameter("op", OP_SHOWMODERATEFORUM);
+      pageNavigationURL.setParameter("f", "" + forumId);
+      pageNavigationURL.setParameter("topicDays", "" + topicDays);
+
+      //generate Page nav bar
+      GotoWithOffset toForum = new GotoWithOffset(totalTopicsAndStickies,
+         start, topicsPerPage, pageNavigationURL + "&start=", bundle
+         .getString("Goto_page"), bundle.getString("Previous"), bundle
+         .getString("Next"));
+
+      String pageNumber = bundle.getString("Page_of_0")
+         + ((int)Math.floor((double)start / topicsPerPage) + 1)
+         + bundle.getString("Page_of_1")
+         + ((int)Math.ceil((double)totalTopicsAndStickies / topicsPerPage));
+      //page nav bar
+      root.put("PAGE_NUMBER", pageNumber.toString());
+      root.put("PAGINATION", toForum.generate());
+
+      //      root.put("JUMPBOX", makeJumpBox("viewforum", loggedIn));
+      return root;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param req  DOCUMENT_ME
+    * @param resp DOCUMENT_ME
+    */
+   public void forum_watches(JBossActionRequest req, JBossActionResponse resp)
+   {
+      try
+      {
+         if (req.getParameters().getParameterExists("watch"))
+         {
+            Integer id = req.getParameters().getIntObject("forum_id", -1);
+            boolean linked = "linked".equals(req.getParameter("watch_mode"));
+            Forum forum = forumsModule.findForumById(id);
+            Poster poster = forumsModule.findPosterByUserId(req.getUser()
+               .getId().toString());
+            String[] test = new String[]{forum.getCategory().getTitle(),
+               forum.getName()};
+            if (ForumsTools.hasPermission(req, test, "ReadForum"))
+            {
+               if (poster == null)
+               {
+                  poster = forumsModule.createPoster(req.getUser().getId().toString());
+               }
+               forumsModule.createWatch(poster, forum,
+                  linked ? ForumsConstants.WATCH_MODE_LINKED
+                     : ForumsConstants.WATCH_MODE_EMBEDED);
+            }
+         }
+         else if (req.getParameters().getParameterExists("update"))
+         {
+            Integer forumWatchId = req.getParameters().getIntObject("forumwatch_id", -1);
+            boolean linked = "linked".equals(req.getParameter("watch_mode"));
+            ForumWatch watch = forumsModule.findForumWatchById(forumWatchId);
+            watch.setMode(linked ? ForumsConstants.WATCH_MODE_LINKED
+               : ForumsConstants.WATCH_MODE_EMBEDED);
+         }
+         else if (req.getParameters().getParameterExists("unwatch"))
+         {
+            Integer forumWatchId = req.getParameters().getIntObject("forumwatch_id", -1);
+            ForumWatch watch = forumsModule.findForumWatchById(forumWatchId);
+            forumsModule.removeWatch(watch);
+         }
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param req  DOCUMENT_ME
+    * @param resp DOCUMENT_ME
+    */
+   public void topic_watches(JBossActionRequest req, JBossActionResponse resp)
+   {
+      try
+      {
+         Integer topicWatchId = req.getParameters().getIntObject("topicwatch_id", -1);
+         TopicWatch watch = forumsModule.findTopicWatchById(topicWatchId);
+         forumsModule.removeWatch(watch);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   private DelegateContext fillShowWatchedForums(JBossRenderRequest req,
+                                                 JBossRenderResponse resp, DelegateContext root)
+   {
+      Set forumIds = new HashSet();
+      Collection watches;
+      try
+      {
+         watches = forumsModule.findForumWatchByUser(req.getUser());
+         if (watches.size() > 0)
+         {
+            root.next("switch_watched_forums_block");
+            for (IndexIterator i = IndexIterator.wrap(watches.iterator()); i
+               .hasNext();)
+            {
+               ForumWatch watch = (ForumWatch)i.next();
+               Forum forum = watch.getForum();
+
+               // See if the user is authorized
+               Category category = forum.getCategory();
+               String[] test = new String[]{category.getTitle(),
+                  forum.getName()};
+               if (ForumsTools.hasPermission(req, test, "ReadForum"))
+               {
+                  boolean linked = watch.getMode() == ForumsConstants.WATCH_MODE_LINKED;
+                  Integer forumId = forum.getId();
+                  forumIds.add(forumId);
+                  String forumIdAsString = forumId.toString();
+                  PortletURL viewForumURL = resp.createRenderURL();
+                  viewForumURL.setParameter("op", OP_SHOWFORUM);
+                  viewForumURL.setParameter("f", forumIdAsString);
+                  root
+                     .next("forum_watch_row")
+                     .put("ROW_CLASS",
+                        theme
+                           .getProperty(((i.getIndex() & 1) == 0) ? "td_class1"
+                           : "td_class2")).put("U_FORUM_LINK",
+                     viewForumURL.toString()).put("FORUMWATCH_ID",
+                     watch.getId()).put("FORUM_ID", forumIdAsString)
+                     .put("S_FORUM_TITLE", forum.getName()).put("LINKED",
+                     linked ? "checked=\"checked\"" : "").put("EMBEDED", linked ? "" : "checked=\"checked\"");
+               }
+            }
+         }
+         else
+         {
+            root.next("switch_no_watched_forums");
+         }
+
+         StringBuffer select = new StringBuffer("<select name=\"forum_id\"><option value=\"\"></option>");
+         Collection forums = forumsModule.findForums();
+         for (Iterator i = forums.iterator(); i.hasNext();)
+         {
+            Forum forum = (Forum)i.next();
+
+            // Get the forum level
+            Category category = forum.getCategory();
+            String[] test = new String[]{category.getTitle(), forum.getName()};
+
+            // Display it only if the user is authorized
+            if (ForumsTools.hasPermission(req, test, "ReadForum"))
+            {
+               Integer forumid = forum.getId();
+               if (!forumIds.contains(forumid))
+               {
+                  select.append("<option value=\"").append(forum.getId())
+                     .append("\">").append(forum.getName()).append("</option>");
+               }
+            }
+         }
+
+         select.append("</select>");
+         root.put("S_FORUM_WATCH_SELECT", select.toString());
+
+         //         display(theme.TPL_THEME_WATCHED_FORUMS_BODY, root, page);
+         //      }
+         //      catch(Exception e)
+         //      {
+         //         Die.rollback(GENERAL_ERROR, "Could not obtain watch forum information");
+         //      }
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      return root;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param text DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public String formatTitle(PortletRequest req, String text)
+   {
+      StringWriter stringWriter = new StringWriter();
+      getToHTMLRenderer(req).setWriter(stringWriter);
+
+      getToHTMLRenderer(req).render(text.toCharArray(), 0, text.length());
+      return stringWriter.toString();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param text        DOCUMENT_ME
+    * @param allowBBCode DOCUMENT_ME
+    * @param allowHTML   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public String formatMessage(PortletRequest req, String text, boolean allowBBCode, boolean allowHTML)
+   {
+      if (allowHTML)
+      {
+         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_ALWAYS_PRINT);
+         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
+      }
+      else
+      {
+         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_NEVER_PRINT);
+         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
+      }
+      return formatTitle(req, text);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param text        DOCUMENT_ME
+    * @param allowBBCode DOCUMENT_ME
+    * @param allowHTML   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public String formatSignature(PortletRequest req, String text, boolean allowBBCode, boolean allowHTML)
+   {
+      if (allowHTML)
+      {
+         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_ALWAYS_PRINT);
+         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
+      }
+      else
+      {
+         getToHTMLRenderer(req).getConfig().setFilterMode(ToHTMLConfig.FILTER_MODE_NEVER_PRINT);
+         getToHTMLRenderer(req).getConfig().setOuputMode(ToHTMLConfig.OUTPUT_MODE_REMOVE);
+      }
+      return "<br/>_________________<br/>" + formatTitle(req, text);
+   }
+
+
+   /**
+    *
+    */
+   public String formatUserName(User user)
+   {
+      return user.getUserName();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param cmd DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws CommandException DOCUMENT_ME
+    */
+   public Result executeForumCommand(JBossActionRequest request,
+                                     JBossActionResponse response, ForumCommand cmd)
+      throws CommandException
+   {
+      // Finish the command configuration
+      cmd.setModule(forumsModule);
+
+      //      cmd.setHomes(homesRW);
+      // Execute the command
+      return forumsModule.invoke(cmd);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param resp  DOCUMENT_ME
+    * @param key   DOCUMENT_ME
+    * @param error DOCUMENT_ME
+    */
+   public void addErrorMessage(JBossActionResponse resp, String key,
+                               String error)
+   {
+      resp.setRenderParameter(key.toLowerCase() + "_error", error);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param resp    DOCUMENT_ME
+    * @param key     DOCUMENT_ME
+    * @param success DOCUMENT_ME
+    */
+   public void addSuccessMessage(JBossActionResponse resp, String key,
+                                 String success)
+   {
+      resp.setRenderParameter(key.toLowerCase() + "_success", success);
+   }
+
+   /**
+    * Get a <code>SimpleDateFormat</code> object from the session. The object is stored
+    * in the session because it is expensive to create and we want to reuse it as
+    * much as we can. Also it is configured with the date format taken from the preference
+    * of the user if it exists.
+    *
+    * @param req the request that maybe contains the format object
+    * @return the format object
+    */
+   public SimpleDateFormat getSDF(PortletRequest req)
+   {
+      // Get the pattern
+      String pattern = req.getPreferences().getValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN);
+
+      // Get the simple date format if it exists
+      SimpleDateFormat sdf = (SimpleDateFormat)req.getPortletSession().getAttribute("SDF");
+
+      // Do we have it ?
+      if (sdf == null)
+      {
+         // Create a new one
+         sdf = new SimpleDateFormat(pattern, req.getLocale());
+
+         // Put it in the session
+         req.getPortletSession().setAttribute("SDF", sdf);
+      }
+      else
+      {
+         // Check if config has not changed
+         if (!sdf.toPattern().equals(pattern))
+         {
+            sdf.applyPattern(pattern);
+         }
+      }
+      return sdf;
+   }
+
+   private ToHTMLRenderer getToHTMLRenderer(PortletRequest req)
+   {
+      ToHTMLRenderer renderer = (ToHTMLRenderer)req.getPortletSession().getAttribute("RENDERER");
+      if (renderer == null)
+      {
+         // Create the HTMLRenderer for BBCode
+         ToHTMLConfig config = new ToHTMLConfig();
+         config.setLoader(loader);
+         Locale locale = req.getLocale();
+         ResourceBundle bundle = getPortletConfig().getResourceBundle(locale);
+         renderer = new ToHTMLRenderer(config, bundle);
+         req.getPortletSession().setAttribute("RENDERER", renderer);
+      }
+      return renderer;
+   }
+
+   public AttachmentTokenManager getAttachmentManager(PortletRequest req)
+   {
+      // Get the simple date format if it exists
+      AttachmentTokenManager atm = (AttachmentTokenManager)req.getPortletSession().getAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER, PortletSession.APPLICATION_SCOPE);
+
+      // Do we have it ?
+      if (atm == null)
+      {
+         // Create a new one
+         atm = new AttachmentTokenManager();
+         // Put it in the session
+         req.getPortletSession().setAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER, atm, PortletSession.APPLICATION_SCOPE);
+      }
+      else
+      {
+         //what else?
+      }
+      return atm;
+   }
+
+
+
+
+
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/Action.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/Action.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/Action.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,20 +1,20 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1.1.1 $
- */
-public class Action
-{
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class Action
+{
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/EditPostAction.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/EditPostAction.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/EditPostAction.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,214 +1,214 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.impl.PollImpl;
-import org.jboss.portlet.forums.model.*;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.6 $
- */
-public class EditPostAction
-   extends PostAction
-{
-   private Message message;
-   private Poster poster;
-   private int postId;
-   private List attachments;
-   private Post post;
-   private Topic topic;
-   private Poll poll;
-   private boolean firstPost;
-
-   //   /** An optional delete attachment command. */
-   //   protected DeleteAttachmentCommand dac;
-   public EditPostAction(Message message,
-                         Poster poster,
-                         int postId,
-                         List attachments,
-                         Poll poll)
-   {
-      super(ForumAction.REFRESH);
-      this.message = message;
-      this.poster = poster;
-      this.postId = postId;
-      this.attachments = attachments;
-      this.poll = poll;
-   }
-
-   /**
-    * Creates a new {@link EditPostAction} object.
-    *
-    * @param postId DOCUMENT_ME
-    */
-   public EditPostAction(int postId)
-   {
-      super(ForumAction.INIT);
-      this.message = null;
-      this.poster = null;
-      this.postId = postId;
-      this.poll = new PollImpl();
-      this.attachments = Collections.EMPTY_LIST;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Post getPost()
-   {
-      return post;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Topic getTopic()
-   {
-      return topic;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Forum getForum()
-   {
-      return getTopic().getForum();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Poster getPoster()
-   {
-      return getMode() == ForumAction.INIT ? getPost().getPoster() : poster;
-      //return poster;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Message getMessage()
-   {
-      return (getMode() == ForumAction.INIT) ? getPost().getMessage() : message;
-      //return message;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public List getAttachments()
-   {
-      return attachments;
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public void init()
-   {
-      try
-      {
-         post = module.findPostById(new Integer(postId));
-         topic = post.getTopic();
-         if (topic.getFirstPost().getId().equals(post.getId()))
-         {
-            firstPost = true;
-         }
-         Topic topic = post.getTopic();
-         //message.setSubject(topic.getSubject());
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-      /*
-         try
-         {
-            post = homes.post.findByPrimaryKey(new Integer(postId));
-            topic = post.getTopic();
-            firstPost = EJB.areIdentical(post, topic.getFirstPost());
-            if (getMode() == INIT)
-            {
-               message = post.getMessage();
-               if (firstPost)
-               {
-                  message.setSubject(topic.getTitle());
-               }
-               PollEJBLocal poll = topic.getPoll();
-               if (poll != null)
-               {
-                  this.poll.setTitle(poll.getText());
-                  this.poll.setLength(poll.getLength());
-                  // try
-                  // {
-                  for (Iterator i = homes.option.findByPoll(poll).iterator();i.hasNext();)
-                  {
-                     OptionEJBLocal option = (OptionEJBLocal)i.next();
-                     this.poll.getOptions().add(option.getText());
-                  }
-                  // }
-                  //    catch(FinderException e)
-                  // {
-                  //    throw new ValidationException(TYPE_COULD_NOT_OBTAIN_VOTE_DATA);
-                  // }
-               }
-               else
-               {
-                  this.poll.setTitle("");
-                  this.poll.setLength(0);
-                  this.poll.setOptions(Collections.EMPTY_LIST);
-               }
-            }
-         }
-         catch (FinderException e)
-         {
-            throw new RuntimeException(e);
-         }
-       */
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Poll getPoll()
-   {
-      return poll;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean isFirstPost()
-   {
-      return firstPost;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.impl.PollImpl;
+import org.jboss.portlet.forums.model.*;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.6 $
+ */
+public class EditPostAction
+   extends PostAction
+{
+   private Message message;
+   private Poster poster;
+   private int postId;
+   private List attachments;
+   private Post post;
+   private Topic topic;
+   private Poll poll;
+   private boolean firstPost;
+
+   //   /** An optional delete attachment command. */
+   //   protected DeleteAttachmentCommand dac;
+   public EditPostAction(Message message,
+                         Poster poster,
+                         int postId,
+                         List attachments,
+                         Poll poll)
+   {
+      super(ForumAction.REFRESH);
+      this.message = message;
+      this.poster = poster;
+      this.postId = postId;
+      this.attachments = attachments;
+      this.poll = poll;
+   }
+
+   /**
+    * Creates a new {@link EditPostAction} object.
+    *
+    * @param postId DOCUMENT_ME
+    */
+   public EditPostAction(int postId)
+   {
+      super(ForumAction.INIT);
+      this.message = null;
+      this.poster = null;
+      this.postId = postId;
+      this.poll = new PollImpl();
+      this.attachments = Collections.EMPTY_LIST;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Post getPost()
+   {
+      return post;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Topic getTopic()
+   {
+      return topic;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Forum getForum()
+   {
+      return getTopic().getForum();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Poster getPoster()
+   {
+      return getMode() == ForumAction.INIT ? getPost().getPoster() : poster;
+      //return poster;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Message getMessage()
+   {
+      return (getMode() == ForumAction.INIT) ? getPost().getMessage() : message;
+      //return message;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public List getAttachments()
+   {
+      return attachments;
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public void init()
+   {
+      try
+      {
+         post = module.findPostById(new Integer(postId));
+         topic = post.getTopic();
+         if (topic.getFirstPost().getId().equals(post.getId()))
+         {
+            firstPost = true;
+         }
+         Topic topic = post.getTopic();
+         //message.setSubject(topic.getSubject());
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+      /*
+         try
+         {
+            post = homes.post.findByPrimaryKey(new Integer(postId));
+            topic = post.getTopic();
+            firstPost = EJB.areIdentical(post, topic.getFirstPost());
+            if (getMode() == INIT)
+            {
+               message = post.getMessage();
+               if (firstPost)
+               {
+                  message.setSubject(topic.getTitle());
+               }
+               PollEJBLocal poll = topic.getPoll();
+               if (poll != null)
+               {
+                  this.poll.setTitle(poll.getText());
+                  this.poll.setLength(poll.getLength());
+                  // try
+                  // {
+                  for (Iterator i = homes.option.findByPoll(poll).iterator();i.hasNext();)
+                  {
+                     OptionEJBLocal option = (OptionEJBLocal)i.next();
+                     this.poll.getOptions().add(option.getText());
+                  }
+                  // }
+                  //    catch(FinderException e)
+                  // {
+                  //    throw new ValidationException(TYPE_COULD_NOT_OBTAIN_VOTE_DATA);
+                  // }
+               }
+               else
+               {
+                  this.poll.setTitle("");
+                  this.poll.setLength(0);
+                  this.poll.setOptions(Collections.EMPTY_LIST);
+               }
+            }
+         }
+         catch (FinderException e)
+         {
+            throw new RuntimeException(e);
+         }
+       */
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Poll getPoll()
+   {
+      return poll;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isFirstPost()
+   {
+      return firstPost;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ForumAction.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ForumAction.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ForumAction.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,111 +1,111 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-import java.util.List;
-
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poster;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.3 $
- */
-public abstract class ForumAction
-   extends Action
-{
-   /**
-    * DOCUMENT_ME
-    */
-   protected ForumsModule module;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int INIT = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int REFRESH = 1;
-   private final int mode;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param module DOCUMENT_ME
-    */
-   public void setModule(ForumsModule module)
-   {
-      this.module = module;
-   }
-
-   /**
-    * Creates a new {@link ForumAction} object.
-    *
-    * @param mode DOCUMENT_ME
-    */
-   protected ForumAction(int mode)
-   {
-      if ((mode < 0) || (mode > 1))
-      {
-         throw new IllegalArgumentException("mode not accepted");
-      }
-
-      this.mode = mode;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int getMode()
-   {
-      return mode;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract Poster getPoster();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract Forum getForum();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract Message getMessage();
-
-   /**
-    * DOCUMENT_ME
-    */
-   public abstract void init();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract List getAttachments();
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+import java.util.List;
+
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Poster;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.3 $
+ */
+public abstract class ForumAction
+   extends Action
+{
+   /**
+    * DOCUMENT_ME
+    */
+   protected ForumsModule module;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int INIT = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int REFRESH = 1;
+   private final int mode;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param module DOCUMENT_ME
+    */
+   public void setModule(ForumsModule module)
+   {
+      this.module = module;
+   }
+
+   /**
+    * Creates a new {@link ForumAction} object.
+    *
+    * @param mode DOCUMENT_ME
+    */
+   protected ForumAction(int mode)
+   {
+      if ((mode < 0) || (mode > 1))
+      {
+         throw new IllegalArgumentException("mode not accepted");
+      }
+
+      this.mode = mode;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getMode()
+   {
+      return mode;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract Poster getPoster();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract Forum getForum();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract Message getMessage();
+
+   /**
+    * DOCUMENT_ME
+    */
+   public abstract void init();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract List getAttachments();
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/NewTopicAction.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/NewTopicAction.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/NewTopicAction.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,147 +1,147 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.impl.MessageImpl;
-import org.jboss.portlet.forums.impl.PollImpl;
-import org.jboss.portlet.forums.impl.PosterImpl;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.Poster;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.4 $
- */
-public class NewTopicAction
-   extends ForumAction
-{
-   private int forumId;
-   private Poster poster;
-   private Message message;
-   private Poll poll;
-   private List attachments;
-   private Forum forum;
-
-   /**
-    * Creates a new {@link NewTopicAction} object.
-    *
-    * @param poster      DOCUMENT_ME
-    * @param message     DOCUMENT_ME
-    * @param forumId     DOCUMENT_ME
-    * @param attachments DOCUMENT_ME
-    * @param poll        DOCUMENT_ME
-    */
-   public NewTopicAction(Poster poster,
-                         Message message,
-                         int forumId,
-                         List attachments,
-                         Poll poll)
-   {
-      super(REFRESH);
-      this.poster = poster;
-      this.message = message;
-      this.forumId = forumId;
-      this.attachments = attachments;
-      this.poll = poll;
-   }
-
-   /**
-    * Creates a new {@link NewTopicAction} object.
-    *
-    * @param forumId DOCUMENT_ME
-    */
-   public NewTopicAction(int forumId)
-   {
-      super(INIT);
-      this.poster = new PosterImpl();
-      this.message = new MessageImpl();
-      this.forumId = forumId;
-      this.attachments = Collections.EMPTY_LIST;
-      this.poll = new PollImpl();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Poster getPoster()
-   {
-      return poster;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Forum getForum()
-   {
-      return forum;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Message getMessage()
-   {
-      return message;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public List getAttachments()
-   {
-      return attachments;
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public void init()
-   {
-      try
-      {
-         forum = module.findForumById(new Integer(forumId));
-         if (getMode() == INIT)
-         {
-            message.setSignatureEnabled((poster.getUser().getSignature() != null)
-               && (poster.getUser().getSignature().trim().length() != 0));
-         }
-      }
-      catch (ModuleException e)
-      {
-         throw new RuntimeException();
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Poll getPoll()
-   {
-      return poll;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.impl.MessageImpl;
+import org.jboss.portlet.forums.impl.PollImpl;
+import org.jboss.portlet.forums.impl.PosterImpl;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Poll;
+import org.jboss.portlet.forums.model.Poster;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.4 $
+ */
+public class NewTopicAction
+   extends ForumAction
+{
+   private int forumId;
+   private Poster poster;
+   private Message message;
+   private Poll poll;
+   private List attachments;
+   private Forum forum;
+
+   /**
+    * Creates a new {@link NewTopicAction} object.
+    *
+    * @param poster      DOCUMENT_ME
+    * @param message     DOCUMENT_ME
+    * @param forumId     DOCUMENT_ME
+    * @param attachments DOCUMENT_ME
+    * @param poll        DOCUMENT_ME
+    */
+   public NewTopicAction(Poster poster,
+                         Message message,
+                         int forumId,
+                         List attachments,
+                         Poll poll)
+   {
+      super(REFRESH);
+      this.poster = poster;
+      this.message = message;
+      this.forumId = forumId;
+      this.attachments = attachments;
+      this.poll = poll;
+   }
+
+   /**
+    * Creates a new {@link NewTopicAction} object.
+    *
+    * @param forumId DOCUMENT_ME
+    */
+   public NewTopicAction(int forumId)
+   {
+      super(INIT);
+      this.poster = new PosterImpl();
+      this.message = new MessageImpl();
+      this.forumId = forumId;
+      this.attachments = Collections.EMPTY_LIST;
+      this.poll = new PollImpl();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Poster getPoster()
+   {
+      return poster;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Forum getForum()
+   {
+      return forum;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Message getMessage()
+   {
+      return message;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public List getAttachments()
+   {
+      return attachments;
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public void init()
+   {
+      try
+      {
+         forum = module.findForumById(new Integer(forumId));
+         if (getMode() == INIT)
+         {
+            message.setSignatureEnabled((poster.getUser().getSignature() != null)
+               && (poster.getUser().getSignature().trim().length() != 0));
+         }
+      }
+      catch (ModuleException e)
+      {
+         throw new RuntimeException();
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Poll getPoll()
+   {
+      return poll;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/PostAction.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/PostAction.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/PostAction.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,45 +1,45 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-import org.jboss.portlet.forums.model.Post;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1.1.1 $
- */
-public abstract class PostAction
-   extends TopicAction
-{
-   /**
-    * Creates a new {@link PostAction} object.
-    *
-    * @param mode DOCUMENT_ME
-    */
-   protected PostAction(int mode)
-   {
-      super(mode);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract Post getPost();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract boolean isFirstPost();
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+import org.jboss.portlet.forums.model.Post;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class PostAction
+   extends TopicAction
+{
+   /**
+    * Creates a new {@link PostAction} object.
+    *
+    * @param mode DOCUMENT_ME
+    */
+   protected PostAction(int mode)
+   {
+      super(mode);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract Post getPost();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract boolean isFirstPost();
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ProcessCommandAction.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ProcessCommandAction.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ProcessCommandAction.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,43 +1,43 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-import org.jboss.portlet.forums.commands.post.ForumCommand;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1.1.1 $
- */
-public class ProcessCommandAction
-   extends Action
-{
-   private final ForumCommand command;
-
-   /**
-    * Creates a new {@link ProcessCommandAction} object.
-    *
-    * @param command DOCUMENT_ME
-    */
-   public ProcessCommandAction(ForumCommand command)
-   {
-      this.command = command;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public ForumCommand getCommand()
-   {
-      return command;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+import org.jboss.portlet.forums.commands.post.ForumCommand;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class ProcessCommandAction
+   extends Action
+{
+   private final ForumCommand command;
+
+   /**
+    * Creates a new {@link ProcessCommandAction} object.
+    *
+    * @param command DOCUMENT_ME
+    */
+   public ProcessCommandAction(ForumCommand command)
+   {
+      this.command = command;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ForumCommand getCommand()
+   {
+      return command;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ReplyAction.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ReplyAction.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/ReplyAction.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,196 +1,196 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.forums.model.Topic;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.4 $
- */
-public class ReplyAction
-   extends PostAction
-{
-   private boolean quote;
-   private int postId;
-   private Message message;
-   private Poster poster;
-   private List attachments;
-   private Post post;
-   private Topic topic;
-   private boolean firstPost = false;
-
-   /**
-    * Creates a new {@link ReplyAction} object.
-    *
-    * @param postId      DOCUMENT_ME
-    * @param message     DOCUMENT_ME
-    * @param poster      DOCUMENT_ME
-    * @param attachments DOCUMENT_ME
-    */
-   public ReplyAction(int postId,
-                      Message message,
-                      Poster poster,
-                      List attachments)
-   {
-      super(REFRESH);
-      this.postId = postId;
-      this.message = message;
-      this.poster = poster;
-      this.attachments = attachments;
-   }
-
-   /**
-    * Creates a new {@link ReplyAction} object.
-    *
-    * @param quote   DOCUMENT_ME
-    * @param postId  DOCUMENT_ME
-    * @param message DOCUMENT_ME
-    * @param poster  DOCUMENT_ME
-    */
-   public ReplyAction(boolean quote,
-                      int postId,
-                      Message message,
-                      Poster poster)
-   {
-      super(INIT);
-      this.quote = quote;
-      this.postId = postId;
-      this.message = message;
-      this.poster = poster;
-      this.attachments = Collections.EMPTY_LIST;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Post getPost()
-   {
-      return post;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Topic getTopic()
-   {
-      return getPost().getTopic();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Forum getForum()
-   {
-      return getTopic().getForum();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Poster getPoster()
-   {
-      return poster;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Message getMessage()
-   {
-      return message;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public List getAttachments()
-   {
-      return attachments;
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public void init()
-   {
-      try
-      {
-         post = module.findPostById(new Integer(postId));
-         topic = post.getTopic();
-         if (topic.getFirstPost().getId().equals(post.getId()))
-         {
-            firstPost = true;
-         }
-
-         //        firstPost = EJB.areIdentical(post, topic.getFirstPost());
-         if (getMode() == ForumAction.INIT)
-         {
-            //            if (quote)
-            //            {
-            //               message = (Message)post.getMessage().clone();
-            //               message.setText("[quote=\"" + post.getPoster().getUserName() + "\"]" + message.getText() + "[/quote]");
-            //            }
-            //            else
-            //            {
-            Topic topic = post.getTopic();
-            message.setSubject(topic.getSubject());
-
-            //            }
-            if (!message.getSubject().startsWith("Re:"))
-            {
-               message.setSubject("Re: " + message.getSubject());
-            }
-
-            String signature = getPoster().getUser().getSignature();
-            if ((signature != null) && (signature.trim().length() != 0))
-            {
-               message.setSignatureEnabled(true);
-            }
-         }
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean isFirstPost()
-   {
-      return firstPost;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Poster;
+import org.jboss.portlet.forums.model.Topic;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.4 $
+ */
+public class ReplyAction
+   extends PostAction
+{
+   private boolean quote;
+   private int postId;
+   private Message message;
+   private Poster poster;
+   private List attachments;
+   private Post post;
+   private Topic topic;
+   private boolean firstPost = false;
+
+   /**
+    * Creates a new {@link ReplyAction} object.
+    *
+    * @param postId      DOCUMENT_ME
+    * @param message     DOCUMENT_ME
+    * @param poster      DOCUMENT_ME
+    * @param attachments DOCUMENT_ME
+    */
+   public ReplyAction(int postId,
+                      Message message,
+                      Poster poster,
+                      List attachments)
+   {
+      super(REFRESH);
+      this.postId = postId;
+      this.message = message;
+      this.poster = poster;
+      this.attachments = attachments;
+   }
+
+   /**
+    * Creates a new {@link ReplyAction} object.
+    *
+    * @param quote   DOCUMENT_ME
+    * @param postId  DOCUMENT_ME
+    * @param message DOCUMENT_ME
+    * @param poster  DOCUMENT_ME
+    */
+   public ReplyAction(boolean quote,
+                      int postId,
+                      Message message,
+                      Poster poster)
+   {
+      super(INIT);
+      this.quote = quote;
+      this.postId = postId;
+      this.message = message;
+      this.poster = poster;
+      this.attachments = Collections.EMPTY_LIST;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Post getPost()
+   {
+      return post;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Topic getTopic()
+   {
+      return getPost().getTopic();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Forum getForum()
+   {
+      return getTopic().getForum();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Poster getPoster()
+   {
+      return poster;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Message getMessage()
+   {
+      return message;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public List getAttachments()
+   {
+      return attachments;
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public void init()
+   {
+      try
+      {
+         post = module.findPostById(new Integer(postId));
+         topic = post.getTopic();
+         if (topic.getFirstPost().getId().equals(post.getId()))
+         {
+            firstPost = true;
+         }
+
+         //        firstPost = EJB.areIdentical(post, topic.getFirstPost());
+         if (getMode() == ForumAction.INIT)
+         {
+            //            if (quote)
+            //            {
+            //               message = (Message)post.getMessage().clone();
+            //               message.setText("[quote=\"" + post.getPoster().getUserName() + "\"]" + message.getText() + "[/quote]");
+            //            }
+            //            else
+            //            {
+            Topic topic = post.getTopic();
+            message.setSubject(topic.getSubject());
+
+            //            }
+            if (!message.getSubject().startsWith("Re:"))
+            {
+               message.setSubject("Re: " + message.getSubject());
+            }
+
+            String signature = getPoster().getUser().getSignature();
+            if ((signature != null) && (signature.trim().length() != 0))
+            {
+               message.setSignatureEnabled(true);
+            }
+         }
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isFirstPost()
+   {
+      return firstPost;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/TopicAction.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/TopicAction.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/action/TopicAction.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,38 +1,38 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.action;
-
-import org.jboss.portlet.forums.model.Topic;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1.1.1 $
- */
-public abstract class TopicAction
-   extends ForumAction
-{
-   /**
-    * Creates a new {@link TopicAction} object.
-    *
-    * @param mode DOCUMENT_ME
-    */
-   protected TopicAction(int mode)
-   {
-      super(mode);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract Topic getTopic();
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.action;
+
+import org.jboss.portlet.forums.model.Topic;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class TopicAction
+   extends ForumAction
+{
+   /**
+    * Creates a new {@link TopicAction} object.
+    *
+    * @param mode DOCUMENT_ME
+    */
+   protected TopicAction(int mode)
+   {
+      super(mode);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract Topic getTopic();
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/AbstractCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/AbstractCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/AbstractCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,49 +1,49 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.command.Command;
-import org.jboss.portal.common.command.Configurator;
-import org.jboss.portal.common.command.ReflectedConfigurator;
-import org.jboss.portlet.command.ActionCommand;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.3 $
- */
-public abstract class AbstractCommand
-   extends ActionCommand
-   implements CommandConstants
-{
-   /**
-    * DOCUMENT_ME
-    */
-   protected Logger log = Logger.getLogger(getClass());
-   private final ReflectedConfigurator configurator = new ReflectedConfigurator(this);
-
-   protected AbstractCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Configurator getConfigurator()
-   {
-      return configurator;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.command.Command;
+import org.jboss.portal.common.command.Configurator;
+import org.jboss.portal.common.command.ReflectedConfigurator;
+import org.jboss.portlet.command.ActionCommand;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.3 $
+ */
+public abstract class AbstractCommand
+   extends ActionCommand
+   implements CommandConstants
+{
+   /**
+    * DOCUMENT_ME
+    */
+   protected Logger log = Logger.getLogger(getClass());
+   private final ReflectedConfigurator configurator = new ReflectedConfigurator(this);
+
+   protected AbstractCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Configurator getConfigurator()
+   {
+      return configurator;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/BBAttributeType.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/BBAttributeType.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/BBAttributeType.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,96 +1,96 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands;
-
-import org.jboss.portal.common.command.AttributeType;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class BBAttributeType
-   extends AttributeType
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType MODULE = new BBAttributeType("module");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType HOMES = new BBAttributeType("homes");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType NOTIFY = new BBAttributeType("notify");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType POLL_DELETE = new BBAttributeType("poll_delete");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType TOPIC_TYPE = new BBAttributeType("topic_type");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType POLL = new BBAttributeType("poll");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType MODE = new BBAttributeType("mode");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType CURRENT_TIME = new BBAttributeType("current_time");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType MESSAGE = new BBAttributeType("message");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType POST_ID = new BBAttributeType("postId");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType TOPIC_ID = new BBAttributeType("topicId");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType FORUM_ID = new BBAttributeType("forumId");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType VOTE_OPTION_ID = new BBAttributeType("voteOptionId");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final BBAttributeType QUOTE = new BBAttributeType("quote");
-
-   private BBAttributeType(String name)
-   {
-      super(name);
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands;
+
+import org.jboss.portal.common.command.AttributeType;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class BBAttributeType
+   extends AttributeType
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType MODULE = new BBAttributeType("module");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType HOMES = new BBAttributeType("homes");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType NOTIFY = new BBAttributeType("notify");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType POLL_DELETE = new BBAttributeType("poll_delete");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType TOPIC_TYPE = new BBAttributeType("topic_type");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType POLL = new BBAttributeType("poll");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType MODE = new BBAttributeType("mode");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType CURRENT_TIME = new BBAttributeType("current_time");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType MESSAGE = new BBAttributeType("message");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType POST_ID = new BBAttributeType("postId");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType TOPIC_ID = new BBAttributeType("topicId");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType FORUM_ID = new BBAttributeType("forumId");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType VOTE_OPTION_ID = new BBAttributeType("voteOptionId");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final BBAttributeType QUOTE = new BBAttributeType("quote");
+
+   private BBAttributeType(String name)
+   {
+      super(name);
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CommandConstants.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CommandConstants.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CommandConstants.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,401 +1,401 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.result.ResultType;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-public interface CommandConstants
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @author $author$
-    * @version $Revision: 1.2 $
-    */
-   public class ImmutableResult
-      extends ResultType
-      implements Result
-   {
-      /**
-       * Creates a new {@link ImmutableResult} object.
-       *
-       * @param name DOCUMENT_ME
-       */
-      public ImmutableResult(String name)
-      {
-         super(name);
-      }
-
-      /**
-       * DOCUMENT_ME
-       *
-       * @return DOCUMENT_ME
-       */
-      public ResultType getType()
-      {
-         return this;
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   ResultType TYPE_POST_DELETED = SimpleResultType.TYPE_POST_DELETED;
-
-   /**
-    * DOCUMENT_ME
-    */
-   ResultType TYPE_COMPOSITE = SimpleResultType.TYPE_COMPOSITE;
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_INSERT_VOTE = new ImmutableResult("TYPE_CANNOT_INSERT_VOTE");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_OBTAIN_USER_DATA = new ImmutableResult("TYPE_CANNOT_OBTAIN_USER_DATA");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_VOTE_CAST = new ImmutableResult("TYPE_VOTE_CAST");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_NO_VOTE_OPTION = new ImmutableResult("TYPE_NO_VOTE_OPTION");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_REDIRECT = new ImmutableResult("TYPE_REDIRECT");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_ERROR_IN_POSTING = new ImmutableResult("TYPE_ERROR_IN_POSTING");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_ERROR_IN_DELETING_POST = new ImmutableResult("TYPE_ERROR_IN_DELETING_POST");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_ERROR_IN_DELETING_POLL = new ImmutableResult("TYPE_ERROR_IN_DELETING_POLL");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_POLL_DELETED = new ImmutableResult("TYPE_POLL_DELETED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CONTINUE = new ImmutableResult("TYPE_CONTINUE");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_FORUM_LOCKED = new ImmutableResult("TYPE_FORUM_LOCKED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_ALREADY_VOTED = new ImmutableResult("TYPE_ALREADY_VOTED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_NOT_AUTHORIZED = new ImmutableResult("TYPE_NOT_AUTHORIZED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOPIC_IS_LOCKED = new ImmutableResult("TYPE_TOPIC_IS_LOCKED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR =
-      new ImmutableResult("TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_DELETE_REPLIED = new ImmutableResult("TYPE_CANNOT_DELETE_REPLIED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_DELETE_POLL = new ImmutableResult("TYPE_CANNOT_DELETE_POLL");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_FORUM_CREATED = new ImmutableResult("TYPE_FORUM_CREATED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_CREATE_FORUM_INVALID_NAME =
-      new ImmutableResult("TYPE_CANNOT_CREATE_FORUM_INVALID_NAME");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY =
-      new ImmutableResult("TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED =
-      new ImmutableResult("TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CATEGORY_CREATED = new ImmutableResult("TYPE_CATEGORY_CREATED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED =
-      new ImmutableResult("TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME =
-      new ImmutableResult("TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_FORUM_REMOVED = new ImmutableResult("TYPE_FORUM_REMOVED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED =
-      new ImmutableResult("TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_FORUM_MOVED_AND_REMOVED = new ImmutableResult("TYPE_FORUM_MOVED_AND_REMOVED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_MOVE_AND_REMOVE_FORUM = new ImmutableResult("TYPE_CANNOT_MOVE_AND_REMOVE_FORUM");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CATEGORY_REMOVED = new ImmutableResult("TYPE_CATEGORY_REMOVED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_REMOVE_CATEGORY = new ImmutableResult("TYPE_CANNOT_REMOVE_CATEGORY");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_FORUMS_ORDERED = new ImmutableResult("TYPE_FORUMS_ORDERED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_ORDER_FORUMS = new ImmutableResult("TYPE_CANNOT_ORDER_FORUMS");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CATEGORIES_ORDERED = new ImmutableResult("TYPE_CATEGORIES_ORDERED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_ORDER_CATEGORIES = new ImmutableResult("TYPE_CANNOT_ORDER_CATEGORIES");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CATEGORY_UPDATED = new ImmutableResult("TYPE_CATEGORY_UPDATED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_FORUM_UPDATED = new ImmutableResult("TYPE_FORUM_UPDATED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOPICS_REMOVED = new ImmutableResult("TYPE_TOPICS_REMOVED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_REMOVE_TOPICS = new ImmutableResult("TYPE_CANNOT_REMOVE_TOPICS");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOPIC_MOVED = new ImmutableResult("TYPE_TOPIC_MOVED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_MOVE_TOPIC = new ImmutableResult("TYPE_CANNOT_MOVE_TOPIC");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOPIC_LOCKED = new ImmutableResult("TYPE_TOPIC_LOCKED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOPIC_UNLOCKED = new ImmutableResult("TYPE_TOPIC_UNLOCKED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_LOCK_TOPIC_MOVED = new ImmutableResult("TYPE_CANNOT_LOCK_TOPIC_MOVED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOPIC_SPLITED = new ImmutableResult("TYPE_TOPIC_SPLITED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_SPLIT_TOPIC = new ImmutableResult("TYPE_CANNOT_SPLIT_TOPIC");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_NEW_TOPIC_POSTED = new ImmutableResult("TYPE_NEW_TOPIC_POSTED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_EDIT_POST_POSTED = new ImmutableResult("TYPE_EDIT_POST_POSTED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_REPOSTED = new ImmutableResult("TYPE_REPOSTED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_REPLY_POSTED = new ImmutableResult("TYPE_REPLY_POSTED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_NO_SUCH_FORUM = new ImmutableResult("TYPE_NO_SUCH_FORUM");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_NO_SUCH_TOPIC = new ImmutableResult("TYPE_NO_SUCH_TOPIC");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_NO_SUCH_POST = new ImmutableResult("TYPE_NO_SUCH_POST");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_QUERY = new ImmutableResult("TYPE_CANNOT_QUERY");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_INVALID_POST_SUBJECT = new ImmutableResult("TYPE_INVALID_POST_SUBJECT");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_INVALID_POST_MESSAGE = new ImmutableResult("TYPE_INVALID_POST_MESSAGE");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_INVALID_POLL_TITLE = new ImmutableResult("TYPE_INVALID_POLL_TITLE");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOO_FEW_POLL_OPTION = new ImmutableResult("TYPE_TOO_FEW_POLL_OPTION");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_TOO_MANY_POLL_OPTION = new ImmutableResult("TYPE_TOO_MANY_POLL_OPTION");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_INVALID_POLL_OPTION = new ImmutableResult("TYPE_INVALID_POLL_OPTION");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_FLOODING_CANNOT_CREATE = new ImmutableResult("TYPE_FLOODING_CANNOT_CREATE");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_COULD_NOT_OBTAIN_VOTE_DATA = new ImmutableResult("TYPE_COULD_NOT_OBTAIN_VOTE_DATA");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_NOT_SELECTED_VOTE = new ImmutableResult("TYPE_NOT_SELECTED_VOTE");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_ADD_ATTACHMENT = new ImmutableResult("TYPE_CANNOT_ADD_ATTACHMENT");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_CANNOT_DELETE_ATTACHMENT = new ImmutableResult("TYPE_CANNOT_DELETE_ATTACHMENT");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_ERROR_IN_DELETING_ATTACHMENT = new ImmutableResult("TYPE_ERROR_IN_DELETING_ATTACHMENT");
-
-   /**
-    * DOCUMENT_ME
-    */
-   ImmutableResult TYPE_VOTE_POSTED = new ImmutableResult("TYPE_VOTE_POSTED");
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.result.ResultType;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+public interface CommandConstants
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @author $author$
+    * @version $Revision: 1.2 $
+    */
+   public class ImmutableResult
+      extends ResultType
+      implements Result
+   {
+      /**
+       * Creates a new {@link ImmutableResult} object.
+       *
+       * @param name DOCUMENT_ME
+       */
+      public ImmutableResult(String name)
+      {
+         super(name);
+      }
+
+      /**
+       * DOCUMENT_ME
+       *
+       * @return DOCUMENT_ME
+       */
+      public ResultType getType()
+      {
+         return this;
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   ResultType TYPE_POST_DELETED = SimpleResultType.TYPE_POST_DELETED;
+
+   /**
+    * DOCUMENT_ME
+    */
+   ResultType TYPE_COMPOSITE = SimpleResultType.TYPE_COMPOSITE;
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_INSERT_VOTE = new ImmutableResult("TYPE_CANNOT_INSERT_VOTE");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_OBTAIN_USER_DATA = new ImmutableResult("TYPE_CANNOT_OBTAIN_USER_DATA");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_VOTE_CAST = new ImmutableResult("TYPE_VOTE_CAST");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_NO_VOTE_OPTION = new ImmutableResult("TYPE_NO_VOTE_OPTION");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_REDIRECT = new ImmutableResult("TYPE_REDIRECT");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_ERROR_IN_POSTING = new ImmutableResult("TYPE_ERROR_IN_POSTING");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_ERROR_IN_DELETING_POST = new ImmutableResult("TYPE_ERROR_IN_DELETING_POST");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_ERROR_IN_DELETING_POLL = new ImmutableResult("TYPE_ERROR_IN_DELETING_POLL");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_POLL_DELETED = new ImmutableResult("TYPE_POLL_DELETED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CONTINUE = new ImmutableResult("TYPE_CONTINUE");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_FORUM_LOCKED = new ImmutableResult("TYPE_FORUM_LOCKED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_ALREADY_VOTED = new ImmutableResult("TYPE_ALREADY_VOTED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_NOT_AUTHORIZED = new ImmutableResult("TYPE_NOT_AUTHORIZED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOPIC_IS_LOCKED = new ImmutableResult("TYPE_TOPIC_IS_LOCKED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR =
+      new ImmutableResult("TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_DELETE_REPLIED = new ImmutableResult("TYPE_CANNOT_DELETE_REPLIED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_DELETE_POLL = new ImmutableResult("TYPE_CANNOT_DELETE_POLL");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_FORUM_CREATED = new ImmutableResult("TYPE_FORUM_CREATED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_CREATE_FORUM_INVALID_NAME =
+      new ImmutableResult("TYPE_CANNOT_CREATE_FORUM_INVALID_NAME");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY =
+      new ImmutableResult("TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED =
+      new ImmutableResult("TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CATEGORY_CREATED = new ImmutableResult("TYPE_CATEGORY_CREATED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED =
+      new ImmutableResult("TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME =
+      new ImmutableResult("TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_FORUM_REMOVED = new ImmutableResult("TYPE_FORUM_REMOVED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED =
+      new ImmutableResult("TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_FORUM_MOVED_AND_REMOVED = new ImmutableResult("TYPE_FORUM_MOVED_AND_REMOVED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_MOVE_AND_REMOVE_FORUM = new ImmutableResult("TYPE_CANNOT_MOVE_AND_REMOVE_FORUM");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CATEGORY_REMOVED = new ImmutableResult("TYPE_CATEGORY_REMOVED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_REMOVE_CATEGORY = new ImmutableResult("TYPE_CANNOT_REMOVE_CATEGORY");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_FORUMS_ORDERED = new ImmutableResult("TYPE_FORUMS_ORDERED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_ORDER_FORUMS = new ImmutableResult("TYPE_CANNOT_ORDER_FORUMS");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CATEGORIES_ORDERED = new ImmutableResult("TYPE_CATEGORIES_ORDERED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_ORDER_CATEGORIES = new ImmutableResult("TYPE_CANNOT_ORDER_CATEGORIES");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CATEGORY_UPDATED = new ImmutableResult("TYPE_CATEGORY_UPDATED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_FORUM_UPDATED = new ImmutableResult("TYPE_FORUM_UPDATED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOPICS_REMOVED = new ImmutableResult("TYPE_TOPICS_REMOVED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_REMOVE_TOPICS = new ImmutableResult("TYPE_CANNOT_REMOVE_TOPICS");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOPIC_MOVED = new ImmutableResult("TYPE_TOPIC_MOVED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_MOVE_TOPIC = new ImmutableResult("TYPE_CANNOT_MOVE_TOPIC");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOPIC_LOCKED = new ImmutableResult("TYPE_TOPIC_LOCKED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOPIC_UNLOCKED = new ImmutableResult("TYPE_TOPIC_UNLOCKED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_LOCK_TOPIC_MOVED = new ImmutableResult("TYPE_CANNOT_LOCK_TOPIC_MOVED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOPIC_SPLITED = new ImmutableResult("TYPE_TOPIC_SPLITED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_SPLIT_TOPIC = new ImmutableResult("TYPE_CANNOT_SPLIT_TOPIC");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_NEW_TOPIC_POSTED = new ImmutableResult("TYPE_NEW_TOPIC_POSTED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_EDIT_POST_POSTED = new ImmutableResult("TYPE_EDIT_POST_POSTED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_REPOSTED = new ImmutableResult("TYPE_REPOSTED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_REPLY_POSTED = new ImmutableResult("TYPE_REPLY_POSTED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_NO_SUCH_FORUM = new ImmutableResult("TYPE_NO_SUCH_FORUM");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_NO_SUCH_TOPIC = new ImmutableResult("TYPE_NO_SUCH_TOPIC");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_NO_SUCH_POST = new ImmutableResult("TYPE_NO_SUCH_POST");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_QUERY = new ImmutableResult("TYPE_CANNOT_QUERY");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_INVALID_POST_SUBJECT = new ImmutableResult("TYPE_INVALID_POST_SUBJECT");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_INVALID_POST_MESSAGE = new ImmutableResult("TYPE_INVALID_POST_MESSAGE");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_INVALID_POLL_TITLE = new ImmutableResult("TYPE_INVALID_POLL_TITLE");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOO_FEW_POLL_OPTION = new ImmutableResult("TYPE_TOO_FEW_POLL_OPTION");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_TOO_MANY_POLL_OPTION = new ImmutableResult("TYPE_TOO_MANY_POLL_OPTION");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_INVALID_POLL_OPTION = new ImmutableResult("TYPE_INVALID_POLL_OPTION");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_FLOODING_CANNOT_CREATE = new ImmutableResult("TYPE_FLOODING_CANNOT_CREATE");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_COULD_NOT_OBTAIN_VOTE_DATA = new ImmutableResult("TYPE_COULD_NOT_OBTAIN_VOTE_DATA");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_NOT_SELECTED_VOTE = new ImmutableResult("TYPE_NOT_SELECTED_VOTE");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_ADD_ATTACHMENT = new ImmutableResult("TYPE_CANNOT_ADD_ATTACHMENT");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_CANNOT_DELETE_ATTACHMENT = new ImmutableResult("TYPE_CANNOT_DELETE_ATTACHMENT");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_ERROR_IN_DELETING_ATTACHMENT = new ImmutableResult("TYPE_ERROR_IN_DELETING_ATTACHMENT");
+
+   /**
+    * DOCUMENT_ME
+    */
+   ImmutableResult TYPE_VOTE_POSTED = new ImmutableResult("TYPE_VOTE_POSTED");
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,69 +1,69 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.jboss.portal.common.command.Command;
-import org.jboss.portal.common.command.Configurator;
-import org.jboss.portal.common.command.EmptyConfigurator;
-import org.jboss.portal.common.command.result.Result;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class CompositeCommand
-   implements Command
-{
-   private final LinkedList list = new LinkedList();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param cmd DOCUMENT_ME
-    */
-   public void add(Command cmd)
-   {
-      list.add(cmd);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Configurator getConfigurator()
-   {
-      return EmptyConfigurator.EMPTY_CONFIGURATOR;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Iterator iterator()
-   {
-      return list.iterator();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      throw new RuntimeException("Cannot be executed directly");
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.jboss.portal.common.command.Command;
+import org.jboss.portal.common.command.Configurator;
+import org.jboss.portal.common.command.EmptyConfigurator;
+import org.jboss.portal.common.command.result.Result;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class CompositeCommand
+   implements Command
+{
+   private final LinkedList list = new LinkedList();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param cmd DOCUMENT_ME
+    */
+   public void add(Command cmd)
+   {
+      list.add(cmd);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Configurator getConfigurator()
+   {
+      return EmptyConfigurator.EMPTY_CONFIGURATOR;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Iterator iterator()
+   {
+      return list.iterator();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      throw new RuntimeException("Cannot be executed directly");
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeResult.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeResult.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/CompositeResult.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,58 +1,58 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.result.ResultType;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class CompositeResult
-   implements Result
-{
-   private final List results = new LinkedList();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param result DOCUMENT_ME
-    */
-   public void addResult(Result result)
-   {
-      results.add(result);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Iterator iterator()
-   {
-      return results.iterator();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public ResultType getType()
-   {
-      return CommandConstants.TYPE_COMPOSITE;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.result.ResultType;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class CompositeResult
+   implements Result
+{
+   private final List results = new LinkedList();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param result DOCUMENT_ME
+    */
+   public void addResult(Result result)
+   {
+      results.add(result);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Iterator iterator()
+   {
+      return results.iterator();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResultType getType()
+   {
+      return CommandConstants.TYPE_COMPOSITE;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/SimpleResultType.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/SimpleResultType.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/SimpleResultType.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,36 +1,36 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands;
-
-import org.jboss.portal.common.command.result.ResultType;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class SimpleResultType
-   extends ResultType
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public static final ResultType TYPE_POST_DELETED = new SimpleResultType("TYPE_POST_DELETED");
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final ResultType TYPE_COMPOSITE = new SimpleResultType("TYPE_COMPOSITE");
-
-   private SimpleResultType(String name)
-   {
-      super(name);
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands;
+
+import org.jboss.portal.common.command.result.ResultType;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class SimpleResultType
+   extends ResultType
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public static final ResultType TYPE_POST_DELETED = new SimpleResultType("TYPE_POST_DELETED");
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final ResultType TYPE_COMPOSITE = new SimpleResultType("TYPE_COMPOSITE");
+
+   private SimpleResultType(String name)
+   {
+      super(name);
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/ValidationException.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/ValidationException.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/ValidationException.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,43 +1,43 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands;
-
-import org.jboss.portal.common.command.result.Result;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1.1.1 $
- */
-public class ValidationException
-   extends Exception
-{
-   /**
-    * Creates a new {@link ValidationException} object.
-    *
-    * @param result DOCUMENT_ME
-    */
-   public ValidationException(Result result)
-   {
-      this.result = result;
-   }
-
-   private Result result;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result getResult()
-   {
-      return result;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands;
+
+import org.jboss.portal.common.command.result.Result;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class ValidationException
+   extends Exception
+{
+   /**
+    * Creates a new {@link ValidationException} object.
+    *
+    * @param result DOCUMENT_ME
+    */
+   public ValidationException(Result result)
+   {
+      this.result = result;
+   }
+
+   private Result result;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result getResult()
+   {
+      return result;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateCategoryCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateCategoryCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateCategoryCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,66 +1,66 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.3 $
- */
-public class CreateCategoryCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public String name;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule module;
-
-   public CreateCategoryCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      if (name == null)
-      {
-         return TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME;
-      }
-
-      try
-      {
-         module.createCategory(name);
-         return TYPE_CATEGORY_CREATED;
-      }
-      catch (ModuleException e)
-      {
-         log.error("", e);
-         return TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED;
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.3 $
+ */
+public class CreateCategoryCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public String name;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule module;
+
+   public CreateCategoryCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      if (name == null)
+      {
+         return TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME;
+      }
+
+      try
+      {
+         module.createCategory(name);
+         return TYPE_CATEGORY_CREATED;
+      }
+      catch (ModuleException e)
+      {
+         log.error("", e);
+         return TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED;
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateForumCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateForumCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/CreateForumCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,82 +1,82 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.3 $
- */
-public class CreateForumCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public String name;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String description;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Category category;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule module;
-
-   public CreateForumCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      if ("".equals(name))
-      {
-         return TYPE_CANNOT_CREATE_FORUM_INVALID_NAME;
-      }
-
-      if (category == null)
-      {
-         return TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY;
-      }
-
-      try
-      {
-         module.createForum(category, name, description);
-         return TYPE_FORUM_CREATED;
-      }
-      catch (ModuleException e)
-      {
-         log.error("", e);
-         return TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED;
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.3 $
+ */
+public class CreateForumCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public String name;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String description;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Category category;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule module;
+
+   public CreateForumCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      if ("".equals(name))
+      {
+         return TYPE_CANNOT_CREATE_FORUM_INVALID_NAME;
+      }
+
+      if (category == null)
+      {
+         return TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY;
+      }
+
+      try
+      {
+         module.createForum(category, name, description);
+         return TYPE_FORUM_CREATED;
+      }
+      catch (ModuleException e)
+      {
+         log.error("", e);
+         return TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED;
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteCategoryCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteCategoryCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteCategoryCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,32 +1,32 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-//import org.jboss.nukes.addons.modules.bb.commands.AbstractCommand;
-
-import org.jboss.portal.common.command.result.Result;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class DeleteCategoryCommand //  extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      throw new UnsupportedOperationException();
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+//import org.jboss.nukes.addons.modules.bb.commands.AbstractCommand;
+
+import org.jboss.portal.common.command.result.Result;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class DeleteCategoryCommand //  extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      throw new UnsupportedOperationException();
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteForumCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteForumCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteForumCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,136 +1,136 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.impl.PostImpl;
-import org.jboss.portlet.forums.impl.TopicImpl;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.util.collection.CompoundIterator;
-
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-public class DeleteForumCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public Forum forum;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule module;
-
-   public DeleteForumCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      try
-      {
-         /*if (forum.getLastPost() == null) {
-            module.removeForum(forum);
-            return TYPE_FORUM_REMOVED;
-         }
-         Post p = forum.getLastPost();
-         Topic t = p.getTopic();
-         if (t.getFirstPost().getId().intValue() == t.getLastPost().getId().intValue())
-         {
-            t.setFirstPost(null);
-            t.setLastPost(null);
-            forum.setLastPost(null);
-            module.removePost(p);
-            module.removeTopic(p.getTopic());
-         }
-         else
-         {
-            forum.setLastPost(null);
-            p = t.getFirstPost();
-            t.setFirstPost(null);
-            module.removePost(p);
-            p= t.getLastPost();
-            t.setLastPost(null);
-            module.removePost(p);
-            Iterator ip = module.findPostsByTopicId(t.getId()).iterator();
-            while(ip.hasNext())
-            {
-               p = (Post)ip.next();
-               module.removePost(p);
-            }
-            module.removeTopic(p.getTopic());
-         }
-
-         //Iterator it = forum.getTopics().iterator();
-         Iterator it = module.findTopics(forum).iterator();
-         while(it.hasNext())
-         {
-            t = (Topic)it.next();
-            if (t.getFirstPost().getId().intValue() == t.getLastPost().getId().intValue())
-            {
-               p = t.getFirstPost();
-               t.setFirstPost(null);
-               t.setLastPost(null);
-               //forum.setLastPost(null);
-               module.removePost(p);
-               module.removeTopic(p.getTopic());
-            }
-            else
-            {
-               p = t.getFirstPost();
-               t.setFirstPost(null);
-               module.removePost(p);
-               p= t.getLastPost();
-               t.setLastPost(null);
-               module.removePost(p);
-               Iterator ip = module.findPostsByTopicId(t.getId()).iterator();
-               while(ip.hasNext())
-               {
-                  p = (Post)ip.next();
-                  module.removePost(p);
-               }
-               module.removeTopic(p.getTopic());
-            }
-         }
-         module.removeForum(t.getForum());*/
-         module.removeForum(forum);
-         return TYPE_FORUM_REMOVED;
-      }
-      catch (ModuleException e)
-      {
-         return TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED;
-      }
-   }
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.impl.PostImpl;
+import org.jboss.portlet.forums.impl.TopicImpl;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.util.collection.CompoundIterator;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.4 $
+ */
+public class DeleteForumCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public Forum forum;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule module;
+
+   public DeleteForumCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      try
+      {
+         /*if (forum.getLastPost() == null) {
+            module.removeForum(forum);
+            return TYPE_FORUM_REMOVED;
+         }
+         Post p = forum.getLastPost();
+         Topic t = p.getTopic();
+         if (t.getFirstPost().getId().intValue() == t.getLastPost().getId().intValue())
+         {
+            t.setFirstPost(null);
+            t.setLastPost(null);
+            forum.setLastPost(null);
+            module.removePost(p);
+            module.removeTopic(p.getTopic());
+         }
+         else
+         {
+            forum.setLastPost(null);
+            p = t.getFirstPost();
+            t.setFirstPost(null);
+            module.removePost(p);
+            p= t.getLastPost();
+            t.setLastPost(null);
+            module.removePost(p);
+            Iterator ip = module.findPostsByTopicId(t.getId()).iterator();
+            while(ip.hasNext())
+            {
+               p = (Post)ip.next();
+               module.removePost(p);
+            }
+            module.removeTopic(p.getTopic());
+         }
+
+         //Iterator it = forum.getTopics().iterator();
+         Iterator it = module.findTopics(forum).iterator();
+         while(it.hasNext())
+         {
+            t = (Topic)it.next();
+            if (t.getFirstPost().getId().intValue() == t.getLastPost().getId().intValue())
+            {
+               p = t.getFirstPost();
+               t.setFirstPost(null);
+               t.setLastPost(null);
+               //forum.setLastPost(null);
+               module.removePost(p);
+               module.removeTopic(p.getTopic());
+            }
+            else
+            {
+               p = t.getFirstPost();
+               t.setFirstPost(null);
+               module.removePost(p);
+               p= t.getLastPost();
+               t.setLastPost(null);
+               module.removePost(p);
+               Iterator ip = module.findPostsByTopicId(t.getId()).iterator();
+               while(ip.hasNext())
+               {
+                  p = (Post)ip.next();
+                  module.removePost(p);
+               }
+               module.removeTopic(p.getTopic());
+            }
+         }
+         module.removeForum(t.getForum());*/
+         module.removeForum(forum);
+         return TYPE_FORUM_REMOVED;
+      }
+      catch (ModuleException e)
+      {
+         return TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED;
+      }
+   }
+
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveCategoryCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveCategoryCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveCategoryCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,94 +1,94 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.*;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.5 $
- */
-public class DeleteMoveCategoryCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public Category source;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Category target;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule module;
-
-   public DeleteMoveCategoryCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      try
-      {
-         if ((source != null) && (target != null) && !source.getId().equals(target.getId()))
-         {
-            module.addAllForums(source, target);
-
-            /* OK. this is really piece of shit... It's nessesary with current wrong hibernate schema
-             * with a lot of cached fields and not working cascade delete. All dependancies have to be
-             * cleanded in this wird style before removing category. It should be replaced after */
-            /*Iterator it = module.findForumsByCategoryId(source.getId()).iterator();
-            while (it.hasNext())
-            {
-               Forum f = (Forum)it.next();
-               if(f.getLastPost() != null){
-                  f.getLastPost().getTopic().getForum().setCategory(target);
-                  f.getLastPost().getTopic().getLastPost().getTopic().getForum().setCategory(target);
-                  f.getLastPost().getTopic().getFirstPost().getTopic().getForum().setCategory(target);
-               }
-               f.setCategory(target);
-
-               Iterator itn = module.findTopics(f).iterator();
-               while (itn.hasNext())
-               {
-                  Topic t = (Topic)itn.next();
-                  t.getForum().setCategory(target);
-               }
-            }*/
-         }
-         module.removeCategory(source);
-         return TYPE_CATEGORY_REMOVED;
-      }
-      catch (ModuleException e)
-      {
-         log.error("", e);
-         return TYPE_CANNOT_REMOVE_CATEGORY;
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.*;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+public class DeleteMoveCategoryCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public Category source;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Category target;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule module;
+
+   public DeleteMoveCategoryCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      try
+      {
+         if ((source != null) && (target != null) && !source.getId().equals(target.getId()))
+         {
+            module.addAllForums(source, target);
+
+            /* OK. this is really piece of shit... It's nessesary with current wrong hibernate schema
+             * with a lot of cached fields and not working cascade delete. All dependancies have to be
+             * cleanded in this wird style before removing category. It should be replaced after */
+            /*Iterator it = module.findForumsByCategoryId(source.getId()).iterator();
+            while (it.hasNext())
+            {
+               Forum f = (Forum)it.next();
+               if(f.getLastPost() != null){
+                  f.getLastPost().getTopic().getForum().setCategory(target);
+                  f.getLastPost().getTopic().getLastPost().getTopic().getForum().setCategory(target);
+                  f.getLastPost().getTopic().getFirstPost().getTopic().getForum().setCategory(target);
+               }
+               f.setCategory(target);
+
+               Iterator itn = module.findTopics(f).iterator();
+               while (itn.hasNext())
+               {
+                  Topic t = (Topic)itn.next();
+                  t.getForum().setCategory(target);
+               }
+            }*/
+         }
+         module.removeCategory(source);
+         return TYPE_CATEGORY_REMOVED;
+      }
+      catch (ModuleException e)
+      {
+         log.error("", e);
+         return TYPE_CANNOT_REMOVE_CATEGORY;
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveForumCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveForumCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/DeleteMoveForumCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,184 +1,184 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import java.util.Iterator;
-import java.util.ArrayList;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.*;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.5 $
- */
-public class DeleteMoveForumCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public Forum source;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Forum target;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule module;
-
-   public DeleteMoveForumCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      //Iterator topics = source.getTopics().iterator();
-      // TODO This is not good, it makes N requests instead of an atomic:
-      // UPDATE jbp_forums_topics SET jbp_forum_id = 'targetId' WHERE jbp_forum_id = 'sourceId'
-
-      /*
-         while (topics.hasNext())
-         {
-            Topic topic = (Topic)topics.next();
-            topic.setForum(target);
-         }
-       */
-      /*try
-      {
-         target.setLastPost(source.getLastPost());
-         target.setPostCount(target.getPostCount() + source.getPostCount());
-         target.setTopicCount(target.getTopicCount() + source.getTopicCount());
-         module.removeForum(source);
-      }
-      catch (ModuleException e)
-      {
-         target.setLastPost(null);
-      }
-*/
-
-      try
-      {
-         //Iterator it = forum.getTopics().iterator();
-
-         /*target.setLastPost(source.getLastPost());
-         source.getLastPost().getTopic().setForum(target);
-         source.setLastPost(null);
-         source.setCategory(null);
-         target.setPostCount(target.getPostCount() + source.getPostCount());
-         target.setTopicCount(target.getTopicCount() + source.getTopicCount());
-         Iterator it = module.findTopics(source).iterator();
-         while(it.hasNext())
-         {
-            Topic t = (Topic)it.next();
-            t.setForum(target);
-         }*/
-         target.getTopics().addAll(source.getTopics());
-         target.setPostCount(target.getPostCount() + source.getPostCount());
-         target.setTopicCount(target.getTopicCount() + source.getTopicCount());
-         for (Iterator i = target.getTopics().iterator(); i.hasNext();)
-         {
-            Topic tp = (Topic)i.next();
-            tp.setForum(target);
-         }
-         source.setTopics(new ArrayList());
-         module.removeForum(source);
-         return TYPE_FORUM_REMOVED;
-      }
-      catch (ModuleException e)
-      {
-         return TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED;
-      }
-      //return TYPE_FORUM_MOVED_AND_REMOVED;
-   }
-
-   /*
-      public Integer sourceId;
-      public Integer targetId;
-      public DataSource postDataSource;
-      public String postTableName;
-      public String postForumFKColumnName;
-      public DataSource topicDataSource;
-      public String topicTableName;
-      public String topicForumFKColumnName;
-      public ForumEJBLocalHome forumHome;
-      public TopicEJBLocalHome topicHome;
-      public PostEJBLocalHome postHome;
-      public Result execute()
-      {
-         Connection conn1 = null;
-         Connection conn2 = null;
-         PreparedStatement ps1 = null;
-         PreparedStatement ps2 = null;
-         try
-         {
-            // get the source and target EJBs
-            ForumEJBLocal source = forumHome.findByPrimaryKey(sourceId);
-            ForumEJBLocal target = forumHome.findByPrimaryKey(targetId);
-            // update the topics
-            conn1 = topicDataSource.getConnection();
-            ps1 = conn1.prepareStatement("UPDATE " + topicTableName + " SET " + topicForumFKColumnName + "=? WHERE " + topicForumFKColumnName + "=?");
-            ps1.setInt(1, target.getId().intValue());
-            ps1.setInt(2, source.getId().intValue());
-            ps1.executeUpdate();
-            // update the posts
-            conn2 = postDataSource.getConnection();
-            ps2 = conn1.prepareStatement("UPDATE " + postTableName + " SET " + postForumFKColumnName + "=? WHERE " + postForumFKColumnName + "=?");
-            ps2.setInt(1, target.getId().intValue());
-            ps2.setInt(2, source.getId().intValue());
-            ps2.executeUpdate();
-            // here we must invalidate the EJB caches
-            // update values cached in EJBs
-            target.setTopicSize(target.getTopicSize() + source.getTopicSize());
-            target.setPostSize(target.getPostSize() + source.getPostSize());
-            try
-            {
-               target.setLastPost(postHome.findLastPost(target));
-            }
-            catch(ObjectNotFoundException e)
-            {
-               target.setLastPost(null);
-            }
-            // finally delete source forum
-            source.remove();
-         }
-         catch(Exception e)
-         {
-            log.error("", e);
-            return TYPE_CANNOT_MOVE_AND_REMOVE_FORUM;
-         }
-         finally
-         {
-            Tools.safeClose(ps2);
-            Tools.safeClose(ps1);
-            Tools.safeClose(conn1);
-            Tools.safeClose(conn2);
-         }
-         return TYPE_FORUM_MOVED_AND_REMOVED;
-      }
-    */
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import java.util.Iterator;
+import java.util.ArrayList;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.*;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+public class DeleteMoveForumCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public Forum source;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Forum target;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule module;
+
+   public DeleteMoveForumCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      //Iterator topics = source.getTopics().iterator();
+      // TODO This is not good, it makes N requests instead of an atomic:
+      // UPDATE jbp_forums_topics SET jbp_forum_id = 'targetId' WHERE jbp_forum_id = 'sourceId'
+
+      /*
+         while (topics.hasNext())
+         {
+            Topic topic = (Topic)topics.next();
+            topic.setForum(target);
+         }
+       */
+      /*try
+      {
+         target.setLastPost(source.getLastPost());
+         target.setPostCount(target.getPostCount() + source.getPostCount());
+         target.setTopicCount(target.getTopicCount() + source.getTopicCount());
+         module.removeForum(source);
+      }
+      catch (ModuleException e)
+      {
+         target.setLastPost(null);
+      }
+*/
+
+      try
+      {
+         //Iterator it = forum.getTopics().iterator();
+
+         /*target.setLastPost(source.getLastPost());
+         source.getLastPost().getTopic().setForum(target);
+         source.setLastPost(null);
+         source.setCategory(null);
+         target.setPostCount(target.getPostCount() + source.getPostCount());
+         target.setTopicCount(target.getTopicCount() + source.getTopicCount());
+         Iterator it = module.findTopics(source).iterator();
+         while(it.hasNext())
+         {
+            Topic t = (Topic)it.next();
+            t.setForum(target);
+         }*/
+         target.getTopics().addAll(source.getTopics());
+         target.setPostCount(target.getPostCount() + source.getPostCount());
+         target.setTopicCount(target.getTopicCount() + source.getTopicCount());
+         for (Iterator i = target.getTopics().iterator(); i.hasNext();)
+         {
+            Topic tp = (Topic)i.next();
+            tp.setForum(target);
+         }
+         source.setTopics(new ArrayList());
+         module.removeForum(source);
+         return TYPE_FORUM_REMOVED;
+      }
+      catch (ModuleException e)
+      {
+         return TYPE_CANNOT_REMOVE_FORUM_REMOVAL_FAILED;
+      }
+      //return TYPE_FORUM_MOVED_AND_REMOVED;
+   }
+
+   /*
+      public Integer sourceId;
+      public Integer targetId;
+      public DataSource postDataSource;
+      public String postTableName;
+      public String postForumFKColumnName;
+      public DataSource topicDataSource;
+      public String topicTableName;
+      public String topicForumFKColumnName;
+      public ForumEJBLocalHome forumHome;
+      public TopicEJBLocalHome topicHome;
+      public PostEJBLocalHome postHome;
+      public Result execute()
+      {
+         Connection conn1 = null;
+         Connection conn2 = null;
+         PreparedStatement ps1 = null;
+         PreparedStatement ps2 = null;
+         try
+         {
+            // get the source and target EJBs
+            ForumEJBLocal source = forumHome.findByPrimaryKey(sourceId);
+            ForumEJBLocal target = forumHome.findByPrimaryKey(targetId);
+            // update the topics
+            conn1 = topicDataSource.getConnection();
+            ps1 = conn1.prepareStatement("UPDATE " + topicTableName + " SET " + topicForumFKColumnName + "=? WHERE " + topicForumFKColumnName + "=?");
+            ps1.setInt(1, target.getId().intValue());
+            ps1.setInt(2, source.getId().intValue());
+            ps1.executeUpdate();
+            // update the posts
+            conn2 = postDataSource.getConnection();
+            ps2 = conn1.prepareStatement("UPDATE " + postTableName + " SET " + postForumFKColumnName + "=? WHERE " + postForumFKColumnName + "=?");
+            ps2.setInt(1, target.getId().intValue());
+            ps2.setInt(2, source.getId().intValue());
+            ps2.executeUpdate();
+            // here we must invalidate the EJB caches
+            // update values cached in EJBs
+            target.setTopicSize(target.getTopicSize() + source.getTopicSize());
+            target.setPostSize(target.getPostSize() + source.getPostSize());
+            try
+            {
+               target.setLastPost(postHome.findLastPost(target));
+            }
+            catch(ObjectNotFoundException e)
+            {
+               target.setLastPost(null);
+            }
+            // finally delete source forum
+            source.remove();
+         }
+         catch(Exception e)
+         {
+            log.error("", e);
+            return TYPE_CANNOT_MOVE_AND_REMOVE_FORUM;
+         }
+         finally
+         {
+            Tools.safeClose(ps2);
+            Tools.safeClose(ps1);
+            Tools.safeClose(conn1);
+            Tools.safeClose(conn2);
+         }
+         return TYPE_FORUM_MOVED_AND_REMOVED;
+      }
+    */
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderCategoryCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderCategoryCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderCategoryCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,75 +1,75 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import java.util.Iterator;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.4 $
- */
-public class OrderCategoryCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public int move;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Category category;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule module;
-
-   public OrderCategoryCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      try
-      {
-         category.setOrder(category.getOrder() + move);
-         Iterator categories = module.findCategories().iterator();
-         for (int index = 10; categories.hasNext(); index += 10)
-         {
-            category = (Category)categories.next();
-            category.setOrder(index);
-         }
-
-         return TYPE_CATEGORIES_ORDERED;
-      }
-      catch (ModuleException e)
-      {
-         log.error("", e);
-         return TYPE_CANNOT_ORDER_CATEGORIES;
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import java.util.Iterator;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.4 $
+ */
+public class OrderCategoryCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public int move;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Category category;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule module;
+
+   public OrderCategoryCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      try
+      {
+         category.setOrder(category.getOrder() + move);
+         Iterator categories = module.findCategories().iterator();
+         for (int index = 10; categories.hasNext(); index += 10)
+         {
+            category = (Category)categories.next();
+            category.setOrder(index);
+         }
+
+         return TYPE_CATEGORIES_ORDERED;
+      }
+      catch (ModuleException e)
+      {
+         log.error("", e);
+         return TYPE_CANNOT_ORDER_CATEGORIES;
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderForumCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderForumCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/OrderForumCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,76 +1,76 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import java.util.Iterator;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.6 $
- */
-public class OrderForumCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public int move;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Forum forum;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule module;
-
-   public OrderForumCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      try
-      {
-         forum.setOrder(forum.getOrder() + move);
-         Iterator forums = module.findForumsByCategoryId(forum.getCategory().getId()).iterator();
-         for (int index = 10; forums.hasNext(); index += 10)
-         {
-            forum = (Forum)forums.next();
-            forum.setOrder(index);
-         }
-
-         return TYPE_FORUMS_ORDERED;
-      }
-      catch (ModuleException e)
-      {
-         log.error("", e);
-         return TYPE_CANNOT_ORDER_FORUMS;
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import java.util.Iterator;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.6 $
+ */
+public class OrderForumCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public int move;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Forum forum;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule module;
+
+   public OrderForumCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      try
+      {
+         forum.setOrder(forum.getOrder() + move);
+         Iterator forums = module.findForumsByCategoryId(forum.getCategory().getId()).iterator();
+         for (int index = 10; forums.hasNext(); index += 10)
+         {
+            forum = (Forum)forums.next();
+            forum.setOrder(index);
+         }
+
+         return TYPE_FORUMS_ORDERED;
+      }
+      catch (ModuleException e)
+      {
+         log.error("", e);
+         return TYPE_CANNOT_ORDER_FORUMS;
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateCategoryCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateCategoryCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateCategoryCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,52 +1,52 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.3 $
- */
-public class UpdateCategoryCommand
-   extends AbstractCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public Category category;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String title;
-
-   public UpdateCategoryCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      category.setTitle(title);
-      return TYPE_CATEGORY_UPDATED;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.3 $
+ */
+public class UpdateCategoryCommand
+   extends AbstractCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public Category category;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String title;
+
+   public UpdateCategoryCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      category.setTitle(title);
+      return TYPE_CATEGORY_UPDATED;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateForumCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateForumCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/admin/UpdateForumCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,65 +1,65 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.admin;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.5 $
- */
-public class UpdateForumCommand
-   extends AbstractCommand
-{
-   /**
-    * Name of the forum
-    */
-   public String name;
-
-   /**
-    * Description of the forum
-    */
-   public String description;
-
-   /**
-    * Cagtegory of the forum
-    */
-   public Category category;
-
-   /**
-    * Forum to edit
-    */
-   public Forum forum;
-
-   public UpdateForumCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * Edit the forum
-    *
-    * @return Result saying if the forum has been successfully updated
-    */
-   public Result execute()
-   {
-      forum.setCategory(category);
-      forum.setName(name);
-      forum.setDescription(description);
-      return TYPE_FORUM_UPDATED;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.admin;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.5 $
+ */
+public class UpdateForumCommand
+   extends AbstractCommand
+{
+   /**
+    * Name of the forum
+    */
+   public String name;
+
+   /**
+    * Description of the forum
+    */
+   public String description;
+
+   /**
+    * Cagtegory of the forum
+    */
+   public Category category;
+
+   /**
+    * Forum to edit
+    */
+   public Forum forum;
+
+   public UpdateForumCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * Edit the forum
+    *
+    * @return Result saying if the forum has been successfully updated
+    */
+   public Result execute()
+   {
+      forum.setCategory(category);
+      forum.setName(name);
+      forum.setDescription(description);
+      return TYPE_FORUM_UPDATED;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/DeleteTopicCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/DeleteTopicCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/DeleteTopicCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,97 +1,97 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.moderation;
-
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.core.modules.ModuleException;
-
-import java.util.Iterator;
-import java.util.Collection;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.3 $
- */
-public class DeleteTopicCommand extends AbstractCommand
-{
-   public Collection topicIds;
-   public ForumsModule module;
-
-   public DeleteTopicCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   public Result execute() throws CommandException
-   {
-      for (Iterator i = topicIds.iterator(); i.hasNext();)
-      {
-         try
-         {
-            Integer tid = (Integer)i.next();
-            Topic topic = module.findTopicById(tid);
-            module.removeTopic(topic);
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            return TYPE_CANNOT_REMOVE_TOPICS;
-         }
-      }
-
-      return TYPE_TOPICS_REMOVED;
-   }
-   /*
-     public Homes homes;
-     public TopicEJBLocal topic;
-     public Result execute()
-     {
-        try
-        {
-           ForumEJBLocal forum = topic.getForum();
-           int replies = topic.getReplies();
-           // cascade delete will take care of removing watches, polls, posts, links
-           topic.remove();
-           forum.setPostSize(forum.getPostSize() - 1 - replies);
-           forum.setTopicSize(forum.getTopicSize() - 1);
-           try
-           {
-              forum.setLastPost(homes.post.findLastPost(forum));
-           }
-           catch(ObjectNotFoundException e)
-           {
-              // no last post
-           }
-        }
-        catch(RemoveException e)
-        {
-           log.error("Cannot remove a topic", e);
-           return TYPE_CANNOT_REMOVE_TOPICS;
-        }
-        catch(FinderException e)
-        {
-           log.error("Cannot find the last post in the forum when during topic removal", e);
-           return TYPE_CANNOT_REMOVE_TOPICS;
-        }
-        return TYPE_TOPICS_REMOVED;
-     }
-   */
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.moderation;
+
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.core.modules.ModuleException;
+
+import java.util.Iterator;
+import java.util.Collection;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.3 $
+ */
+public class DeleteTopicCommand extends AbstractCommand
+{
+   public Collection topicIds;
+   public ForumsModule module;
+
+   public DeleteTopicCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   public Result execute() throws CommandException
+   {
+      for (Iterator i = topicIds.iterator(); i.hasNext();)
+      {
+         try
+         {
+            Integer tid = (Integer)i.next();
+            Topic topic = module.findTopicById(tid);
+            module.removeTopic(topic);
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            return TYPE_CANNOT_REMOVE_TOPICS;
+         }
+      }
+
+      return TYPE_TOPICS_REMOVED;
+   }
+   /*
+     public Homes homes;
+     public TopicEJBLocal topic;
+     public Result execute()
+     {
+        try
+        {
+           ForumEJBLocal forum = topic.getForum();
+           int replies = topic.getReplies();
+           // cascade delete will take care of removing watches, polls, posts, links
+           topic.remove();
+           forum.setPostSize(forum.getPostSize() - 1 - replies);
+           forum.setTopicSize(forum.getTopicSize() - 1);
+           try
+           {
+              forum.setLastPost(homes.post.findLastPost(forum));
+           }
+           catch(ObjectNotFoundException e)
+           {
+              // no last post
+           }
+        }
+        catch(RemoveException e)
+        {
+           log.error("Cannot remove a topic", e);
+           return TYPE_CANNOT_REMOVE_TOPICS;
+        }
+        catch(FinderException e)
+        {
+           log.error("Cannot find the last post in the forum when during topic removal", e);
+           return TYPE_CANNOT_REMOVE_TOPICS;
+        }
+        return TYPE_TOPICS_REMOVED;
+     }
+   */
+
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/LockTopicCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/LockTopicCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/LockTopicCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,109 +1,109 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.moderation;
-
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.core.modules.ModuleException;
-
-import java.util.Iterator;
-import java.util.Collection;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.3 $
- */
-public class LockTopicCommand extends AbstractCommand
-{
-   public Collection topicIds;
-   public ForumsModule module;
-   public boolean unlockAction = false;
-
-   public LockTopicCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   public Result execute() throws CommandException
-   {
-
-      if (!unlockAction)
-      {
-         for (Iterator i = topicIds.iterator(); i.hasNext();)
-         {
-            Integer tid = (Integer)i.next();
-            Topic topic = null;
-            try
-            {
-               topic = module.findTopicById(tid);
-            }
-            catch (ModuleException e)
-            {
-               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-               return TYPE_NO_SUCH_TOPIC;
-            }
-            topic.setStatus(ForumsConstants.TOPIC_LOCKED);
-         }
-
-         return TYPE_TOPIC_LOCKED;  //To change body of implemented methods use File | Settings | File Templates.
-      }
-      else
-      {
-         for (Iterator i = topicIds.iterator(); i.hasNext();)
-         {
-            Integer tid = (Integer)i.next();
-            Topic topic = null;
-            try
-            {
-               topic = module.findTopicById(tid);
-            }
-            catch (ModuleException e)
-            {
-               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-               return TYPE_NO_SUCH_TOPIC;
-            }
-            topic.setStatus(ForumsConstants.TOPIC_UNLOCKED);
-         }
-         return TYPE_TOPIC_UNLOCKED;
-      }
-   }
-   /*
-     public TopicEJBLocal topic;
-     public boolean lock;
-     public Result execute()
-     {
-        if (topic.getStatus() != BBConstants.TOPIC_MOVED)
-        {
-           if (lock)
-           {
-              topic.setStatus(BBConstants.TOPIC_LOCKED);
-              return TYPE_TOPIC_LOCKED;
-           }
-           else
-           {
-              topic.setStatus(BBConstants.TOPIC_UNLOCKED);
-              return TYPE_TOPIC_UNLOCKED;
-           }
-        }
-        return TYPE_CANNOT_LOCK_TOPIC_MOVED;
-     }
-   */
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.moderation;
+
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.core.modules.ModuleException;
+
+import java.util.Iterator;
+import java.util.Collection;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.3 $
+ */
+public class LockTopicCommand extends AbstractCommand
+{
+   public Collection topicIds;
+   public ForumsModule module;
+   public boolean unlockAction = false;
+
+   public LockTopicCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   public Result execute() throws CommandException
+   {
+
+      if (!unlockAction)
+      {
+         for (Iterator i = topicIds.iterator(); i.hasNext();)
+         {
+            Integer tid = (Integer)i.next();
+            Topic topic = null;
+            try
+            {
+               topic = module.findTopicById(tid);
+            }
+            catch (ModuleException e)
+            {
+               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+               return TYPE_NO_SUCH_TOPIC;
+            }
+            topic.setStatus(ForumsConstants.TOPIC_LOCKED);
+         }
+
+         return TYPE_TOPIC_LOCKED;  //To change body of implemented methods use File | Settings | File Templates.
+      }
+      else
+      {
+         for (Iterator i = topicIds.iterator(); i.hasNext();)
+         {
+            Integer tid = (Integer)i.next();
+            Topic topic = null;
+            try
+            {
+               topic = module.findTopicById(tid);
+            }
+            catch (ModuleException e)
+            {
+               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+               return TYPE_NO_SUCH_TOPIC;
+            }
+            topic.setStatus(ForumsConstants.TOPIC_UNLOCKED);
+         }
+         return TYPE_TOPIC_UNLOCKED;
+      }
+   }
+   /*
+     public TopicEJBLocal topic;
+     public boolean lock;
+     public Result execute()
+     {
+        if (topic.getStatus() != BBConstants.TOPIC_MOVED)
+        {
+           if (lock)
+           {
+              topic.setStatus(BBConstants.TOPIC_LOCKED);
+              return TYPE_TOPIC_LOCKED;
+           }
+           else
+           {
+              topic.setStatus(BBConstants.TOPIC_UNLOCKED);
+              return TYPE_TOPIC_UNLOCKED;
+           }
+        }
+        return TYPE_CANNOT_LOCK_TOPIC_MOVED;
+     }
+   */
+
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/MoveTopicCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/MoveTopicCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/MoveTopicCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,168 +1,168 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.moderation;
-
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.core.modules.ModuleException;
-
-import java.util.Iterator;
-import java.util.Collection;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.3 $
- */
-public class MoveTopicCommand extends AbstractCommand//   extends AbstractCommand
-{
-   public Collection topicIds;
-   //public Integer sourceForumId;
-   public Integer destinationForumId;
-   //Forum sourceForum;
-   Forum destForum;
-   public ForumsModule module;
-   public boolean leaveShadow = false;
-
-   public MoveTopicCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-
-   public Result execute() throws CommandException
-   {
-
-      try
-      {
-         destForum = module.findForumById(destinationForumId);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         return TYPE_NO_SUCH_FORUM;
-      }
-
-      //TODO: Leave shadow implementation
-      for (Iterator i = topicIds.iterator(); i.hasNext();)
-      {
-         Integer tid = (Integer)i.next();
-         Topic topic = null;
-         try
-         {
-            topic = module.findTopicById(tid);
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            return TYPE_NO_SUCH_TOPIC;
-         }
-
-         //this is great... with hibernate parent/child rel. movement is only single line :D
-         destForum.addTopic(topic);
-      }
-      /*int replies = topic.getReplies();
-  sourceForum.setPostCount(sourceForum.getPostCount() - 1 - replies);
-  destForum.setPostCount(destForum.getPostCount() + replies + 1);*/
-      return TYPE_TOPIC_MOVED;  //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-   /*
-     public TopicEJBLocal topic;
-     public Homes homes;
-     public ForumEJBLocal source = null;
-     public ForumEJBLocal target = null;
-     public boolean leaveShadow;
-     public Result execute()
-     {
-        if (topic.getStatus() != BBConstants.TOPIC_MOVED)
-        {
-           topic.setForum(target);
-           for (Iterator it2 = topic.getPosts().iterator(); it2.hasNext();)
-           {
-              PostEJBLocal movedPostEJB = (PostEJBLocal)it2.next();
-              movedPostEJB.setForum(target);
-           }
-           // a finder will force the to flush the changes to the store
-           // per the specification 10.5.3 2.0 so we can use them safely
-           // then we update the last post field on the source
-           try
-           {
-              source.setLastPost(homes.post.findLastPost(source));
-           }
-           catch(ObjectNotFoundException e)
-           {
-              // no last post
-              source.setLastPost(null);
-           }
-           catch(FinderException e)
-           {
-              log.error("Cannot find last posts for the forum " + source.getId(), e);
-              return TYPE_CANNOT_MOVE_TOPIC;
-           }
-           // and the destination
-           try
-           {
-              target.setLastPost(homes.post.findLastPost(target));
-           }
-           catch(ObjectNotFoundException e)
-           {
-              target.setLastPost(null);
-              // no last post
-              // bad situation ???
-           }
-           catch(FinderException e)
-           {
-              log.error("Cannot find last posts for the forum " + source.getId(), e);
-              return TYPE_CANNOT_MOVE_TOPIC;
-           }
-           // now we update the fields
-           int replies = topic.getReplies();
-           source.setTopicSize(source.getTopicSize() - 1);
-           source.setPostSize(source.getPostSize() - 1 - replies);
-           target.setTopicSize(target.getTopicSize() + 1);
-           target.setPostSize(target.getPostSize() + replies + 1);
-           //
-           if (leaveShadow)
-           {
-     //                        $sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id)
-     //                           VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)";
-     //                        if ( !$db->sql_query($sql) )
-     //                        {
-     //                           message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
-     //                        }
-                 // todo
-     //                           TopicEJBLocal shadowEJB = topicHome.create(
-     //                                   movedEJB.getTitle(),
-     //                                   movedEJB.getPoster(),
-     //                                   movedEJB.getCreationDate(),
-     //                                   sourceForumEJB,
-     //                                   TOPIC_MOVED,
-     //                                   POST_NORMAL,
-     //                                   movedEJB.getVote()
-     //                           );
-              }
-           }
-     //                  // Sync the forum indexes
-     //                  sync('forum', $new_forum_id);
-     //                  sync('forum', $old_forum_id);
-     //               message = "${bb.Topics_moved}<br/><br/>";
-           return TYPE_TOPIC_MOVED;
-        }
-   */
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.moderation;
+
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.core.modules.ModuleException;
+
+import java.util.Iterator;
+import java.util.Collection;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.3 $
+ */
+public class MoveTopicCommand extends AbstractCommand//   extends AbstractCommand
+{
+   public Collection topicIds;
+   //public Integer sourceForumId;
+   public Integer destinationForumId;
+   //Forum sourceForum;
+   Forum destForum;
+   public ForumsModule module;
+   public boolean leaveShadow = false;
+
+   public MoveTopicCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+
+   public Result execute() throws CommandException
+   {
+
+      try
+      {
+         destForum = module.findForumById(destinationForumId);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         return TYPE_NO_SUCH_FORUM;
+      }
+
+      //TODO: Leave shadow implementation
+      for (Iterator i = topicIds.iterator(); i.hasNext();)
+      {
+         Integer tid = (Integer)i.next();
+         Topic topic = null;
+         try
+         {
+            topic = module.findTopicById(tid);
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            return TYPE_NO_SUCH_TOPIC;
+         }
+
+         //this is great... with hibernate parent/child rel. movement is only single line :D
+         destForum.addTopic(topic);
+      }
+      /*int replies = topic.getReplies();
+  sourceForum.setPostCount(sourceForum.getPostCount() - 1 - replies);
+  destForum.setPostCount(destForum.getPostCount() + replies + 1);*/
+      return TYPE_TOPIC_MOVED;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   /*
+     public TopicEJBLocal topic;
+     public Homes homes;
+     public ForumEJBLocal source = null;
+     public ForumEJBLocal target = null;
+     public boolean leaveShadow;
+     public Result execute()
+     {
+        if (topic.getStatus() != BBConstants.TOPIC_MOVED)
+        {
+           topic.setForum(target);
+           for (Iterator it2 = topic.getPosts().iterator(); it2.hasNext();)
+           {
+              PostEJBLocal movedPostEJB = (PostEJBLocal)it2.next();
+              movedPostEJB.setForum(target);
+           }
+           // a finder will force the to flush the changes to the store
+           // per the specification 10.5.3 2.0 so we can use them safely
+           // then we update the last post field on the source
+           try
+           {
+              source.setLastPost(homes.post.findLastPost(source));
+           }
+           catch(ObjectNotFoundException e)
+           {
+              // no last post
+              source.setLastPost(null);
+           }
+           catch(FinderException e)
+           {
+              log.error("Cannot find last posts for the forum " + source.getId(), e);
+              return TYPE_CANNOT_MOVE_TOPIC;
+           }
+           // and the destination
+           try
+           {
+              target.setLastPost(homes.post.findLastPost(target));
+           }
+           catch(ObjectNotFoundException e)
+           {
+              target.setLastPost(null);
+              // no last post
+              // bad situation ???
+           }
+           catch(FinderException e)
+           {
+              log.error("Cannot find last posts for the forum " + source.getId(), e);
+              return TYPE_CANNOT_MOVE_TOPIC;
+           }
+           // now we update the fields
+           int replies = topic.getReplies();
+           source.setTopicSize(source.getTopicSize() - 1);
+           source.setPostSize(source.getPostSize() - 1 - replies);
+           target.setTopicSize(target.getTopicSize() + 1);
+           target.setPostSize(target.getPostSize() + replies + 1);
+           //
+           if (leaveShadow)
+           {
+     //                        $sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id)
+     //                           VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)";
+     //                        if ( !$db->sql_query($sql) )
+     //                        {
+     //                           message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
+     //                        }
+                 // todo
+     //                           TopicEJBLocal shadowEJB = topicHome.create(
+     //                                   movedEJB.getTitle(),
+     //                                   movedEJB.getPoster(),
+     //                                   movedEJB.getCreationDate(),
+     //                                   sourceForumEJB,
+     //                                   TOPIC_MOVED,
+     //                                   POST_NORMAL,
+     //                                   movedEJB.getVote()
+     //                           );
+              }
+           }
+     //                  // Sync the forum indexes
+     //                  sync('forum', $new_forum_id);
+     //                  sync('forum', $old_forum_id);
+     //               message = "${bb.Topics_moved}<br/><br/>";
+           return TYPE_TOPIC_MOVED;
+        }
+   */
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/SplitTopicCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/SplitTopicCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/moderation/SplitTopicCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,159 +1,159 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.moderation;
-
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.impl.TopicImpl;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.core.modules.ModuleException;
-
-import java.util.Iterator;
-import java.util.Collection;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-public class SplitTopicCommand extends AbstractCommand
-{
-   public Integer topicId;
-   public Integer destinationForumId;
-   public Collection postIds;
-   public String userId;
-   Forum destForum;
-   Topic newTopic;
-   Topic orgTopic;
-   public String newSubject;
-   public ForumsModule module;
-   public boolean splitAfter = false;
-
-   public SplitTopicCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-
-   public Result execute() throws CommandException
-   {
-
-      try
-      {
-         //get destination forum
-         destForum = module.findForumById(destinationForumId);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         return TYPE_NO_SUCH_FORUM;
-      }
-      try
-      {
-         // and topic to get posts from
-         orgTopic = module.findTopicById(topicId);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         return TYPE_NO_SUCH_TOPIC;
-      }
-
-      //create new topic
-      newTopic = new TopicImpl();
-      /*try
-      {
-         newTopic.setPoster(module.createPoster(userId));
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         //TODO: some nice error message
-         //TODO: should I return and not proceed.
-      }*/
-      //TODO: lastPostDate
-      /* newTopic.setLastPostDate(orgTopic.getLastPostDate());
-      newTopic.setType(orgTopic.getType());
-      newTopic.setStatus(orgTopic.getStatus());
-      newTopic.setSubject(newSubject);*/
-      //TODO: clone watches
-
-      try
-      {
-         newTopic = module.createTopic(orgTopic.getForum(), userId, newSubject, orgTopic.getType());
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         //TODO: error message and escape...
-      }
-
-      //case we put selected posts into new topic
-      if (!splitAfter)
-      {
-         for (Iterator i = postIds.iterator(); i.hasNext();)
-         {
-            Integer pid = (Integer)i.next();
-            Post post = null;
-            try
-            {
-               post = module.findPostById(pid);
-            }
-            catch (ModuleException e)
-            {
-               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-               return TYPE_NO_SUCH_TOPIC;
-            }
-            //with hibernate parent/child rel. post will be automaticly removed from previouse topic posts collection
-            newTopic.addPost(post);
-         }
-      }
-      //case we split topic after selected post
-      else if (postIds.size() > 0)
-      {
-         Integer pid = (Integer)postIds.iterator().next();
-         Iterator i = orgTopic.getPosts().iterator();
-         Post post = null;
-         for (; i.hasNext();)
-         {
-            post = (Post)i.next();
-            //we try to find post to split after
-            if (post.getId().equals(pid))
-            {
-               break;
-            }
-         }
-         //and move this post and all after it to new topic
-         if (post != null)
-         {
-            newTopic.addPost(post);
-         }
-         while (i.hasNext())
-         {
-            newTopic.addPost((Post)i.next());
-         }
-      }
-      //add new topic to dest forum
-      destForum.addTopic(newTopic);
-
-      newTopic.setLastPostDate(newTopic.getLastPost().getCreateDate());
-      return TYPE_TOPIC_SPLITED;  //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.moderation;
+
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.impl.TopicImpl;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.core.modules.ModuleException;
+
+import java.util.Iterator;
+import java.util.Collection;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.4 $
+ */
+public class SplitTopicCommand extends AbstractCommand
+{
+   public Integer topicId;
+   public Integer destinationForumId;
+   public Collection postIds;
+   public String userId;
+   Forum destForum;
+   Topic newTopic;
+   Topic orgTopic;
+   public String newSubject;
+   public ForumsModule module;
+   public boolean splitAfter = false;
+
+   public SplitTopicCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+
+   public Result execute() throws CommandException
+   {
+
+      try
+      {
+         //get destination forum
+         destForum = module.findForumById(destinationForumId);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         return TYPE_NO_SUCH_FORUM;
+      }
+      try
+      {
+         // and topic to get posts from
+         orgTopic = module.findTopicById(topicId);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         return TYPE_NO_SUCH_TOPIC;
+      }
+
+      //create new topic
+      newTopic = new TopicImpl();
+      /*try
+      {
+         newTopic.setPoster(module.createPoster(userId));
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         //TODO: some nice error message
+         //TODO: should I return and not proceed.
+      }*/
+      //TODO: lastPostDate
+      /* newTopic.setLastPostDate(orgTopic.getLastPostDate());
+      newTopic.setType(orgTopic.getType());
+      newTopic.setStatus(orgTopic.getStatus());
+      newTopic.setSubject(newSubject);*/
+      //TODO: clone watches
+
+      try
+      {
+         newTopic = module.createTopic(orgTopic.getForum(), userId, newSubject, orgTopic.getType());
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         //TODO: error message and escape...
+      }
+
+      //case we put selected posts into new topic
+      if (!splitAfter)
+      {
+         for (Iterator i = postIds.iterator(); i.hasNext();)
+         {
+            Integer pid = (Integer)i.next();
+            Post post = null;
+            try
+            {
+               post = module.findPostById(pid);
+            }
+            catch (ModuleException e)
+            {
+               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+               return TYPE_NO_SUCH_TOPIC;
+            }
+            //with hibernate parent/child rel. post will be automaticly removed from previouse topic posts collection
+            newTopic.addPost(post);
+         }
+      }
+      //case we split topic after selected post
+      else if (postIds.size() > 0)
+      {
+         Integer pid = (Integer)postIds.iterator().next();
+         Iterator i = orgTopic.getPosts().iterator();
+         Post post = null;
+         for (; i.hasNext();)
+         {
+            post = (Post)i.next();
+            //we try to find post to split after
+            if (post.getId().equals(pid))
+            {
+               break;
+            }
+         }
+         //and move this post and all after it to new topic
+         if (post != null)
+         {
+            newTopic.addPost(post);
+         }
+         while (i.hasNext())
+         {
+            newTopic.addPost((Post)i.next());
+         }
+      }
+      //add new topic to dest forum
+      destForum.addTopic(newTopic);
+
+      newTopic.setLastPostDate(newTopic.getLastPost().getCreateDate());
+      return TYPE_TOPIC_SPLITED;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePollCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePollCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePollCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,97 +1,97 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.commands.ValidationException;
-import org.jboss.portlet.forums.model.AuthType;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.5 $
- */
-public class DeletePollCommand
-   extends PostCommand
-{
-
-   public DeletePollCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int authType()
-   {
-      return AuthType.DELETE;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws ValidationException DOCUMENT_ME
-    */
-   protected void prepare()
-      throws ValidationException
-   {
-      /*      super.prepare();
-         if (!isAuthMod)
-         {
-            throw new ValidationException(TYPE_CANNOT_DELETE_POLL);
-         }
-       */
-      try
-      {
-         Integer tid = forumsModule.findPostById(new Integer(postId)).getTopic().getId();
-         topic = forumsModule.findTopicById(tid);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   protected Result __execute()
-   {
-      /*      try
-         {
-            topic.getPoll().remove();
-            topic.setVote(false);
-         }
-         catch(RemoveException e)
-         {
-            log.error("Cannot remove poll", e);
-            return TYPE_ERROR_IN_DELETING_POLL;
-         }
-       */
-      try
-      {
-         forumsModule.removePollInTopic(topic);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-      return TYPE_POLL_DELETED;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.commands.ValidationException;
+import org.jboss.portlet.forums.model.AuthType;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.5 $
+ */
+public class DeletePollCommand
+   extends PostCommand
+{
+
+   public DeletePollCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int authType()
+   {
+      return AuthType.DELETE;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws ValidationException DOCUMENT_ME
+    */
+   protected void prepare()
+      throws ValidationException
+   {
+      /*      super.prepare();
+         if (!isAuthMod)
+         {
+            throw new ValidationException(TYPE_CANNOT_DELETE_POLL);
+         }
+       */
+      try
+      {
+         Integer tid = forumsModule.findPostById(new Integer(postId)).getTopic().getId();
+         topic = forumsModule.findTopicById(tid);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected Result __execute()
+   {
+      /*      try
+         {
+            topic.getPoll().remove();
+            topic.setVote(false);
+         }
+         catch(RemoveException e)
+         {
+            log.error("Cannot remove poll", e);
+            return TYPE_ERROR_IN_DELETING_POLL;
+         }
+       */
+      try
+      {
+         forumsModule.removePollInTopic(topic);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+      return TYPE_POLL_DELETED;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePostCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePostCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/DeletePostCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,146 +1,146 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.result.SimpleResult;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.commands.ValidationException;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.AuthType;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.7 $
- */
-public class DeletePostCommand
-   extends PostCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean pd_first_post;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean pd_last_post;
-
-   public DeletePostCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int authType()
-   {
-      return AuthType.DELETE;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws ValidationException DOCUMENT_ME
-    */
-   protected void prepare()
-      throws ValidationException
-   {
-      super.prepare();
-/*
-         if (!isAuthMod && !EJB.areIdentical(post..getPoster().getUser(), getPoster().getUser()))
-         {
-            throw new ValidationException(TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR);
-         }
-         if (!pd_last_post && !isAuthMod)
-         {
-            throw new ValidationException(TYPE_CANNOT_DELETE_REPLIED);
-         }
-
-*/
-      pd_first_post = topic.getFirstPost().getId().intValue() == post.getId().intValue();
-      pd_last_post = topic.getLastPost().getId().intValue() == post.getId().intValue();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   protected Result __execute()
-   {
-      try
-      {
-         Integer postId = post.getId();
-         if (pd_last_post && pd_first_post)
-         {
-            // cascade delete will take care of removing
-            // the post
-            // the watches
-            // the poll
-            // the links
-
-            //topic.setFirstPost(null);
-            //topic.setLastPost(null);
-            //forum.setLastPost(null);
-            //forumsModule.removePost(post);
-            forumsModule.removeTopic(post.getTopic());
-            forum.setPostCount(forum.getPostCount() - 1);
-            forum.setTopicCount(forum.getTopicCount() - 1);
-            //forum.setLastPost(forumsModule.findLastPost(forum));
-         }
-         else
-         {
-
-            /*if(pd_last_post)
-            {
-               topic.setLastPost(null);
-               forum.setLastPost(null);
-            }*/
-            /*if(pd_first_post)
-            {
-               topic.setFirstPost(null);
-            }*/
-            forumsModule.removePost(post);
-            topic.setReplies(topic.getReplies() - 1);
-            forum.setPostCount(forum.getPostCount() - 1);
-            /*if (pd_first_post)
-            {
-               topic.setFirstPost(forumsModule.findFirstPost(topic));
-            }*/
-            //else if
-            if (pd_last_post)
-            {
-               Post lastPost = forumsModule.findLastPost(topic);
-               //topic.setLastPost(lastPost);
-               topic.setLastPostDate(lastPost.getCreateDate());
-               //forum.setLastPost(forumsModule.findLastPost(topic));
-
-            }
-         }
-         SimpleResult result = new SimpleResult(TYPE_POST_DELETED);
-         result.put("POST_ID", postId);
-         return result;
-      }
-      catch (ModuleException e)
-      {
-         log.error("Error in removing post", e);
-         return TYPE_ERROR_IN_DELETING_POST;
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.result.SimpleResult;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.commands.ValidationException;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.AuthType;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.7 $
+ */
+public class DeletePostCommand
+   extends PostCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean pd_first_post;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean pd_last_post;
+
+   public DeletePostCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int authType()
+   {
+      return AuthType.DELETE;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws ValidationException DOCUMENT_ME
+    */
+   protected void prepare()
+      throws ValidationException
+   {
+      super.prepare();
+/*
+         if (!isAuthMod && !EJB.areIdentical(post..getPoster().getUser(), getPoster().getUser()))
+         {
+            throw new ValidationException(TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR);
+         }
+         if (!pd_last_post && !isAuthMod)
+         {
+            throw new ValidationException(TYPE_CANNOT_DELETE_REPLIED);
+         }
+
+*/
+      pd_first_post = topic.getFirstPost().getId().intValue() == post.getId().intValue();
+      pd_last_post = topic.getLastPost().getId().intValue() == post.getId().intValue();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected Result __execute()
+   {
+      try
+      {
+         Integer postId = post.getId();
+         if (pd_last_post && pd_first_post)
+         {
+            // cascade delete will take care of removing
+            // the post
+            // the watches
+            // the poll
+            // the links
+
+            //topic.setFirstPost(null);
+            //topic.setLastPost(null);
+            //forum.setLastPost(null);
+            //forumsModule.removePost(post);
+            forumsModule.removeTopic(post.getTopic());
+            forum.setPostCount(forum.getPostCount() - 1);
+            forum.setTopicCount(forum.getTopicCount() - 1);
+            //forum.setLastPost(forumsModule.findLastPost(forum));
+         }
+         else
+         {
+
+            /*if(pd_last_post)
+            {
+               topic.setLastPost(null);
+               forum.setLastPost(null);
+            }*/
+            /*if(pd_first_post)
+            {
+               topic.setFirstPost(null);
+            }*/
+            forumsModule.removePost(post);
+            topic.setReplies(topic.getReplies() - 1);
+            forum.setPostCount(forum.getPostCount() - 1);
+            /*if (pd_first_post)
+            {
+               topic.setFirstPost(forumsModule.findFirstPost(topic));
+            }*/
+            //else if
+            if (pd_last_post)
+            {
+               Post lastPost = forumsModule.findLastPost(topic);
+               //topic.setLastPost(lastPost);
+               topic.setLastPostDate(lastPost.getCreateDate());
+               //forum.setLastPost(forumsModule.findLastPost(topic));
+
+            }
+         }
+         SimpleResult result = new SimpleResult(TYPE_POST_DELETED);
+         result.put("POST_ID", postId);
+         return result;
+      }
+      catch (ModuleException e)
+      {
+         log.error("Error in removing post", e);
+         return TYPE_ERROR_IN_DELETING_POST;
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/EditPostCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/EditPostCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/EditPostCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,398 +1,398 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-import java.util.*;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.commands.ValidationException;
-import org.jboss.portlet.forums.model.AuthType;
-import org.jboss.portlet.forums.model.PollOption;
-import org.jboss.portlet.forums.model.Attachment;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at users.sourceforge.net">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.7 $
- */
-public class EditPostCommand
-   extends PostCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public int topic_type;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Date current_time;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean notify;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean poll_delete;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean pd_first_post;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean pd_last_post;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean pd_edit_poll;
-
-   /**
-    * DOCUMENT_ME
-    */
-   //public Integer[] deletedAttachments;
-   public List deletedAttachments;
-
-   public Map updatedAttachments;
-
-   public EditPostCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int authType()
-   {
-      return AuthType.EDIT;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws ValidationException DOCUMENT_ME
-    */
-   protected void prepare()
-      throws ValidationException
-   {
-      /*
-         super.prepare();
-         if (!isAuthMod && !EJB.areIdentical(post.getUser(), getPoster().getUser()))
-         {
-            throw new ValidationException(TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR);
-         }
-         pd_first_post = EJB.areIdentical(topic.getFirstPost(), post);
-         pd_last_post = EJB.areIdentical(topic.getLastPost(), post);
-         if (pd_first_post)
-         {
-            // Same in BBModule
-            switch (topic.getPollLevel())
-            {
-            case TopicEJB.POLL_LEVEL_EMPTY:
-               pd_edit_poll = isAuthPollCreate || isAuthMod;
-               break;
-            case TopicEJB.POLL_LEVEL_NO_POLL:
-               pd_edit_poll = isAuthPollCreate || isAuthMod;
-               break;
-            case TopicEJB.POLL_LEVEL_NON_EMPTY:
-               pd_edit_poll = isAuthMod;
-               break;
-            }
-         }
-         if (!isAuthMod && getPoster() != null)
-         {
-            poster.setUserName(getPoster().getUserName());
-         }
-         if (deletedAttachments.length > 0 && !(isAuthMod || isAuthAttachments))
-         {
-            throw new ValidationException(TYPE_CANNOT_DELETE_ATTACHMENT);
-         }
-         PostTools.validate(message);
-         PostTools.validate(poll);
-       */
-      /*pd_first_post = topic.getFirstPost().getId().intValue() == post.getId().intValue();
-  pd_last_post = topic.getLastPost().getId().intValue() == post.getId().intValue();*/
-
-      try
-      {
-         Integer tid = forumsModule.findPostById(new Integer(postId)).getTopic().getId();
-         topic = forumsModule.findTopicById(tid);
-         Integer fpid = topic.getFirstPost().getId();
-         pd_first_post = postId == fpid.intValue();
-
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   protected Result __execute()
-   {
-      if (pd_first_post && (topic.getPoll() != null))
-      {
-         topic.setSubject(message.getSubject());
-         topic.setType(topic_type);
-         //topic.getPoll().setLength(poll.getLength());
-         //topic.getPoll().setTitle(poll.getTitle());
-
-         //topic.getPoll().setOptions(poll.getOptions());
-         Iterator npoi = poll.getOptions().iterator();
-         Iterator opoi = topic.getPoll().getOptions().iterator();
-         List newopts = new LinkedList();
-         if (!npoi.hasNext())
-         {
-            topic.setPoll(null);
-         }
-         else
-         {
-            poll.setVoted(topic.getPoll().getVoted());
-            poll.setCreationDate(topic.getPoll().getCreationDate());
-            while (npoi.hasNext() && opoi.hasNext())
-            {
-               PollOption newPollOption = (PollOption)npoi.next();
-               PollOption oldPollOption = (PollOption)opoi.next();
-               newPollOption.setVotes(oldPollOption.getVotes());
-            }
-            /*while (opoi.hasNext())
-            {
-               PollOption oldPollOption = (PollOption) opoi.next();
-               poll.getOptions().add(oldPollOption);
-            }*/
-            try
-            {
-               forumsModule.addPollToTopic(topic, poll);
-            }
-            catch (ModuleException e)
-            {
-               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            }
-         }
-      }
-      else if (pd_first_post && (topic.getPoll() == null) && (poll.getOptions().size() != 0))
-      {
-         try
-         {
-            /*Poll p = new PollImpl();
-            p.setCreationDate(poll.getCreationDate());*/
-            topic.setSubject(message.getSubject());
-            topic.setType(topic_type);
-            forumsModule.addPollToTopic(topic, poll);
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         }
-      }
-      else if (pd_first_post)
-      {
-         topic.setSubject(message.getSubject());
-         topic.setType(topic_type);
-      }
-
-      //      post.setPosterUserName(poster.getUsername());
-      try
-      {
-         post = forumsModule.findPostById(new Integer(postId));
-      }
-      catch (ModuleException e)
-      {
-         System.out.println("Probably post not found...");
-         e.printStackTrace();
-      }
-      if (post == null)
-      {
-         System.out.println("Critical Error - this shouldn't happened - post to edit is null");
-         return TYPE_NO_SUCH_POST;
-      }
-
-
-      post.setMessage(message);
-      post.setEditCount(post.getEditCount() + 1);
-      post.setEditDate(new Date());
-      //remove existing attachments + update comments
-      attachmentsLoop: for(Iterator i = post.getAttachments().iterator();i.hasNext();)
-      {
-         Attachment attachment = (Attachment)i.next();
-         for(Iterator j = deletedAttachments.iterator();j.hasNext();)
-         {
-            Integer index = (Integer)j.next();
-            if(attachment.getId().intValue() == index.intValue())
-            {
-               i.remove();
-               continue attachmentsLoop;
-            }
-         }
-         for(Iterator j = updatedAttachments.keySet().iterator();j.hasNext();)
-         {
-            Integer index = (Integer)j.next();
-            if(attachment.getId().intValue() == index.intValue())
-            {
-               attachment.setComment((String)updatedAttachments.get(index));
-               break;
-            }
-         }
-      }
-      //and add new uploaded files
-      for (Iterator i = attachments.iterator();i.hasNext(); )
-      {
-         post.addAttachment((Attachment)i.next());
-      }
-
-
-
-
-      /*
-        try
-        {
-           try
-           {
-              TopicWatch watch = homes.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(getPoster().getUser().getId(), topic.getId()));
-              if (!notify)
-              {
-                 watch.remove();
-              }
-           }
-           catch (ObjectNotFoundException e)
-           {
-              if (notify)
-              {
-                 homes.topicWatch.create(getPoster().getUser(), topic);
-              }
-           }
-        }
-        catch (Exception e)
-        {
-           log.error("Cannot get watch", e);
-           return TYPE_ERROR_IN_POSTING;
-        }
-        if (pd_last_post && EJB.areIdentical(post.getUser(), getPoster().getUser()))
-        {
-           post.setEditDate(current_time);
-           post.setEditCount(post.getEditCount() + 1);
-        }
-        try
-        {
-           if (pd_edit_poll && poll.getTitle() != null && poll.getOptions().size() >= 2)
-           {
-              // Get the poll
-              PollEJBLocal pollEJB = topic.getPoll();
-              //
-              String pollTitle = poll.getTitle();
-              int pollLength = poll.getLength();
-              // Update infos
-              pollEJB.setText(pollTitle);
-              pollEJB.setLength(pollLength);
-              // Update the options
-              Collection options = homes.option.findByPoll(pollEJB);
-              for (IndexIterator iterator = IndexIterator.wrap(options.iterator(), -1);iterator.hasNext();)
-              {
-                 OptionEJBLocal optionEJB = (OptionEJBLocal)iterator.next();
-                 int index = iterator.getIndex();
-                 if (index < poll.getOptions().size())
-                 {
-                    String text = (String)poll.getOptions().get(index);
-                    if (text != null)
-                    {
-                       // $option_text = str_replace("\'", "''", htmlspecialchars($option_text));
-                       optionEJB.setText(text);
-                    }
-                    else
-                    {
-                       optionEJB.remove();
-                    }
-                 }
-                 else
-                 {
-                    optionEJB.remove();
-                 }
-              }
-              topic.setVote(true);
-           }
-           else
-           {
-              topic.setVote(false);
-           }
-        }
-        catch (FinderException e)
-        {
-           log.error("Cannot find options for a poll", e);
-           return TYPE_ERROR_IN_POSTING;
-        }
-        catch (RemoveException e)
-        {
-           log.error("Cannot remove target option", e);
-           return TYPE_ERROR_IN_POSTING;
-        }
-        try
-        {
-           // Remove deleted attachments
-           for (Iterator i = post.getAttachments().iterator();i.hasNext();)
-           {
-              AttachmentEJBLocal attachment = (AttachmentEJBLocal)i.next();
-              Integer id = attachment.getId();
-              for (int j = 0;j < deletedAttachments.length;j++)
-              {
-                 if (id.equals(deletedAttachments[j]))
-                 {
-                    i.remove();
-                    attachment.remove();
-                 }
-              }
-           }
-        }
-        catch (RemoveException e)
-        {
-           log.error("Cannot remove attachment", e);
-           return TYPE_ERROR_IN_POSTING;
-        }
-        try
-        {
-           // Add attachments
-           for (int i = 0;i < attachments.length;i++)
-           {
-              UploadedFile attachment = attachments[i];
-              homes.attachment.create(post,
-                    attachment.getFile().getName(),
-                    attachment.getFile().getContent(),
-                    attachment.getComment(),
-                    attachment.getFile().getContentType(),
-                    attachment.getFile().getSize(),
-                    current_time);
-           }
-        }
-        catch (CreateException e)
-        {
-           log.error("Cannot insert attachment", e);
-           return TYPE_ERROR_IN_POSTING;
-        }
-      */
-      return TYPE_EDIT_POST_POSTED;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+import java.util.*;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.commands.ValidationException;
+import org.jboss.portlet.forums.model.AuthType;
+import org.jboss.portlet.forums.model.PollOption;
+import org.jboss.portlet.forums.model.Attachment;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at users.sourceforge.net">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.7 $
+ */
+public class EditPostCommand
+   extends PostCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public int topic_type;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Date current_time;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean notify;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean poll_delete;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean pd_first_post;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean pd_last_post;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean pd_edit_poll;
+
+   /**
+    * DOCUMENT_ME
+    */
+   //public Integer[] deletedAttachments;
+   public List deletedAttachments;
+
+   public Map updatedAttachments;
+
+   public EditPostCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int authType()
+   {
+      return AuthType.EDIT;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws ValidationException DOCUMENT_ME
+    */
+   protected void prepare()
+      throws ValidationException
+   {
+      /*
+         super.prepare();
+         if (!isAuthMod && !EJB.areIdentical(post.getUser(), getPoster().getUser()))
+         {
+            throw new ValidationException(TYPE_CANNOT_XXX_OTHER_POST_WHEN_NOT_MODERATOR);
+         }
+         pd_first_post = EJB.areIdentical(topic.getFirstPost(), post);
+         pd_last_post = EJB.areIdentical(topic.getLastPost(), post);
+         if (pd_first_post)
+         {
+            // Same in BBModule
+            switch (topic.getPollLevel())
+            {
+            case TopicEJB.POLL_LEVEL_EMPTY:
+               pd_edit_poll = isAuthPollCreate || isAuthMod;
+               break;
+            case TopicEJB.POLL_LEVEL_NO_POLL:
+               pd_edit_poll = isAuthPollCreate || isAuthMod;
+               break;
+            case TopicEJB.POLL_LEVEL_NON_EMPTY:
+               pd_edit_poll = isAuthMod;
+               break;
+            }
+         }
+         if (!isAuthMod && getPoster() != null)
+         {
+            poster.setUserName(getPoster().getUserName());
+         }
+         if (deletedAttachments.length > 0 && !(isAuthMod || isAuthAttachments))
+         {
+            throw new ValidationException(TYPE_CANNOT_DELETE_ATTACHMENT);
+         }
+         PostTools.validate(message);
+         PostTools.validate(poll);
+       */
+      /*pd_first_post = topic.getFirstPost().getId().intValue() == post.getId().intValue();
+  pd_last_post = topic.getLastPost().getId().intValue() == post.getId().intValue();*/
+
+      try
+      {
+         Integer tid = forumsModule.findPostById(new Integer(postId)).getTopic().getId();
+         topic = forumsModule.findTopicById(tid);
+         Integer fpid = topic.getFirstPost().getId();
+         pd_first_post = postId == fpid.intValue();
+
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected Result __execute()
+   {
+      if (pd_first_post && (topic.getPoll() != null))
+      {
+         topic.setSubject(message.getSubject());
+         topic.setType(topic_type);
+         //topic.getPoll().setLength(poll.getLength());
+         //topic.getPoll().setTitle(poll.getTitle());
+
+         //topic.getPoll().setOptions(poll.getOptions());
+         Iterator npoi = poll.getOptions().iterator();
+         Iterator opoi = topic.getPoll().getOptions().iterator();
+         List newopts = new LinkedList();
+         if (!npoi.hasNext())
+         {
+            topic.setPoll(null);
+         }
+         else
+         {
+            poll.setVoted(topic.getPoll().getVoted());
+            poll.setCreationDate(topic.getPoll().getCreationDate());
+            while (npoi.hasNext() && opoi.hasNext())
+            {
+               PollOption newPollOption = (PollOption)npoi.next();
+               PollOption oldPollOption = (PollOption)opoi.next();
+               newPollOption.setVotes(oldPollOption.getVotes());
+            }
+            /*while (opoi.hasNext())
+            {
+               PollOption oldPollOption = (PollOption) opoi.next();
+               poll.getOptions().add(oldPollOption);
+            }*/
+            try
+            {
+               forumsModule.addPollToTopic(topic, poll);
+            }
+            catch (ModuleException e)
+            {
+               e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+         }
+      }
+      else if (pd_first_post && (topic.getPoll() == null) && (poll.getOptions().size() != 0))
+      {
+         try
+         {
+            /*Poll p = new PollImpl();
+            p.setCreationDate(poll.getCreationDate());*/
+            topic.setSubject(message.getSubject());
+            topic.setType(topic_type);
+            forumsModule.addPollToTopic(topic, poll);
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         }
+      }
+      else if (pd_first_post)
+      {
+         topic.setSubject(message.getSubject());
+         topic.setType(topic_type);
+      }
+
+      //      post.setPosterUserName(poster.getUsername());
+      try
+      {
+         post = forumsModule.findPostById(new Integer(postId));
+      }
+      catch (ModuleException e)
+      {
+         System.out.println("Probably post not found...");
+         e.printStackTrace();
+      }
+      if (post == null)
+      {
+         System.out.println("Critical Error - this shouldn't happened - post to edit is null");
+         return TYPE_NO_SUCH_POST;
+      }
+
+
+      post.setMessage(message);
+      post.setEditCount(post.getEditCount() + 1);
+      post.setEditDate(new Date());
+      //remove existing attachments + update comments
+      attachmentsLoop: for(Iterator i = post.getAttachments().iterator();i.hasNext();)
+      {
+         Attachment attachment = (Attachment)i.next();
+         for(Iterator j = deletedAttachments.iterator();j.hasNext();)
+         {
+            Integer index = (Integer)j.next();
+            if(attachment.getId().intValue() == index.intValue())
+            {
+               i.remove();
+               continue attachmentsLoop;
+            }
+         }
+         for(Iterator j = updatedAttachments.keySet().iterator();j.hasNext();)
+         {
+            Integer index = (Integer)j.next();
+            if(attachment.getId().intValue() == index.intValue())
+            {
+               attachment.setComment((String)updatedAttachments.get(index));
+               break;
+            }
+         }
+      }
+      //and add new uploaded files
+      for (Iterator i = attachments.iterator();i.hasNext(); )
+      {
+         post.addAttachment((Attachment)i.next());
+      }
+
+
+
+
+      /*
+        try
+        {
+           try
+           {
+              TopicWatch watch = homes.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(getPoster().getUser().getId(), topic.getId()));
+              if (!notify)
+              {
+                 watch.remove();
+              }
+           }
+           catch (ObjectNotFoundException e)
+           {
+              if (notify)
+              {
+                 homes.topicWatch.create(getPoster().getUser(), topic);
+              }
+           }
+        }
+        catch (Exception e)
+        {
+           log.error("Cannot get watch", e);
+           return TYPE_ERROR_IN_POSTING;
+        }
+        if (pd_last_post && EJB.areIdentical(post.getUser(), getPoster().getUser()))
+        {
+           post.setEditDate(current_time);
+           post.setEditCount(post.getEditCount() + 1);
+        }
+        try
+        {
+           if (pd_edit_poll && poll.getTitle() != null && poll.getOptions().size() >= 2)
+           {
+              // Get the poll
+              PollEJBLocal pollEJB = topic.getPoll();
+              //
+              String pollTitle = poll.getTitle();
+              int pollLength = poll.getLength();
+              // Update infos
+              pollEJB.setText(pollTitle);
+              pollEJB.setLength(pollLength);
+              // Update the options
+              Collection options = homes.option.findByPoll(pollEJB);
+              for (IndexIterator iterator = IndexIterator.wrap(options.iterator(), -1);iterator.hasNext();)
+              {
+                 OptionEJBLocal optionEJB = (OptionEJBLocal)iterator.next();
+                 int index = iterator.getIndex();
+                 if (index < poll.getOptions().size())
+                 {
+                    String text = (String)poll.getOptions().get(index);
+                    if (text != null)
+                    {
+                       // $option_text = str_replace("\'", "''", htmlspecialchars($option_text));
+                       optionEJB.setText(text);
+                    }
+                    else
+                    {
+                       optionEJB.remove();
+                    }
+                 }
+                 else
+                 {
+                    optionEJB.remove();
+                 }
+              }
+              topic.setVote(true);
+           }
+           else
+           {
+              topic.setVote(false);
+           }
+        }
+        catch (FinderException e)
+        {
+           log.error("Cannot find options for a poll", e);
+           return TYPE_ERROR_IN_POSTING;
+        }
+        catch (RemoveException e)
+        {
+           log.error("Cannot remove target option", e);
+           return TYPE_ERROR_IN_POSTING;
+        }
+        try
+        {
+           // Remove deleted attachments
+           for (Iterator i = post.getAttachments().iterator();i.hasNext();)
+           {
+              AttachmentEJBLocal attachment = (AttachmentEJBLocal)i.next();
+              Integer id = attachment.getId();
+              for (int j = 0;j < deletedAttachments.length;j++)
+              {
+                 if (id.equals(deletedAttachments[j]))
+                 {
+                    i.remove();
+                    attachment.remove();
+                 }
+              }
+           }
+        }
+        catch (RemoveException e)
+        {
+           log.error("Cannot remove attachment", e);
+           return TYPE_ERROR_IN_POSTING;
+        }
+        try
+        {
+           // Add attachments
+           for (int i = 0;i < attachments.length;i++)
+           {
+              UploadedFile attachment = attachments[i];
+              homes.attachment.create(post,
+                    attachment.getFile().getName(),
+                    attachment.getFile().getContent(),
+                    attachment.getComment(),
+                    attachment.getFile().getContentType(),
+                    attachment.getFile().getSize(),
+                    current_time);
+           }
+        }
+        catch (CreateException e)
+        {
+           log.error("Cannot insert attachment", e);
+           return TYPE_ERROR_IN_POSTING;
+        }
+      */
+      return TYPE_EDIT_POST_POSTED;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ForumCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ForumCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ForumCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,259 +1,259 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.commands.AbstractCommand;
-import org.jboss.portlet.forums.commands.ValidationException;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at users.sourceforge.net">Thomas Heute</a>
- * @version $Revision: 1.7 $
- */
-public abstract class ForumCommand
-   extends AbstractCommand
-{
-
-   protected ForumCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /*
-      public Homes homes;
-      public Level level;
-      public boolean isAuth;
-      public boolean isAuthRead;
-      public boolean isAuthDelete;
-      public boolean isAuthSticky;
-      public boolean isAuthAnnounce;
-      public boolean isAuthPollCreate;
-      public boolean isAuthMod;
-      public boolean isAuthAttachments;
-    */
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int forumId;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public User currentUser;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Forum forum;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Category category;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Poster poster;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Message message;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Poll poll;
-
-   //   public UploadedFile[] attachments;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public ForumsModule forumsModule;
-   private String category_title;
-   private String forum_name;
-   private int forum_status;
-
-   /**
-    * DOCUMENT_ME
-    */
-   protected void find()
-   {
-      try
-      {
-         forum = forumsModule.findForumById(new Integer(forumId));
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-      category = forum.getCategory();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws ValidationException DOCUMENT_ME
-    */
-   protected void prepare()
-      throws ValidationException
-   {
-      find();
-      category_title = category.getTitle();
-      forum_status = forum.getStatus();
-      forum_name = forum.getName();
-
-      //      level = module.secGetLevel(category_title + ":" + forum_name + ":", currentUser);
-      // boolean loggedIn = getPoster().getUser() != null;
-
-      /*
-         int[] types = new int[] {
-         authType(),
-         Auth.TYPE_READ,
-         Auth.TYPE_DELETE,
-         Auth.TYPE_STICKY,
-         Auth.TYPE_ANNOUNCE,
-         Auth.TYPE_POLL,
-         Auth.TYPE_ATTACH };
-         boolean[] auths =forum.getAuth().can(types, loggedIn, level);
-         isAuth = auths[0];
-         isAuthRead = auths[1];
-         isAuthDelete = auths[2];
-         isAuthSticky = auths[3];
-         isAuthAnnounce = auths[4];
-         isAuthPollCreate = auths[5];
-         isAuthAttachments = auths[6];
-         isAuthMod = Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
-         //
-         if (forum_status == BBConstants.FORUM_LOCKED && !isAuthMod)
-         {
-         throw new ValidationException(TYPE_FORUM_LOCKED);
-         }
-         //
-         if (!isAuth)
-         {
-         throw new ValidationException(TYPE_NOT_AUTHORIZED);
-         }
-         // Should not be here, maybe the inheritance heirarchy is not good
-         if (attachments != null && attachments.length > 0 && !(isAuthMod || isAuthAttachments))
-         {
-         throw new ValidationException(TYPE_CANNOT_ADD_ATTACHMENT);
-         }
-       */
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result execute()
-   {
-      try
-      {
-         prepare();
-         return __execute();
-      }
-      catch (ValidationException e)
-      {
-         return e.getResult();
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public abstract int authType();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   protected abstract Result __execute();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public User currentUser()
-   {
-      return currentUser;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param currentUser DOCUMENT_ME
-    */
-   public void setCurrentUser(User currentUser)
-   {
-      this.currentUser = currentUser;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Poster getPoster()
-   {
-      return poster;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param poster DOCUMENT_ME
-    */
-   public void setPoster(Poster poster)
-   {
-      this.poster = poster;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public ForumsModule getModule()
-   {
-      return forumsModule;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param module DOCUMENT_ME
-    */
-   public void setModule(ForumsModule module)
-   {
-      this.forumsModule = module;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.commands.AbstractCommand;
+import org.jboss.portlet.forums.commands.ValidationException;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Poll;
+import org.jboss.portlet.forums.model.Poster;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at users.sourceforge.net">Thomas Heute</a>
+ * @version $Revision: 1.7 $
+ */
+public abstract class ForumCommand
+   extends AbstractCommand
+{
+
+   protected ForumCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /*
+      public Homes homes;
+      public Level level;
+      public boolean isAuth;
+      public boolean isAuthRead;
+      public boolean isAuthDelete;
+      public boolean isAuthSticky;
+      public boolean isAuthAnnounce;
+      public boolean isAuthPollCreate;
+      public boolean isAuthMod;
+      public boolean isAuthAttachments;
+    */
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int forumId;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public User currentUser;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Forum forum;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Category category;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Poster poster;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Message message;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Poll poll;
+
+   //   public UploadedFile[] attachments;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public ForumsModule forumsModule;
+   private String category_title;
+   private String forum_name;
+   private int forum_status;
+
+   /**
+    * DOCUMENT_ME
+    */
+   protected void find()
+   {
+      try
+      {
+         forum = forumsModule.findForumById(new Integer(forumId));
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+      category = forum.getCategory();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws ValidationException DOCUMENT_ME
+    */
+   protected void prepare()
+      throws ValidationException
+   {
+      find();
+      category_title = category.getTitle();
+      forum_status = forum.getStatus();
+      forum_name = forum.getName();
+
+      //      level = module.secGetLevel(category_title + ":" + forum_name + ":", currentUser);
+      // boolean loggedIn = getPoster().getUser() != null;
+
+      /*
+         int[] types = new int[] {
+         authType(),
+         Auth.TYPE_READ,
+         Auth.TYPE_DELETE,
+         Auth.TYPE_STICKY,
+         Auth.TYPE_ANNOUNCE,
+         Auth.TYPE_POLL,
+         Auth.TYPE_ATTACH };
+         boolean[] auths =forum.getAuth().can(types, loggedIn, level);
+         isAuth = auths[0];
+         isAuthRead = auths[1];
+         isAuthDelete = auths[2];
+         isAuthSticky = auths[3];
+         isAuthAnnounce = auths[4];
+         isAuthPollCreate = auths[5];
+         isAuthAttachments = auths[6];
+         isAuthMod = Auth.hasLevel(Auth.LEVEL_MOD, loggedIn, level);
+         //
+         if (forum_status == BBConstants.FORUM_LOCKED && !isAuthMod)
+         {
+         throw new ValidationException(TYPE_FORUM_LOCKED);
+         }
+         //
+         if (!isAuth)
+         {
+         throw new ValidationException(TYPE_NOT_AUTHORIZED);
+         }
+         // Should not be here, maybe the inheritance heirarchy is not good
+         if (attachments != null && attachments.length > 0 && !(isAuthMod || isAuthAttachments))
+         {
+         throw new ValidationException(TYPE_CANNOT_ADD_ATTACHMENT);
+         }
+       */
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result execute()
+   {
+      try
+      {
+         prepare();
+         return __execute();
+      }
+      catch (ValidationException e)
+      {
+         return e.getResult();
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public abstract int authType();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected abstract Result __execute();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public User currentUser()
+   {
+      return currentUser;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param currentUser DOCUMENT_ME
+    */
+   public void setCurrentUser(User currentUser)
+   {
+      this.currentUser = currentUser;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Poster getPoster()
+   {
+      return poster;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param poster DOCUMENT_ME
+    */
+   public void setPoster(Poster poster)
+   {
+      this.poster = poster;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ForumsModule getModule()
+   {
+      return forumsModule;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param module DOCUMENT_ME
+    */
+   public void setModule(ForumsModule module)
+   {
+      this.forumsModule = module;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/NewTopicCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/NewTopicCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/NewTopicCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,161 +1,161 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.commands.ValidationException;
-import org.jboss.portlet.forums.model.Post;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at users.sourceforge.net">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.9 $
- */
-public final class NewTopicCommand
-   extends ForumCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public Date current_time;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int topic_type;
-
-   /**
-    * Notification when someone replies
-    */
-   public boolean notify;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Post post;
-
-   public List attachments;
-
-   public NewTopicCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int authType()
-   {
-      return ForumsConstants.TOPIC_TYPE_TO_AUTH_TYPE[topic_type];
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws ValidationException DOCUMENT_ME
-    */
-   protected void prepare()
-      throws ValidationException
-   {
-      super.prepare();
-      PostTools.validate(message);
-
-      //      PostTools.validate(poll);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   protected Result __execute()
-   {
-      try
-      {
-         post = forumsModule.createTopic(forum,
-            message,
-            new Date(),
-            poster,
-            poll,
-            attachments,
-            topic_type);
-         forumsModule.createWatch(poster, post.getTopic());
-         poster.incrementPostCount();
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-
-      /*
-         boolean topic_vote = poll.getTitle() != null && poll.getOptions().size() >= 2;
-         TopicEJBLocal topicEJB = null;
-         try
-         {
-            topicEJB = homes.topic.create(message.getSubject(),
-                  getPoster().getUser(),
-                  current_time,
-                  forum,
-                  BBConstants.TOPIC_UNLOCKED,
-                  topic_type,
-                  topic_vote);
-            forum.setTopicSize(forum.getTopicSize() + 1);
-            post = homes.post.create(topicEJB, forum, getPoster(), message, current_time);
-            topicEJB.setFirstPost(post);
-            topicEJB.setLastPost(post);
-            topicEJB.setLastPostDate(current_time);
-            forum.setLastPost(post);
-           forum.setPostSize(forum.getPostSize() + 1);
-            for (int i = 0;i < attachments.length;i++)
-            {
-               UploadedFile attachment = attachments[i];
-               homes.attachment.create(post,
-                     attachment.getFile().getName(),
-                     attachment.getFile().getContent(),
-                     attachment.getComment(),
-                     attachment.getFile().getContentType(),
-                     attachment.getFile().getSize(),
-                     current_time);
-            }
-            if (topic_vote)
-            {
-               PollEJBLocal pollEJB = homes.poll.create(topicEJB, poll.getTitle(), current_time, poll.getLength());
-               for (int i = 0;i < poll.getOptions().size();i++)
-               {
-                  String text = (String)poll.getOptions().get(i);
-                  homes.option.create(pollEJB, text);
-               }
-            }
-            if (notify)
-            {
-               homes.topicWatch.create(getPoster().getUser(), topicEJB);
-            }
-         }
-         catch (CreateException e)
-         {
-            log.error("Cannot insert topic", e);
-            return TYPE_ERROR_IN_POSTING;
-         }
-       */
-      return TYPE_NEW_TOPIC_POSTED;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.commands.ValidationException;
+import org.jboss.portlet.forums.model.Post;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at users.sourceforge.net">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.9 $
+ */
+public final class NewTopicCommand
+   extends ForumCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public Date current_time;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int topic_type;
+
+   /**
+    * Notification when someone replies
+    */
+   public boolean notify;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Post post;
+
+   public List attachments;
+
+   public NewTopicCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int authType()
+   {
+      return ForumsConstants.TOPIC_TYPE_TO_AUTH_TYPE[topic_type];
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws ValidationException DOCUMENT_ME
+    */
+   protected void prepare()
+      throws ValidationException
+   {
+      super.prepare();
+      PostTools.validate(message);
+
+      //      PostTools.validate(poll);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected Result __execute()
+   {
+      try
+      {
+         post = forumsModule.createTopic(forum,
+            message,
+            new Date(),
+            poster,
+            poll,
+            attachments,
+            topic_type);
+         forumsModule.createWatch(poster, post.getTopic());
+         poster.incrementPostCount();
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      /*
+         boolean topic_vote = poll.getTitle() != null && poll.getOptions().size() >= 2;
+         TopicEJBLocal topicEJB = null;
+         try
+         {
+            topicEJB = homes.topic.create(message.getSubject(),
+                  getPoster().getUser(),
+                  current_time,
+                  forum,
+                  BBConstants.TOPIC_UNLOCKED,
+                  topic_type,
+                  topic_vote);
+            forum.setTopicSize(forum.getTopicSize() + 1);
+            post = homes.post.create(topicEJB, forum, getPoster(), message, current_time);
+            topicEJB.setFirstPost(post);
+            topicEJB.setLastPost(post);
+            topicEJB.setLastPostDate(current_time);
+            forum.setLastPost(post);
+           forum.setPostSize(forum.getPostSize() + 1);
+            for (int i = 0;i < attachments.length;i++)
+            {
+               UploadedFile attachment = attachments[i];
+               homes.attachment.create(post,
+                     attachment.getFile().getName(),
+                     attachment.getFile().getContent(),
+                     attachment.getComment(),
+                     attachment.getFile().getContentType(),
+                     attachment.getFile().getSize(),
+                     current_time);
+            }
+            if (topic_vote)
+            {
+               PollEJBLocal pollEJB = homes.poll.create(topicEJB, poll.getTitle(), current_time, poll.getLength());
+               for (int i = 0;i < poll.getOptions().size();i++)
+               {
+                  String text = (String)poll.getOptions().get(i);
+                  homes.option.create(pollEJB, text);
+               }
+            }
+            if (notify)
+            {
+               homes.topicWatch.create(getPoster().getUser(), topicEJB);
+            }
+         }
+         catch (CreateException e)
+         {
+            log.error("Cannot insert topic", e);
+            return TYPE_ERROR_IN_POSTING;
+         }
+       */
+      return TYPE_NEW_TOPIC_POSTED;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,63 +1,63 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.5 $
- */
-public abstract class PostCommand
-   extends TopicCommand
-{
-
-   protected PostCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int postId;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Post post;
-
-   public List attachments;
-
-   /**
-    * DOCUMENT_ME
-    */
-   protected void find()
-   {
-      try
-      {
-         post = forumsModule.findPostById(new Integer(postId));
-         topic = post.getTopic();
-         forum = topic.getForum();
-         category = forum.getCategory();
-      }
-      catch (ModuleException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.5 $
+ */
+public abstract class PostCommand
+   extends TopicCommand
+{
+
+   protected PostCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int postId;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Post post;
+
+   public List attachments;
+
+   /**
+    * DOCUMENT_ME
+    */
+   protected void find()
+   {
+      try
+      {
+         post = forumsModule.findPostById(new Integer(postId));
+         topic = post.getTopic();
+         forum = topic.getForum();
+         category = forum.getCategory();
+      }
+      catch (ModuleException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostTools.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostTools.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/PostTools.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,83 +1,83 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-import java.util.Iterator;
-
-import org.jboss.portlet.forums.commands.CommandConstants;
-import org.jboss.portlet.forums.commands.ValidationException;
-import org.jboss.portlet.forums.helper.ForumsTools;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Poll;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.3 $
- */
-public class PostTools
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @param message DOCUMENT_ME
-    * @throws ValidationException DOCUMENT_ME
-    */
-   public static void validate(Message message)
-      throws ValidationException
-   {
-      if (ForumsTools.isNullOrBlank(message.getSubject()))
-      {
-         throw new ValidationException(CommandConstants.TYPE_INVALID_POST_SUBJECT);
-      }
-
-      if (ForumsTools.isNullOrBlank(message.getText()))
-      {
-         throw new ValidationException(CommandConstants.TYPE_INVALID_POST_MESSAGE);
-      }
-
-      //      if (BBTools.isNullOrBlank(message.userName))
-      //      {
-      //         message.userName = "";
-      //      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param poll DOCUMENT_ME
-    * @throws ValidationException DOCUMENT_ME
-    */
-   public static void validate(Poll poll)
-      throws ValidationException
-   {
-      //      if (isNullOrBlank(poll.title))
-      //      {
-      //         throw new ValidationException(CommandConstants.TYPE_INVALID_POLL_TITLE);
-      //      }
-      //      if (poll.options.size() < 2)
-      //      {
-      //         throw new ValidationException(CommandConstants.TYPE_TOO_FEW_POLL_OPTION);
-      //      }
-      if (poll.getOptions().size() > 10) // $board_config['max_poll_options']
-      {
-         throw new ValidationException(CommandConstants.TYPE_TOO_MANY_POLL_OPTION);
-      }
-
-      for (Iterator i = poll.getOptions().iterator(); i.hasNext();)
-      {
-         String txt = (String)i.next();
-         if (ForumsTools.isNullOrBlank(txt))
-         {
-            throw new ValidationException(CommandConstants.TYPE_INVALID_POLL_OPTION);
-         }
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+import java.util.Iterator;
+
+import org.jboss.portlet.forums.commands.CommandConstants;
+import org.jboss.portlet.forums.commands.ValidationException;
+import org.jboss.portlet.forums.helper.ForumsTools;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Poll;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.3 $
+ */
+public class PostTools
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @param message DOCUMENT_ME
+    * @throws ValidationException DOCUMENT_ME
+    */
+   public static void validate(Message message)
+      throws ValidationException
+   {
+      if (ForumsTools.isNullOrBlank(message.getSubject()))
+      {
+         throw new ValidationException(CommandConstants.TYPE_INVALID_POST_SUBJECT);
+      }
+
+      if (ForumsTools.isNullOrBlank(message.getText()))
+      {
+         throw new ValidationException(CommandConstants.TYPE_INVALID_POST_MESSAGE);
+      }
+
+      //      if (BBTools.isNullOrBlank(message.userName))
+      //      {
+      //         message.userName = "";
+      //      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param poll DOCUMENT_ME
+    * @throws ValidationException DOCUMENT_ME
+    */
+   public static void validate(Poll poll)
+      throws ValidationException
+   {
+      //      if (isNullOrBlank(poll.title))
+      //      {
+      //         throw new ValidationException(CommandConstants.TYPE_INVALID_POLL_TITLE);
+      //      }
+      //      if (poll.options.size() < 2)
+      //      {
+      //         throw new ValidationException(CommandConstants.TYPE_TOO_FEW_POLL_OPTION);
+      //      }
+      if (poll.getOptions().size() > 10) // $board_config['max_poll_options']
+      {
+         throw new ValidationException(CommandConstants.TYPE_TOO_MANY_POLL_OPTION);
+      }
+
+      for (Iterator i = poll.getOptions().iterator(); i.hasNext();)
+      {
+         String txt = (String)i.next();
+         if (ForumsTools.isNullOrBlank(txt))
+         {
+            throw new ValidationException(CommandConstants.TYPE_INVALID_POLL_OPTION);
+         }
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ReplyCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ReplyCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/ReplyCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,137 +1,137 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-import java.util.Date;
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portlet.forums.commands.ValidationException;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.AuthType;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.7 $
- */
-public final class ReplyCommand
-   extends PostCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public Post newPost;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Date current_time;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public boolean notify;
-
-   public ReplyCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int authType()
-   {
-      return AuthType.REPLY;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws ValidationException DOCUMENT_ME
-    */
-   protected void prepare()
-      throws ValidationException
-   {
-      super.prepare();
-      PostTools.validate(message);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Result __execute()
-   {
-      if (topic.getStatus() == ForumsConstants.TOPIC_LOCKED)
-      {
-         log.error("Cannot create post reply- topic locked");
-         return TYPE_ERROR_IN_POSTING;
-
-
-      }
-      try
-      {
-         newPost = forumsModule.createPost(topic,
-            forum,
-            message,
-            current_time,
-            getPoster(),
-            attachments);
-         poster.incrementPostCount();
-
-         /*
-            TopicWatchEJBLocal watch = null;
-            try
-            {
-               watch = homes.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(getPoster().getUser().getId(), topic.getId()));
-            }
-            catch(ObjectNotFoundException e)
-            {
-               // we consider it is ObjectNotFoundException
-            }
-            if (watch == null && notify)
-            {
-               homes.topicWatch.create(getPoster().getUser(), topic);
-            }
-            else if (watch != null && !notify)
-            {
-               watch.remove();
-            }
-            if (attachments != null) {
-               for (int i = 0;i < attachments.length;i++)
-               {
-                  UploadedFile attachment = attachments[i];
-                  homes.attachment.create(post,
-                        attachment.getFile().getName(),
-                        attachment.getFile().getContent(),
-                        attachment.getComment(),
-                        attachment.getFile().getContentType(),
-                        attachment.getFile().getSize(),
-                        current_time);
-               }
-            }
-          */
-      }
-      catch (Exception e)
-      {
-         log.error("Cannot create post reply", e);
-         return TYPE_ERROR_IN_POSTING;
-      }
-
-      return TYPE_REPLY_POSTED;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+import java.util.Date;
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portlet.forums.commands.ValidationException;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.AuthType;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.7 $
+ */
+public final class ReplyCommand
+   extends PostCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public Post newPost;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Date current_time;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public boolean notify;
+
+   public ReplyCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int authType()
+   {
+      return AuthType.REPLY;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws ValidationException DOCUMENT_ME
+    */
+   protected void prepare()
+      throws ValidationException
+   {
+      super.prepare();
+      PostTools.validate(message);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Result __execute()
+   {
+      if (topic.getStatus() == ForumsConstants.TOPIC_LOCKED)
+      {
+         log.error("Cannot create post reply- topic locked");
+         return TYPE_ERROR_IN_POSTING;
+
+
+      }
+      try
+      {
+         newPost = forumsModule.createPost(topic,
+            forum,
+            message,
+            current_time,
+            getPoster(),
+            attachments);
+         poster.incrementPostCount();
+
+         /*
+            TopicWatchEJBLocal watch = null;
+            try
+            {
+               watch = homes.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(getPoster().getUser().getId(), topic.getId()));
+            }
+            catch(ObjectNotFoundException e)
+            {
+               // we consider it is ObjectNotFoundException
+            }
+            if (watch == null && notify)
+            {
+               homes.topicWatch.create(getPoster().getUser(), topic);
+            }
+            else if (watch != null && !notify)
+            {
+               watch.remove();
+            }
+            if (attachments != null) {
+               for (int i = 0;i < attachments.length;i++)
+               {
+                  UploadedFile attachment = attachments[i];
+                  homes.attachment.create(post,
+                        attachment.getFile().getName(),
+                        attachment.getFile().getContent(),
+                        attachment.getComment(),
+                        attachment.getFile().getContentType(),
+                        attachment.getFile().getSize(),
+                        current_time);
+               }
+            }
+          */
+      }
+      catch (Exception e)
+      {
+         log.error("Cannot create post reply", e);
+         return TYPE_ERROR_IN_POSTING;
+      }
+
+      return TYPE_REPLY_POSTED;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/RepostCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/RepostCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/RepostCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,51 +1,51 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portlet.forums.commands.CommandConstants;
-import org.jboss.portlet.forums.model.AuthType;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.3 $
- */
-public class RepostCommand
-   extends PostCommand
-{
-   public RepostCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int authType()
-   {
-      return AuthType.EDIT;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   protected Result __execute()
-   {
-      return CommandConstants.TYPE_REPOSTED;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portlet.forums.commands.CommandConstants;
+import org.jboss.portlet.forums.model.AuthType;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.3 $
+ */
+public class RepostCommand
+   extends PostCommand
+{
+   public RepostCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int authType()
+   {
+      return AuthType.EDIT;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected Result __execute()
+   {
+      return CommandConstants.TYPE_REPOSTED;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/TopicCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/TopicCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/TopicCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,73 +1,73 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-//import org.jboss.nukes.addons.modules.bb.commands.ValidationException;
-//import org.jboss.nukes.addons.modules.bb.ejb.TopicEJBLocal;
-//import org.jboss.nukes.addons.modules.bb.BBConstants;
-
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.3 $
- */
-public abstract class TopicCommand
-   extends ForumCommand
-{
-
-   protected TopicCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int topicId;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public Topic topic;
-
-   /*
-      protected void find() throws ValidationException
-      {
-         try
-         {
-            topic = homes.topic.findByPrimaryKey(new Integer(topicId));
-            forum = topic.getForum();
-            category = forum.getCategory();
-         }
-         catch(ObjectNotFoundException e)
-         {
-            log.error("Topic not found", e);
-            throw new ValidationException(TYPE_NO_SUCH_TOPIC);
-         }
-         catch(FinderException e)
-         {
-            log.error("Cannot find topic", e);
-            throw new ValidationException(TYPE_CANNOT_QUERY);
-         }
-      }
-      protected void prepare() throws ValidationException
-      {
-         super.prepare();
-         if (topic.getStatus() == BBConstants.TOPIC_LOCKED && !isAuthMod)
-         {
-            throw new ValidationException(TYPE_TOPIC_IS_LOCKED);
-         }
-      }
-    */
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+//import org.jboss.nukes.addons.modules.bb.commands.ValidationException;
+//import org.jboss.nukes.addons.modules.bb.ejb.TopicEJBLocal;
+//import org.jboss.nukes.addons.modules.bb.BBConstants;
+
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.3 $
+ */
+public abstract class TopicCommand
+   extends ForumCommand
+{
+
+   protected TopicCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int topicId;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public Topic topic;
+
+   /*
+      protected void find() throws ValidationException
+      {
+         try
+         {
+            topic = homes.topic.findByPrimaryKey(new Integer(topicId));
+            forum = topic.getForum();
+            category = forum.getCategory();
+         }
+         catch(ObjectNotFoundException e)
+         {
+            log.error("Topic not found", e);
+            throw new ValidationException(TYPE_NO_SUCH_TOPIC);
+         }
+         catch(FinderException e)
+         {
+            log.error("Cannot find topic", e);
+            throw new ValidationException(TYPE_CANNOT_QUERY);
+         }
+      }
+      protected void prepare() throws ValidationException
+      {
+         super.prepare();
+         if (topic.getStatus() == BBConstants.TOPIC_LOCKED && !isAuthMod)
+         {
+            throw new ValidationException(TYPE_TOPIC_IS_LOCKED);
+         }
+      }
+    */
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/VoteTopicCommand.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/VoteTopicCommand.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/commands/post/VoteTopicCommand.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,145 +1,145 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.commands.post;
-
-
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.model.*;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.5 $
- */
-public class VoteTopicCommand
-   extends TopicCommand
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public Post post;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public int voteOptionId;
-
-   public VoteTopicCommand(JBossActionRequest request, JBossActionResponse response)
-   {
-      super(request, response);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int authType()
-   {
-      return AuthType.READ;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   protected Result __execute()
-   {
-      if (voteOptionId != -1)
-      {
-         try
-         {
-            topic = forumsModule.findTopicById(new Integer(topicId));
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         }
-         Poll poll = topic.getPoll();
-         poll.getVoted().add(poster.getUserId());
-         int index = 0;
-         PollOption po = null;
-         for (Iterator iter = poll.getOptions().iterator(); iter.hasNext() && (index <= voteOptionId); index++)
-         {
-            po = (PollOption)iter.next();
-         }
-         if (po != null)
-         {
-            po.incVotes();
-         }
-         else
-         {
-            return TYPE_COULD_NOT_OBTAIN_VOTE_DATA;
-         }
-         return TYPE_VOTE_POSTED;
-      }
-      else
-      {
-         return TYPE_NOT_SELECTED_VOTE;
-      }
-
-      /*      if (voteOptionId != -1)
-        {
-           try
-           {
-              OptionEJBLocal optionEJB = homes.option.findByPrimaryKey(new Integer(voteOptionId));
-              PollEJBLocal pollEJB = optionEJB.getPoll();
-              try
-              {
-                 if (getPoster() == null)
-                 {
-                    return TYPE_CANNOT_OBTAIN_USER_DATA;
-                 }
-                 homes.vote.findByPollAndUser(pollEJB, getPoster().getUser());
-                 return TYPE_ALREADY_VOTED;
-              }
-              catch(ObjectNotFoundException e)
-              {
-                 try
-                 {
-                    homes.vote.create(pollEJB, getPoster().getUser(), getPoster().getIp());
-                    optionEJB.setResult(optionEJB.getResult() + 1);
-                 }
-                 catch (CreateException ce)
-                 {
-                    log.error("Cannot insert vote", e);
-                    return TYPE_CANNOT_INSERT_VOTE;
-                 }
-                 return TYPE_VOTE_CAST;
-              }
-              catch (FinderException e)
-              {
-                 return TYPE_CANNOT_OBTAIN_USER_DATA;
-              }
-           }
-           catch(ObjectNotFoundException e)
-           {
-              return TYPE_NO_VOTE_OPTION;
-           }
-           catch(FinderException e)
-           {
-              return TYPE_COULD_NOT_OBTAIN_VOTE_DATA;
-           }
-        }
-        else
-        {
-           return TYPE_NO_VOTE_OPTION;
-        }
-      */
-
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.commands.post;
+
+
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.model.*;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+public class VoteTopicCommand
+   extends TopicCommand
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public Post post;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public int voteOptionId;
+
+   public VoteTopicCommand(JBossActionRequest request, JBossActionResponse response)
+   {
+      super(request, response);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int authType()
+   {
+      return AuthType.READ;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected Result __execute()
+   {
+      if (voteOptionId != -1)
+      {
+         try
+         {
+            topic = forumsModule.findTopicById(new Integer(topicId));
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         }
+         Poll poll = topic.getPoll();
+         poll.getVoted().add(poster.getUserId());
+         int index = 0;
+         PollOption po = null;
+         for (Iterator iter = poll.getOptions().iterator(); iter.hasNext() && (index <= voteOptionId); index++)
+         {
+            po = (PollOption)iter.next();
+         }
+         if (po != null)
+         {
+            po.incVotes();
+         }
+         else
+         {
+            return TYPE_COULD_NOT_OBTAIN_VOTE_DATA;
+         }
+         return TYPE_VOTE_POSTED;
+      }
+      else
+      {
+         return TYPE_NOT_SELECTED_VOTE;
+      }
+
+      /*      if (voteOptionId != -1)
+        {
+           try
+           {
+              OptionEJBLocal optionEJB = homes.option.findByPrimaryKey(new Integer(voteOptionId));
+              PollEJBLocal pollEJB = optionEJB.getPoll();
+              try
+              {
+                 if (getPoster() == null)
+                 {
+                    return TYPE_CANNOT_OBTAIN_USER_DATA;
+                 }
+                 homes.vote.findByPollAndUser(pollEJB, getPoster().getUser());
+                 return TYPE_ALREADY_VOTED;
+              }
+              catch(ObjectNotFoundException e)
+              {
+                 try
+                 {
+                    homes.vote.create(pollEJB, getPoster().getUser(), getPoster().getIp());
+                    optionEJB.setResult(optionEJB.getResult() + 1);
+                 }
+                 catch (CreateException ce)
+                 {
+                    log.error("Cannot insert vote", e);
+                    return TYPE_CANNOT_INSERT_VOTE;
+                 }
+                 return TYPE_VOTE_CAST;
+              }
+              catch (FinderException e)
+              {
+                 return TYPE_CANNOT_OBTAIN_USER_DATA;
+              }
+           }
+           catch(ObjectNotFoundException e)
+           {
+              return TYPE_NO_VOTE_OPTION;
+           }
+           catch(FinderException e)
+           {
+              return TYPE_COULD_NOT_OBTAIN_VOTE_DATA;
+           }
+        }
+        else
+        {
+           return TYPE_NO_VOTE_OPTION;
+        }
+      */
+
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentToken.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentToken.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentToken.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,96 +1,96 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.Date;
-
-/**
- * Token that stores attachment id - to secure download
- *
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class AttachmentToken
-{
-   private Date createDate;
-   private Date expireDate;
-   private int id;
-   private Integer attachmentId;
-
-
-   public AttachmentToken(int id)
-   {
-      this.id = id;
-      createDate = new Date();
-   }
-
-   public AttachmentToken(int tokenId, Integer attachmentId, Date expireDate)
-   {
-      this.id = tokenId;
-      this.attachmentId = attachmentId;
-      this.expireDate = expireDate;
-
-   }
-
-   public Date getCreateDate()
-   {
-      return createDate;
-   }
-
-   public void setCreateDate(Date createDate)
-   {
-      this.createDate = createDate;
-   }
-
-   public Date getExpirationDate()
-   {
-      return expireDate;
-   }
-
-   public void setExpirationDate(Date expireDate)
-   {
-      this.expireDate = expireDate;
-   }
-
-   public int getId()
-   {
-      return id;
-   }
-
-   public void setId(int id)
-   {
-      this.id = id;
-   }
-
-   public Integer getAttachmentId()
-   {
-      return attachmentId;
-   }
-
-   public void setAttachmentId(Integer attachmentId)
-   {
-      this.attachmentId = attachmentId;
-   }
-
-
-   /**
-    * compares createDate and expirationDate
-    * @return
-    */
-   public boolean isValid()
-   {
-      if (expireDate == null)
-      {
-         return true;
-      }
-      Date currentDate = new Date();
-      return currentDate.before(getExpirationDate());
-   }
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+import java.util.Date;
+
+/**
+ * Token that stores attachment id - to secure download
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class AttachmentToken
+{
+   private Date createDate;
+   private Date expireDate;
+   private int id;
+   private Integer attachmentId;
+
+
+   public AttachmentToken(int id)
+   {
+      this.id = id;
+      createDate = new Date();
+   }
+
+   public AttachmentToken(int tokenId, Integer attachmentId, Date expireDate)
+   {
+      this.id = tokenId;
+      this.attachmentId = attachmentId;
+      this.expireDate = expireDate;
+
+   }
+
+   public Date getCreateDate()
+   {
+      return createDate;
+   }
+
+   public void setCreateDate(Date createDate)
+   {
+      this.createDate = createDate;
+   }
+
+   public Date getExpirationDate()
+   {
+      return expireDate;
+   }
+
+   public void setExpirationDate(Date expireDate)
+   {
+      this.expireDate = expireDate;
+   }
+
+   public int getId()
+   {
+      return id;
+   }
+
+   public void setId(int id)
+   {
+      this.id = id;
+   }
+
+   public Integer getAttachmentId()
+   {
+      return attachmentId;
+   }
+
+   public void setAttachmentId(Integer attachmentId)
+   {
+      this.attachmentId = attachmentId;
+   }
+
+
+   /**
+    * compares createDate and expirationDate
+    * @return
+    */
+   public boolean isValid()
+   {
+      if (expireDate == null)
+      {
+         return true;
+      }
+      Date currentDate = new Date();
+      return currentDate.before(getExpirationDate());
+   }
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/AttachmentTokenManager.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,158 +1,158 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.List;
-import java.util.Vector;
-import java.util.Iterator;
-import java.util.Date;
-
-/**
- * Manager that stores and manages AttachmentToken object instances inside of session.
- *
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class AttachmentTokenManager
-{
-   //user vector as it's thread safe
-   private List tokens = new Vector();
-
-   //lenght of tokens list above which it'll be purged from expired tokens
-   private int autoPurgeSize = 100;
-
-   //for id generation
-   private int idCount;
-
-   /**
-    * Method adds new AttachmentToken into store. If there is one with same attachmentId already
-    * it'll be replaced by the new one
-    *
-    * @param newToken
-    */
-
-   public synchronized void addToken(AttachmentToken newToken)
-   {
-      if (tokens.size() < autoPurgeSize)
-      {
-         removeExpiredTokens();
-      }
-
-      for (Iterator i = tokens.iterator(); i.hasNext();)
-      {
-         AttachmentToken at = (AttachmentToken)i.next();
-         if (at.getAttachmentId().intValue() == newToken.getAttachmentId().intValue())
-         {
-            tokens.remove(at);
-            tokens.add(newToken);
-            return;
-         }
-      }
-      tokens.add(newToken);
-   }
-
-   /**
-    * checks if token is in store
-    *
-    * @param id
-    * @return
-    */
-   public boolean hasToken(int id)
-   {
-      for (Iterator i = tokens.iterator(); i.hasNext();)
-      {
-         AttachmentToken at = (AttachmentToken)i.next();
-         if (at.getId() == id)
-         {
-            return true;
-         }
-      }
-      return false;
-   }
-
-   /**
-    * returns token
-    * @param id
-    * @return
-    */
-   public AttachmentToken getToken(int id)
-   {
-
-      for (Iterator i = tokens.iterator(); i.hasNext();)
-      {
-         AttachmentToken at = (AttachmentToken)i.next();
-         if (at.getId() == id)
-         {
-            return at;
-         }
-      }
-      return null;
-   }
-
-
-
-
-   /**
-    * new Tokens chould be obtained with this method to generate proper Id safely
-    *
-    * @return
-    */
-   public synchronized AttachmentToken createNewToken()
-   {
-      if (idCount == Integer.MAX_VALUE)
-      {
-         idCount = 0;
-      }
-      return new AttachmentToken(idCount++);
-   }
-
-   /**
-    * new Tokens chould be obtained with this method to generate proper Id safely
-    *
-    * @return
-    */
-   public synchronized AttachmentToken createNewToken(Integer attachmentId, Date expireDate)
-   {
-      /*if (idCount == Integer.MAX_VALUE)
-      {
-         idCount = 0;
-      }*/
-      AttachmentToken at = createNewToken();
-      at.setAttachmentId(attachmentId);
-      at.setExpirationDate(expireDate);
-      return at;
-   }
-
-
-   /**
-    * Validates all tokens.
-    */
-   public synchronized void removeExpiredTokens()
-   {
-      for (Iterator i = tokens.iterator(); i.hasNext();)
-      {
-         AttachmentToken at = (AttachmentToken)i.next();
-         if (!at.isValid())
-         {
-            tokens.remove(at);
-         }
-      }
-   }
-
-
-   public int getAutoPurgeSize()
-   {
-      return autoPurgeSize;
-   }
-
-   public void setAutoPurgeSize(int autoPurgeSize)
-   {
-      this.autoPurgeSize = autoPurgeSize;
-   }
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+import java.util.List;
+import java.util.Vector;
+import java.util.Iterator;
+import java.util.Date;
+
+/**
+ * Manager that stores and manages AttachmentToken object instances inside of session.
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class AttachmentTokenManager
+{
+   //user vector as it's thread safe
+   private List tokens = new Vector();
+
+   //lenght of tokens list above which it'll be purged from expired tokens
+   private int autoPurgeSize = 100;
+
+   //for id generation
+   private int idCount;
+
+   /**
+    * Method adds new AttachmentToken into store. If there is one with same attachmentId already
+    * it'll be replaced by the new one
+    *
+    * @param newToken
+    */
+
+   public synchronized void addToken(AttachmentToken newToken)
+   {
+      if (tokens.size() < autoPurgeSize)
+      {
+         removeExpiredTokens();
+      }
+
+      for (Iterator i = tokens.iterator(); i.hasNext();)
+      {
+         AttachmentToken at = (AttachmentToken)i.next();
+         if (at.getAttachmentId().intValue() == newToken.getAttachmentId().intValue())
+         {
+            tokens.remove(at);
+            tokens.add(newToken);
+            return;
+         }
+      }
+      tokens.add(newToken);
+   }
+
+   /**
+    * checks if token is in store
+    *
+    * @param id
+    * @return
+    */
+   public boolean hasToken(int id)
+   {
+      for (Iterator i = tokens.iterator(); i.hasNext();)
+      {
+         AttachmentToken at = (AttachmentToken)i.next();
+         if (at.getId() == id)
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+
+   /**
+    * returns token
+    * @param id
+    * @return
+    */
+   public AttachmentToken getToken(int id)
+   {
+
+      for (Iterator i = tokens.iterator(); i.hasNext();)
+      {
+         AttachmentToken at = (AttachmentToken)i.next();
+         if (at.getId() == id)
+         {
+            return at;
+         }
+      }
+      return null;
+   }
+
+
+
+
+   /**
+    * new Tokens chould be obtained with this method to generate proper Id safely
+    *
+    * @return
+    */
+   public synchronized AttachmentToken createNewToken()
+   {
+      if (idCount == Integer.MAX_VALUE)
+      {
+         idCount = 0;
+      }
+      return new AttachmentToken(idCount++);
+   }
+
+   /**
+    * new Tokens chould be obtained with this method to generate proper Id safely
+    *
+    * @return
+    */
+   public synchronized AttachmentToken createNewToken(Integer attachmentId, Date expireDate)
+   {
+      /*if (idCount == Integer.MAX_VALUE)
+      {
+         idCount = 0;
+      }*/
+      AttachmentToken at = createNewToken();
+      at.setAttachmentId(attachmentId);
+      at.setExpirationDate(expireDate);
+      return at;
+   }
+
+
+   /**
+    * Validates all tokens.
+    */
+   public synchronized void removeExpiredTokens()
+   {
+      for (Iterator i = tokens.iterator(); i.hasNext();)
+      {
+         AttachmentToken at = (AttachmentToken)i.next();
+         if (!at.isValid())
+         {
+            tokens.remove(at);
+         }
+      }
+   }
+
+
+   public int getAutoPurgeSize()
+   {
+      return autoPurgeSize;
+   }
+
+   public void setAutoPurgeSize(int autoPurgeSize)
+   {
+      this.autoPurgeSize = autoPurgeSize;
+   }
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/FileBinding.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/FileBinding.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/FileBinding.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,62 +1,62 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-
-package org.jboss.portlet.forums.helper;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-
-public class FileBinding
-{
-
-   protected String fileId;
-   protected String fileName;
-   protected String comment;
-
-   public FileBinding()
-   {
-
-   }
-
-   public String getFileId()
-   {
-      return fileId;
-   }
-
-   public void setFileId(String fileId)
-   {
-      this.fileId = fileId;
-   }
-
-   public String getFileName()
-   {
-      return fileName;
-   }
-
-   public void setFileName(String realName)
-   {
-      this.fileName = realName;
-   }
-
-   public String getComment()
-   {
-      return comment;
-   }
-
-   public void setComment(String comment)
-   {
-      this.comment = comment;
-   }
-}
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+
+package org.jboss.portlet.forums.helper;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+
+public class FileBinding
+{
+
+   protected String fileId;
+   protected String fileName;
+   protected String comment;
+
+   public FileBinding()
+   {
+
+   }
+
+   public String getFileId()
+   {
+      return fileId;
+   }
+
+   public void setFileId(String fileId)
+   {
+      this.fileId = fileId;
+   }
+
+   public String getFileName()
+   {
+      return fileName;
+   }
+
+   public void setFileName(String realName)
+   {
+      this.fileName = realName;
+   }
+
+   public String getComment()
+   {
+      return comment;
+   }
+
+   public void setComment(String comment)
+   {
+      this.comment = comment;
+   }
+}
+
+

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/ForumsTools.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/ForumsTools.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/ForumsTools.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,671 +1,671 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import javax.ejb.EJBLocalHome;
-import javax.ejb.EJBLocalObject;
-import javax.portlet.PortletRequest;
-
-import org.apache.log4j.Logger;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.JBossRenderRequest;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.8 $
- */
-public class ForumsTools
-{
-   private static final Logger log = Logger.getLogger(ForumsTools.class);
-   private static final StandardAnalyzer analyzer = new StandardAnalyzer();
-
-
-   public static void authCan(StringBuffer authCan, JBossRenderRequest req, String[] testArray, ResourceBundle bundle)
-   {
-      boolean authPost = hasPermission(req, testArray, "AddPostInForum");
-      boolean authEdit = hasPermission(req, testArray, "EditPostInForum");
-      boolean authDelete = hasPermission(req, testArray, "DeletePostInForum");
-      boolean authPoll = hasPermission(req, testArray, "AddPollInPost");
-      boolean authVote = hasPermission(req, testArray, "VotePollInPost");
-      //boolean authMod = hasPermission(req, testArray, "ModerateForum");
-
-      authCan.append(authPost ? bundle.getString("Rules_post_can") : bundle.getString("Rules_post_cannot")).
-         append("<br/>").
-         /* append(authEdit ? bundle.getString("Rules_edit_can") : bundle.getString("Rules_edit_cannot")).
-         append("<br/>").
-         append(authDelete ? bundle.getString("Rules_delete_can") : bundle.getString("Rules_delete_cannot")).
-         append("<br/>").*/
-            append(authPoll ? bundle.getString("Rules_poll_can") : bundle.getString("Rules_poll_cannot")).
-         append("<br/>").
-         append(authVote ? bundle.getString("Rules_vote_can") : bundle.getString("Rules_vote_cannot")).
-         append("<br/>");
-   }
-
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer   DOCUMENT_ME
-    * @param name     DOCUMENT_ME
-    * @param value    DOCUMENT_ME
-    * @param selected DOCUMENT_ME
-    */
-   public static void radioButton(StringBuffer buffer,
-                                  String name,
-                                  String value,
-                                  boolean selected)
-   {
-      buffer.append("<input type=\"radio\" name=\"").append(name).append("\" value=\"").append(value).append("\"")
-         .append(selected ? " checked=\"checked\"/>" : "/>");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param url    DOCUMENT_ME
-    * @param target DOCUMENT_ME
-    * @param image  DOCUMENT_ME
-    * @param title  DOCUMENT_ME
-    * @param alt    DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String createImageLink(String url,
-                                        String target,
-                                        String image,
-                                        String title,
-                                        String alt)
-   {
-      return "<a href=\"" + url + "\" target=\"" + target + "\"><img src=\"" + image + "\" " + "alt=\"" + alt
-         + "\" title=\"" + title + "\" border=\"0\"></a>";
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param url   DOCUMENT_ME
-    * @param image DOCUMENT_ME
-    * @param title DOCUMENT_ME
-    * @param alt   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String createImageLink(String url,
-                                        String image,
-                                        String title,
-                                        String alt)
-   {
-      return "<a href=\"" + url + "\"><img src=\"" + image + "\" " + "alt=\"" + alt + "\" title=\"" + title
-         + "\" border=\"0\"></a>";
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param url   DOCUMENT_ME
-    * @param image DOCUMENT_ME
-    * @param title DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String createImageLink(String url,
-                                        String image,
-                                        String title)
-   {
-      return createImageLink(url, image, title, title);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param url  DOCUMENT_ME
-    * @param text DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String createLink(String url,
-                                   String text)
-   {
-      return "<a href=\"" + url + "\">" + text + "</a>";
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param url    DOCUMENT_ME
-    * @param target DOCUMENT_ME
-    * @param text   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String createLink(String url,
-                                   String target,
-                                   String text)
-   {
-      return "<a href=\"" + url + "\" target=\"" + target + "\">" + text + "</a>";
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param text  DOCUMENT_ME
-    * @param field DOCUMENT_ME
-    * @param isOr  DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static Query createQuery(String text,
-                                   String field,
-                                   boolean isOr)
-   {
-      try
-      {
-         QueryParser parser = new QueryParser(field, analyzer);
-         parser.setOperator(isOr ? QueryParser.DEFAULT_OPERATOR_OR : QueryParser.DEFAULT_OPERATOR_AND);
-         return parser.parse(text);
-      }
-      catch (ParseException e)
-      {
-         log.error("Cannot parse query " + text, e);
-         return DUMMY_QUERY;
-      }
-   }
-
-   private static final Query DUMMY_QUERY = new BooleanQuery();
-
-
-   /**
-    * returns html <options> containing forums
-    *
-    * @param forums DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String listTopics(List forums)
-   {
-      Iterator result = forums.iterator();
-
-      // hold the result
-      StringBuffer buffer = new StringBuffer();
-
-      // do the work
-      while (result.hasNext())
-      {
-         Forum forum = (Forum)result.next();
-         buffer.append("<option value=\"").append(forum.getId()).append("\"")
-            .append(">")
-            .append(forum.getName()).append("</option>\n");
-      }
-
-      return buffer.toString();
-   }
-
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forums     DOCUMENT_ME
-    * @param selectedId DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String listForums(List forums,
-                                   int selectedId)
-   {
-      Iterator result = forums.iterator();
-
-      // hold the result
-      StringBuffer buffer = new StringBuffer();
-
-      // do the work
-      while (result.hasNext())
-      {
-         Forum forum = (Forum)result.next();
-         buffer.append("<option value=\"").append(forum.getId()).append("\"")
-            .append((selectedId == forum.getId().intValue()) ? " selected=\"selected\"" : "").append(">")
-            .append(forum.getName()).append("</option>\n");
-      }
-
-      return buffer.toString();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param categories DOCUMENT_ME
-    * @param selectedId DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String listCategories(List categories,
-                                       int selectedId)
-   {
-      Iterator result = categories.iterator();
-
-      // hold the result
-      StringBuffer buffer = new StringBuffer();
-
-      // do the work
-      while (result.hasNext())
-      {
-         Category category = (Category)result.next();
-         buffer.append("<option value=\"").append(category.getId()).append("\"")
-            .append((selectedId == category.getId().intValue()) ? " selected=\"selected\"" : "").append(">")
-            .append(category.getTitle()).append("</option>\n");
-      }
-
-      return buffer.toString();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param categories DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String listForumsCategories(ForumsModule module)
-   {
-      Iterator resultCat = null;
-      try
-      {
-         resultCat = module.findCategories().iterator();
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         return "";
-      }
-
-      // hold the result
-      StringBuffer buffer = new StringBuffer();
-
-      // do the work
-      while (resultCat.hasNext())
-      {
-         Category category = (Category)resultCat.next();
-         buffer.append("<option value=\"").append("cx" + category.getId()).append("\"")
-            .append(">")
-            .append("&nbsp;&nbsp;&nbsp; " + category.getTitle()).append("</option>\n");
-
-         Iterator resultForum = null;
-         try
-         {
-            resultForum = module.findForumsByCategoryId(category.getId()).iterator();
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            return "";
-         }
-
-         // hold the result
-         //StringBuffer buffer = new StringBuffer();
-
-         // do the work
-         while (resultForum.hasNext())
-         {
-            Forum forum = (Forum)resultForum.next();
-            buffer.append("<option value=\"").append("fx" + forum.getId()).append("\"")
-               .append(">")
-               .append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " + forum.getName()).append("</option>\n");
-         }
-
-      }
-
-      return buffer.toString();
-   }
-
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @param days DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String selectDays(String name,
-                                   int days)
-   {
-      StringBuffer selectDays = new StringBuffer("<select name=\"").append(name).append("\">");
-      for (int i = 0; i < ForumsConstants.PREVIOUS_DAYS.length; i++)
-      {
-         selectDays.append("<option value=\"").append(ForumsConstants.PREVIOUS_DAYS[i]).append("\"")
-            .append((days == ForumsConstants.PREVIOUS_DAYS[i]) ? " selected=\"selected\"" : "").append(">")
-            .append(ForumsConstants.PREVIOUS_DAYS_TEXT_TOPICS[i]).append("</option>");
-      }
-
-      selectDays.append("</select>");
-      return selectDays.toString();
-   }
-
-   /**
-    * Performs a generic batch update.
-    */
-   public static void batchUpdate(Connection conn,
-                                  String updateQuery,
-                                  String selectQuery,
-                                  int size)
-      throws SQLException
-   {
-      PreparedStatement updater = null;
-      PreparedStatement selecter = null;
-      ResultSet rs = null;
-      try
-      {
-         updater = conn.prepareStatement(updateQuery);
-
-         // not yet implemented in MySQL Connector/J driver 3.0.9
-         // int size = updater.getParameterMetaData().getParameterCount();
-         selecter = conn.prepareStatement(selectQuery);
-         rs = selecter.executeQuery();
-         while (rs.next())
-         {
-            for (int i = 1; i <= size; i++)
-            {
-               updater.setObject(i,
-                  rs.getObject(i));
-            }
-
-            updater.executeUpdate();
-         }
-      }
-      finally
-      {
-         if (!conn.getAutoCommit())
-         {
-            conn.commit();
-         }
-
-         Tools.safeClose(rs);
-         Tools.safeClose(updater);
-         Tools.safeClose(selecter);
-      }
-   }
-
-//   /**
-//    * DOCUMENT_ME
-//    *
-//    * @param authCan DOCUMENT_ME
-//    * @param forum DOCUMENT_ME
-//    * @param loggedIn DOCUMENT_ME
-//    * @param level DOCUMENT_ME
-//    */
-//   public static void authCan(StringBuffer authCan,
-//                              Forum        forum,
-//                              boolean      loggedIn,
-//                              Level        level)
-//   {
-//      /*
-//         authCan.append(Auth.hasLevel(forum.getAuth().getPost(), loggedIn, level) ? "${bb.Rules_post_can}" : "${bb.Rules_post_cannot}").
-//                 append("<br/>").
-//                 append(Auth.hasLevel(forum.getAuth().getReply(), loggedIn, level) ? "${bb.Rules_reply_can}" : "${bb.Rules_reply_cannot}").
-//                 append("<br/>").
-//                 append(Auth.hasLevel(forum.getAuth().getEdit(), loggedIn, level) ? "${bb.Rules_edit_can}" : "${bb.Rules_edit_cannot}").
-//                 append("<br/>").
-//                 append(Auth.hasLevel(forum.getAuth().getDelete(), loggedIn, level) ? "${bb.Rules_delete_can}" : "${bb.Rules_delete_cannot}").
-//                 append("<br/>").
-//                 append(Auth.hasLevel(forum.getAuth().getVote(), loggedIn, level) ? "${bb.Rules_vote_can}" : "${bb.Rules_vote_cannot}").
-//                 append("<br/>");
-//       */
-//   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param start DOCUMENT_ME
-    * @param size  DOCUMENT_ME
-    * @param per   DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String pageNumber(int start,
-                                   int size,
-                                   int per)
-   {
-      return "${bb.Page_of_0}" + (int)Math.ceil((double)start / (double)(per)) + "${bb.Page_of_1}"
-         + (int)Math.ceil((double)size / (double)per) + "${bb.Page_of_2}";
-   }
-
-   /**
-    * @param home   where the EJBs are taken
-    * @param getter how to get some info about the EJB
-    * @param key    the key used to set the skip or select the item in the list according the all parameter
-    * @param all    force all the items to be displayed
-    * @return
-    */
-   public static String selectEJBs(EJBLocalHome home,
-                                   Method getter,
-                                   Object key,
-                                   boolean all)
-   {
-      try
-      {
-         // empty args for the reflection call
-         Object[] empty = new Object[0];
-
-         // the findAll method will give us all the EJBs
-         Method findAll = home.getClass().getMethod("findAll",
-            new Class[0]);
-         Iterator result = ((Collection)findAll.invoke(home, empty)).iterator();
-
-         // hold the result
-         StringBuffer buffer = new StringBuffer();
-
-         // do the work
-         while (result.hasNext())
-         {
-            EJBLocalObject ejb = (EJBLocalObject)result.next();
-            Object ejbKey = ejb.getPrimaryKey();
-            boolean equals = ejbKey.equals(key);
-            if (all || equals)
-            {
-               buffer.append("<option value=\"").append(ejbKey).append("\"")
-                  .append(equals ? " selected=\"selected\"" : "").append(">").append(getter.invoke(ejb, empty))
-                  .append("</option>\n");
-            }
-         }
-
-         // return the string buffer content
-         return buffer.toString();
-      }
-      catch (Exception e)
-      {
-         log.error("Cannot list ejbs", e);
-         return "";
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param clazz  DOCUMENT_ME
-    * @param prefix DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static String[][] collectFields(Class clazz,
-                                          String prefix)
-   {
-      Field[] fields = clazz.getDeclaredFields();
-      List values = new ArrayList(fields.length);
-      for (int i = 0; i < fields.length; i++)
-      {
-         Field field = fields[i];
-         int modifier = field.getModifiers();
-         if (field.getName().startsWith(prefix)
-            && Modifier.isFinal(modifier)
-            && Modifier.isPublic(modifier)
-            && Modifier.isStatic(modifier))
-         {
-            try
-            {
-               values.add(new String[]
-                  {
-                     field.getName(),
-                     (String)field.get(null)
-                  });
-            }
-            catch (Exception ignore)
-            {
-               Logger.getLogger(clazz).error("", ignore);
-            }
-         }
-      }
-
-      return (String[][])values.toArray(new String[values.size()][]);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param c DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static Object head(Collection c)
-   {
-      Iterator iterator = c.iterator();
-      return iterator.hasNext() ? iterator.next() : null;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param format_1_00 DOCUMENT_ME
-    * @param forumId     DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static final String computeCacheKey(boolean format_1_00,
-                                              String forumId)
-   {
-      return (format_1_00 ? "rss/1.00" : "rss/0.91") + ((forumId != null) ? ("/" + forumId) : "");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param s DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static boolean isNullOrBlank(String s)
-   {
-      if (s != null)
-      {
-         for (int i = 0; i < s.length(); i++)
-         {
-            if (!Character.isWhitespace(s.charAt(i)))
-            {
-               return false;
-            }
-         }
-      }
-
-      return true;
-   }
-
-   public static boolean hasPermission(PortletRequest req, String[] test, String permission)
-   {
-      return hasPermission(req, permission);
-   }
-
-   public static boolean hasPermission(PortletRequest req, String perm)
-   {
-
-      if (perm.equals("Admin")
-         || perm.equals("Delete")
-         || perm.equals("AdminCategory")
-         || perm.equals("DeleteForumInCategory")
-         || perm.equals("AddForumInCategory")
-         || perm.equals("EditCategory")
-         || perm.equals("AddForumInCategory")
-         || perm.equals("EditForumInCategory")
-         )
-      {
-         if (req.isUserInRole("ForumsAdmin"))
-         {
-            return true;
-         }
-      }
-
-      if (perm.equals("ModerateForum")
-         || perm.equals("AddPollInPost")
-         || perm.equals("EditPollInPost")
-         || perm.equals("AddAttachmentInPost")
-         || perm.equals("DeletePostInForum")
-         || perm.equals("EditPostInForum")
-         )
-      {
-         if (req.isUserInRole("ForumsAdmin")
-            || req.isUserInRole("ForumsModerator"))
-         {
-            return true;
-         }
-      }
-
-      if (perm.equals("AddPollInPost"))
-      {
-         if (req.isUserInRole("ForumsAdmin")
-            || req.isUserInRole("ForumsModerator")
-            || req.isUserInRole("ForumsPolls"))
-         {
-            return true;
-         }
-      }
-
-
-      if (perm.equals("AddAttachmentInPost"))
-      {
-         if (req.isUserInRole("ForumsAdmin")
-            || req.isUserInRole("ForumsModerator")
-            || req.isUserInRole("ForumsAttachments"))
-         {
-            return true;
-         }
-      }
-
-      if (perm.equals("AddPostInForum")
-         || perm.equals("VotePollInPost")
-
-         )
-      {
-         if (req.isUserInRole("ForumsAdmin")
-            || req.isUserInRole("ForumsModerator")
-            || req.isUserInRole("ForumsAttachments")
-            || req.isUserInRole("ForumsPolls")
-            || req.isUserInRole("ForumsUser"))
-         {
-            return true;
-         }
-      }
-
-
-      if (perm.equals("ReadCategory")
-         || perm.equals("ReadForum"))
-      {
-         return true;
-      }
-
-      return false;
-   }
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
+import javax.portlet.PortletRequest;
+
+import org.apache.log4j.Logger;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.JBossRenderRequest;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.8 $
+ */
+public class ForumsTools
+{
+   private static final Logger log = Logger.getLogger(ForumsTools.class);
+   private static final StandardAnalyzer analyzer = new StandardAnalyzer();
+
+
+   public static void authCan(StringBuffer authCan, JBossRenderRequest req, String[] testArray, ResourceBundle bundle)
+   {
+      boolean authPost = hasPermission(req, testArray, "AddPostInForum");
+      boolean authEdit = hasPermission(req, testArray, "EditPostInForum");
+      boolean authDelete = hasPermission(req, testArray, "DeletePostInForum");
+      boolean authPoll = hasPermission(req, testArray, "AddPollInPost");
+      boolean authVote = hasPermission(req, testArray, "VotePollInPost");
+      //boolean authMod = hasPermission(req, testArray, "ModerateForum");
+
+      authCan.append(authPost ? bundle.getString("Rules_post_can") : bundle.getString("Rules_post_cannot")).
+         append("<br/>").
+         /* append(authEdit ? bundle.getString("Rules_edit_can") : bundle.getString("Rules_edit_cannot")).
+         append("<br/>").
+         append(authDelete ? bundle.getString("Rules_delete_can") : bundle.getString("Rules_delete_cannot")).
+         append("<br/>").*/
+            append(authPoll ? bundle.getString("Rules_poll_can") : bundle.getString("Rules_poll_cannot")).
+         append("<br/>").
+         append(authVote ? bundle.getString("Rules_vote_can") : bundle.getString("Rules_vote_cannot")).
+         append("<br/>");
+   }
+
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer   DOCUMENT_ME
+    * @param name     DOCUMENT_ME
+    * @param value    DOCUMENT_ME
+    * @param selected DOCUMENT_ME
+    */
+   public static void radioButton(StringBuffer buffer,
+                                  String name,
+                                  String value,
+                                  boolean selected)
+   {
+      buffer.append("<input type=\"radio\" name=\"").append(name).append("\" value=\"").append(value).append("\"")
+         .append(selected ? " checked=\"checked\"/>" : "/>");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param url    DOCUMENT_ME
+    * @param target DOCUMENT_ME
+    * @param image  DOCUMENT_ME
+    * @param title  DOCUMENT_ME
+    * @param alt    DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String createImageLink(String url,
+                                        String target,
+                                        String image,
+                                        String title,
+                                        String alt)
+   {
+      return "<a href=\"" + url + "\" target=\"" + target + "\"><img src=\"" + image + "\" " + "alt=\"" + alt
+         + "\" title=\"" + title + "\" border=\"0\"></a>";
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param url   DOCUMENT_ME
+    * @param image DOCUMENT_ME
+    * @param title DOCUMENT_ME
+    * @param alt   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String createImageLink(String url,
+                                        String image,
+                                        String title,
+                                        String alt)
+   {
+      return "<a href=\"" + url + "\"><img src=\"" + image + "\" " + "alt=\"" + alt + "\" title=\"" + title
+         + "\" border=\"0\"></a>";
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param url   DOCUMENT_ME
+    * @param image DOCUMENT_ME
+    * @param title DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String createImageLink(String url,
+                                        String image,
+                                        String title)
+   {
+      return createImageLink(url, image, title, title);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param url  DOCUMENT_ME
+    * @param text DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String createLink(String url,
+                                   String text)
+   {
+      return "<a href=\"" + url + "\">" + text + "</a>";
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param url    DOCUMENT_ME
+    * @param target DOCUMENT_ME
+    * @param text   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String createLink(String url,
+                                   String target,
+                                   String text)
+   {
+      return "<a href=\"" + url + "\" target=\"" + target + "\">" + text + "</a>";
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param text  DOCUMENT_ME
+    * @param field DOCUMENT_ME
+    * @param isOr  DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static Query createQuery(String text,
+                                   String field,
+                                   boolean isOr)
+   {
+      try
+      {
+         QueryParser parser = new QueryParser(field, analyzer);
+         parser.setOperator(isOr ? QueryParser.DEFAULT_OPERATOR_OR : QueryParser.DEFAULT_OPERATOR_AND);
+         return parser.parse(text);
+      }
+      catch (ParseException e)
+      {
+         log.error("Cannot parse query " + text, e);
+         return DUMMY_QUERY;
+      }
+   }
+
+   private static final Query DUMMY_QUERY = new BooleanQuery();
+
+
+   /**
+    * returns html <options> containing forums
+    *
+    * @param forums DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String listTopics(List forums)
+   {
+      Iterator result = forums.iterator();
+
+      // hold the result
+      StringBuffer buffer = new StringBuffer();
+
+      // do the work
+      while (result.hasNext())
+      {
+         Forum forum = (Forum)result.next();
+         buffer.append("<option value=\"").append(forum.getId()).append("\"")
+            .append(">")
+            .append(forum.getName()).append("</option>\n");
+      }
+
+      return buffer.toString();
+   }
+
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forums     DOCUMENT_ME
+    * @param selectedId DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String listForums(List forums,
+                                   int selectedId)
+   {
+      Iterator result = forums.iterator();
+
+      // hold the result
+      StringBuffer buffer = new StringBuffer();
+
+      // do the work
+      while (result.hasNext())
+      {
+         Forum forum = (Forum)result.next();
+         buffer.append("<option value=\"").append(forum.getId()).append("\"")
+            .append((selectedId == forum.getId().intValue()) ? " selected=\"selected\"" : "").append(">")
+            .append(forum.getName()).append("</option>\n");
+      }
+
+      return buffer.toString();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param categories DOCUMENT_ME
+    * @param selectedId DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String listCategories(List categories,
+                                       int selectedId)
+   {
+      Iterator result = categories.iterator();
+
+      // hold the result
+      StringBuffer buffer = new StringBuffer();
+
+      // do the work
+      while (result.hasNext())
+      {
+         Category category = (Category)result.next();
+         buffer.append("<option value=\"").append(category.getId()).append("\"")
+            .append((selectedId == category.getId().intValue()) ? " selected=\"selected\"" : "").append(">")
+            .append(category.getTitle()).append("</option>\n");
+      }
+
+      return buffer.toString();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param categories DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String listForumsCategories(ForumsModule module)
+   {
+      Iterator resultCat = null;
+      try
+      {
+         resultCat = module.findCategories().iterator();
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         return "";
+      }
+
+      // hold the result
+      StringBuffer buffer = new StringBuffer();
+
+      // do the work
+      while (resultCat.hasNext())
+      {
+         Category category = (Category)resultCat.next();
+         buffer.append("<option value=\"").append("cx" + category.getId()).append("\"")
+            .append(">")
+            .append("&nbsp;&nbsp;&nbsp; " + category.getTitle()).append("</option>\n");
+
+         Iterator resultForum = null;
+         try
+         {
+            resultForum = module.findForumsByCategoryId(category.getId()).iterator();
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            return "";
+         }
+
+         // hold the result
+         //StringBuffer buffer = new StringBuffer();
+
+         // do the work
+         while (resultForum.hasNext())
+         {
+            Forum forum = (Forum)resultForum.next();
+            buffer.append("<option value=\"").append("fx" + forum.getId()).append("\"")
+               .append(">")
+               .append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " + forum.getName()).append("</option>\n");
+         }
+
+      }
+
+      return buffer.toString();
+   }
+
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @param days DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String selectDays(String name,
+                                   int days)
+   {
+      StringBuffer selectDays = new StringBuffer("<select name=\"").append(name).append("\">");
+      for (int i = 0; i < ForumsConstants.PREVIOUS_DAYS.length; i++)
+      {
+         selectDays.append("<option value=\"").append(ForumsConstants.PREVIOUS_DAYS[i]).append("\"")
+            .append((days == ForumsConstants.PREVIOUS_DAYS[i]) ? " selected=\"selected\"" : "").append(">")
+            .append(ForumsConstants.PREVIOUS_DAYS_TEXT_TOPICS[i]).append("</option>");
+      }
+
+      selectDays.append("</select>");
+      return selectDays.toString();
+   }
+
+   /**
+    * Performs a generic batch update.
+    */
+   public static void batchUpdate(Connection conn,
+                                  String updateQuery,
+                                  String selectQuery,
+                                  int size)
+      throws SQLException
+   {
+      PreparedStatement updater = null;
+      PreparedStatement selecter = null;
+      ResultSet rs = null;
+      try
+      {
+         updater = conn.prepareStatement(updateQuery);
+
+         // not yet implemented in MySQL Connector/J driver 3.0.9
+         // int size = updater.getParameterMetaData().getParameterCount();
+         selecter = conn.prepareStatement(selectQuery);
+         rs = selecter.executeQuery();
+         while (rs.next())
+         {
+            for (int i = 1; i <= size; i++)
+            {
+               updater.setObject(i,
+                  rs.getObject(i));
+            }
+
+            updater.executeUpdate();
+         }
+      }
+      finally
+      {
+         if (!conn.getAutoCommit())
+         {
+            conn.commit();
+         }
+
+         Tools.safeClose(rs);
+         Tools.safeClose(updater);
+         Tools.safeClose(selecter);
+      }
+   }
+
+//   /**
+//    * DOCUMENT_ME
+//    *
+//    * @param authCan DOCUMENT_ME
+//    * @param forum DOCUMENT_ME
+//    * @param loggedIn DOCUMENT_ME
+//    * @param level DOCUMENT_ME
+//    */
+//   public static void authCan(StringBuffer authCan,
+//                              Forum        forum,
+//                              boolean      loggedIn,
+//                              Level        level)
+//   {
+//      /*
+//         authCan.append(Auth.hasLevel(forum.getAuth().getPost(), loggedIn, level) ? "${bb.Rules_post_can}" : "${bb.Rules_post_cannot}").
+//                 append("<br/>").
+//                 append(Auth.hasLevel(forum.getAuth().getReply(), loggedIn, level) ? "${bb.Rules_reply_can}" : "${bb.Rules_reply_cannot}").
+//                 append("<br/>").
+//                 append(Auth.hasLevel(forum.getAuth().getEdit(), loggedIn, level) ? "${bb.Rules_edit_can}" : "${bb.Rules_edit_cannot}").
+//                 append("<br/>").
+//                 append(Auth.hasLevel(forum.getAuth().getDelete(), loggedIn, level) ? "${bb.Rules_delete_can}" : "${bb.Rules_delete_cannot}").
+//                 append("<br/>").
+//                 append(Auth.hasLevel(forum.getAuth().getVote(), loggedIn, level) ? "${bb.Rules_vote_can}" : "${bb.Rules_vote_cannot}").
+//                 append("<br/>");
+//       */
+//   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param start DOCUMENT_ME
+    * @param size  DOCUMENT_ME
+    * @param per   DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String pageNumber(int start,
+                                   int size,
+                                   int per)
+   {
+      return "${bb.Page_of_0}" + (int)Math.ceil((double)start / (double)(per)) + "${bb.Page_of_1}"
+         + (int)Math.ceil((double)size / (double)per) + "${bb.Page_of_2}";
+   }
+
+   /**
+    * @param home   where the EJBs are taken
+    * @param getter how to get some info about the EJB
+    * @param key    the key used to set the skip or select the item in the list according the all parameter
+    * @param all    force all the items to be displayed
+    * @return
+    */
+   public static String selectEJBs(EJBLocalHome home,
+                                   Method getter,
+                                   Object key,
+                                   boolean all)
+   {
+      try
+      {
+         // empty args for the reflection call
+         Object[] empty = new Object[0];
+
+         // the findAll method will give us all the EJBs
+         Method findAll = home.getClass().getMethod("findAll",
+            new Class[0]);
+         Iterator result = ((Collection)findAll.invoke(home, empty)).iterator();
+
+         // hold the result
+         StringBuffer buffer = new StringBuffer();
+
+         // do the work
+         while (result.hasNext())
+         {
+            EJBLocalObject ejb = (EJBLocalObject)result.next();
+            Object ejbKey = ejb.getPrimaryKey();
+            boolean equals = ejbKey.equals(key);
+            if (all || equals)
+            {
+               buffer.append("<option value=\"").append(ejbKey).append("\"")
+                  .append(equals ? " selected=\"selected\"" : "").append(">").append(getter.invoke(ejb, empty))
+                  .append("</option>\n");
+            }
+         }
+
+         // return the string buffer content
+         return buffer.toString();
+      }
+      catch (Exception e)
+      {
+         log.error("Cannot list ejbs", e);
+         return "";
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param clazz  DOCUMENT_ME
+    * @param prefix DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static String[][] collectFields(Class clazz,
+                                          String prefix)
+   {
+      Field[] fields = clazz.getDeclaredFields();
+      List values = new ArrayList(fields.length);
+      for (int i = 0; i < fields.length; i++)
+      {
+         Field field = fields[i];
+         int modifier = field.getModifiers();
+         if (field.getName().startsWith(prefix)
+            && Modifier.isFinal(modifier)
+            && Modifier.isPublic(modifier)
+            && Modifier.isStatic(modifier))
+         {
+            try
+            {
+               values.add(new String[]
+                  {
+                     field.getName(),
+                     (String)field.get(null)
+                  });
+            }
+            catch (Exception ignore)
+            {
+               Logger.getLogger(clazz).error("", ignore);
+            }
+         }
+      }
+
+      return (String[][])values.toArray(new String[values.size()][]);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param c DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static Object head(Collection c)
+   {
+      Iterator iterator = c.iterator();
+      return iterator.hasNext() ? iterator.next() : null;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param format_1_00 DOCUMENT_ME
+    * @param forumId     DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static final String computeCacheKey(boolean format_1_00,
+                                              String forumId)
+   {
+      return (format_1_00 ? "rss/1.00" : "rss/0.91") + ((forumId != null) ? ("/" + forumId) : "");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param s DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static boolean isNullOrBlank(String s)
+   {
+      if (s != null)
+      {
+         for (int i = 0; i < s.length(); i++)
+         {
+            if (!Character.isWhitespace(s.charAt(i)))
+            {
+               return false;
+            }
+         }
+      }
+
+      return true;
+   }
+
+   public static boolean hasPermission(PortletRequest req, String[] test, String permission)
+   {
+      return hasPermission(req, permission);
+   }
+
+   public static boolean hasPermission(PortletRequest req, String perm)
+   {
+
+      if (perm.equals("Admin")
+         || perm.equals("Delete")
+         || perm.equals("AdminCategory")
+         || perm.equals("DeleteForumInCategory")
+         || perm.equals("AddForumInCategory")
+         || perm.equals("EditCategory")
+         || perm.equals("AddForumInCategory")
+         || perm.equals("EditForumInCategory")
+         )
+      {
+         if (req.isUserInRole("ForumsAdmin"))
+         {
+            return true;
+         }
+      }
+
+      if (perm.equals("ModerateForum")
+         || perm.equals("AddPollInPost")
+         || perm.equals("EditPollInPost")
+         || perm.equals("AddAttachmentInPost")
+         || perm.equals("DeletePostInForum")
+         || perm.equals("EditPostInForum")
+         )
+      {
+         if (req.isUserInRole("ForumsAdmin")
+            || req.isUserInRole("ForumsModerator"))
+         {
+            return true;
+         }
+      }
+
+      if (perm.equals("AddPollInPost"))
+      {
+         if (req.isUserInRole("ForumsAdmin")
+            || req.isUserInRole("ForumsModerator")
+            || req.isUserInRole("ForumsPolls"))
+         {
+            return true;
+         }
+      }
+
+
+      if (perm.equals("AddAttachmentInPost"))
+      {
+         if (req.isUserInRole("ForumsAdmin")
+            || req.isUserInRole("ForumsModerator")
+            || req.isUserInRole("ForumsAttachments"))
+         {
+            return true;
+         }
+      }
+
+      if (perm.equals("AddPostInForum")
+         || perm.equals("VotePollInPost")
+
+         )
+      {
+         if (req.isUserInRole("ForumsAdmin")
+            || req.isUserInRole("ForumsModerator")
+            || req.isUserInRole("ForumsAttachments")
+            || req.isUserInRole("ForumsPolls")
+            || req.isUserInRole("ForumsUser"))
+         {
+            return true;
+         }
+      }
+
+
+      if (perm.equals("ReadCategory")
+         || perm.equals("ReadForum"))
+      {
+         return true;
+      }
+
+      return false;
+   }
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Goto.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Goto.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Goto.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,194 +1,194 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-public class Goto
-   extends Range
-{
-   private int postSize;
-   private int postsPerPage;
-   private int topicId;
-   private String imgUrl;
-   private String gotoText;
-   private String url;
-
-   /**
-    * Creates a new {@link Goto} object.
-    *
-    * @param postsPerPage DOCUMENT_ME
-    * @param gotoText     DOCUMENT_ME
-    */
-   public Goto(int postsPerPage,
-               String gotoText, String url)
-   {
-      super(3, 0, 3);
-      this.postsPerPage = postsPerPage;
-      this.gotoText = gotoText;
-      this.url = url;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int getPostSize()
-   {
-      return postSize;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param postSize DOCUMENT_ME
-    */
-   public void setPostSize(int postSize)
-   {
-      this.postSize = postSize;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int getTopicId()
-   {
-      return topicId;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topicId DOCUMENT_ME
-    */
-   public void setTopicId(int topicId)
-   {
-      this.topicId = topicId;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public String getImgUrl()
-   {
-      return imgUrl;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param imgUrl DOCUMENT_ME
-    */
-   public void setImgUrl(String imgUrl)
-   {
-      this.imgUrl = imgUrl;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public String generate()
-   {
-      if (postSize >= postsPerPage)
-      {
-         return build((int)Math.ceil((double)(postSize + 1) / (double)postsPerPage), -1);
-      }
-      else
-      {
-         return "";
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    */
-   protected void start(StringBuffer buffer)
-   {
-      buffer.append("[ <img src=\"").append(imgUrl).append("\" alt=\"" + gotoText + "\" title=\"" + gotoText
-         + "\"/>" + gotoText + ": ");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    */
-   protected final void end(StringBuffer buffer)
-   {
-      buffer.append(" ] ");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void normal(StringBuffer buffer,
-                               int index)
-   {
-      lastNormal(buffer, index);
-      buffer.append(", ");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void enhanced(StringBuffer buffer,
-                                 int index)
-   {
-      lastNormal(buffer, index);
-      buffer.append(", ");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void lastNormal(StringBuffer buffer,
-                                   int index)
-   {
-      buffer.append("<a href=\"").append(url).append("&t=").append(topicId) .append("&start=")
-         .append(index * postsPerPage).append("\">").append(index + 1).append("</a>");
-      /*buffer.append("<a href=\"index.html?module=bb&op=viewtopic&t=").append(topicId).append("&start=")
-         .append(index * postsPerPage).append("\">").append(index + 1).append("</a>");*/
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void lastEnhanced(StringBuffer buffer,
-                                     int index)
-   {
-      lastNormal(buffer, index);
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+public class Goto
+   extends Range
+{
+   private int postSize;
+   private int postsPerPage;
+   private int topicId;
+   private String imgUrl;
+   private String gotoText;
+   private String url;
+
+   /**
+    * Creates a new {@link Goto} object.
+    *
+    * @param postsPerPage DOCUMENT_ME
+    * @param gotoText     DOCUMENT_ME
+    */
+   public Goto(int postsPerPage,
+               String gotoText, String url)
+   {
+      super(3, 0, 3);
+      this.postsPerPage = postsPerPage;
+      this.gotoText = gotoText;
+      this.url = url;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getPostSize()
+   {
+      return postSize;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param postSize DOCUMENT_ME
+    */
+   public void setPostSize(int postSize)
+   {
+      this.postSize = postSize;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getTopicId()
+   {
+      return topicId;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topicId DOCUMENT_ME
+    */
+   public void setTopicId(int topicId)
+   {
+      this.topicId = topicId;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String getImgUrl()
+   {
+      return imgUrl;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param imgUrl DOCUMENT_ME
+    */
+   public void setImgUrl(String imgUrl)
+   {
+      this.imgUrl = imgUrl;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String generate()
+   {
+      if (postSize >= postsPerPage)
+      {
+         return build((int)Math.ceil((double)(postSize + 1) / (double)postsPerPage), -1);
+      }
+      else
+      {
+         return "";
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    */
+   protected void start(StringBuffer buffer)
+   {
+      buffer.append("[ <img src=\"").append(imgUrl).append("\" alt=\"" + gotoText + "\" title=\"" + gotoText
+         + "\"/>" + gotoText + ": ");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    */
+   protected final void end(StringBuffer buffer)
+   {
+      buffer.append(" ] ");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void normal(StringBuffer buffer,
+                               int index)
+   {
+      lastNormal(buffer, index);
+      buffer.append(", ");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void enhanced(StringBuffer buffer,
+                                 int index)
+   {
+      lastNormal(buffer, index);
+      buffer.append(", ");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void lastNormal(StringBuffer buffer,
+                                   int index)
+   {
+      buffer.append("<a href=\"").append(url).append("&t=").append(topicId) .append("&start=")
+         .append(index * postsPerPage).append("\">").append(index + 1).append("</a>");
+      /*buffer.append("<a href=\"index.html?module=bb&op=viewtopic&t=").append(topicId).append("&start=")
+         .append(index * postsPerPage).append("\">").append(index + 1).append("</a>");*/
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void lastEnhanced(StringBuffer buffer,
+                                     int index)
+   {
+      lastNormal(buffer, index);
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/GotoWithOffset.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/GotoWithOffset.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/GotoWithOffset.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,167 +1,167 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.2 $
- */
-public class GotoWithOffset
-   extends Range
-{
-   private int perPage;
-   private String URL;
-   private int offset;
-   private int size;
-   private String gotoPageLabel;
-   private String previousLabel;
-   private String nextLabel;
-
-   /**
-    * Creates a new {@link GotoWithOffset} object.
-    *
-    * @param size          DOCUMENT_ME
-    * @param offset        DOCUMENT_ME
-    * @param perPage       DOCUMENT_ME
-    * @param URL           DOCUMENT_ME
-    * @param gotoPageLabel DOCUMENT_ME
-    * @param previousLabel DOCUMENT_ME
-    * @param nextLabel     DOCUMENT_ME
-    */
-   public GotoWithOffset(int size,
-                         int offset,
-                         int perPage,
-                         String URL,
-                         String gotoPageLabel,
-                         String previousLabel,
-                         String nextLabel)
-   {
-      super(3, 3, 3);
-      this.size = size;
-      this.offset = offset;
-      this.perPage = perPage;
-      this.URL = URL;
-      this.gotoPageLabel = gotoPageLabel;
-      this.previousLabel = previousLabel;
-      this.nextLabel = nextLabel;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param offset DOCUMENT_ME
-    */
-   public void setOffset(int offset)
-   {
-      this.offset = offset;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    */
-   protected final void start(StringBuffer buffer)
-   {
-      buffer.append(gotoPageLabel);
-      buffer.append(" ");
-      int offset = (int)Math.floor((double)this.offset / (double)perPage);
-      if (offset > 0)
-      {
-         offset = (offset - 1) * perPage;
-         buffer.append(" <a href=\"").append(URL).append(offset).append("\">").append(previousLabel).append("</a>&nbsp;&nbsp;");
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    */
-   protected final void end(StringBuffer buffer)
-   {
-      int nextOffset = (int)(Math.floor((double)this.offset / (double)perPage) + 1) * perPage;
-      if (nextOffset < size)
-      {
-         buffer.append("&nbsp;&nbsp;<a href=\"").append(URL).append(nextOffset).append("\">").append(nextLabel)
-            .append("</a>&nbsp;&nbsp;");
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void normal(StringBuffer buffer,
-                               int index)
-   {
-      lastNormal(buffer, index);
-      buffer.append(", ");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void enhanced(StringBuffer buffer,
-                                 int index)
-   {
-      lastEnhanced(buffer, index);
-      buffer.append(", ");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void lastNormal(StringBuffer buffer,
-                                   int index)
-   {
-      buffer.append("<a href=\"").append(URL).append(index * perPage).append("\">").append(index + 1).append("</a>");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param buffer DOCUMENT_ME
-    * @param index  DOCUMENT_ME
-    */
-   protected final void lastEnhanced(StringBuffer buffer,
-                                     int index)
-   {
-      buffer.append("<b>").append(index + 1).append("</b>");
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public String generate()
-   {
-      if (size > perPage)
-      {
-         return build((int)Math.ceil(size / (double)perPage), (int)Math.floor(offset / (double)perPage));
-      }
-      else
-      {
-         return "";
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.2 $
+ */
+public class GotoWithOffset
+   extends Range
+{
+   private int perPage;
+   private String URL;
+   private int offset;
+   private int size;
+   private String gotoPageLabel;
+   private String previousLabel;
+   private String nextLabel;
+
+   /**
+    * Creates a new {@link GotoWithOffset} object.
+    *
+    * @param size          DOCUMENT_ME
+    * @param offset        DOCUMENT_ME
+    * @param perPage       DOCUMENT_ME
+    * @param URL           DOCUMENT_ME
+    * @param gotoPageLabel DOCUMENT_ME
+    * @param previousLabel DOCUMENT_ME
+    * @param nextLabel     DOCUMENT_ME
+    */
+   public GotoWithOffset(int size,
+                         int offset,
+                         int perPage,
+                         String URL,
+                         String gotoPageLabel,
+                         String previousLabel,
+                         String nextLabel)
+   {
+      super(3, 3, 3);
+      this.size = size;
+      this.offset = offset;
+      this.perPage = perPage;
+      this.URL = URL;
+      this.gotoPageLabel = gotoPageLabel;
+      this.previousLabel = previousLabel;
+      this.nextLabel = nextLabel;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param offset DOCUMENT_ME
+    */
+   public void setOffset(int offset)
+   {
+      this.offset = offset;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    */
+   protected final void start(StringBuffer buffer)
+   {
+      buffer.append(gotoPageLabel);
+      buffer.append(" ");
+      int offset = (int)Math.floor((double)this.offset / (double)perPage);
+      if (offset > 0)
+      {
+         offset = (offset - 1) * perPage;
+         buffer.append(" <a href=\"").append(URL).append(offset).append("\">").append(previousLabel).append("</a>&nbsp;&nbsp;");
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    */
+   protected final void end(StringBuffer buffer)
+   {
+      int nextOffset = (int)(Math.floor((double)this.offset / (double)perPage) + 1) * perPage;
+      if (nextOffset < size)
+      {
+         buffer.append("&nbsp;&nbsp;<a href=\"").append(URL).append(nextOffset).append("\">").append(nextLabel)
+            .append("</a>&nbsp;&nbsp;");
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void normal(StringBuffer buffer,
+                               int index)
+   {
+      lastNormal(buffer, index);
+      buffer.append(", ");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void enhanced(StringBuffer buffer,
+                                 int index)
+   {
+      lastEnhanced(buffer, index);
+      buffer.append(", ");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void lastNormal(StringBuffer buffer,
+                                   int index)
+   {
+      buffer.append("<a href=\"").append(URL).append(index * perPage).append("\">").append(index + 1).append("</a>");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param buffer DOCUMENT_ME
+    * @param index  DOCUMENT_ME
+    */
+   protected final void lastEnhanced(StringBuffer buffer,
+                                     int index)
+   {
+      buffer.append("<b>").append(index + 1).append("</b>");
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String generate()
+   {
+      if (size > perPage)
+      {
+         return build((int)Math.ceil(size / (double)perPage), (int)Math.floor(offset / (double)perPage));
+      }
+      else
+      {
+         return "";
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/IndexIterator.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/IndexIterator.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/IndexIterator.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,112 +1,112 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.Iterator;
-
-/**
- * An iterator wrapper than keeps track of the index.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class IndexIterator
-   implements Iterator
-{
-   private int index;
-   private Iterator iterator;
-
-   /**
-    * Creates a new {@link IndexIterator} object.
-    *
-    * @param iterator DOCUMENT_ME
-    */
-   public IndexIterator(Iterator iterator)
-   {
-      this(iterator, 0);
-   }
-
-   /**
-    * Creates a new {@link IndexIterator} object.
-    *
-    * @param iterator DOCUMENT_ME
-    * @param start    DOCUMENT_ME
-    */
-   public IndexIterator(Iterator iterator,
-                        int start)
-   {
-      this.iterator = iterator;
-      this.index = start;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean hasNext()
-   {
-      return iterator.hasNext();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public Object next()
-   {
-      index++;
-      return iterator.next();
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public void remove()
-   {
-      iterator.remove();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public int getIndex()
-   {
-      return index;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param iterator DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static IndexIterator wrap(Iterator iterator)
-   {
-      return new IndexIterator(iterator);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param iterator DOCUMENT_ME
-    * @param start    DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static IndexIterator wrap(Iterator iterator,
-                                    int start)
-   {
-      return new IndexIterator(iterator, start);
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+import java.util.Iterator;
+
+/**
+ * An iterator wrapper than keeps track of the index.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class IndexIterator
+   implements Iterator
+{
+   private int index;
+   private Iterator iterator;
+
+   /**
+    * Creates a new {@link IndexIterator} object.
+    *
+    * @param iterator DOCUMENT_ME
+    */
+   public IndexIterator(Iterator iterator)
+   {
+      this(iterator, 0);
+   }
+
+   /**
+    * Creates a new {@link IndexIterator} object.
+    *
+    * @param iterator DOCUMENT_ME
+    * @param start    DOCUMENT_ME
+    */
+   public IndexIterator(Iterator iterator,
+                        int start)
+   {
+      this.iterator = iterator;
+      this.index = start;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean hasNext()
+   {
+      return iterator.hasNext();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Object next()
+   {
+      index++;
+      return iterator.next();
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public void remove()
+   {
+      iterator.remove();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getIndex()
+   {
+      return index;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param iterator DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static IndexIterator wrap(Iterator iterator)
+   {
+      return new IndexIterator(iterator);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param iterator DOCUMENT_ME
+    * @param start    DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static IndexIterator wrap(Iterator iterator,
+                                    int start)
+   {
+      return new IndexIterator(iterator, start);
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Range.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Range.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Range.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,248 +1,248 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-
-/**
- * Generate a jump bar like : [0,1,2,...,10,11,12,...,21,22,23]
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class Range
-{
-   /**
-    * @param left   is the max number of items displayed on the left part
-    * @param middle is the max number of items displayed in the middle part
-    * @param right  is the max number of items displayed in the right part
-    */
-   public Range(int left,
-                int middle,
-                int right)
-   {
-      this.left = left;
-      this.middle = middle;
-      this.right = right;
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   protected final int left;
-
-   /**
-    * DOCUMENT_ME
-    */
-   protected final int middle;
-
-   /**
-    * DOCUMENT_ME
-    */
-   protected final int right;
-
-   /**
-    * Begin the generated string.
-    */
-   protected void start(StringBuffer buffer)
-   {
-      buffer.append("[");
-   }
-
-   /**
-    * End the generated string.
-    */
-   protected void end(StringBuffer buffer)
-   {
-      buffer.append("]");
-   }
-
-   /**
-    * Generates a non last normal item.
-    */
-   protected void normal(StringBuffer buffer,
-                         int index)
-   {
-      buffer.append(index).append(",");
-   }
-
-   /**
-    * Generates a last normal item.
-    */
-   protected void lastNormal(StringBuffer buffer,
-                             int index)
-   {
-      buffer.append(index);
-   }
-
-   /**
-    * Generates a non last enhanced item.
-    */
-   protected void enhanced(StringBuffer buffer,
-                           int index)
-   {
-      buffer.append("-").append(index).append("-,");
-   }
-
-   /**
-    * Generates a last enhanced item.
-    */
-   protected void lastEnhanced(StringBuffer buffer,
-                               int index)
-   {
-      buffer.append("-").append(index).append("-");
-   }
-
-   /**
-    * Generates a gap.
-    */
-   protected void gap(StringBuffer buffer)
-   {
-      buffer.append(" ... ");
-   }
-
-   /**
-    * Generates a separator.
-    */
-   protected void separe(StringBuffer buffer)
-   {
-      buffer.append(", ");
-   }
-
-   /**
-    * Do the job.
-    */
-   protected final String build(int size,
-                                int offset)
-   {
-      // Computes the boundaries a priori
-      int l1 = 0;
-      int r1 = left;
-      int l2 = offset - (middle / 2);
-      int r2 = offset + ((middle + 1) / 2);
-      int l3 = size - right;
-      int r3 = size;
-
-      // Check that the left part is not bigger than the entire range
-      if (size < r1)
-      {
-         r1 = size;
-      }
-
-      // Check that the right part does not span on the left one
-      if (l3 < r1)
-      {
-         l3 = r1;
-      }
-
-      // Correct the left boundary of the mid part if necessary
-      if (l2 < r1)
-      {
-         l2 = r1;
-      }
-
-      // Correct the right boundary of the mid part if necessary
-      if (l3 < r2)
-      {
-         r2 = l3;
-      }
-
-      StringBuffer buffer = new StringBuffer();
-      start(buffer);
-
-      // Displays the left part
-      range(buffer, l1, offset, r1);
-
-      if (l2 < r2)
-      {
-         gap(buffer, r1, l2);
-         range(buffer, l2, offset, r2);
-         gap(buffer, r2, l3);
-         range(buffer, l3, offset, r3);
-      }
-      else if (l3 < r3)
-      {
-         gap(buffer, r1, l3);
-         range(buffer, l3, offset, r3);
-      }
-
-      end(buffer);
-
-      return buffer.toString();
-   }
-
-   private void gap(StringBuffer buffer,
-                    int from,
-                    int to)
-   {
-      if (from < to)
-      {
-         gap(buffer);
-      }
-      else if (from == to)
-      {
-         separe(buffer);
-      }
-   }
-
-   /**
-    * @param buffer the output buffer
-    * @param from   inclusive
-    * @param offset the highlighted offset
-    * @param to     exclusive
-    */
-   private void range(StringBuffer buffer,
-                      int from,
-                      int offset,
-                      int to)
-   {
-      boolean last = from < to--;
-      if ((from <= offset) && (offset <= to))
-      {
-         while (from < offset)
-         {
-            normal(buffer, from++);
-         }
-
-         if (from < to)
-         {
-            enhanced(buffer, from++);
-         }
-         while (from < to)
-         {
-            normal(buffer, from++);
-         }
-
-         if (last)
-         {
-            if (offset == from)
-            {
-               lastEnhanced(buffer, from);
-            }
-            else
-            {
-               lastNormal(buffer, from);
-            }
-         }
-      }
-      else
-      {
-         while (from < to)
-         {
-            normal(buffer, from++);
-         }
-
-         if (last)
-         {
-            lastNormal(buffer, from);
-         }
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+
+/**
+ * Generate a jump bar like : [0,1,2,...,10,11,12,...,21,22,23]
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class Range
+{
+   /**
+    * @param left   is the max number of items displayed on the left part
+    * @param middle is the max number of items displayed in the middle part
+    * @param right  is the max number of items displayed in the right part
+    */
+   public Range(int left,
+                int middle,
+                int right)
+   {
+      this.left = left;
+      this.middle = middle;
+      this.right = right;
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   protected final int left;
+
+   /**
+    * DOCUMENT_ME
+    */
+   protected final int middle;
+
+   /**
+    * DOCUMENT_ME
+    */
+   protected final int right;
+
+   /**
+    * Begin the generated string.
+    */
+   protected void start(StringBuffer buffer)
+   {
+      buffer.append("[");
+   }
+
+   /**
+    * End the generated string.
+    */
+   protected void end(StringBuffer buffer)
+   {
+      buffer.append("]");
+   }
+
+   /**
+    * Generates a non last normal item.
+    */
+   protected void normal(StringBuffer buffer,
+                         int index)
+   {
+      buffer.append(index).append(",");
+   }
+
+   /**
+    * Generates a last normal item.
+    */
+   protected void lastNormal(StringBuffer buffer,
+                             int index)
+   {
+      buffer.append(index);
+   }
+
+   /**
+    * Generates a non last enhanced item.
+    */
+   protected void enhanced(StringBuffer buffer,
+                           int index)
+   {
+      buffer.append("-").append(index).append("-,");
+   }
+
+   /**
+    * Generates a last enhanced item.
+    */
+   protected void lastEnhanced(StringBuffer buffer,
+                               int index)
+   {
+      buffer.append("-").append(index).append("-");
+   }
+
+   /**
+    * Generates a gap.
+    */
+   protected void gap(StringBuffer buffer)
+   {
+      buffer.append(" ... ");
+   }
+
+   /**
+    * Generates a separator.
+    */
+   protected void separe(StringBuffer buffer)
+   {
+      buffer.append(", ");
+   }
+
+   /**
+    * Do the job.
+    */
+   protected final String build(int size,
+                                int offset)
+   {
+      // Computes the boundaries a priori
+      int l1 = 0;
+      int r1 = left;
+      int l2 = offset - (middle / 2);
+      int r2 = offset + ((middle + 1) / 2);
+      int l3 = size - right;
+      int r3 = size;
+
+      // Check that the left part is not bigger than the entire range
+      if (size < r1)
+      {
+         r1 = size;
+      }
+
+      // Check that the right part does not span on the left one
+      if (l3 < r1)
+      {
+         l3 = r1;
+      }
+
+      // Correct the left boundary of the mid part if necessary
+      if (l2 < r1)
+      {
+         l2 = r1;
+      }
+
+      // Correct the right boundary of the mid part if necessary
+      if (l3 < r2)
+      {
+         r2 = l3;
+      }
+
+      StringBuffer buffer = new StringBuffer();
+      start(buffer);
+
+      // Displays the left part
+      range(buffer, l1, offset, r1);
+
+      if (l2 < r2)
+      {
+         gap(buffer, r1, l2);
+         range(buffer, l2, offset, r2);
+         gap(buffer, r2, l3);
+         range(buffer, l3, offset, r3);
+      }
+      else if (l3 < r3)
+      {
+         gap(buffer, r1, l3);
+         range(buffer, l3, offset, r3);
+      }
+
+      end(buffer);
+
+      return buffer.toString();
+   }
+
+   private void gap(StringBuffer buffer,
+                    int from,
+                    int to)
+   {
+      if (from < to)
+      {
+         gap(buffer);
+      }
+      else if (from == to)
+      {
+         separe(buffer);
+      }
+   }
+
+   /**
+    * @param buffer the output buffer
+    * @param from   inclusive
+    * @param offset the highlighted offset
+    * @param to     exclusive
+    */
+   private void range(StringBuffer buffer,
+                      int from,
+                      int offset,
+                      int to)
+   {
+      boolean last = from < to--;
+      if ((from <= offset) && (offset <= to))
+      {
+         while (from < offset)
+         {
+            normal(buffer, from++);
+         }
+
+         if (from < to)
+         {
+            enhanced(buffer, from++);
+         }
+         while (from < to)
+         {
+            normal(buffer, from++);
+         }
+
+         if (last)
+         {
+            if (offset == from)
+            {
+               lastEnhanced(buffer, from);
+            }
+            else
+            {
+               lastNormal(buffer, from);
+            }
+         }
+      }
+      else
+      {
+         while (from < to)
+         {
+            normal(buffer, from++);
+         }
+
+         if (last)
+         {
+            lastNormal(buffer, from);
+         }
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/TempFileBinding.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/TempFileBinding.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/TempFileBinding.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,175 +1,175 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-
-package org.jboss.portlet.forums.helper;
-
-import org.jboss.portlet.forums.model.UploadedFile;
-import org.jboss.portlet.forums.model.Attachment;
-import org.jboss.portlet.forums.impl.UploadedFileImpl;
-import org.jboss.portlet.forums.impl.AttachmentImpl;
-import org.hibernate.Hibernate;
-
-import java.io.IOException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.sql.Blob;
-import java.sql.SQLException;
-
-
-/**
- * Provides binding to temp file stored to disk.
- *
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class TempFileBinding extends FileBinding
-{
-   private String filePath;
-
-   private String contentType;
-   //private String fileID;
-
-   /**
-    * Creates TempFileBinding. Content will be strored in temporary file using File.createTempFile
-    * @param contentType
-    * @param content
-    * @param name
-    * @param id
-    * @throws IOException
-    */
-   public TempFileBinding(String contentType, byte[] content, String name, String id) throws IOException
-   {
-      setContentType(contentType);
-      setFileName(name);
-      setFileId(id);
-      File tmpFile = File.createTempFile(id, "portal-forums-tmpfile");
-      setFilePath(tmpFile.getCanonicalPath());
-      FileOutputStream fo = new FileOutputStream(tmpFile);
-      fo.write(content);
-
-      fo.close();
-   }
-
-   /**
-    * Deletes stored on disk file.
-    */
-   public void delete()
-   {
-      File file = new File(filePath);
-      if (!file.delete())
-      {
-         file.deleteOnExit();
-      }
-   }
-
-   public String getFilePath()
-   {
-      return filePath;
-   }
-
-   public void setFilePath(String filePath)
-   {
-      this.filePath = filePath;
-   }
-
-
-   public String getContentType()
-   {
-      return contentType;
-   }
-
-   public void setContentType(String contentType)
-   {
-      this.contentType = contentType;
-   }
-
-   /**
-    * produces UploadedFile from stored on disk file.
-    * @return
-    */
-   public UploadedFile produceUploadedFile()
-   {
-      File tmp = new File(this.filePath);
-
-      try
-      {
-         /*Blob content = Hibernate.createBlob(getBytesFromFile(tmp));
-   return new UploadedFileImpl(contentType, content, fileName, tmp.length() );*/
-         return new UploadedFileImpl(contentType, getBytesFromFile(tmp), fileName, tmp.length());
-      }
-      catch (FileNotFoundException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-      catch (IOException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-      return null;
-   }
-
-   /**
-    * produces Attachment object form stored on disk file
-    * @return
-    */
-   public Attachment produceAttachment()
-   {
-      Attachment attach = new AttachmentImpl();
-      attach.setComment(comment);
-      attach.setFile(produceUploadedFile());
-      return attach;
-   }
-
-   // Returns the contents of the file in a byte array.
-   public static byte[] getBytesFromFile(File file) throws IOException
-   {
-      InputStream is = new FileInputStream(file);
-
-      // Get the size of the file
-      long length = file.length();
-
-      // You cannot create an array using a long type.
-      // It needs to be an int type.
-      // Before converting to an int type, check
-      // to ensure that file is not larger than Integer.MAX_VALUE.
-      if (length > Integer.MAX_VALUE)
-      {
-         //TODO:BD To long file - do smthng...
-         // File is too large
-      }
-
-      // Create the byte array to hold the data
-      byte[] bytes = new byte[(int)length];
-
-      // Read in the bytes
-      int offset = 0;
-      int numRead = 0;
-      while (offset < bytes.length
-         && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)
-      {
-         offset += numRead;
-      }
-
-      // Ensure all the bytes have been read in
-      if (offset < bytes.length)
-      {
-         throw new IOException("Could not completely read file " + file.getName());
-      }
-
-      // Close the input stream and return bytes
-      is.close();
-      return bytes;
-   }
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+
+package org.jboss.portlet.forums.helper;
+
+import org.jboss.portlet.forums.model.UploadedFile;
+import org.jboss.portlet.forums.model.Attachment;
+import org.jboss.portlet.forums.impl.UploadedFileImpl;
+import org.jboss.portlet.forums.impl.AttachmentImpl;
+import org.hibernate.Hibernate;
+
+import java.io.IOException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.sql.Blob;
+import java.sql.SQLException;
+
+
+/**
+ * Provides binding to temp file stored to disk.
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class TempFileBinding extends FileBinding
+{
+   private String filePath;
+
+   private String contentType;
+   //private String fileID;
+
+   /**
+    * Creates TempFileBinding. Content will be strored in temporary file using File.createTempFile
+    * @param contentType
+    * @param content
+    * @param name
+    * @param id
+    * @throws IOException
+    */
+   public TempFileBinding(String contentType, byte[] content, String name, String id) throws IOException
+   {
+      setContentType(contentType);
+      setFileName(name);
+      setFileId(id);
+      File tmpFile = File.createTempFile(id, "portal-forums-tmpfile");
+      setFilePath(tmpFile.getCanonicalPath());
+      FileOutputStream fo = new FileOutputStream(tmpFile);
+      fo.write(content);
+
+      fo.close();
+   }
+
+   /**
+    * Deletes stored on disk file.
+    */
+   public void delete()
+   {
+      File file = new File(filePath);
+      if (!file.delete())
+      {
+         file.deleteOnExit();
+      }
+   }
+
+   public String getFilePath()
+   {
+      return filePath;
+   }
+
+   public void setFilePath(String filePath)
+   {
+      this.filePath = filePath;
+   }
+
+
+   public String getContentType()
+   {
+      return contentType;
+   }
+
+   public void setContentType(String contentType)
+   {
+      this.contentType = contentType;
+   }
+
+   /**
+    * produces UploadedFile from stored on disk file.
+    * @return
+    */
+   public UploadedFile produceUploadedFile()
+   {
+      File tmp = new File(this.filePath);
+
+      try
+      {
+         /*Blob content = Hibernate.createBlob(getBytesFromFile(tmp));
+   return new UploadedFileImpl(contentType, content, fileName, tmp.length() );*/
+         return new UploadedFileImpl(contentType, getBytesFromFile(tmp), fileName, tmp.length());
+      }
+      catch (FileNotFoundException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+      catch (IOException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+      return null;
+   }
+
+   /**
+    * produces Attachment object form stored on disk file
+    * @return
+    */
+   public Attachment produceAttachment()
+   {
+      Attachment attach = new AttachmentImpl();
+      attach.setComment(comment);
+      attach.setFile(produceUploadedFile());
+      return attach;
+   }
+
+   // Returns the contents of the file in a byte array.
+   public static byte[] getBytesFromFile(File file) throws IOException
+   {
+      InputStream is = new FileInputStream(file);
+
+      // Get the size of the file
+      long length = file.length();
+
+      // You cannot create an array using a long type.
+      // It needs to be an int type.
+      // Before converting to an int type, check
+      // to ensure that file is not larger than Integer.MAX_VALUE.
+      if (length > Integer.MAX_VALUE)
+      {
+         //TODO:BD To long file - do smthng...
+         // File is too large
+      }
+
+      // Create the byte array to hold the data
+      byte[] bytes = new byte[(int)length];
+
+      // Read in the bytes
+      int offset = 0;
+      int numRead = 0;
+      while (offset < bytes.length
+         && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)
+      {
+         offset += numRead;
+      }
+
+      // Ensure all the bytes have been read in
+      if (offset < bytes.length)
+      {
+         throw new IOException("Could not completely read file " + file.getName());
+      }
+
+      // Close the input stream and return bytes
+      is.close();
+      return bytes;
+   }
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Time.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Time.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/helper/Time.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,84 +1,84 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.helper;
-
-import java.util.Date;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class Time
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int SAME_DATE = 0x01;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int LEFT_NULL = 0x02;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int RIGHT_NULL = 0x04;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int BOTH_NULL = 0x08;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int LEFT_AFTER = 0x10;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int RIGHT_AFTER = 0x20;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param left  DOCUMENT_ME
-    * @param right DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public static int compare(Date left,
-                             Date right)
-   {
-      if (left == null)
-      {
-         return (right == null) ? BOTH_NULL : LEFT_NULL;
-      }
-
-      if (right == null)
-      {
-         return (left == null) ? BOTH_NULL : RIGHT_NULL;
-      }
-
-      if (left.equals(right))
-      {
-         return SAME_DATE;
-      }
-      else if (left.after(right))
-      {
-         return LEFT_AFTER;
-      }
-      else
-      {
-         return RIGHT_AFTER;
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.helper;
+
+import java.util.Date;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class Time
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int SAME_DATE = 0x01;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int LEFT_NULL = 0x02;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int RIGHT_NULL = 0x04;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int BOTH_NULL = 0x08;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int LEFT_AFTER = 0x10;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int RIGHT_AFTER = 0x20;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param left  DOCUMENT_ME
+    * @param right DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public static int compare(Date left,
+                             Date right)
+   {
+      if (left == null)
+      {
+         return (right == null) ? BOTH_NULL : LEFT_NULL;
+      }
+
+      if (right == null)
+      {
+         return (left == null) ? BOTH_NULL : RIGHT_NULL;
+      }
+
+      if (left.equals(right))
+      {
+         return SAME_DATE;
+      }
+      else if (left.after(right))
+      {
+         return LEFT_AFTER;
+      }
+      else
+      {
+         return RIGHT_AFTER;
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/AttachmentImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/AttachmentImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/AttachmentImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,95 +1,95 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-
-package org.jboss.portlet.forums.impl;
-
-import org.jboss.portlet.forums.model.Attachment;
-import org.jboss.portlet.forums.model.UploadedFile;
-import org.jboss.portlet.forums.model.Post;
-
-import java.io.Serializable;
-
-/**
- * Created on 29 juil. 2004
- * @author theute
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * $Revision: 1.1 $
- * @hibernate.class table="jbp_forums_attachments"
- */
-public class AttachmentImpl implements Attachment, Serializable
-{
-   private Integer id;
-   private UploadedFile file;
-   private String comment;
-   private Post post;
-
-
-   public AttachmentImpl()
-   {
-
-   }
-
-   /**
-    * @hibernate.property column="jbp_comment"
-    * type="text"
-    */
-   public String getComment() {
-      return comment;
-   }
-   /**
-    * @param comment The comment to set.
-    */
-   public void setComment(String comment) {
-      this.comment = comment;
-   }
-
-   /**
-    * @hibernate.component class="org.jboss.portlet.forums.impl.UploadedFileImpl"
-    */
-   public UploadedFile getFile() {
-      return file;
-   }
-   /**
-    * @param file The file to set.
-    */
-   public void setFile(UploadedFile file) {
-      this.file = file;
-   }
-
-   /**
-    * @hibernate.id column="jbp_attachment_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   public void setId(Integer id)
-   {
-      this.id = id;
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_post_id"
-    * class="org.jboss.portlet.forums.impl.PostImpl"
-    */
-   public Post getPost()
-   {
-      return post;
-   }
-
-   public void setPost(Post post)
-   {
-      this.post = post;
-   }
-}
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+
+package org.jboss.portlet.forums.impl;
+
+import org.jboss.portlet.forums.model.Attachment;
+import org.jboss.portlet.forums.model.UploadedFile;
+import org.jboss.portlet.forums.model.Post;
+
+import java.io.Serializable;
+
+/**
+ * Created on 29 juil. 2004
+ * @author theute
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * $Revision: 1.1 $
+ * @hibernate.class table="jbp_forums_attachments"
+ */
+public class AttachmentImpl implements Attachment, Serializable
+{
+   private Integer id;
+   private UploadedFile file;
+   private String comment;
+   private Post post;
+
+
+   public AttachmentImpl()
+   {
+
+   }
+
+   /**
+    * @hibernate.property column="jbp_comment"
+    * type="text"
+    */
+   public String getComment() {
+      return comment;
+   }
+   /**
+    * @param comment The comment to set.
+    */
+   public void setComment(String comment) {
+      this.comment = comment;
+   }
+
+   /**
+    * @hibernate.component class="org.jboss.portlet.forums.impl.UploadedFileImpl"
+    */
+   public UploadedFile getFile() {
+      return file;
+   }
+   /**
+    * @param file The file to set.
+    */
+   public void setFile(UploadedFile file) {
+      this.file = file;
+   }
+
+   /**
+    * @hibernate.id column="jbp_attachment_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   public void setId(Integer id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_post_id"
+    * class="org.jboss.portlet.forums.impl.PostImpl"
+    */
+   public Post getPost()
+   {
+      return post;
+   }
+
+   public void setPost(Post post)
+   {
+      this.post = post;
+   }
+}
+

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/CategoryImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/CategoryImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/CategoryImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,134 +1,134 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.ArrayList;
-
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-
-/**
- * Category of forums.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.7 $
- * @hibernate.class table="jbp_forums_categories"
- */
-public class CategoryImpl
-   implements Serializable,
-   Category
-{
-   private List forums;
-   private int order;
-   private String title;
-   private Integer id;
-
-   /**
-    * Creates a new {@link CategoryImpl} object.
-    */
-   public CategoryImpl()
-   {
-      setForums(new ArrayList());
-   }
-
-   /**
-    * @hibernate.bag lazy="true"
-    * inverse="true"
-    * cascade="all-delete-orphan"
-    * order-by="jbp_order asc"
-    * table="jbp_forums_forums"
-    * @hibernate.collection-key column="jbp_category_id"
-    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.ForumImpl"
-    */
-   public List getForums()
-   {
-      return forums;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   public void setForums(List value)
-   {
-      forums = value;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   public void addForum(Forum value)
-   {
-      value.setCategory(this);
-      forums.add(value);
-   }
-
-   /**
-    * @hibernate.property column="jbp_order"
-    * unique="false"
-    * update="true"
-    */
-   public int getOrder()
-   {
-      return order;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param order DOCUMENT_ME
-    */
-   public void setOrder(int order)
-   {
-      this.order = order;
-   }
-
-   /**
-    * @hibernate.property column="jbp_title"
-    * unique="false"
-    * update="true"
-    */
-   public String getTitle()
-   {
-      return title;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param title DOCUMENT_ME
-    */
-   public void setTitle(String title)
-   {
-      this.title = title;
-   }
-
-   /**
-    * @hibernate.id column="jbp_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   private void setId(Integer id)
-   {
-      this.id = id;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Forum;
+
+/**
+ * Category of forums.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.7 $
+ * @hibernate.class table="jbp_forums_categories"
+ */
+public class CategoryImpl
+   implements Serializable,
+   Category
+{
+   private List forums;
+   private int order;
+   private String title;
+   private Integer id;
+
+   /**
+    * Creates a new {@link CategoryImpl} object.
+    */
+   public CategoryImpl()
+   {
+      setForums(new ArrayList());
+   }
+
+   /**
+    * @hibernate.bag lazy="true"
+    * inverse="true"
+    * cascade="all-delete-orphan"
+    * order-by="jbp_order asc"
+    * table="jbp_forums_forums"
+    * @hibernate.collection-key column="jbp_category_id"
+    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.ForumImpl"
+    */
+   public List getForums()
+   {
+      return forums;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   public void setForums(List value)
+   {
+      forums = value;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   public void addForum(Forum value)
+   {
+      value.setCategory(this);
+      forums.add(value);
+   }
+
+   /**
+    * @hibernate.property column="jbp_order"
+    * unique="false"
+    * update="true"
+    */
+   public int getOrder()
+   {
+      return order;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param order DOCUMENT_ME
+    */
+   public void setOrder(int order)
+   {
+      this.order = order;
+   }
+
+   /**
+    * @hibernate.property column="jbp_title"
+    * unique="false"
+    * update="true"
+    */
+   public String getTitle()
+   {
+      return title;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param title DOCUMENT_ME
+    */
+   public void setTitle(String title)
+   {
+      this.title = title;
+   }
+
+   /**
+    * @hibernate.id column="jbp_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   private void setId(Integer id)
+   {
+      this.id = id;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,401 +1,401 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Topic;
-
-/**
- * Category of forums.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.9 $
- * @hibernate.class table="jbp_forums_forums"
- */
-public class ForumImpl
-   implements Serializable,
-   Forum
-{
-   /**
-    * Creates a new {@link ForumImpl} object.
-    */
-   public ForumImpl()
-   {
-      setTopics(new ArrayList());
-   }
-
-   private Category category;
-   private String description;
-   private Integer id;
-   //private Post       lastPost;
-   private String name;
-   private int order;
-   //private int        topicCount;
-   //private int        postCount;
-   //private boolean pruneEnable;
-   //private int pruneNext;
-   private int status;
-   private List topics;
-   private Collection watch;
-   //private int        type;
-   private List watches;
-
-   /**
-    * @hibernate.many-to-one column="jbp_category_id"
-    * class="org.jboss.portlet.forums.impl.CategoryImpl"
-    */
-   public Category getCategory()
-   {
-      return category;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param category DOCUMENT_ME
-    */
-   public void setCategory(Category category)
-   {
-      this.category = category;
-   }
-
-   /**
-    * @hibernate.property column="jbp_description"
-    * unique="false"
-    * update="true"
-    */
-   public String getDescription()
-   {
-      return description;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param description DOCUMENT_ME
-    */
-   public void setDescription(String description)
-   {
-      this.description = description;
-   }
-
-   /**
-    * @hibernate.id column="jbp_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   private void setId(Integer id)
-   {
-      this.id = id;
-   }
-
-   /**
-    * _ at _hibernate.many-to-one
-    * _cascade_="all"
-    * _column_="jbp_last_post_id"
-    * _class_="org.jboss.portlet.forums.impl.PostImpl"
-    */
-   public Post getLastPost()
-   {
-      Post post = null;
-      for (Iterator i = getTopics().iterator(); i.hasNext();)
-      {
-         post = ((Topic)i.next()).getLastPost();
-      }
-      return post;
-      //return lastPost;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param lastPost DOCUMENT_ME
-    */
-   public void setLastPost(Post lastPost)
-   {
-      //this.lastPost = lastPost;
-   }
-
-   /**
-    * @hibernate.property column="jbp_name"
-    * unique="false"
-    * update="true"
-    */
-   public String getName()
-   {
-      return name;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    */
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   /**
-    * @hibernate.property column="jbp_order"
-    * unique="false"
-    * update="true"
-    */
-   public int getOrder()
-   {
-      return order;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param order DOCUMENT_ME
-    */
-   public void setOrder(int order)
-   {
-      this.order = order;
-   }
-
-   /**
-    * @hibernate.property column="jbp_topic_count"
-    * unique="false"
-    * update="true"
-    */
-   public int getTopicCount()
-   {
-      //return topicCount;
-      return getTopics().size();
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param size DOCUMENT_ME
-    */
-   public void setTopicCount(int size)
-   {
-      //this.topicCount = size;
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public void addTopicSize()
-   {
-      //setTopicCount(topicCount + 1);
-   }
-
-   /**
-    * @hibernate.property column="jbp_post_count"
-    * unique="false"
-    * update="true"
-    */
-   public int getPostCount()
-   {
-      int sum = 0;
-      for (Iterator i = getTopics().iterator(); i.hasNext();)
-      {
-         Topic topic = (Topic)i.next();
-         sum += topic.getPosts().size();
-      }
-      return sum;
-      //return postCount;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param size DOCUMENT_ME
-    */
-   public void setPostCount(int size)
-   {
-      //this.postCount = size;
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public void addPostSize()
-   {
-      //setPostCount(postCount + 1);
-   }
-
-   /**
-    * _ at ___ hibernate.property column="jbp_prune_enable"
-    * unique="false"
-    * update="true"
-    */
-   public boolean getPruneEnable()
-   {
-      //return pruneEnable;
-      return false;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param enable DOCUMENT_ME
-    */
-   public void setPruneEnable(boolean enable)
-   {
-      //this.pruneEnable = enable;
-   }
-
-   /**
-    * _ at ___ hibernate.property column="jbp_prune_next"
-    * unique="false"
-    * update="true"
-    */
-   public int getPruneNext()
-   {
-      //return pruneNext;
-      return 0;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param next DOCUMENT_ME
-    */
-   public void setPruneNext(int next)
-   {
-      //this.pruneNext = next;
-   }
-
-   /**
-    * @hibernate.property column="jbp_status"
-    * unique="false"
-    * update="true"
-    */
-   public int getStatus()
-   {
-      return status;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param status DOCUMENT_ME
-    */
-   public void setStatus(int status)
-   {
-      this.status = status;
-   }
-
-   /**
-    * @hibernate.bag lazy="true"
-    * inverse="true"
-    * cascade="all-delete-orphan"
-    * order-by="jbp_last_post_date asc"
-    * table="jbp_forums_topics"
-    * @hibernate.collection-key column="jbp_forum_id"
-    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.TopicImpl"
-    */
-   public List getTopics()
-   {
-      return topics;
-
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   public void setTopics(List value)
-   {
-      topics = value;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   public void addTopic(Topic value)
-   {
-      value.setForum(this);
-      topics.add(value);
-   }
-
-   /**
-    * @hibernate.bag lazy="true"
-    * inverse="true"
-    * cascade="all"
-    * @hibernate.collection-key column="jbp_forum_id"
-    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.ForumWatchImpl"
-    */
-   public Collection getForumWatch()
-   {
-      return watch;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param watch DOCUMENT_ME
-    */
-   public void setForumWatch(Collection watch)
-   {
-      this.watch = watch;
-   }
-
-   /**
-    * @hibernate.property
-    *    column="jbp_type"
-    *    update="true"
-    */
-   /*public int getType()
-   {
-      return type;
-   }*/
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param type DOCUMENT_ME
-    */
-   /*public void setType(int type)
-   {
-      this.type = type;
-   }*/
-
-   /**
-    * @hibernate.bag lazy="true"
-    * inverse="true"
-    * cascade="all"
-    * @hibernate.collection-key column="jbp_forum_id"
-    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.ForumWatchImpl"
-    */
-   public List getWatches()
-   {
-      return watches;
-   }
-
-   public void setWatches(List watches)
-   {
-      this.watches = watches;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Topic;
+
+/**
+ * Category of forums.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.9 $
+ * @hibernate.class table="jbp_forums_forums"
+ */
+public class ForumImpl
+   implements Serializable,
+   Forum
+{
+   /**
+    * Creates a new {@link ForumImpl} object.
+    */
+   public ForumImpl()
+   {
+      setTopics(new ArrayList());
+   }
+
+   private Category category;
+   private String description;
+   private Integer id;
+   //private Post       lastPost;
+   private String name;
+   private int order;
+   //private int        topicCount;
+   //private int        postCount;
+   //private boolean pruneEnable;
+   //private int pruneNext;
+   private int status;
+   private List topics;
+   private Collection watch;
+   //private int        type;
+   private List watches;
+
+   /**
+    * @hibernate.many-to-one column="jbp_category_id"
+    * class="org.jboss.portlet.forums.impl.CategoryImpl"
+    */
+   public Category getCategory()
+   {
+      return category;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param category DOCUMENT_ME
+    */
+   public void setCategory(Category category)
+   {
+      this.category = category;
+   }
+
+   /**
+    * @hibernate.property column="jbp_description"
+    * unique="false"
+    * update="true"
+    */
+   public String getDescription()
+   {
+      return description;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param description DOCUMENT_ME
+    */
+   public void setDescription(String description)
+   {
+      this.description = description;
+   }
+
+   /**
+    * @hibernate.id column="jbp_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   private void setId(Integer id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * _ at _hibernate.many-to-one
+    * _cascade_="all"
+    * _column_="jbp_last_post_id"
+    * _class_="org.jboss.portlet.forums.impl.PostImpl"
+    */
+   public Post getLastPost()
+   {
+      Post post = null;
+      for (Iterator i = getTopics().iterator(); i.hasNext();)
+      {
+         post = ((Topic)i.next()).getLastPost();
+      }
+      return post;
+      //return lastPost;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param lastPost DOCUMENT_ME
+    */
+   public void setLastPost(Post lastPost)
+   {
+      //this.lastPost = lastPost;
+   }
+
+   /**
+    * @hibernate.property column="jbp_name"
+    * unique="false"
+    * update="true"
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    */
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   /**
+    * @hibernate.property column="jbp_order"
+    * unique="false"
+    * update="true"
+    */
+   public int getOrder()
+   {
+      return order;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param order DOCUMENT_ME
+    */
+   public void setOrder(int order)
+   {
+      this.order = order;
+   }
+
+   /**
+    * @hibernate.property column="jbp_topic_count"
+    * unique="false"
+    * update="true"
+    */
+   public int getTopicCount()
+   {
+      //return topicCount;
+      return getTopics().size();
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param size DOCUMENT_ME
+    */
+   public void setTopicCount(int size)
+   {
+      //this.topicCount = size;
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public void addTopicSize()
+   {
+      //setTopicCount(topicCount + 1);
+   }
+
+   /**
+    * @hibernate.property column="jbp_post_count"
+    * unique="false"
+    * update="true"
+    */
+   public int getPostCount()
+   {
+      int sum = 0;
+      for (Iterator i = getTopics().iterator(); i.hasNext();)
+      {
+         Topic topic = (Topic)i.next();
+         sum += topic.getPosts().size();
+      }
+      return sum;
+      //return postCount;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param size DOCUMENT_ME
+    */
+   public void setPostCount(int size)
+   {
+      //this.postCount = size;
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public void addPostSize()
+   {
+      //setPostCount(postCount + 1);
+   }
+
+   /**
+    * _ at ___ hibernate.property column="jbp_prune_enable"
+    * unique="false"
+    * update="true"
+    */
+   public boolean getPruneEnable()
+   {
+      //return pruneEnable;
+      return false;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param enable DOCUMENT_ME
+    */
+   public void setPruneEnable(boolean enable)
+   {
+      //this.pruneEnable = enable;
+   }
+
+   /**
+    * _ at ___ hibernate.property column="jbp_prune_next"
+    * unique="false"
+    * update="true"
+    */
+   public int getPruneNext()
+   {
+      //return pruneNext;
+      return 0;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param next DOCUMENT_ME
+    */
+   public void setPruneNext(int next)
+   {
+      //this.pruneNext = next;
+   }
+
+   /**
+    * @hibernate.property column="jbp_status"
+    * unique="false"
+    * update="true"
+    */
+   public int getStatus()
+   {
+      return status;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param status DOCUMENT_ME
+    */
+   public void setStatus(int status)
+   {
+      this.status = status;
+   }
+
+   /**
+    * @hibernate.bag lazy="true"
+    * inverse="true"
+    * cascade="all-delete-orphan"
+    * order-by="jbp_last_post_date asc"
+    * table="jbp_forums_topics"
+    * @hibernate.collection-key column="jbp_forum_id"
+    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.TopicImpl"
+    */
+   public List getTopics()
+   {
+      return topics;
+
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   public void setTopics(List value)
+   {
+      topics = value;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   public void addTopic(Topic value)
+   {
+      value.setForum(this);
+      topics.add(value);
+   }
+
+   /**
+    * @hibernate.bag lazy="true"
+    * inverse="true"
+    * cascade="all"
+    * @hibernate.collection-key column="jbp_forum_id"
+    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.ForumWatchImpl"
+    */
+   public Collection getForumWatch()
+   {
+      return watch;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param watch DOCUMENT_ME
+    */
+   public void setForumWatch(Collection watch)
+   {
+      this.watch = watch;
+   }
+
+   /**
+    * @hibernate.property
+    *    column="jbp_type"
+    *    update="true"
+    */
+   /*public int getType()
+   {
+      return type;
+   }*/
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param type DOCUMENT_ME
+    */
+   /*public void setType(int type)
+   {
+      this.type = type;
+   }*/
+
+   /**
+    * @hibernate.bag lazy="true"
+    * inverse="true"
+    * cascade="all"
+    * @hibernate.collection-key column="jbp_forum_id"
+    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.ForumWatchImpl"
+    */
+   public List getWatches()
+   {
+      return watches;
+   }
+
+   public void setWatches(List watches)
+   {
+      this.watches = watches;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumWatchImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumWatchImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumWatchImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,62 +1,62 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-
-import org.jboss.portal.identity.User;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.ForumWatch;
-import org.jboss.portlet.forums.model.Poster;
-
-/**
- * Watchers of forums.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @version $Revision: 1.8 $
- * @hibernate.joined-subclass table="jbp_forums_forumswatch"
- * @hibernate.joined-subclass-key column="jbp_id"
- */
-public class ForumWatchImpl
-   extends WatchImpl
-   implements Serializable,
-   ForumWatch
-{
-   private Forum forum;
-   //private int     mode;
-
-   /**
-    * Creates a new {@link ForumWatchImpl} object.
-    */
-   public ForumWatchImpl()
-   {
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_forum_id"
-    * class="org.jboss.portlet.forums.impl.ForumImpl"
-    */
-   public Forum getForum()
-   {
-      return forum;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum DOCUMENT_ME
-    */
-   public void setForum(Forum forum)
-   {
-      this.forum = forum;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.ForumWatch;
+import org.jboss.portlet.forums.model.Poster;
+
+/**
+ * Watchers of forums.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @version $Revision: 1.8 $
+ * @hibernate.joined-subclass table="jbp_forums_forumswatch"
+ * @hibernate.joined-subclass-key column="jbp_id"
+ */
+public class ForumWatchImpl
+   extends WatchImpl
+   implements Serializable,
+   ForumWatch
+{
+   private Forum forum;
+   //private int     mode;
+
+   /**
+    * Creates a new {@link ForumWatchImpl} object.
+    */
+   public ForumWatchImpl()
+   {
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_forum_id"
+    * class="org.jboss.portlet.forums.impl.ForumImpl"
+    */
+   public Forum getForum()
+   {
+      return forum;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum DOCUMENT_ME
+    */
+   public void setForum(Forum forum)
+   {
+      this.forum = forum;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,1324 +1,1324 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.common.command.filter.CompositeFilter;
-import org.jboss.portal.common.command.filter.ExecuteFilter;
-import org.jboss.portal.common.command.filter.CommandFilter;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portal.core.modules.AbstractModule;
-import org.jboss.portal.core.hibernate.HibernateProvider;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.ForumWatch;
-import org.jboss.portlet.forums.model.Watch;
-import org.jboss.portlet.forums.model.TopicWatch;
-import org.jboss.portlet.forums.model.Attachment;
-import org.jboss.portlet.forums.interceptors.FloodControlInterceptor;
-import org.jboss.portlet.command.ActionCommand;
-import org.hibernate.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.SessionFactory;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.21 $
- * @jmx.mbean
- * @jboss.xmbean
- */
-public class ForumsModuleImpl
-   extends AbstractModule
-   implements ForumsModule
-{
-
-   private final Logger log = Logger.getLogger(getClass());
-
-   private HibernateProvider hibernate;
-   private SessionFactory factory;
-
-   private int floodInterval;
-
-   private String fromAddress;
-
-// private final ResourceCacheInvalidatorInterceptor resourceInterceptor;
-// private final IndexInterceptor indexInterceptor;
-   private CompositeFilter compositeInterceptor;
-// private NotificationInterceptor notificationInterceptor;
-   private FloodControlInterceptor floodControlInterceptor;
-   private ExecuteFilter executeInterceptor;
-   private CommandFilter chain;
-
-   protected void startService() throws Exception
-   {
-      super.startService();
-
-      factory = hibernate.getSessionFactory();
-
-      // Define the chain of interceptors
-      chain = compositeInterceptor = new CompositeFilter();
-//    resourceInterceptor = new ResourceCacheInvalidatorInterceptor();
-//    indexInterceptor = new IndexInterceptor();
-//    notificationInterceptor = new NotificationInterceptor(this);
-//    notificationInterceptor.setFrom(fromAddress);
-      floodControlInterceptor = new FloodControlInterceptor();
-      floodControlInterceptor.setFloodInterval(floodInterval);
-      executeInterceptor = new ExecuteFilter();
-
-      // Assemble the chain
-//    compositeInterceptor.setNext(resourceInterceptor);
-//    resourceInterceptor.setNext(indexInterceptor);
-//    indexInterceptor.setNext(notificationInterceptor);
-
-      compositeInterceptor.setNext(executeInterceptor);
-//    notificationInterceptor.setNext(floodControlInterceptor);
-      floodControlInterceptor.setNext(executeInterceptor);
-   }
-
-   /**
-    * @jmx.managed-attribute
-    */
-   public HibernateProvider getHibernate()
-   {
-      return hibernate;
-   }
-
-   /**
-    * @jmx.managed-attribute
-    */
-   public void setHibernate(HibernateProvider hibernate)
-   {
-      this.hibernate = hibernate;
-   }
-
-   /**
-    * @jmx.managed-attribute
-    */
-   public int getFloodInterval()
-   {
-      return floodInterval;
-   }
-
-   /**
-    * @jmx.managed-attribute
-    */
-   public void setFloodInterval(int floodInterval)
-   {
-      this.floodInterval = floodInterval;
-   }
-
-   /**
-    * @jmx.managed-attribute
-    */
-   public String getFromAddress()
-   {
-      return fromAddress;
-   }
-
-   /**
-    * @jmx.managed-attribute
-    */
-   public void setFromAddress(String fromAddress)
-   {
-      this.fromAddress = fromAddress;
-   }
-
-   public Forum findForumById(Integer id)
-      throws ModuleException
-   {
-      if (id != null)
-      {
-         try
-         {
-            Session session = getSession();
-            ForumImpl forum = (ForumImpl)session.get(ForumImpl.class, id);
-            if (forum == null)
-            {
-               throw new ModuleException("No forum found for " + id);
-            }
-
-            return forum;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find forum by id " + id;
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("id cannot be null");
-      }
-   }
-
-   public Category findCategoryById(Integer id)
-      throws ModuleException
-   {
-      if (id != null)
-      {
-         try
-         {
-            Session session = getSession();
-            CategoryImpl category = (CategoryImpl)session.get(CategoryImpl.class, id);
-            if (category == null)
-            {
-               throw new ModuleException("No category found for " + id);
-            }
-
-            return category;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find category by id " + id;
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("id cannot be null");
-      }
-   }
-
-   public Poster findPosterByUserId(String userId)
-      throws ModuleException
-   {
-      if (userId != null)
-      {
-         try
-         {
-            Session session = getSession();
-            Query query = session.createQuery("from PosterImpl as u where u.userId=:userId");
-            query.setString("userId", userId);
-            PosterImpl user = (PosterImpl)query.uniqueResult();
-            return user;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find poster by name " + userId;
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("user name cannot be null");
-      }
-   }
-
-   public Poster createPoster(String userId)
-      throws ModuleException
-   {
-      if (userId != null)
-      {
-         try
-         {
-            Session session = getSession();
-            PosterImpl user = new PosterImpl();
-            user.setUserId(userId);
-            session.save(user);
-            return user;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot create Poster";
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("user name cannot be null");
-      }
-   }
-
-   public List findCategories()
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query = session.createQuery("from CategoryImpl as c order by c.order asc");
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find categories";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findForums()
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query = session.createQuery("from ForumImpl as f order by f.order asc");
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find forums";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findForumsByCategoryId(Integer categoryId)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from ForumImpl as f where f.category=:categoryId order by f.order asc");
-         query.setString("categoryId",
-            categoryId.toString());
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find forums";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findAnnouncements(Forum forum)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from TopicImpl as t where t.forum=:forumid and t.type = :type order by t.lastPostDate");
-         query.setString("forumid", "" + forum.getId());
-         query.setString("type", "" + ForumsConstants.POST_ANNOUNCE);
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find forums";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findTopics() throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from TopicImpl");
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find topics";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-
-
-   }
-
-   private List findTopics(Forum forum,
-                           int type,
-                           int start,
-                           int perPage,
-                           String order)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from TopicImpl as t where t.forum = :forumid and t.type <> :type order by t.lastPostDate " + order);
-         query.setFirstResult(start);
-         query.setMaxResults(perPage);
-         query.setString("forumid", "" + forum.getId());
-         query.setString("type", "" + type);
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find topics";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-
-   public List findTopicsAsc(Forum forum,
-                             int type,
-                             int start,
-                             int perPage)
-      throws ModuleException
-   {
-      return findTopics(forum, type, start, perPage, "asc");
-   }
-
-
-   public List findTopicsDesc(Forum forum,
-                              int type,
-                              int start,
-                              int perPage)
-      throws ModuleException
-   {
-      return findTopics(forum, type, start, perPage, "desc");
-   }
-
-   public List findTopicsBefore(Forum forum,
-                                int type,
-                                int start,
-                                int perPage,
-                                Date date)
-      throws ModuleException
-   {
-      return null;
-   }
-
-   public List findTopicsHot(int replies, int limit)
-      throws ModuleException
-   {
-      try
-      {
-         //"SELECT OBJECT(t) FROM topic AS t WHERE t.replies > ?1 ORDER BY t.creationDate DESC LIMIT ?2"
-         Session session = getSession();
-         Query query =
-            session.createQuery("from TopicImpl as t where t.replies > :replies order by t.lastPostDate desc");
-         query.setMaxResults(limit);
-         query.setInteger("replies", replies);
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find topics";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findTopicsByLatestPosts(int limit)
-      throws ModuleException
-   {
-      try
-      {
-         //SELECT DISTINCT OBJECT(t) FROM topic AS t ORDER BY t.lastPostDate DESC LIMIT ?1"
-
-         Session session = getSession();
-         Query query =
-            session.createQuery("from TopicImpl as t order by t.lastPostDate desc");
-         query.setMaxResults(limit);
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find topics";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findTopicsHottest(Date after, int limit)
-      throws ModuleException
-   {
-      try
-      {
-         //"SELECT OBJECT(t) FROM topic AS t WHERE t.lastPostDate > ?1 ORDER BY t.replies DESC LIMIT ?2"
-         Session session = getSession();
-         Query query =
-            session.createQuery("from TopicImpl as t where t.lastPostDate > :after order by t.replies desc");
-         query.setMaxResults(limit);
-         query.setDate("after", after);
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find topics";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findTopicsMostViewed(Date after, int limit)
-      throws ModuleException
-   {
-      try
-      {
-         //"SELECT OBJECT(t) FROM topic AS t WHERE t.lastPostDate > ?1 ORDER BY t.views DESC LIMIT ?2"
-         Session session = getSession();
-         Query query =
-            session.createQuery("from TopicImpl as t where t.lastPostDate > :after order by t.viewCount desc");
-         query.setMaxResults(limit);
-         query.setDate("after", after);
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find topics";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-
-   public Post createTopic(Forum forum,
-                           Message message,
-                           Date creationDate,
-                           Poster poster,
-                           Poll poll,
-                           List attachments,
-                           int type)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-
-         session.save(poster);
-         session.save(poll);
-
-         
-
-         PostImpl post = new PostImpl();
-         post.setMessage(message);
-         post.setCreateDate(creationDate);
-         post.setPoster(poster);
-         //post.setAttachments(attachments);
-         for (Iterator i = attachments.iterator(); i.hasNext();)
-         {
-            Attachment a = (Attachment)i.next();
-            session.save(a);
-            post.addAttachment(a);
-         }                 
-         session.save(post);
-
-         TopicImpl topic = new TopicImpl();
-         topic.setSubject(message.getSubject());
-         //topic.setForum(forum);
-         forum.addTopic(topic);
-         topic.setPoster(poster);
-         //topic.setFirstPost(post);
-         //topic.setLastPost(post);
-         topic.addPost(post);
-         //post.setTopic(topic);
-         topic.setLastPostDate(creationDate);
-         topic.setType(type);
-         topic.setStatus(ForumsConstants.TOPIC_UNLOCKED);
-         topic.setPoll(poll);
-
-
-         session.save(topic);
-
-         forum.addTopicSize();
-         forum.addPostSize();
-
-         post.setTopic(topic);
-         return post;
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot create topic";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public Topic createTopic(Forum forum,
-                            String userId,
-                            String subject,
-                            int type)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-
-         Poster poster = findPosterByUserId(userId);
-
-         if (poster == null)
-         {
-            poster = createPoster(userId);
-         }
-         session.save(poster);
-
-         TopicImpl topic = new TopicImpl();
-         topic.setSubject(subject);
-         //topic.setForum(forum);
-         forum.addTopic(topic);
-         topic.setPoster(poster);
-         //topic.setFirstPost(post);
-         //topic.setLastPost(post);
-         //topic.addPost(post);
-         //post.setTopic(topic);
-         //topic.setLastPostDate(creationDate);
-         topic.setType(type);
-
-         topic.setPoll(null);
-
-
-         session.save(topic);
-         //forum.addTopicSize();
-         //forum.addPostSize();
-
-
-         return topic;
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot create topic";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-
-   public Post createPost(Topic topic,
-                          Forum forum,
-                          Message message,
-                          Date creationDate,
-                          Poster poster,
-                          List attachments)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         session.save(poster);
-
-
-         PostImpl post = new PostImpl();
-         post.setMessage(message);
-         post.setCreateDate(creationDate);
-         post.setPoster(poster);
-         //post.setAttachments(attachments);
-         for (Iterator i = attachments.iterator(); i.hasNext();)
-         {
-            Attachment a = (Attachment)i.next();
-            session.save(a);
-            post.addAttachment(a);
-         }
-
-
-         session.save(post);
-
-         topic.addPost(post);
-         //post.setTopic(topic);
-
-         //topic.setLastPost(post);
-         topic.setLastPostDate(post.getCreateDate());
-         topic.setReplies(topic.getReplies() + 1);
-         session.save(topic);
-         //forum.setLastPost(post);
-         forum.addPostSize();
-         return post;
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot create topic";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public Poll addPollToTopic(Topic topic,
-                              Poll poll)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Poll oldpoll = topic.getPoll();
-         if (oldpoll != null)
-         {
-            session.delete(oldpoll);
-         }
-         session.save(poll);
-         topic.setPoll(poll);
-         return poll;
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot add poll to topic";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   private int getLastCategoryOrder()
-   {
-      try
-      {
-         Session session = getSession();
-         Query query = session.createQuery("select max(c.order) from CategoryImpl as c");
-         Integer lastCategoryOrder = (Integer)query.uniqueResult();
-         return (lastCategoryOrder != null) ? lastCategoryOrder.intValue() : 0;
-      }
-      catch (HibernateException e)
-      {
-         return 0;
-      }
-   }
-
-   public Category createCategory(String name)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-
-         CategoryImpl category = new CategoryImpl();
-         category.setTitle(name);
-         category.setOrder(getLastCategoryOrder() + 10);
-         session.save(category);
-         return category;
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot create topic";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public void removeCategory(Category category)
-      throws ModuleException
-   {
-      Session session = getSession();
-      try
-      {
-         //session.flush();
-         session.delete(category);
-         //session.flush();
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot delete category";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public void removeForum(Forum forum)
-      throws ModuleException
-   {
-      Session session = getSession();
-      try
-      {
-         //session.delete(forum);
-         if (forum.getCategory() != null)
-         {
-            forum.getCategory().getForums().remove(forum);
-            forum.setCategory(null);
-         }
-         else
-         {
-            session.delete(forum);
-         }
-
-         //session.flush();
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot delete forum";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public void removePost(Post post)
-      throws ModuleException
-   {
-      Session session = getSession();
-      try
-      {
-         //session.flush();
-         //session.delete(post);
-         if (post.getTopic() != null)
-         {
-            post.getTopic().getPosts().remove(post);
-            post.setTopic(null);
-         }
-         else
-         {
-            session.delete(post);
-         }
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot delete post";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public void removePollInTopic(Topic topic)
-      throws ModuleException
-   {
-      Session session = getSession();
-      try
-      {
-         //session.flush();
-         Poll poll = topic.getPoll();
-         topic.setPoll(null);
-         session.delete(poll);
-
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot delete poll";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public void removeTopic(Topic topic)
-      throws ModuleException
-   {
-      Session session = getSession();
-      try
-      {
-         //session.flush();
-         //session.delete(topic);
-         if (topic.getForum() != null)
-         {
-            topic.getForum().getTopics().remove(topic);
-            topic.setForum(null);
-            //session.delete(topic);
-         }
-         else
-         {
-            session.delete(topic);
-         }
-         //session.flush();
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot delete topic";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   private int getLastForumOrder(Category category)
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("select max(f.order) from ForumImpl as f where f.category = :categoryId");
-         query.setString("categoryId", "" + category.getId());
-         Integer lastForumOrder = (Integer)query.uniqueResult();
-         return (lastForumOrder != null) ? lastForumOrder.intValue() : 0;
-      }
-      catch (HibernateException e)
-      {
-         return 0;
-      }
-   }
-
-   public Forum createForum(Category category,
-                            String name,
-                            String description)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-
-         ForumImpl forum = new ForumImpl();
-         //forum.setCategory(category);
-         category.addForum(forum);
-         forum.setName(name);
-         forum.setDescription(description);
-         forum.setOrder(getLastForumOrder(category) + 10);
-         session.save(forum);
-         return forum;
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot create forum";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public Topic findTopicById(Integer id)
-      throws ModuleException
-   {
-      if (id != null)
-      {
-         try
-         {
-            Session session = getSession();
-            TopicImpl topic = (TopicImpl)session.get(TopicImpl.class, id);
-            if (topic == null)
-            {
-               throw new ModuleException("No topic found for " + id);
-            }
-
-            return topic;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find forum by id " + id;
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("id cannot be null");
-      }
-   }
-
-   public List findTopics(Forum forum)
-      throws ModuleException
-   {
-      if (forum != null)
-      {
-         try
-         {
-            Session session = getSession();
-            Query query =
-               session.createQuery("from TopicImpl as t where t.forum = :forumid");
-            query.setString("forumid", "" + forum.getId());
-            Iterator iterator = query.iterate();
-            return Tools.toList(iterator);
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find topics";
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("forum cannot be null");
-      }
-   }
-
-   public List findPosts()
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from PostImpl");
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find posts";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public Post findPostById(Integer id)
-      throws ModuleException
-   {
-      if (id != null)
-      {
-         try
-         {
-            Session session = getSession();
-            PostImpl post = (PostImpl)session.get(PostImpl.class, id);
-            if (post == null)
-            {
-               throw new ModuleException("No post found for " + id);
-            }
-
-            return post;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find post by id " + id;
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("id cannot be null");
-      }
-   }
-
-   public Attachment findFindAttachmentById(Integer attachID)
-      throws ModuleException
-   {
-      if (attachID != null)
-      {
-         try
-         {
-            Session session = getSession();
-            Attachment attach = (Attachment)session.get(AttachmentImpl.class, attachID);
-            if (attach == null)
-            {
-               throw new ModuleException("No attachment found for " + attachID);
-            }
-
-            return attach;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find attachment by id " + attachID;
-            log.error(message, e);
-            throw new ModuleException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("id cannot be null");
-      }
-   }
-
-   private List findPostsByTopicId(Integer topicId,
-                                   int start,
-                                   int limit,
-                                   String order)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from PostImpl as p where p.topic=:topicId order by p.createDate " + order);
-         query.setString("topicId",
-            topicId.toString());
-         query.setFirstResult(start);
-         if (limit != 0)
-         {
-            query.setMaxResults(limit);
-         }
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find posts";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public List findPostsByTopicId(Integer topicId)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from PostImpl as p where p.topic=:topicId");
-         query.setString("topicId",
-            topicId.toString());
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find posts";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-
-   public void addAllForums(Category source,
-                            Category target)
-   {
-      List list = source.getForums();
-      target.getForums().addAll(source.getForums());
-      Iterator iterator = target.getForums().iterator();
-      while (iterator.hasNext())
-      {
-         Forum forum = (Forum)iterator.next();
-         forum.setCategory(target);
-      }
-      source.setForums(new ArrayList());
-   }
-
-   public List findPostsByTopicIdAsc(Integer topicId,
-                                     int start,
-                                     int limit)
-      throws ModuleException
-   {
-      return findPostsByTopicId(topicId, start, limit, "asc");
-   }
-
-   public List findPostsByTopicIdDesc(Integer topicId,
-                                      int start,
-                                      int limit)
-      throws ModuleException
-   {
-      return findPostsByTopicId(topicId, start, limit, "desc");
-   }
-
-   public Date findLastPostDateForUser(User user)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("select max(p.createDate) from PostImpl as p where p.poster.userId = :userId");
-         query.setString("userId", "" + user.getId().toString());
-         Date lastPostDate = (Date)query.uniqueResult();
-         return lastPostDate;
-      }
-      catch (HibernateException e)
-      {
-         e.printStackTrace();
-         return null;
-      }
-   }
-
-   public Post findLastPost(Forum forum)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from PostImpl as p where p.topic.forum  = :forumId order by p.createDate desc");
-         query.setString("forumId", "" + forum.getId());
-         query.setFirstResult(0);
-         query.setMaxResults(1);
-         Post lastPost = (Post)query.uniqueResult();
-         return lastPost;
-      }
-      catch (HibernateException e)
-      {
-         e.printStackTrace();
-         return null;
-      }
-   }
-
-   public Post findFirstPost(Topic topic)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from PostImpl as p where p.topic  = :topicId order by p.createDate asc");
-         query.setString("topicId", "" + topic.getId());
-         query.setFirstResult(0);
-         query.setMaxResults(1);
-         Post firstPost = (Post)query.uniqueResult();
-         return firstPost;
-      }
-      catch (HibernateException e)
-      {
-         e.printStackTrace();
-         return null;
-      }
-   }
-
-   public Post findLastPost(Topic topic)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query =
-            session.createQuery("from PostImpl as p where p.topic  = :topicId order by p.createDate desc");
-         query.setString("topicId", "" + topic.getId());
-         query.setFirstResult(0);
-         query.setMaxResults(1);
-         Post lastPost = (Post)query.uniqueResult();
-         return lastPost;
-      }
-      catch (HibernateException e)
-      {
-         e.printStackTrace();
-         return null;
-      }
-   }
-
-   public List findForumWatchByUser(User user) throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query = session.createQuery("from ForumWatchImpl as f where f.poster.userId = :userId");
-         query.setString("userId", user.getId().toString());
-         Iterator iterator = query.iterate();
-         return Tools.toList(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find forum watch";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public void createWatch(Poster poster, Forum forum, int mode) throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-
-         if (poster == null)
-         {
-            throw new ModuleException("poster must not be null");
-         }
-
-         if (forum == null)
-         {
-            throw new ModuleException("forum must not be null");
-         }
-
-         ForumWatch forumWatch = new ForumWatchImpl();
-         forumWatch.setPoster(poster);
-         forumWatch.setForum(forum);
-         forumWatch.setMode(mode);
-         session.save(forumWatch);
-
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot create forum watch";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public void removeWatch(Watch watch) throws ModuleException
-   {
-      Session session = getSession();
-      try
-      {
-         session.delete(watch);
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot delete watch";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public ForumWatch findForumWatchById(Integer forumWatchId)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query = session.createQuery("from ForumWatchImpl as f where f.id = :forumWatchId");
-         query.setString("forumWatchId",
-            forumWatchId.toString());
-         return (ForumWatch)query.uniqueResult();
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find forum watch";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public void createWatch(Poster poster, Topic topic)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-
-         if (poster == null)
-         {
-            throw new ModuleException("poster must not be null");
-         }
-
-         if (topic == null)
-         {
-            throw new ModuleException("topic must not be null");
-         }
-
-         TopicWatch topicWatch = new TopicWatchImpl();
-         topicWatch.setPoster(poster);
-         topicWatch.setTopic(topic);
-         session.save(topicWatch);
-      }
-      catch (HibernateException e)
-      {
-         String errorMessage = "Cannot create topic watch";
-         log.error(errorMessage, e);
-         throw new ModuleException(errorMessage, e);
-      }
-   }
-
-   public TopicWatch findTopicWatchById(Integer topicWatchId)
-      throws ModuleException
-   {
-      try
-      {
-         Session session = getSession();
-         Query query = session.createQuery("from TopicWatchImpl as f where f.id = :topicWatchId");
-         query.setString("topicWatchId",
-            topicWatchId.toString());
-         return (TopicWatch)query.uniqueResult();
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find topic watch";
-         log.error(message, e);
-         throw new ModuleException(message, e);
-      }
-   }
-
-   public Result invoke(ActionCommand cmd) throws CommandException
-   {
-      //throw new UnsupportedOperationException();
-      return chain.filter(cmd);
-   }
-   
-   protected Session getSession () {
-       return factory.getCurrentSession();
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.common.command.filter.CompositeFilter;
+import org.jboss.portal.common.command.filter.ExecuteFilter;
+import org.jboss.portal.common.command.filter.CommandFilter;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.core.modules.AbstractModule;
+import org.jboss.portal.jems.hibernate.HibernateProvider;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.model.Poster;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Poll;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.ForumWatch;
+import org.jboss.portlet.forums.model.Watch;
+import org.jboss.portlet.forums.model.TopicWatch;
+import org.jboss.portlet.forums.model.Attachment;
+import org.jboss.portlet.forums.interceptors.FloodControlInterceptor;
+import org.jboss.portlet.command.ActionCommand;
+import org.hibernate.Session;
+import org.hibernate.HibernateException;
+import org.hibernate.Query;
+import org.hibernate.SessionFactory;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.22 $
+ * @jmx.mbean
+ * @jboss.xmbean
+ */
+public class ForumsModuleImpl
+   extends AbstractModule
+   implements ForumsModule
+{
+
+   private final Logger log = Logger.getLogger(getClass());
+
+   private HibernateProvider hibernate;
+   private SessionFactory factory;
+
+   private int floodInterval;
+
+   private String fromAddress;
+
+// private final ResourceCacheInvalidatorInterceptor resourceInterceptor;
+// private final IndexInterceptor indexInterceptor;
+   private CompositeFilter compositeInterceptor;
+// private NotificationInterceptor notificationInterceptor;
+   private FloodControlInterceptor floodControlInterceptor;
+   private ExecuteFilter executeInterceptor;
+   private CommandFilter chain;
+
+   protected void startService() throws Exception
+   {
+      super.startService();
+
+      factory = hibernate.getSessionFactory();
+
+      // Define the chain of interceptors
+      chain = compositeInterceptor = new CompositeFilter();
+//    resourceInterceptor = new ResourceCacheInvalidatorInterceptor();
+//    indexInterceptor = new IndexInterceptor();
+//    notificationInterceptor = new NotificationInterceptor(this);
+//    notificationInterceptor.setFrom(fromAddress);
+      floodControlInterceptor = new FloodControlInterceptor();
+      floodControlInterceptor.setFloodInterval(floodInterval);
+      executeInterceptor = new ExecuteFilter();
+
+      // Assemble the chain
+//    compositeInterceptor.setNext(resourceInterceptor);
+//    resourceInterceptor.setNext(indexInterceptor);
+//    indexInterceptor.setNext(notificationInterceptor);
+
+      compositeInterceptor.setNext(executeInterceptor);
+//    notificationInterceptor.setNext(floodControlInterceptor);
+      floodControlInterceptor.setNext(executeInterceptor);
+   }
+
+   /**
+    * @jmx.managed-attribute
+    */
+   public HibernateProvider getHibernate()
+   {
+      return hibernate;
+   }
+
+   /**
+    * @jmx.managed-attribute
+    */
+   public void setHibernate(HibernateProvider hibernate)
+   {
+      this.hibernate = hibernate;
+   }
+
+   /**
+    * @jmx.managed-attribute
+    */
+   public int getFloodInterval()
+   {
+      return floodInterval;
+   }
+
+   /**
+    * @jmx.managed-attribute
+    */
+   public void setFloodInterval(int floodInterval)
+   {
+      this.floodInterval = floodInterval;
+   }
+
+   /**
+    * @jmx.managed-attribute
+    */
+   public String getFromAddress()
+   {
+      return fromAddress;
+   }
+
+   /**
+    * @jmx.managed-attribute
+    */
+   public void setFromAddress(String fromAddress)
+   {
+      this.fromAddress = fromAddress;
+   }
+
+   public Forum findForumById(Integer id)
+      throws ModuleException
+   {
+      if (id != null)
+      {
+         try
+         {
+            Session session = getSession();
+            ForumImpl forum = (ForumImpl)session.get(ForumImpl.class, id);
+            if (forum == null)
+            {
+               throw new ModuleException("No forum found for " + id);
+            }
+
+            return forum;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find forum by id " + id;
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("id cannot be null");
+      }
+   }
+
+   public Category findCategoryById(Integer id)
+      throws ModuleException
+   {
+      if (id != null)
+      {
+         try
+         {
+            Session session = getSession();
+            CategoryImpl category = (CategoryImpl)session.get(CategoryImpl.class, id);
+            if (category == null)
+            {
+               throw new ModuleException("No category found for " + id);
+            }
+
+            return category;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find category by id " + id;
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("id cannot be null");
+      }
+   }
+
+   public Poster findPosterByUserId(String userId)
+      throws ModuleException
+   {
+      if (userId != null)
+      {
+         try
+         {
+            Session session = getSession();
+            Query query = session.createQuery("from PosterImpl as u where u.userId=:userId");
+            query.setString("userId", userId);
+            PosterImpl user = (PosterImpl)query.uniqueResult();
+            return user;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find poster by name " + userId;
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("user name cannot be null");
+      }
+   }
+
+   public Poster createPoster(String userId)
+      throws ModuleException
+   {
+      if (userId != null)
+      {
+         try
+         {
+            Session session = getSession();
+            PosterImpl user = new PosterImpl();
+            user.setUserId(userId);
+            session.save(user);
+            return user;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot create Poster";
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("user name cannot be null");
+      }
+   }
+
+   public List findCategories()
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query = session.createQuery("from CategoryImpl as c order by c.order asc");
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find categories";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findForums()
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query = session.createQuery("from ForumImpl as f order by f.order asc");
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find forums";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findForumsByCategoryId(Integer categoryId)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from ForumImpl as f where f.category=:categoryId order by f.order asc");
+         query.setString("categoryId",
+            categoryId.toString());
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find forums";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findAnnouncements(Forum forum)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from TopicImpl as t where t.forum=:forumid and t.type = :type order by t.lastPostDate");
+         query.setString("forumid", "" + forum.getId());
+         query.setString("type", "" + ForumsConstants.POST_ANNOUNCE);
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find forums";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findTopics() throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from TopicImpl");
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find topics";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+
+
+   }
+
+   private List findTopics(Forum forum,
+                           int type,
+                           int start,
+                           int perPage,
+                           String order)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from TopicImpl as t where t.forum = :forumid and t.type <> :type order by t.lastPostDate " + order);
+         query.setFirstResult(start);
+         query.setMaxResults(perPage);
+         query.setString("forumid", "" + forum.getId());
+         query.setString("type", "" + type);
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find topics";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+
+   public List findTopicsAsc(Forum forum,
+                             int type,
+                             int start,
+                             int perPage)
+      throws ModuleException
+   {
+      return findTopics(forum, type, start, perPage, "asc");
+   }
+
+
+   public List findTopicsDesc(Forum forum,
+                              int type,
+                              int start,
+                              int perPage)
+      throws ModuleException
+   {
+      return findTopics(forum, type, start, perPage, "desc");
+   }
+
+   public List findTopicsBefore(Forum forum,
+                                int type,
+                                int start,
+                                int perPage,
+                                Date date)
+      throws ModuleException
+   {
+      return null;
+   }
+
+   public List findTopicsHot(int replies, int limit)
+      throws ModuleException
+   {
+      try
+      {
+         //"SELECT OBJECT(t) FROM topic AS t WHERE t.replies > ?1 ORDER BY t.creationDate DESC LIMIT ?2"
+         Session session = getSession();
+         Query query =
+            session.createQuery("from TopicImpl as t where t.replies > :replies order by t.lastPostDate desc");
+         query.setMaxResults(limit);
+         query.setInteger("replies", replies);
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find topics";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findTopicsByLatestPosts(int limit)
+      throws ModuleException
+   {
+      try
+      {
+         //SELECT DISTINCT OBJECT(t) FROM topic AS t ORDER BY t.lastPostDate DESC LIMIT ?1"
+
+         Session session = getSession();
+         Query query =
+            session.createQuery("from TopicImpl as t order by t.lastPostDate desc");
+         query.setMaxResults(limit);
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find topics";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findTopicsHottest(Date after, int limit)
+      throws ModuleException
+   {
+      try
+      {
+         //"SELECT OBJECT(t) FROM topic AS t WHERE t.lastPostDate > ?1 ORDER BY t.replies DESC LIMIT ?2"
+         Session session = getSession();
+         Query query =
+            session.createQuery("from TopicImpl as t where t.lastPostDate > :after order by t.replies desc");
+         query.setMaxResults(limit);
+         query.setDate("after", after);
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find topics";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findTopicsMostViewed(Date after, int limit)
+      throws ModuleException
+   {
+      try
+      {
+         //"SELECT OBJECT(t) FROM topic AS t WHERE t.lastPostDate > ?1 ORDER BY t.views DESC LIMIT ?2"
+         Session session = getSession();
+         Query query =
+            session.createQuery("from TopicImpl as t where t.lastPostDate > :after order by t.viewCount desc");
+         query.setMaxResults(limit);
+         query.setDate("after", after);
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find topics";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+
+   public Post createTopic(Forum forum,
+                           Message message,
+                           Date creationDate,
+                           Poster poster,
+                           Poll poll,
+                           List attachments,
+                           int type)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+
+         session.save(poster);
+         session.save(poll);
+
+         
+
+         PostImpl post = new PostImpl();
+         post.setMessage(message);
+         post.setCreateDate(creationDate);
+         post.setPoster(poster);
+         //post.setAttachments(attachments);
+         for (Iterator i = attachments.iterator(); i.hasNext();)
+         {
+            Attachment a = (Attachment)i.next();
+            session.save(a);
+            post.addAttachment(a);
+         }                 
+         session.save(post);
+
+         TopicImpl topic = new TopicImpl();
+         topic.setSubject(message.getSubject());
+         //topic.setForum(forum);
+         forum.addTopic(topic);
+         topic.setPoster(poster);
+         //topic.setFirstPost(post);
+         //topic.setLastPost(post);
+         topic.addPost(post);
+         //post.setTopic(topic);
+         topic.setLastPostDate(creationDate);
+         topic.setType(type);
+         topic.setStatus(ForumsConstants.TOPIC_UNLOCKED);
+         topic.setPoll(poll);
+
+
+         session.save(topic);
+
+         forum.addTopicSize();
+         forum.addPostSize();
+
+         post.setTopic(topic);
+         return post;
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot create topic";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public Topic createTopic(Forum forum,
+                            String userId,
+                            String subject,
+                            int type)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+
+         Poster poster = findPosterByUserId(userId);
+
+         if (poster == null)
+         {
+            poster = createPoster(userId);
+         }
+         session.save(poster);
+
+         TopicImpl topic = new TopicImpl();
+         topic.setSubject(subject);
+         //topic.setForum(forum);
+         forum.addTopic(topic);
+         topic.setPoster(poster);
+         //topic.setFirstPost(post);
+         //topic.setLastPost(post);
+         //topic.addPost(post);
+         //post.setTopic(topic);
+         //topic.setLastPostDate(creationDate);
+         topic.setType(type);
+
+         topic.setPoll(null);
+
+
+         session.save(topic);
+         //forum.addTopicSize();
+         //forum.addPostSize();
+
+
+         return topic;
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot create topic";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+
+   public Post createPost(Topic topic,
+                          Forum forum,
+                          Message message,
+                          Date creationDate,
+                          Poster poster,
+                          List attachments)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         session.save(poster);
+
+
+         PostImpl post = new PostImpl();
+         post.setMessage(message);
+         post.setCreateDate(creationDate);
+         post.setPoster(poster);
+         //post.setAttachments(attachments);
+         for (Iterator i = attachments.iterator(); i.hasNext();)
+         {
+            Attachment a = (Attachment)i.next();
+            session.save(a);
+            post.addAttachment(a);
+         }
+
+
+         session.save(post);
+
+         topic.addPost(post);
+         //post.setTopic(topic);
+
+         //topic.setLastPost(post);
+         topic.setLastPostDate(post.getCreateDate());
+         topic.setReplies(topic.getReplies() + 1);
+         session.save(topic);
+         //forum.setLastPost(post);
+         forum.addPostSize();
+         return post;
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot create topic";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public Poll addPollToTopic(Topic topic,
+                              Poll poll)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Poll oldpoll = topic.getPoll();
+         if (oldpoll != null)
+         {
+            session.delete(oldpoll);
+         }
+         session.save(poll);
+         topic.setPoll(poll);
+         return poll;
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot add poll to topic";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   private int getLastCategoryOrder()
+   {
+      try
+      {
+         Session session = getSession();
+         Query query = session.createQuery("select max(c.order) from CategoryImpl as c");
+         Integer lastCategoryOrder = (Integer)query.uniqueResult();
+         return (lastCategoryOrder != null) ? lastCategoryOrder.intValue() : 0;
+      }
+      catch (HibernateException e)
+      {
+         return 0;
+      }
+   }
+
+   public Category createCategory(String name)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+
+         CategoryImpl category = new CategoryImpl();
+         category.setTitle(name);
+         category.setOrder(getLastCategoryOrder() + 10);
+         session.save(category);
+         return category;
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot create topic";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public void removeCategory(Category category)
+      throws ModuleException
+   {
+      Session session = getSession();
+      try
+      {
+         //session.flush();
+         session.delete(category);
+         //session.flush();
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot delete category";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public void removeForum(Forum forum)
+      throws ModuleException
+   {
+      Session session = getSession();
+      try
+      {
+         //session.delete(forum);
+         if (forum.getCategory() != null)
+         {
+            forum.getCategory().getForums().remove(forum);
+            forum.setCategory(null);
+         }
+         else
+         {
+            session.delete(forum);
+         }
+
+         //session.flush();
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot delete forum";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public void removePost(Post post)
+      throws ModuleException
+   {
+      Session session = getSession();
+      try
+      {
+         //session.flush();
+         //session.delete(post);
+         if (post.getTopic() != null)
+         {
+            post.getTopic().getPosts().remove(post);
+            post.setTopic(null);
+         }
+         else
+         {
+            session.delete(post);
+         }
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot delete post";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public void removePollInTopic(Topic topic)
+      throws ModuleException
+   {
+      Session session = getSession();
+      try
+      {
+         //session.flush();
+         Poll poll = topic.getPoll();
+         topic.setPoll(null);
+         session.delete(poll);
+
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot delete poll";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public void removeTopic(Topic topic)
+      throws ModuleException
+   {
+      Session session = getSession();
+      try
+      {
+         //session.flush();
+         //session.delete(topic);
+         if (topic.getForum() != null)
+         {
+            topic.getForum().getTopics().remove(topic);
+            topic.setForum(null);
+            //session.delete(topic);
+         }
+         else
+         {
+            session.delete(topic);
+         }
+         //session.flush();
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot delete topic";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   private int getLastForumOrder(Category category)
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("select max(f.order) from ForumImpl as f where f.category = :categoryId");
+         query.setString("categoryId", "" + category.getId());
+         Integer lastForumOrder = (Integer)query.uniqueResult();
+         return (lastForumOrder != null) ? lastForumOrder.intValue() : 0;
+      }
+      catch (HibernateException e)
+      {
+         return 0;
+      }
+   }
+
+   public Forum createForum(Category category,
+                            String name,
+                            String description)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+
+         ForumImpl forum = new ForumImpl();
+         //forum.setCategory(category);
+         category.addForum(forum);
+         forum.setName(name);
+         forum.setDescription(description);
+         forum.setOrder(getLastForumOrder(category) + 10);
+         session.save(forum);
+         return forum;
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot create forum";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public Topic findTopicById(Integer id)
+      throws ModuleException
+   {
+      if (id != null)
+      {
+         try
+         {
+            Session session = getSession();
+            TopicImpl topic = (TopicImpl)session.get(TopicImpl.class, id);
+            if (topic == null)
+            {
+               throw new ModuleException("No topic found for " + id);
+            }
+
+            return topic;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find forum by id " + id;
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("id cannot be null");
+      }
+   }
+
+   public List findTopics(Forum forum)
+      throws ModuleException
+   {
+      if (forum != null)
+      {
+         try
+         {
+            Session session = getSession();
+            Query query =
+               session.createQuery("from TopicImpl as t where t.forum = :forumid");
+            query.setString("forumid", "" + forum.getId());
+            Iterator iterator = query.iterate();
+            return Tools.toList(iterator);
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find topics";
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("forum cannot be null");
+      }
+   }
+
+   public List findPosts()
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from PostImpl");
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find posts";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public Post findPostById(Integer id)
+      throws ModuleException
+   {
+      if (id != null)
+      {
+         try
+         {
+            Session session = getSession();
+            PostImpl post = (PostImpl)session.get(PostImpl.class, id);
+            if (post == null)
+            {
+               throw new ModuleException("No post found for " + id);
+            }
+
+            return post;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find post by id " + id;
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("id cannot be null");
+      }
+   }
+
+   public Attachment findFindAttachmentById(Integer attachID)
+      throws ModuleException
+   {
+      if (attachID != null)
+      {
+         try
+         {
+            Session session = getSession();
+            Attachment attach = (Attachment)session.get(AttachmentImpl.class, attachID);
+            if (attach == null)
+            {
+               throw new ModuleException("No attachment found for " + attachID);
+            }
+
+            return attach;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find attachment by id " + attachID;
+            log.error(message, e);
+            throw new ModuleException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("id cannot be null");
+      }
+   }
+
+   private List findPostsByTopicId(Integer topicId,
+                                   int start,
+                                   int limit,
+                                   String order)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from PostImpl as p where p.topic=:topicId order by p.createDate " + order);
+         query.setString("topicId",
+            topicId.toString());
+         query.setFirstResult(start);
+         if (limit != 0)
+         {
+            query.setMaxResults(limit);
+         }
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find posts";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public List findPostsByTopicId(Integer topicId)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from PostImpl as p where p.topic=:topicId");
+         query.setString("topicId",
+            topicId.toString());
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find posts";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+
+   public void addAllForums(Category source,
+                            Category target)
+   {
+      List list = source.getForums();
+      target.getForums().addAll(source.getForums());
+      Iterator iterator = target.getForums().iterator();
+      while (iterator.hasNext())
+      {
+         Forum forum = (Forum)iterator.next();
+         forum.setCategory(target);
+      }
+      source.setForums(new ArrayList());
+   }
+
+   public List findPostsByTopicIdAsc(Integer topicId,
+                                     int start,
+                                     int limit)
+      throws ModuleException
+   {
+      return findPostsByTopicId(topicId, start, limit, "asc");
+   }
+
+   public List findPostsByTopicIdDesc(Integer topicId,
+                                      int start,
+                                      int limit)
+      throws ModuleException
+   {
+      return findPostsByTopicId(topicId, start, limit, "desc");
+   }
+
+   public Date findLastPostDateForUser(User user)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("select max(p.createDate) from PostImpl as p where p.poster.userId = :userId");
+         query.setString("userId", "" + user.getId().toString());
+         Date lastPostDate = (Date)query.uniqueResult();
+         return lastPostDate;
+      }
+      catch (HibernateException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   public Post findLastPost(Forum forum)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from PostImpl as p where p.topic.forum  = :forumId order by p.createDate desc");
+         query.setString("forumId", "" + forum.getId());
+         query.setFirstResult(0);
+         query.setMaxResults(1);
+         Post lastPost = (Post)query.uniqueResult();
+         return lastPost;
+      }
+      catch (HibernateException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   public Post findFirstPost(Topic topic)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from PostImpl as p where p.topic  = :topicId order by p.createDate asc");
+         query.setString("topicId", "" + topic.getId());
+         query.setFirstResult(0);
+         query.setMaxResults(1);
+         Post firstPost = (Post)query.uniqueResult();
+         return firstPost;
+      }
+      catch (HibernateException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   public Post findLastPost(Topic topic)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query =
+            session.createQuery("from PostImpl as p where p.topic  = :topicId order by p.createDate desc");
+         query.setString("topicId", "" + topic.getId());
+         query.setFirstResult(0);
+         query.setMaxResults(1);
+         Post lastPost = (Post)query.uniqueResult();
+         return lastPost;
+      }
+      catch (HibernateException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   public List findForumWatchByUser(User user) throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query = session.createQuery("from ForumWatchImpl as f where f.poster.userId = :userId");
+         query.setString("userId", user.getId().toString());
+         Iterator iterator = query.iterate();
+         return Tools.toList(iterator);
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find forum watch";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public void createWatch(Poster poster, Forum forum, int mode) throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+
+         if (poster == null)
+         {
+            throw new ModuleException("poster must not be null");
+         }
+
+         if (forum == null)
+         {
+            throw new ModuleException("forum must not be null");
+         }
+
+         ForumWatch forumWatch = new ForumWatchImpl();
+         forumWatch.setPoster(poster);
+         forumWatch.setForum(forum);
+         forumWatch.setMode(mode);
+         session.save(forumWatch);
+
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot create forum watch";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public void removeWatch(Watch watch) throws ModuleException
+   {
+      Session session = getSession();
+      try
+      {
+         session.delete(watch);
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot delete watch";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public ForumWatch findForumWatchById(Integer forumWatchId)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query = session.createQuery("from ForumWatchImpl as f where f.id = :forumWatchId");
+         query.setString("forumWatchId",
+            forumWatchId.toString());
+         return (ForumWatch)query.uniqueResult();
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find forum watch";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public void createWatch(Poster poster, Topic topic)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+
+         if (poster == null)
+         {
+            throw new ModuleException("poster must not be null");
+         }
+
+         if (topic == null)
+         {
+            throw new ModuleException("topic must not be null");
+         }
+
+         TopicWatch topicWatch = new TopicWatchImpl();
+         topicWatch.setPoster(poster);
+         topicWatch.setTopic(topic);
+         session.save(topicWatch);
+      }
+      catch (HibernateException e)
+      {
+         String errorMessage = "Cannot create topic watch";
+         log.error(errorMessage, e);
+         throw new ModuleException(errorMessage, e);
+      }
+   }
+
+   public TopicWatch findTopicWatchById(Integer topicWatchId)
+      throws ModuleException
+   {
+      try
+      {
+         Session session = getSession();
+         Query query = session.createQuery("from TopicWatchImpl as f where f.id = :topicWatchId");
+         query.setString("topicWatchId",
+            topicWatchId.toString());
+         return (TopicWatch)query.uniqueResult();
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find topic watch";
+         log.error(message, e);
+         throw new ModuleException(message, e);
+      }
+   }
+
+   public Result invoke(ActionCommand cmd) throws CommandException
+   {
+      //throw new UnsupportedOperationException();
+      return chain.filter(cmd);
+   }
+   
+   protected Session getSession () {
+       return factory.getCurrentSession();
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/MessageImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/MessageImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/MessageImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,148 +1,148 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-
-import org.jboss.portlet.forums.model.Message;
-
-/**
- * A DVC object that groups the message informations for a post.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-public class MessageImpl
-   implements Message,
-   Serializable,
-   Cloneable
-{
-   private String subject = "";
-   private String text = "";
-   private boolean BBCodeEnabled = true;
-   private boolean HTMLEnabled = false;
-   private boolean smiliesEnabled = false;
-   private boolean signatureEnabled = true;
-
-   /**
-    * @hibernate.property column="jbp_subject"
-    */
-   public String getSubject()
-   {
-      return subject;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param subject DOCUMENT_ME
-    */
-   public void setSubject(String subject)
-   {
-      this.subject = subject;
-   }
-
-   /**
-    * @hibernate.property column="jbp_text"
-    * type="text"
-    */
-   public String getText()
-   {
-      return text;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param text DOCUMENT_ME
-    */
-   public void setText(String text)
-   {
-      this.text = text;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean getBBCodeEnabled()
-   {
-      return BBCodeEnabled;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param BBCodeEnabled DOCUMENT_ME
-    */
-   public void setBBCodeEnabled(boolean BBCodeEnabled)
-   {
-      this.BBCodeEnabled = BBCodeEnabled;
-   }
-
-   public boolean getHTMLEnabled()
-   {
-      return HTMLEnabled;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param HTMLEnabled DOCUMENT_ME
-    */
-   public void setHTMLEnabled(boolean HTMLEnabled)
-   {
-      this.HTMLEnabled = HTMLEnabled;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean getSmiliesEnabled()
-   {
-      return smiliesEnabled;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param smiliesEnabled DOCUMENT_ME
-    */
-   public void setSmiliesEnabled(boolean smiliesEnabled)
-   {
-      this.smiliesEnabled = smiliesEnabled;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean getSignatureEnabled()
-   {
-      return signatureEnabled;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param signatureEnabled DOCUMENT_ME
-    */
-   public void setSignatureEnabled(boolean signatureEnabled)
-   {
-      this.signatureEnabled = signatureEnabled;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+
+import org.jboss.portlet.forums.model.Message;
+
+/**
+ * A DVC object that groups the message informations for a post.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.4 $
+ */
+public class MessageImpl
+   implements Message,
+   Serializable,
+   Cloneable
+{
+   private String subject = "";
+   private String text = "";
+   private boolean BBCodeEnabled = true;
+   private boolean HTMLEnabled = false;
+   private boolean smiliesEnabled = false;
+   private boolean signatureEnabled = true;
+
+   /**
+    * @hibernate.property column="jbp_subject"
+    */
+   public String getSubject()
+   {
+      return subject;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param subject DOCUMENT_ME
+    */
+   public void setSubject(String subject)
+   {
+      this.subject = subject;
+   }
+
+   /**
+    * @hibernate.property column="jbp_text"
+    * type="text"
+    */
+   public String getText()
+   {
+      return text;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param text DOCUMENT_ME
+    */
+   public void setText(String text)
+   {
+      this.text = text;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean getBBCodeEnabled()
+   {
+      return BBCodeEnabled;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param BBCodeEnabled DOCUMENT_ME
+    */
+   public void setBBCodeEnabled(boolean BBCodeEnabled)
+   {
+      this.BBCodeEnabled = BBCodeEnabled;
+   }
+
+   public boolean getHTMLEnabled()
+   {
+      return HTMLEnabled;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param HTMLEnabled DOCUMENT_ME
+    */
+   public void setHTMLEnabled(boolean HTMLEnabled)
+   {
+      this.HTMLEnabled = HTMLEnabled;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean getSmiliesEnabled()
+   {
+      return smiliesEnabled;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param smiliesEnabled DOCUMENT_ME
+    */
+   public void setSmiliesEnabled(boolean smiliesEnabled)
+   {
+      this.smiliesEnabled = smiliesEnabled;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean getSignatureEnabled()
+   {
+      return signatureEnabled;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param signatureEnabled DOCUMENT_ME
+    */
+   public void setSignatureEnabled(boolean signatureEnabled)
+   {
+      this.signatureEnabled = signatureEnabled;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,181 +1,181 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-import java.util.*;
-
-import org.jboss.portlet.forums.model.Poll;
-import org.jboss.portlet.forums.model.PollOption;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.7 $
- * @hibernate.class table="jbp_forums_polls"
- */
-public class PollImpl
-   implements Serializable,
-   Poll
-{
-   /**
-    * Creates a new {@link PollImpl} object.
-    */
-   public PollImpl()
-   {
-      setOptions(new LinkedList());
-      setVoted(new HashSet());
-   }
-
-   private Integer id;
-   private String title;
-   private List options;
-   private int length;
-   /*private boolean isEnded = false;*/
-   private Set voted;
-   private Date creationDate;
-
-   /**
-    * @hibernate.id column="jbp_poll_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   private void setId(Integer id)
-   {
-      this.id = id;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.portlet.forums.model.Poll#setTitle(java.lang.String)
-    */
-   public void setTitle(String string)
-   {
-      this.title = string;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.portlet.forums.model.Poll#setLength(int)
-    */
-   public void setLength(int i)
-   {
-      this.length = i;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.portlet.forums.model.Poll#setOptions(java.util.LinkedList)
-    */
-   public void setOptions(List list)
-   {
-      this.options = list;
-   }
-
-   /**
-    * @hibernate.list lazy="true"
-    * cascade="all"
-    * update="true"
-    * table="jbp_forums_poll_option"
-    * @hibernate.collection-key column="jbp_poll_id"
-    * @hibernate.collection-index column="jbp_poll_option_position"
-    * @hibernate.collection-composite-element class="org.jboss.portlet.forums.impl.PollOptionImpl"
-    */
-   public List getOptions()
-   {
-      return this.options;
-      //class="org.jboss.portlet.forums.impl.PollOptionImpl"
-      /*type="string"
-    *    column="jbp_poll_option_question"
-    *    not-null="true"*/
-   }
-
-   /**
-    * @hibernate.property column="jbp_title"
-    */
-   public String getTitle()
-   {
-      return this.title;
-   }
-
-   /**
-    * @hibernate.property column="jbp_length"
-    * unique="false"
-    * update="true"
-    */
-   public int getLength()
-   {
-      return this.length;
-   }
-
-   /**
-    * _ at _ hibernate.property
-    *    column="jbp_ended"
-    *    unique="false"
-    *    update="true"
-    */
-   /*public boolean getIsEnded()
-   {
-      return isEnded;
-   }*/
-
-   /*public void setIsEnded(boolean ended)
-   {
-      isEnded = ended;
-   }*/
-
-   /**
-    * @hibernate.set lazy="true"
-    * cascade="all"
-    * table="jbp_forums_poll_voted"
-    * @hibernate.collection-key column="jbp_poll_id"
-    * @hibernate.collection-element type="integer"
-    * column="jbp_poll_voted"
-    * not-null="true"
-    */
-   public Set getVoted()
-   {
-      return voted;
-   }
-
-   public void setVoted(Set voted)
-   {
-      this.voted = voted;
-   }
-
-   public int getVotesSum()
-   {
-      int sum = 0;
-      for (Iterator i = getOptions().iterator(); i.hasNext();)
-      {
-         sum += ((PollOption)i.next()).getVotes();
-      }
-      return sum;
-   }
-
-   /**
-    * @hibernate.property column="jbp_creation_date"
-    * not-null="true"
-    */
-   public Date getCreationDate()
-   {
-      return creationDate;
-   }
-
-   public void setCreationDate(Date creationDate)
-   {
-      this.creationDate = creationDate;
-   }
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+import java.util.*;
+
+import org.jboss.portlet.forums.model.Poll;
+import org.jboss.portlet.forums.model.PollOption;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.7 $
+ * @hibernate.class table="jbp_forums_polls"
+ */
+public class PollImpl
+   implements Serializable,
+   Poll
+{
+   /**
+    * Creates a new {@link PollImpl} object.
+    */
+   public PollImpl()
+   {
+      setOptions(new LinkedList());
+      setVoted(new HashSet());
+   }
+
+   private Integer id;
+   private String title;
+   private List options;
+   private int length;
+   /*private boolean isEnded = false;*/
+   private Set voted;
+   private Date creationDate;
+
+   /**
+    * @hibernate.id column="jbp_poll_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   private void setId(Integer id)
+   {
+      this.id = id;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.portlet.forums.model.Poll#setTitle(java.lang.String)
+    */
+   public void setTitle(String string)
+   {
+      this.title = string;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.portlet.forums.model.Poll#setLength(int)
+    */
+   public void setLength(int i)
+   {
+      this.length = i;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.portlet.forums.model.Poll#setOptions(java.util.LinkedList)
+    */
+   public void setOptions(List list)
+   {
+      this.options = list;
+   }
+
+   /**
+    * @hibernate.list lazy="true"
+    * cascade="all"
+    * update="true"
+    * table="jbp_forums_poll_option"
+    * @hibernate.collection-key column="jbp_poll_id"
+    * @hibernate.collection-index column="jbp_poll_option_position"
+    * @hibernate.collection-composite-element class="org.jboss.portlet.forums.impl.PollOptionImpl"
+    */
+   public List getOptions()
+   {
+      return this.options;
+      //class="org.jboss.portlet.forums.impl.PollOptionImpl"
+      /*type="string"
+    *    column="jbp_poll_option_question"
+    *    not-null="true"*/
+   }
+
+   /**
+    * @hibernate.property column="jbp_title"
+    */
+   public String getTitle()
+   {
+      return this.title;
+   }
+
+   /**
+    * @hibernate.property column="jbp_length"
+    * unique="false"
+    * update="true"
+    */
+   public int getLength()
+   {
+      return this.length;
+   }
+
+   /**
+    * _ at _ hibernate.property
+    *    column="jbp_ended"
+    *    unique="false"
+    *    update="true"
+    */
+   /*public boolean getIsEnded()
+   {
+      return isEnded;
+   }*/
+
+   /*public void setIsEnded(boolean ended)
+   {
+      isEnded = ended;
+   }*/
+
+   /**
+    * @hibernate.set lazy="true"
+    * cascade="all"
+    * table="jbp_forums_poll_voted"
+    * @hibernate.collection-key column="jbp_poll_id"
+    * @hibernate.collection-element type="integer"
+    * column="jbp_poll_voted"
+    * not-null="true"
+    */
+   public Set getVoted()
+   {
+      return voted;
+   }
+
+   public void setVoted(Set voted)
+   {
+      this.voted = voted;
+   }
+
+   public int getVotesSum()
+   {
+      int sum = 0;
+      for (Iterator i = getOptions().iterator(); i.hasNext();)
+      {
+         sum += ((PollOption)i.next()).getVotes();
+      }
+      return sum;
+   }
+
+   /**
+    * @hibernate.property column="jbp_creation_date"
+    * not-null="true"
+    */
+   public Date getCreationDate()
+   {
+      return creationDate;
+   }
+
+   public void setCreationDate(Date creationDate)
+   {
+      this.creationDate = creationDate;
+   }
+
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollOptionImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollOptionImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PollOptionImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,74 +1,74 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import org.jboss.portlet.forums.model.PollOption;
-import org.jboss.portlet.forums.model.Poll;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Date;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-
-public class PollOptionImpl
-   implements PollOption, Serializable
-{
-   private String question;
-   private int votes = 0;
-
-
-   public PollOptionImpl()
-   {
-   }
-
-   public PollOptionImpl(String question)
-   {
-      setQuestion(question);
-   }
-
-   /**
-    * @hibernate.property column="jbp_votes"
-    * not-null="true"
-    */
-   public int getVotes()
-   {
-      return votes;
-   }
-
-   public void setVotes(int votes)
-   {
-      this.votes = votes;
-   }
-
-   /**
-    * @hibernate.property column="jbp_question"
-    * not-null="true"
-    */
-   public String getQuestion()
-   {
-      return question;
-   }
-
-   public void setQuestion(String question)
-   {
-      this.question = question;
-   }
-
-   public void incVotes()
-   {
-      votes++;
-   }
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import org.jboss.portlet.forums.model.PollOption;
+import org.jboss.portlet.forums.model.Poll;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Date;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+
+public class PollOptionImpl
+   implements PollOption, Serializable
+{
+   private String question;
+   private int votes = 0;
+
+
+   public PollOptionImpl()
+   {
+   }
+
+   public PollOptionImpl(String question)
+   {
+      setQuestion(question);
+   }
+
+   /**
+    * @hibernate.property column="jbp_votes"
+    * not-null="true"
+    */
+   public int getVotes()
+   {
+      return votes;
+   }
+
+   public void setVotes(int votes)
+   {
+      this.votes = votes;
+   }
+
+   /**
+    * @hibernate.property column="jbp_question"
+    * not-null="true"
+    */
+   public String getQuestion()
+   {
+      return question;
+   }
+
+   public void setQuestion(String question)
+   {
+      this.question = question;
+   }
+
+   public void incVotes()
+   {
+      votes++;
+   }
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PostImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PostImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PostImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,235 +1,235 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.jboss.portal.identity.User;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Poster;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Attachment;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.9 $
- * @hibernate.class table="jbp_forums_posts"
- */
-public class PostImpl
-   implements Serializable,
-   Post
-{
-   private Topic topic;
-   private User user;
-   private int count;
-   private Date date;
-   private Integer id;
-   private Date createDate;
-   private Message message;
-   private Poster poster;
-   private List attachments;
-
-   /**
-    * Creates a new {@link PostImpl} object.
-    */
-   public PostImpl()
-   {
-      attachments = new LinkedList();
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_topic_id"
-    * class="org.jboss.portlet.forums.impl.TopicImpl"
-    */
-   public Topic getTopic()
-   {
-      return topic;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topic DOCUMENT_ME
-    */
-   public void setTopic(Topic topic)
-   {
-      this.topic = topic;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public User getUser()
-   {
-      return user;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param user DOCUMENT_ME
-    */
-   public void setUser(User user)
-   {
-      this.user = user;
-   }
-
-   /**
-    * @hibernate.property column="jbp_edit_count"
-    * unique="false"
-    * update="true"
-    */
-   public int getEditCount()
-   {
-      return count;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param count DOCUMENT_ME
-    */
-   public void setEditCount(int count)
-   {
-      this.count = count;
-   }
-
-   /**
-    * @hibernate.property column="jbp_edit_date"
-    * unique="false"
-    * update="true"
-    */
-   public Date getEditDate()
-   {
-      return date;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param date DOCUMENT_ME
-    */
-   public void setEditDate(Date date)
-   {
-      this.date = date;
-   }
-
-   /**
-    * @hibernate.id column="jbp_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param id DOCUMENT_ME
-    */
-   public void setId(Integer id)
-   {
-      this.id = id;
-   }
-
-   /**
-    * @hibernate.property column="jbp_create_date"
-    * unique="false"
-    * update="false"
-    */
-   public Date getCreateDate()
-   {
-      return createDate;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param createDate DOCUMENT_ME
-    */
-   public void setCreateDate(Date createDate)
-   {
-      this.createDate = createDate;
-   }
-
-   /**
-    * @hibernate.component class="org.jboss.portlet.forums.impl.MessageImpl"
-    */
-   public Message getMessage()
-   {
-      return message;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param message DOCUMENT_ME
-    */
-   public void setMessage(Message message)
-   {
-      this.message = message;
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_poster_id"
-    * class="org.jboss.portlet.forums.impl.PosterImpl"
-    */
-   public Poster getPoster()
-   {
-      return poster;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param poster DOCUMENT_ME
-    */
-   public void setPoster(Poster poster)
-   {
-      this.poster = poster;
-   }
-
-
-   //TODO:BD - order it by something... is name ok?
-   /**
-    * @hibernate.bag lazy="true"
-    * cascade="all-delete-orphan"
-    * order-by="jbp_name asc"
-    * inverse="true"
-    * table="jbp_forums_attachments"
-    * @hibernate.collection-key column="jbp_post_id"
-    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.AttachmentImpl"
-    */
-   public List getAttachments()
-   {
-      return attachments;
-   }
-
-   public void setAttachments(List attachments)
-   {
-      this.attachments = attachments;
-   }
-
-   public void addAttachment(Attachment attachment)
-   {
-      attachment.setPost(this);
-      attachments.add(attachment);
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+import java.util.LinkedList;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Poster;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Attachment;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.9 $
+ * @hibernate.class table="jbp_forums_posts"
+ */
+public class PostImpl
+   implements Serializable,
+   Post
+{
+   private Topic topic;
+   private User user;
+   private int count;
+   private Date date;
+   private Integer id;
+   private Date createDate;
+   private Message message;
+   private Poster poster;
+   private List attachments;
+
+   /**
+    * Creates a new {@link PostImpl} object.
+    */
+   public PostImpl()
+   {
+      attachments = new LinkedList();
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_topic_id"
+    * class="org.jboss.portlet.forums.impl.TopicImpl"
+    */
+   public Topic getTopic()
+   {
+      return topic;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topic DOCUMENT_ME
+    */
+   public void setTopic(Topic topic)
+   {
+      this.topic = topic;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public User getUser()
+   {
+      return user;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param user DOCUMENT_ME
+    */
+   public void setUser(User user)
+   {
+      this.user = user;
+   }
+
+   /**
+    * @hibernate.property column="jbp_edit_count"
+    * unique="false"
+    * update="true"
+    */
+   public int getEditCount()
+   {
+      return count;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param count DOCUMENT_ME
+    */
+   public void setEditCount(int count)
+   {
+      this.count = count;
+   }
+
+   /**
+    * @hibernate.property column="jbp_edit_date"
+    * unique="false"
+    * update="true"
+    */
+   public Date getEditDate()
+   {
+      return date;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param date DOCUMENT_ME
+    */
+   public void setEditDate(Date date)
+   {
+      this.date = date;
+   }
+
+   /**
+    * @hibernate.id column="jbp_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param id DOCUMENT_ME
+    */
+   public void setId(Integer id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * @hibernate.property column="jbp_create_date"
+    * unique="false"
+    * update="false"
+    */
+   public Date getCreateDate()
+   {
+      return createDate;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param createDate DOCUMENT_ME
+    */
+   public void setCreateDate(Date createDate)
+   {
+      this.createDate = createDate;
+   }
+
+   /**
+    * @hibernate.component class="org.jboss.portlet.forums.impl.MessageImpl"
+    */
+   public Message getMessage()
+   {
+      return message;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param message DOCUMENT_ME
+    */
+   public void setMessage(Message message)
+   {
+      this.message = message;
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_poster_id"
+    * class="org.jboss.portlet.forums.impl.PosterImpl"
+    */
+   public Poster getPoster()
+   {
+      return poster;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param poster DOCUMENT_ME
+    */
+   public void setPoster(Poster poster)
+   {
+      this.poster = poster;
+   }
+
+
+   //TODO:BD - order it by something... is name ok?
+   /**
+    * @hibernate.bag lazy="true"
+    * cascade="all-delete-orphan"
+    * order-by="jbp_name asc"
+    * inverse="true"
+    * table="jbp_forums_attachments"
+    * @hibernate.collection-key column="jbp_post_id"
+    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.AttachmentImpl"
+    */
+   public List getAttachments()
+   {
+      return attachments;
+   }
+
+   public void setAttachments(List attachments)
+   {
+      this.attachments = attachments;
+   }
+
+   public void addAttachment(Attachment attachment)
+   {
+      attachment.setPost(this);
+      attachments.add(attachment);
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PosterImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PosterImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/PosterImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,139 +1,140 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.portal.identity.User;
-import org.jboss.portal.core.modules.ModuleConstants;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portal.identity.UserModule;
-import org.jboss.portlet.forums.model.Poster;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.12 $
- * @hibernate.class table="jbp_forums_posters"
- */
-public class PosterImpl
-   implements Poster
-{
-   private Integer id;
-   private String userId;
-   //private String  userName;
-   private User user;
-   private int nbPosts = 0;
-
-   /**
-    * Creates a new {@link PosterImpl} object.
-    */
-   public PosterImpl()
-   {
-   }
-
-   public PosterImpl(String userId)
-   {
-      setUserId(userId);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public User getUser()
-   {
-      if (user == null)
-      {
-         try
-         {                                
-            UserModule userModule = (UserModule)new InitialContext().lookup(ModuleConstants.USERMODULE_JNDINAME);
-            user = userModule.findUserById(userId);
-         }
-         catch (NamingException e)
-         {
-            return null;
-         }
-         catch (IllegalArgumentException e)
-         {
-            e.printStackTrace();
-            return null;
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();
-            return null;
-         }
-      }
-      return user;
-   }
-
-   /**
-    * @return Returns the id.
-    * @hibernate.id column="jbp_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   /**
-    * @param id The id to set.
-    */
-   public void setId(Integer id)
-   {
-      this.id = id;
-   }
-
-   /**
-    * This column has the unique constraints as it reflects the user id.
-    *
-    * @return Returns the id.
-    * @hibernate.property column="jbp_user_id"
-    * unique="true"
-    */
-   public String getUserId()
-   {
-      return userId;
-   }
-
-   /**
-    * @param userId The id to set.
-    */
-   public void setUserId(String userId)
-   {
-      this.userId = userId;
-   }
-
-   /**
-    * @hibernate.property column="jbp_post_count"
-    */
-   public int getPostCount()
-   {
-      return nbPosts;
-   }
-
-   private void setPostCount(int nbPosts)
-   {
-      this.nbPosts = nbPosts;
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public void incrementPostCount()
-   {
-      setPostCount(nbPosts + 1);
-   }
-}
\ No newline at end of file
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.modules.ModuleConstants;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portlet.forums.model.Poster;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.13 $
+ * @hibernate.class table="jbp_forums_posters"
+ */
+public class PosterImpl
+   implements Poster
+{
+   private Integer id;
+   private String userId;
+   //private String  userName;
+   private User user;
+   private int nbPosts = 0;
+
+   /**
+    * Creates a new {@link PosterImpl} object.
+    */
+   public PosterImpl()
+   {
+   }
+
+   public PosterImpl(String userId)
+   {
+      setUserId(userId);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public User getUser()
+   {
+      if (user == null)
+      {
+         try
+         {                                
+            UserModule userModule = (UserModule)new InitialContext().lookup(ModuleConstants.USERMODULE_JNDINAME);
+            user = userModule.findUserById(userId);
+         }
+         catch (NamingException e)
+         {
+            return null;
+         }
+         catch (IllegalArgumentException e)
+         {
+            e.printStackTrace();
+            return null;
+         }
+         catch (IdentityException e)
+         {
+            e.printStackTrace();
+            return null;
+         }
+      }
+      return user;
+   }
+
+   /**
+    * @return Returns the id.
+    * @hibernate.id column="jbp_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   /**
+    * @param id The id to set.
+    */
+   public void setId(Integer id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * This column has the unique constraints as it reflects the user id.
+    *
+    * @return Returns the id.
+    * @hibernate.property column="jbp_user_id"
+    * unique="true"
+    */
+   public String getUserId()
+   {
+      return userId;
+   }
+
+   /**
+    * @param userId The id to set.
+    */
+   public void setUserId(String userId)
+   {
+      this.userId = userId;
+   }
+
+   /**
+    * @hibernate.property column="jbp_post_count"
+    */
+   public int getPostCount()
+   {
+      return nbPosts;
+   }
+
+   private void setPostCount(int nbPosts)
+   {
+      this.nbPosts = nbPosts;
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public void incrementPostCount()
+   {
+      setPostCount(nbPosts + 1);
+   }
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,430 +1,430 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-import java.util.*;
-
-import org.jboss.portlet.forums.model.*;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.8 $
- * @hibernate.class table="jbp_forums_topics"
- */
-public class TopicImpl
-   implements Serializable,
-   Comparable,
-   Topic
-{
-   private Integer id;
-   private List posts;
-   private Forum forum;
-   private int viewCount;
-   //private Date       date;
-   //private int        replies;
-   //private Post       firstPost;
-   //private Post       lastPost;
-   //this field is cached but was left as it's easier to sort topics with HQL having such column
-   private Date lastPostDate;
-   //private Date       editDate;
-   private Poster poster;
-   private int type;
-   private int status;
-   //private Topic      target;
-   private String subject;
-   private List watches;
-   private Poll poll;
-
-   /**
-    * Creates a new {@link TopicImpl} object.
-    */
-   public TopicImpl()
-   {
-      setPosts(new ArrayList());
-   }
-
-
-   //we are implementing comparable to be able to sort topics by last post date without to have
-   //a column in db.
-   public int compareTo(Object comp)
-   {
-      Date thisDate = getLastPostDate();
-      Date thatDate = ((Topic)comp).getLastPostDate();
-      if (thisDate != null && (thatDate != null))
-      {
-         return thisDate.compareTo(thatDate);
-      }
-      else if (thisDate == null && (thatDate != null))
-      {
-         return -1;
-      }
-      else if (thisDate != null && (thatDate == null))
-      {
-         return 1;
-      }
-      else
-      {
-         return 0;
-      }
-   }
-
-
-   /**
-    * @hibernate.id column="jbp_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param id DOCUMENT_ME
-    */
-   public void setId(Integer id)
-   {
-      this.id = id;
-   }
-
-   /*
-    * __ at hibernate.collection-many-to-one
-    * __class="org.jboss.portlet.forums.impl.PostImpl"
-    */
-
-   /**
-    * @hibernate.bag lazy="true"
-    * cascade="all-delete-orphan"
-    * order-by="jbp_create_date asc"
-    * inverse="true"
-    * table="jbp_forums_posts"
-    * @hibernate.collection-key column="jbp_topic_id"
-    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.PostImpl"
-    */
-   public List getPosts()
-   {
-      //Hibernate.initialize(posts);
-      return posts;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   public void setPosts(List value)
-   {
-      posts = value;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param post DOCUMENT_ME
-    */
-   public void addPost(Post post)
-   {
-      post.setTopic(this);
-      posts.add(post);
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_forum_id"
-    * class="org.jboss.portlet.forums.impl.ForumImpl"
-    */
-   public Forum getForum()
-   {
-      return forum;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum DOCUMENT_ME
-    */
-   public void setForum(Forum forum)
-   {
-      this.forum = forum;
-   }
-
-   /**
-    * @hibernate.property column="jbp_view_count"
-    * unique="false"
-    * update="true"
-    */
-   public int getViewCount()
-   {
-      return viewCount;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param viewCount DOCUMENT_ME
-    */
-   public void setViewCount(int viewCount)
-   {
-      this.viewCount = viewCount;
-   }
-
-   /**
-    * @hibernate.property column="jbp_replies"
-    * unique="false"
-    * update="true"
-    */
-   public int getReplies()
-   {
-
-      return getPosts().size() - 1;
-      //return replies;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param replies DOCUMENT_ME
-    */
-   public void setReplies(int replies)
-   {
-      //this.replies = replies;
-   }
-
-   /**
-    * _ at _hibernate.many-to-one
-    * _column_="jbp_first_post_id"
-    * _class_="org.jboss.portlet.forums.impl.PostImpl"
-    */
-   public Post getFirstPost()
-   {
-      //return firstPost;
-      //Hibernate.initialize(posts);
-      Iterator i = getPosts().iterator();
-      if (i.hasNext())
-      {
-         return (Post)i.next();
-      }
-      else
-      {
-         return null;
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param post DOCUMENT_ME
-    */
-   public void setFirstPost(Post post)
-   {
-      if (post != null)
-      {
-         posts.add(post);
-      }
-      //this.firstPost = post;
-   }
-
-   /**
-    * _ at _hibernate.many-to-one
-    * _column_="jbp_last_post_id"
-    * _class_="org.jboss.portlet.forums.impl.PostImpl"
-    */
-   public Post getLastPost()
-   {
-      //return lastPost;
-      //Hibernate.initialize(posts);
-      if (posts == null || (posts.size() == 0))
-      {
-         return null;
-      }
-      return (Post)posts.get(posts.size() - 1);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param post DOCUMENT_ME
-    */
-   public void setLastPost(Post post)
-   {
-      if (post != null)
-      {
-         posts.add(post);
-      }
-      //forum.setLastPost(post);
-      //this.lastPost = post;
-   }
-
-   /**
-    * @hibernate.property column="jbp_last_post_date"
-    * unique="false"
-    * update="true"
-    */
-   public Date getLastPostDate()
-   {
-      return lastPostDate;
-      /*Post post = getLastPost();
-      if(post!=null)
-      {
-         return post.getCreateDate();
-      }
-      else
-      {
-         return null;
-      }
-*/
-
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param lastPostDate DOCUMENT_ME
-    */
-   public void setLastPostDate(Date lastPostDate)
-   {
-      this.lastPostDate = lastPostDate;
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_poster"
-    * class="org.jboss.portlet.forums.impl.PosterImpl"
-    */
-   public Poster getPoster()
-   {
-      return poster;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param poster DOCUMENT_ME
-    */
-   public void setPoster(Poster poster)
-   {
-      this.poster = poster;
-   }
-
-   /**
-    * @hibernate.property column="jbp_type"
-    * unique="false"
-    * update="true"
-    */
-   public int getType()
-   {
-      return type;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param type DOCUMENT_ME
-    */
-   public void setType(int type)
-   {
-      this.type = type;
-   }
-
-   /**
-    * @hibernate.property column="jbp_status"
-    * unique="false"
-    * update="true"
-    */
-   public int getStatus()
-   {
-      return status;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param status DOCUMENT_ME
-    */
-   public void setStatus(int status)
-   {
-      this.status = status;
-   }
-
-   /**
-    * _ at hibernate.one-to-one
-    *    _column="jbp_target"
-    *    _class="org.jboss.portlet.forums.impl.TopicImpl"
-    */
-   /*public Topic getTarget()
-   {
-      return target;
-   }*/
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param target DOCUMENT_ME
-    */
-   /*public void setTarget(Topic target)
-   {
-      this.target = target;
-   }*/
-
-   /**
-    * @hibernate.property column="jbp_subject"
-    * unique="false"
-    * update="true"
-    */
-   public String getSubject()
-   {
-      return subject;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param subject DOCUMENT_ME
-    */
-   public void setSubject(String subject)
-   {
-      this.subject = subject;
-   }
-
-   /**
-    * @hibernate.bag lazy="true"
-    * inverse="true"
-    * cascade="all"
-    * @hibernate.collection-key column="jbp_topic_id"
-    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.TopicWatchImpl"
-    */
-   public List getWatches()
-   {
-      return watches;
-   }
-
-   public void setWatches(List watches)
-   {
-      this.watches = watches;
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_poll"
-    * class="org.jboss.portlet.forums.impl.PollImpl"
-    * not-null="false"
-    */
-   public Poll getPoll()
-   {
-      return poll;
-   }
-
-   public void setPoll(Poll poll)
-   {
-      this.poll = poll;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+import java.util.*;
+
+import org.jboss.portlet.forums.model.*;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.8 $
+ * @hibernate.class table="jbp_forums_topics"
+ */
+public class TopicImpl
+   implements Serializable,
+   Comparable,
+   Topic
+{
+   private Integer id;
+   private List posts;
+   private Forum forum;
+   private int viewCount;
+   //private Date       date;
+   //private int        replies;
+   //private Post       firstPost;
+   //private Post       lastPost;
+   //this field is cached but was left as it's easier to sort topics with HQL having such column
+   private Date lastPostDate;
+   //private Date       editDate;
+   private Poster poster;
+   private int type;
+   private int status;
+   //private Topic      target;
+   private String subject;
+   private List watches;
+   private Poll poll;
+
+   /**
+    * Creates a new {@link TopicImpl} object.
+    */
+   public TopicImpl()
+   {
+      setPosts(new ArrayList());
+   }
+
+
+   //we are implementing comparable to be able to sort topics by last post date without to have
+   //a column in db.
+   public int compareTo(Object comp)
+   {
+      Date thisDate = getLastPostDate();
+      Date thatDate = ((Topic)comp).getLastPostDate();
+      if (thisDate != null && (thatDate != null))
+      {
+         return thisDate.compareTo(thatDate);
+      }
+      else if (thisDate == null && (thatDate != null))
+      {
+         return -1;
+      }
+      else if (thisDate != null && (thatDate == null))
+      {
+         return 1;
+      }
+      else
+      {
+         return 0;
+      }
+   }
+
+
+   /**
+    * @hibernate.id column="jbp_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param id DOCUMENT_ME
+    */
+   public void setId(Integer id)
+   {
+      this.id = id;
+   }
+
+   /*
+    * __ at hibernate.collection-many-to-one
+    * __class="org.jboss.portlet.forums.impl.PostImpl"
+    */
+
+   /**
+    * @hibernate.bag lazy="true"
+    * cascade="all-delete-orphan"
+    * order-by="jbp_create_date asc"
+    * inverse="true"
+    * table="jbp_forums_posts"
+    * @hibernate.collection-key column="jbp_topic_id"
+    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.PostImpl"
+    */
+   public List getPosts()
+   {
+      //Hibernate.initialize(posts);
+      return posts;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   public void setPosts(List value)
+   {
+      posts = value;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param post DOCUMENT_ME
+    */
+   public void addPost(Post post)
+   {
+      post.setTopic(this);
+      posts.add(post);
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_forum_id"
+    * class="org.jboss.portlet.forums.impl.ForumImpl"
+    */
+   public Forum getForum()
+   {
+      return forum;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum DOCUMENT_ME
+    */
+   public void setForum(Forum forum)
+   {
+      this.forum = forum;
+   }
+
+   /**
+    * @hibernate.property column="jbp_view_count"
+    * unique="false"
+    * update="true"
+    */
+   public int getViewCount()
+   {
+      return viewCount;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param viewCount DOCUMENT_ME
+    */
+   public void setViewCount(int viewCount)
+   {
+      this.viewCount = viewCount;
+   }
+
+   /**
+    * @hibernate.property column="jbp_replies"
+    * unique="false"
+    * update="true"
+    */
+   public int getReplies()
+   {
+
+      return getPosts().size() - 1;
+      //return replies;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param replies DOCUMENT_ME
+    */
+   public void setReplies(int replies)
+   {
+      //this.replies = replies;
+   }
+
+   /**
+    * _ at _hibernate.many-to-one
+    * _column_="jbp_first_post_id"
+    * _class_="org.jboss.portlet.forums.impl.PostImpl"
+    */
+   public Post getFirstPost()
+   {
+      //return firstPost;
+      //Hibernate.initialize(posts);
+      Iterator i = getPosts().iterator();
+      if (i.hasNext())
+      {
+         return (Post)i.next();
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param post DOCUMENT_ME
+    */
+   public void setFirstPost(Post post)
+   {
+      if (post != null)
+      {
+         posts.add(post);
+      }
+      //this.firstPost = post;
+   }
+
+   /**
+    * _ at _hibernate.many-to-one
+    * _column_="jbp_last_post_id"
+    * _class_="org.jboss.portlet.forums.impl.PostImpl"
+    */
+   public Post getLastPost()
+   {
+      //return lastPost;
+      //Hibernate.initialize(posts);
+      if (posts == null || (posts.size() == 0))
+      {
+         return null;
+      }
+      return (Post)posts.get(posts.size() - 1);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param post DOCUMENT_ME
+    */
+   public void setLastPost(Post post)
+   {
+      if (post != null)
+      {
+         posts.add(post);
+      }
+      //forum.setLastPost(post);
+      //this.lastPost = post;
+   }
+
+   /**
+    * @hibernate.property column="jbp_last_post_date"
+    * unique="false"
+    * update="true"
+    */
+   public Date getLastPostDate()
+   {
+      return lastPostDate;
+      /*Post post = getLastPost();
+      if(post!=null)
+      {
+         return post.getCreateDate();
+      }
+      else
+      {
+         return null;
+      }
+*/
+
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param lastPostDate DOCUMENT_ME
+    */
+   public void setLastPostDate(Date lastPostDate)
+   {
+      this.lastPostDate = lastPostDate;
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_poster"
+    * class="org.jboss.portlet.forums.impl.PosterImpl"
+    */
+   public Poster getPoster()
+   {
+      return poster;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param poster DOCUMENT_ME
+    */
+   public void setPoster(Poster poster)
+   {
+      this.poster = poster;
+   }
+
+   /**
+    * @hibernate.property column="jbp_type"
+    * unique="false"
+    * update="true"
+    */
+   public int getType()
+   {
+      return type;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param type DOCUMENT_ME
+    */
+   public void setType(int type)
+   {
+      this.type = type;
+   }
+
+   /**
+    * @hibernate.property column="jbp_status"
+    * unique="false"
+    * update="true"
+    */
+   public int getStatus()
+   {
+      return status;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param status DOCUMENT_ME
+    */
+   public void setStatus(int status)
+   {
+      this.status = status;
+   }
+
+   /**
+    * _ at hibernate.one-to-one
+    *    _column="jbp_target"
+    *    _class="org.jboss.portlet.forums.impl.TopicImpl"
+    */
+   /*public Topic getTarget()
+   {
+      return target;
+   }*/
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param target DOCUMENT_ME
+    */
+   /*public void setTarget(Topic target)
+   {
+      this.target = target;
+   }*/
+
+   /**
+    * @hibernate.property column="jbp_subject"
+    * unique="false"
+    * update="true"
+    */
+   public String getSubject()
+   {
+      return subject;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param subject DOCUMENT_ME
+    */
+   public void setSubject(String subject)
+   {
+      this.subject = subject;
+   }
+
+   /**
+    * @hibernate.bag lazy="true"
+    * inverse="true"
+    * cascade="all"
+    * @hibernate.collection-key column="jbp_topic_id"
+    * @hibernate.collection-one-to-many class="org.jboss.portlet.forums.impl.TopicWatchImpl"
+    */
+   public List getWatches()
+   {
+      return watches;
+   }
+
+   public void setWatches(List watches)
+   {
+      this.watches = watches;
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_poll"
+    * class="org.jboss.portlet.forums.impl.PollImpl"
+    * not-null="false"
+    */
+   public Poll getPoll()
+   {
+      return poll;
+   }
+
+   public void setPoll(Poll poll)
+   {
+      this.poll = poll;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicWatchImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicWatchImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/TopicWatchImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,61 +1,61 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import java.io.Serializable;
-
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.TopicWatch;
-import org.jboss.portlet.forums.model.Poster;
-
-/**
- * Watchers of topics.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @version $Revision: 1.4 $
- * @hibernate.joined-subclass table="jbp_forums_topicswatch"
- * @hibernate.joined-subclass-key column="jbp_id"
- */
-public class TopicWatchImpl
-   extends WatchImpl
-   implements Serializable,
-   TopicWatch
-{
-
-   private Topic topic;
-
-   /**
-    * Creates a new {@link TopicWatchImpl} object.
-    */
-   public TopicWatchImpl()
-   {
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_topic_id"
-    * class="org.jboss.portlet.forums.impl.TopicImpl"
-    */
-   public Topic getTopic()
-   {
-      return topic;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topic DOCUMENT_ME
-    */
-   public void setTopic(Topic topic)
-   {
-      this.topic = topic;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import java.io.Serializable;
+
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.TopicWatch;
+import org.jboss.portlet.forums.model.Poster;
+
+/**
+ * Watchers of topics.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @version $Revision: 1.4 $
+ * @hibernate.joined-subclass table="jbp_forums_topicswatch"
+ * @hibernate.joined-subclass-key column="jbp_id"
+ */
+public class TopicWatchImpl
+   extends WatchImpl
+   implements Serializable,
+   TopicWatch
+{
+
+   private Topic topic;
+
+   /**
+    * Creates a new {@link TopicWatchImpl} object.
+    */
+   public TopicWatchImpl()
+   {
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_topic_id"
+    * class="org.jboss.portlet.forums.impl.TopicImpl"
+    */
+   public Topic getTopic()
+   {
+      return topic;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topic DOCUMENT_ME
+    */
+   public void setTopic(Topic topic)
+   {
+      this.topic = topic;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/UploadedFileImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/UploadedFileImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/UploadedFileImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,152 +1,152 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import org.jboss.portlet.forums.model.UploadedFile;
-import org.hibernate.Hibernate;
-
-import java.sql.Blob;
-import java.sql.SQLException;
-import java.io.Serializable;
-
-/**
- * An uploaded file.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class UploadedFileImpl implements UploadedFile, Serializable
-{
-
-   private String contentType;
-   private byte[] byteContent;
-   private Blob content;
-   private long size;
-   private String name;
-
-   /**
-    * @param contentType the file content type
-    * @param content the file chunk of bytes
-   * @param name the file name
-   * @param size the size of the file
-    */
-   public UploadedFileImpl(String contentType, byte[] content, String name, long size)
-   {
-      if (contentType == null)
-      {
-         throw new NullPointerException("Content type cannot be null");
-      }
-      if (content == null)
-      {
-         throw new NullPointerException("Content cannot be null");
-      }
-      this.contentType = contentType;
-      this.setByteContent(content);
-      this.content = Hibernate.createBlob(content);
-      this.size = size;
-      this.name = name;
-   }
-
-   /*public UploadedFileImpl(String contentType, Blob content, String name, long size)
-   {
-      if (contentType == null)
-      {
-         throw new NullPointerException("Content type cannot be null");
-      }
-      if (content == null)
-      {
-         throw new NullPointerException("Content cannot be null");
-      }
-      this.contentType = contentType;
-      try
-      {
-         this.setByteContent(content.getBytes(1,(int)content.length()));
-      }
-      catch (SQLException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-      this.content = content;
-      this.size = size;
-      this.name = name;
-   }*/
-
-   public UploadedFileImpl()
-   {
-
-   }
-   /**
-    * @hibernate.property column="jbp_content_type"
-    */
-   public String getContentType()
-   {
-      return contentType;
-   }
-
-   public void setContentType(String type)
-   {
-      this.contentType = type;
-   }
-
-   /**
-    * @hibernate.property column="jbp_size"
-    */
-   public long getSize()
-   {
-        return size;
-   }
-
-   public void setSize(long size)
-   {
-      this.size = size;
-   }
-
-   /**
-    * @hibernate.property column="jbp_name"
-    * type="text"
-    */
-   public String getName()
-   {
-        return name;
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public byte[] getByteContent()
-   {
-      return byteContent;
-   }
-
-   public void setByteContent(byte[] byteContent)
-   {
-      this.byteContent = byteContent;
-   }
-
-   /**
-    * @hibernate.property column="jbp_content"
-    * type="blob"
-    * length="100000000"
-    */
-   public Blob getContent()
-   {
-      return content;
-   }
-
-   public void setContent(Blob content)
-   {
-      this.content = content;
-   }
-}
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import org.jboss.portlet.forums.model.UploadedFile;
+import org.hibernate.Hibernate;
+
+import java.sql.Blob;
+import java.sql.SQLException;
+import java.io.Serializable;
+
+/**
+ * An uploaded file.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class UploadedFileImpl implements UploadedFile, Serializable
+{
+
+   private String contentType;
+   private byte[] byteContent;
+   private Blob content;
+   private long size;
+   private String name;
+
+   /**
+    * @param contentType the file content type
+    * @param content the file chunk of bytes
+   * @param name the file name
+   * @param size the size of the file
+    */
+   public UploadedFileImpl(String contentType, byte[] content, String name, long size)
+   {
+      if (contentType == null)
+      {
+         throw new NullPointerException("Content type cannot be null");
+      }
+      if (content == null)
+      {
+         throw new NullPointerException("Content cannot be null");
+      }
+      this.contentType = contentType;
+      this.setByteContent(content);
+      this.content = Hibernate.createBlob(content);
+      this.size = size;
+      this.name = name;
+   }
+
+   /*public UploadedFileImpl(String contentType, Blob content, String name, long size)
+   {
+      if (contentType == null)
+      {
+         throw new NullPointerException("Content type cannot be null");
+      }
+      if (content == null)
+      {
+         throw new NullPointerException("Content cannot be null");
+      }
+      this.contentType = contentType;
+      try
+      {
+         this.setByteContent(content.getBytes(1,(int)content.length()));
+      }
+      catch (SQLException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+      this.content = content;
+      this.size = size;
+      this.name = name;
+   }*/
+
+   public UploadedFileImpl()
+   {
+
+   }
+   /**
+    * @hibernate.property column="jbp_content_type"
+    */
+   public String getContentType()
+   {
+      return contentType;
+   }
+
+   public void setContentType(String type)
+   {
+      this.contentType = type;
+   }
+
+   /**
+    * @hibernate.property column="jbp_size"
+    */
+   public long getSize()
+   {
+        return size;
+   }
+
+   public void setSize(long size)
+   {
+      this.size = size;
+   }
+
+   /**
+    * @hibernate.property column="jbp_name"
+    * type="text"
+    */
+   public String getName()
+   {
+        return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public byte[] getByteContent()
+   {
+      return byteContent;
+   }
+
+   public void setByteContent(byte[] byteContent)
+   {
+      this.byteContent = byteContent;
+   }
+
+   /**
+    * @hibernate.property column="jbp_content"
+    * type="blob"
+    * length="100000000"
+    */
+   public Blob getContent()
+   {
+      return content;
+   }
+
+   public void setContent(Blob content)
+   {
+      this.content = content;
+   }
+}
+

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/WatchImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/WatchImpl.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/impl/WatchImpl.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,86 +1,86 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.impl;
-
-import org.jboss.portlet.forums.model.Watch;
-import org.jboss.portlet.forums.model.Poster;
-
-import java.io.Serializable;
-
-/**
- * Watchers for email notifications.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.3 $
- * @hibernate.class table="jbp_forums_watch"
- */
-public class WatchImpl implements Serializable, Watch
-{
-
-   /**
-    * .
-    */
-   private Integer id;
-
-   /**
-    * .
-    */
-   private int mode;
-
-   /**
-    * .
-    */
-   private Poster poster;
-
-   /**
-    * @hibernate.id column="jbp_id"
-    * generator-class="native"
-    */
-   public Integer getId()
-   {
-      return id;
-   }
-
-   /**
-    * Called by hibernate only.
-    */
-   private void setId(Integer id)
-   {
-      this.id = id;
-   }
-
-   /**
-    * @hibernate.many-to-one column="jbp_poster_id"
-    * class="org.jboss.portlet.forums.impl.PosterImpl"
-    */
-   public Poster getPoster()
-   {
-      return poster;
-   }
-
-   public void setPoster(Poster poster)
-   {
-      this.poster = poster;
-   }
-
-   /**
-    * @hibernate.property column="jbp_mode"
-    * unique="false"
-    * update="true"
-    */
-   public int getMode()
-   {
-      return mode;
-   }
-
-   public void setMode(int mode)
-   {
-      this.mode = mode;
-   }
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.impl;
+
+import org.jboss.portlet.forums.model.Watch;
+import org.jboss.portlet.forums.model.Poster;
+
+import java.io.Serializable;
+
+/**
+ * Watchers for email notifications.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.3 $
+ * @hibernate.class table="jbp_forums_watch"
+ */
+public class WatchImpl implements Serializable, Watch
+{
+
+   /**
+    * .
+    */
+   private Integer id;
+
+   /**
+    * .
+    */
+   private int mode;
+
+   /**
+    * .
+    */
+   private Poster poster;
+
+   /**
+    * @hibernate.id column="jbp_id"
+    * generator-class="native"
+    */
+   public Integer getId()
+   {
+      return id;
+   }
+
+   /**
+    * Called by hibernate only.
+    */
+   private void setId(Integer id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * @hibernate.many-to-one column="jbp_poster_id"
+    * class="org.jboss.portlet.forums.impl.PosterImpl"
+    */
+   public Poster getPoster()
+   {
+      return poster;
+   }
+
+   public void setPoster(Poster poster)
+   {
+      this.poster = poster;
+   }
+
+   /**
+    * @hibernate.property column="jbp_mode"
+    * unique="false"
+    * update="true"
+    */
+   public int getMode()
+   {
+      return mode;
+   }
+
+   public void setMode(int mode)
+   {
+      this.mode = mode;
+   }
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/FloodControlInterceptor.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/FloodControlInterceptor.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/FloodControlInterceptor.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,103 +1,103 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.interceptors;
-
-import java.util.Date;
-
-import org.jboss.portal.common.command.Command;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.common.command.filter.AbstractCommandFilter;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portlet.forums.commands.CommandConstants;
-import org.jboss.portlet.forums.commands.post.ForumCommand;
-
-/**
- * Interceptor for implementing flood control to stop evil users from flooding
- * the forums.
- *
- * @author <a href="kabirkhan at bigfoot.com">Kabir Khan </a>
- * @author <a href="theute at jboss.org">Thomas Heute </a>
- */
-public class FloodControlInterceptor
-   extends AbstractCommandFilter
-{
-   private long floodInterval;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param cmd DOCUMENT_ME
-    * @return DOCUMENT_ME
-    * @throws CommandException DOCUMENT_ME
-    */
-   public Result filter(Command cmd) throws CommandException
-   {
-      if (cmd instanceof ForumCommand)
-      {
-         ForumCommand command = (ForumCommand)cmd;
-
-         if (command.poster.getId() != null)
-         {
-            User user = command.poster.getUser();
-
-            long lastPostTime = 0;
-
-            try
-            {
-               Date lastPost = command.forumsModule
-                  .findLastPostDateForUser(user);
-               if (lastPost != null)
-               {
-                  lastPostTime = lastPost.getTime();
-               }
-            }
-            catch (ModuleException e)
-            {
-               e.printStackTrace();
-            }
-            if (lastPostTime > 0)
-            {
-               long now = new Date().getTime();
-               long interval = (now - lastPostTime) / 1000;
-
-               if (interval < floodInterval)
-               {
-                  return CommandConstants.TYPE_FLOODING_CANNOT_CREATE;
-               }
-            }
-         }
-      }
-
-      return getNext().filter(cmd);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public long getFloodInterval()
-   {
-      return floodInterval;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param floodInterval DOCUMENT_ME
-    */
-   public void setFloodInterval(long floodInterval)
-   {
-      this.floodInterval = floodInterval;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.interceptors;
+
+import java.util.Date;
+
+import org.jboss.portal.common.command.Command;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.common.command.filter.AbstractCommandFilter;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portlet.forums.commands.CommandConstants;
+import org.jboss.portlet.forums.commands.post.ForumCommand;
+
+/**
+ * Interceptor for implementing flood control to stop evil users from flooding
+ * the forums.
+ *
+ * @author <a href="kabirkhan at bigfoot.com">Kabir Khan </a>
+ * @author <a href="theute at jboss.org">Thomas Heute </a>
+ */
+public class FloodControlInterceptor
+   extends AbstractCommandFilter
+{
+   private long floodInterval;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param cmd DOCUMENT_ME
+    * @return DOCUMENT_ME
+    * @throws CommandException DOCUMENT_ME
+    */
+   public Result filter(Command cmd) throws CommandException
+   {
+      if (cmd instanceof ForumCommand)
+      {
+         ForumCommand command = (ForumCommand)cmd;
+
+         if (command.poster.getId() != null)
+         {
+            User user = command.poster.getUser();
+
+            long lastPostTime = 0;
+
+            try
+            {
+               Date lastPost = command.forumsModule
+                  .findLastPostDateForUser(user);
+               if (lastPost != null)
+               {
+                  lastPostTime = lastPost.getTime();
+               }
+            }
+            catch (ModuleException e)
+            {
+               e.printStackTrace();
+            }
+            if (lastPostTime > 0)
+            {
+               long now = new Date().getTime();
+               long interval = (now - lastPostTime) / 1000;
+
+               if (interval < floodInterval)
+               {
+                  return CommandConstants.TYPE_FLOODING_CANNOT_CREATE;
+               }
+            }
+         }
+      }
+
+      return getNext().filter(cmd);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public long getFloodInterval()
+   {
+      return floodInterval;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param floodInterval DOCUMENT_ME
+    */
+   public void setFloodInterval(long floodInterval)
+   {
+      this.floodInterval = floodInterval;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/IndexInterceptor.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/IndexInterceptor.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/IndexInterceptor.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,82 +1,82 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.interceptors;
-
-import org.jboss.portal.common.command.Command;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.common.command.filter.AbstractCommandFilter;
-import org.jboss.portal.common.command.result.Result;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.5 $
- */
-public class IndexInterceptor
-   extends AbstractCommandFilter //   implements IndexConstants
-{
-   /*
-      private Index index;
-      public void setIndex(Index index)
-      {
-         this.index = index;
-      }
-      public Index getIndex()
-      {
-         return index;
-      }
-    */
-   public Result filter(Command cmd)
-      throws CommandException
-   {
-      /*    Result result = getNext().filter(cmd);
-         if (index != null)
-         {
-            if (result == CommandConstants.TYPE_NEW_TOPIC_POSTED)
-            {
-               index.addDocument(createPostDocument(((NewTopicCommand)cmd).post));
-            }
-            else if (result == CommandConstants.TYPE_EDIT_POST_POSTED)
-            {
-               PostEJBLocal post = ((EditPostCommand)cmd).post;
-               Document postDoc = createPostDocument(post);
-               index.removeDocument(new Term("ID", post.getId().toString()));
-               index.addDocument(postDoc);
-            }
-            else if (result == CommandConstants.TYPE_REPLY_POSTED)
-            {
-               index.addDocument(createPostDocument(((ReplyCommand)cmd).newPost));
-            }
-            else if (result == CommandConstants.TYPE_POST_DELETED)
-            {
-               index.removeDocument(new Term("ID", ((SimpleResult)result).get("POST_ID").toString()));
-            }
-         }
-         return result;
-         }
-         private Document createPostDocument(PostEJBLocal post)
-         {
-            Message message = post.getMessage();
-            Document doc = new Document();
-            doc.add(new Field(IDX_MODULE, "bb", true, true, false));
-            doc.add(new Field(IDX_ID, "" + post.getId(), true, true, false));
-            doc.add(new Field("TOPIC_ID", "" + post.getTopic().getId(), true, true, false));
-            doc.add(new Field("FORUM_ID", "" + post.getForum().getId(), true, true, false));
-            doc.add(new Field("CATEGORY_ID", "" + post.getForum().getCategory().getId(), true, true, false));
-            doc.add(new Field(IDX_TITLE, "" + message.getSubject(), true, true, true));
-            doc.add(new Field(IDX_AUTHOR, "" + post.getPoster().getAuthor(false), true, true, false));
-            doc.add(new Field(IDX_TEXT, "" + message.getText(), false, true, true));
-            doc.add(new Field(IDX_CREATIONDATE, "" + DateField.dateToString(post.getPostDate()), true, true, false));
-            doc.add(new Field(IDX_URL, "/index.html?module=bb&op=viewtopic&t=" + post.getId(), true, false, false));
-            return doc;
-       */
-      return null;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.interceptors;
+
+import org.jboss.portal.common.command.Command;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.common.command.filter.AbstractCommandFilter;
+import org.jboss.portal.common.command.result.Result;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.5 $
+ */
+public class IndexInterceptor
+   extends AbstractCommandFilter //   implements IndexConstants
+{
+   /*
+      private Index index;
+      public void setIndex(Index index)
+      {
+         this.index = index;
+      }
+      public Index getIndex()
+      {
+         return index;
+      }
+    */
+   public Result filter(Command cmd)
+      throws CommandException
+   {
+      /*    Result result = getNext().filter(cmd);
+         if (index != null)
+         {
+            if (result == CommandConstants.TYPE_NEW_TOPIC_POSTED)
+            {
+               index.addDocument(createPostDocument(((NewTopicCommand)cmd).post));
+            }
+            else if (result == CommandConstants.TYPE_EDIT_POST_POSTED)
+            {
+               PostEJBLocal post = ((EditPostCommand)cmd).post;
+               Document postDoc = createPostDocument(post);
+               index.removeDocument(new Term("ID", post.getId().toString()));
+               index.addDocument(postDoc);
+            }
+            else if (result == CommandConstants.TYPE_REPLY_POSTED)
+            {
+               index.addDocument(createPostDocument(((ReplyCommand)cmd).newPost));
+            }
+            else if (result == CommandConstants.TYPE_POST_DELETED)
+            {
+               index.removeDocument(new Term("ID", ((SimpleResult)result).get("POST_ID").toString()));
+            }
+         }
+         return result;
+         }
+         private Document createPostDocument(PostEJBLocal post)
+         {
+            Message message = post.getMessage();
+            Document doc = new Document();
+            doc.add(new Field(IDX_MODULE, "bb", true, true, false));
+            doc.add(new Field(IDX_ID, "" + post.getId(), true, true, false));
+            doc.add(new Field("TOPIC_ID", "" + post.getTopic().getId(), true, true, false));
+            doc.add(new Field("FORUM_ID", "" + post.getForum().getId(), true, true, false));
+            doc.add(new Field("CATEGORY_ID", "" + post.getForum().getCategory().getId(), true, true, false));
+            doc.add(new Field(IDX_TITLE, "" + message.getSubject(), true, true, true));
+            doc.add(new Field(IDX_AUTHOR, "" + post.getPoster().getAuthor(false), true, true, false));
+            doc.add(new Field(IDX_TEXT, "" + message.getText(), false, true, true));
+            doc.add(new Field(IDX_CREATIONDATE, "" + DateField.dateToString(post.getPostDate()), true, true, false));
+            doc.add(new Field(IDX_URL, "/index.html?module=bb&op=viewtopic&t=" + post.getId(), true, false, false));
+            return doc;
+       */
+      return null;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,371 +1,371 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.interceptors;
-
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-import org.jboss.portal.common.command.Command;
-import org.jboss.portal.common.command.CommandException;
-import org.jboss.portal.common.command.filter.AbstractCommandFilter;
-import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.transaction.Transactions;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.core.modules.MailModule;
-import org.jboss.portal.core.modules.ModuleConstants;
-import org.jboss.portal.format.render.bbcodehtml.ToTextRenderer;
-import org.jboss.portal.format.template.TemplateLoader;
-import org.jboss.portlet.JBossActionRequest;
-import org.jboss.portlet.JBossActionResponse;
-import org.jboss.portlet.PortalNode;
-import org.jboss.portlet.PortalNodeURL;
-import org.jboss.portlet.command.ActionCommand;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.ForumsPortlet;
-import org.jboss.portlet.forums.commands.CommandConstants;
-import org.jboss.portlet.forums.commands.post.NewTopicCommand;
-import org.jboss.portlet.forums.commands.post.ReplyCommand;
-import org.jboss.portlet.forums.commands.post.RepostCommand;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.ForumWatch;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.TopicWatch;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.TransactionManager;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.18 $
- */
-public class NotificationInterceptor
-   extends AbstractCommandFilter
-{
-   private static final int MODE_POST = 0;
-   private static final int MODE_REPLY = 1;
-   private static final int MODE_REPOST = 2;
-
-   private ForumsModule forumsModule;
-   private TemplateLoader mailTemplates;
-   private String from;
-   private QueuedExecutor executor;
-   private MailModule mailModule;
-//   private JBossPortlet portlet;
-   private TransactionManager tm;
-
-   public NotificationInterceptor(ForumsModule module)
-   {
-      try
-      {
-         this.forumsModule = module;
-         InitialContext ctx = new InitialContext();
-         mailModule = (MailModule)ctx.lookup(ModuleConstants.MAILMODULE_JNDINAME);
-         tm = (TransactionManager)ctx.lookup("java:TransactionManager");
-         executor = new QueuedExecutor(new LinkedQueue());
-      }
-      catch (NamingException e)
-      {
-         log.error("Cannot create notification interceptor", e);
-      }
-   }
-
-   public void stop()
-   {
-      executor.shutdownAfterProcessingCurrentTask();
-      executor = null;
-      forumsModule = null;
-      mailModule = null;
-      tm = null;
-   }
-
-   public void setFrom(String from)
-   {
-      this.from = from;
-   }
-
-   public TemplateLoader getMailTemplates()
-   {
-      return mailTemplates;
-   }
-
-   public Result filter(Command cmd) throws CommandException
-   {
-      ActionCommand actionCmd = (ActionCommand)cmd;
-      JBossActionRequest request = actionCmd.getRequest();
-      JBossActionResponse response = actionCmd.getResponse();
-      Result result = null;
-      result = getNext().filter(cmd);
-      if (result.getType() == CommandConstants.TYPE_REPLY_POSTED)
-      {
-         Post post = ((ReplyCommand)cmd).newPost;
-         schedule(request, response, post, MODE_REPLY);
-      }
-      else if (result.getType() == CommandConstants.TYPE_NEW_TOPIC_POSTED)
-      {
-         Post post = ((NewTopicCommand)cmd).post;
-         schedule(request, response, post, MODE_POST);
-      }
-      else if (result.getType() == CommandConstants.TYPE_REPOSTED)
-      {
-         Post post = ((RepostCommand)cmd).post;
-         schedule(request, response, post, MODE_REPOST);
-      }
-      return result;
-   }
-
-   private void schedule(JBossActionRequest request, JBossActionResponse response, Post post, int mode)
-   {
-      try
-      {
-         // Compute info needed before sending the mail
-         Integer postId = post.getId();
-         PortalNode node = request.getPortalNode();
-         PortalNodeURL viewURL = response.createRenderURL(node);
-         viewURL.setParameter("p", postId.toString());
-         viewURL.setParameter("op", ForumsPortlet.OP_SHOWTOPIC);
-         //String absViewURL = response.createAbsoluteURL(viewURL);
-         String absViewURL = viewURL.toString();
-         PortalNodeURL replyURL = response.createActionURL(node);
-         replyURL.setParameter("op", "posting");
-         replyURL.setParameter("mode", "reply");
-         replyURL.setParameter("p", postId.toString());
-         //String absReplyURL = response.createAbsoluteURL(replyURL);
-         String absReplyURL = replyURL.toString();
-
-         throw new UnsupportedOperationException("I need a resource bundle");
-         //ResourceBundle bundle = portlet.getResourceBundle(request.getLocale()); // Too bad for now we support notifications sent in the locale of the poster :-(
-
-         // Create task
-         // NotificationTask task = new NotificationTask(tm, absViewURL, absReplyURL, postID, mode, realm, bundle);
-
-         // Register at the end of the current tx to broadcast notifications
-         // Transaction tx = tm.getTransaction();
-         // tx.registerSynchronization(task);
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   private String getFrom(Post post)
-   {
-      StringBuffer fromBuf = null;
-      if ((post.getPoster().getUser().getGivenName() != null)
-         && (post.getPoster().getUser().getFamilyName() != null))
-      {
-         fromBuf = new StringBuffer(post.getPoster().getUser().getGivenName()
-            + " " + post.getPoster().getUser().getFamilyName() + " <");
-      }
-      else
-      {
-         fromBuf = new StringBuffer(post.getPoster().getUser().getUserName() + " <");
-      }
-      fromBuf.append(from + ">");
-      return fromBuf.toString();
-   }
-
-   /**
-    * The notification task.
-    */
-   class NotificationTask implements Transactions.Runnable, Synchronization
-   {
-
-      private final TransactionManager tm;
-      private final int mode;
-      private final Integer postId;
-      private final ResourceBundle bundle;
-      private final String viewURL;
-      private final String replyURL;
-      // private final AuthorizationRealm realm;
-
-      NotificationTask(TransactionManager tm, String viewURL, String replyURL, final Integer postId, int mode, ResourceBundle bundle)
-      {
-         this.tm = tm;
-         this.mode = mode;
-         this.postId = postId;
-         this.viewURL = viewURL;
-         this.replyURL = replyURL;
-         this.bundle = bundle;
-         // this.realm = realm;
-      }
-
-      public Object run() throws Exception
-      {
-         try
-         {
-            Post post = forumsModule.findPostById(postId);
-            Forum forum = post.getTopic().getForum();
-            Category category = forum.getCategory();
-            Topic topic = post.getTopic();
-            Message message = post.getMessage();
-            String[] test = new String[]{category.getTitle(), forum.getName()};
-
-            // Hold the notified users to avoid duplicated
-            Set notifieds = new HashSet();
-
-            // If this is not an anonymous post, put the user in the notified list
-            // he won't be notified of his own action
-            User poster = post.getPoster().getUser();
-            if (poster != null)
-            {
-               notifieds.add(poster.getId());
-            }
-
-            char[] chars = message.getText().toCharArray();
-            StringWriter out = new StringWriter();
-            ToTextRenderer renderer = new ToTextRenderer();
-            renderer.setWriter(out);
-            renderer.render(chars, 0, chars.length);
-
-            String forumEmbededArgsSubject = "[" + forum.getName() + "] - "
-               + message.getSubject()
-               + (mode == MODE_REPOST ? " (Repost)" : "");
-
-            String forumEmbededArgsText = out.toString() + "\n\n"
-               + bundle.getString("EMAIL_VIEWORIGINAL") + " : "
-               + viewURL.toString() + "#" + post.getId() + "\n\n"
-               + bundle.getString("EMAIL_REPLY") + " : "
-               + replyURL.toString();
-
-            // Notify the forum watchers
-            for (Iterator i = forum.getWatches().iterator(); i.hasNext();)
-            {
-               try
-               {
-                  ForumWatch watch = (ForumWatch)i.next();
-                  User watcher = watch.getPoster().getUser();
-                  Object watcherId = watcher.getId();
-                  if (!notifieds.contains(watcherId))
-                  {
-                     System.out.println("FIXME IN NOTIFICATION INTERCEPTOR, USE SECURITY FROM CONTAINER");
-                     if (/*realm.hasPermission(watcher.getRoleNames(), test, "ReadForum")*/false)
-                     {
-                        notifieds.add(watcherId);
-                        String subject = null;
-                        String text = null;
-                        if (watch.getMode() == ForumsConstants.WATCH_MODE_LINKED)
-                        {
-                        }
-                        else
-                        {
-                           subject = forumEmbededArgsSubject;
-                           text = forumEmbededArgsText;
-                        }
-                        mailModule.send(getFrom(post), watcher.getRealEmail(), subject, text);
-                     }
-                     else
-                     {
-                        // Not authorized anymore, we remove the watch
-                        forumsModule.removeWatch(watch);
-                     }
-                  }
-               }
-               catch (Exception e)
-               {
-                  log.error("Cannot send an email notification", e);
-               }
-            }
-
-            if (mode == MODE_REPLY)
-            {
-               // Notify the reply watchers
-               for (Iterator i = topic.getWatches().iterator(); i.hasNext();)
-               {
-                  try
-                  {
-                     TopicWatch watch = (TopicWatch)i.next();
-                     User watcher = watch.getPoster().getUser();
-                     Object watcherId = watcher.getId();
-                     if (!notifieds.contains(watcherId))
-                     {
-                        System.out.println("FIXME IN NOTIFICATION INTERCEPTOR, USE SECURITY FROM CONTAINER");
-                        if (/*realm.hasPermission(watcher.getRoleNames(), test, "ReadForum")*/false)
-                        {
-                           // Authorized
-                           notifieds.add(watcherId);
-
-                           String mailBody = bundle.getString("TOPICWATCH_MAIL_1") + "\n\n" + post.getTopic().getSubject() + "\n\n"
-                              + bundle.getString("EMAIL_VIEWORIGINAL") + " : " + viewURL.toString() + "#" + post.getId() + "\n\n";
-
-                           mailModule.send((String)getFrom(post),
-                              watcher.getRealEmail(),
-                              "[" + forum.getName() + "] " + bundle.getString("Topic_reply_notification"),
-                              mailBody);
-                        }
-                        else
-                        {
-                           // Not authorized anymore, we remove the watch
-                           forumsModule.removeWatch(watch);
-                        }
-                     }
-                  }
-                  catch (Exception e)
-                  {
-                     log.error("Cannot send email notification", e);
-                  }
-               }
-            }
-         }
-         catch (IllegalArgumentException e)
-         {
-            log.error("", e);
-         }
-
-         return null;
-      }
-
-      public void beforeCompletion()
-      {
-      }
-
-      public void afterCompletion(int status)
-      {
-         // When transaction succesfully commits broadcast the notification
-         if (status == Status.STATUS_COMMITTED)
-         {
-            try
-            {
-               // Do it asynch
-               executor.execute(new Runnable()
-               {
-                  public void run()
-                  {
-                     try
-                     {
-                        // Wrap with a tx
-                        Transactions.required(tm, NotificationTask.this);
-                     }
-                     catch (Exception e)
-                     {
-                        log.error("Cannot broadcast nofication for post id", e);
-                     }
-                  }
-               });
-            }
-            catch (InterruptedException ignored)
-            {
-            }
-         }
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.interceptors;
+
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+import org.jboss.portal.common.command.Command;
+import org.jboss.portal.common.command.CommandException;
+import org.jboss.portal.common.command.filter.AbstractCommandFilter;
+import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.common.transaction.Transactions;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.modules.MailModule;
+import org.jboss.portal.core.modules.ModuleConstants;
+import org.jboss.portal.format.render.bbcodehtml.ToTextRenderer;
+import org.jboss.portal.format.template.TemplateLoader;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portal.node.PortalNode;
+import org.jboss.portal.node.PortalNodeURL;
+import org.jboss.portlet.command.ActionCommand;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.ForumsPortlet;
+import org.jboss.portlet.forums.commands.CommandConstants;
+import org.jboss.portlet.forums.commands.post.NewTopicCommand;
+import org.jboss.portlet.forums.commands.post.ReplyCommand;
+import org.jboss.portlet.forums.commands.post.RepostCommand;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.ForumWatch;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.TopicWatch;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.TransactionManager;
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.19 $
+ */
+public class NotificationInterceptor
+   extends AbstractCommandFilter
+{
+   private static final int MODE_POST = 0;
+   private static final int MODE_REPLY = 1;
+   private static final int MODE_REPOST = 2;
+
+   private ForumsModule forumsModule;
+   private TemplateLoader mailTemplates;
+   private String from;
+   private QueuedExecutor executor;
+   private MailModule mailModule;
+//   private JBossPortlet portlet;
+   private TransactionManager tm;
+
+   public NotificationInterceptor(ForumsModule module)
+   {
+      try
+      {
+         this.forumsModule = module;
+         InitialContext ctx = new InitialContext();
+         mailModule = (MailModule)ctx.lookup(ModuleConstants.MAILMODULE_JNDINAME);
+         tm = (TransactionManager)ctx.lookup("java:TransactionManager");
+         executor = new QueuedExecutor(new LinkedQueue());
+      }
+      catch (NamingException e)
+      {
+         log.error("Cannot create notification interceptor", e);
+      }
+   }
+
+   public void stop()
+   {
+      executor.shutdownAfterProcessingCurrentTask();
+      executor = null;
+      forumsModule = null;
+      mailModule = null;
+      tm = null;
+   }
+
+   public void setFrom(String from)
+   {
+      this.from = from;
+   }
+
+   public TemplateLoader getMailTemplates()
+   {
+      return mailTemplates;
+   }
+
+   public Result filter(Command cmd) throws CommandException
+   {
+      ActionCommand actionCmd = (ActionCommand)cmd;
+      JBossActionRequest request = actionCmd.getRequest();
+      JBossActionResponse response = actionCmd.getResponse();
+      Result result = null;
+      result = getNext().filter(cmd);
+      if (result.getType() == CommandConstants.TYPE_REPLY_POSTED)
+      {
+         Post post = ((ReplyCommand)cmd).newPost;
+         schedule(request, response, post, MODE_REPLY);
+      }
+      else if (result.getType() == CommandConstants.TYPE_NEW_TOPIC_POSTED)
+      {
+         Post post = ((NewTopicCommand)cmd).post;
+         schedule(request, response, post, MODE_POST);
+      }
+      else if (result.getType() == CommandConstants.TYPE_REPOSTED)
+      {
+         Post post = ((RepostCommand)cmd).post;
+         schedule(request, response, post, MODE_REPOST);
+      }
+      return result;
+   }
+
+   private void schedule(JBossActionRequest request, JBossActionResponse response, Post post, int mode)
+   {
+      try
+      {
+         // Compute info needed before sending the mail
+         Integer postId = post.getId();
+         PortalNode node = request.getPortalNode();
+         PortalNodeURL viewURL = response.createRenderURL(node);
+         viewURL.setParameter("p", postId.toString());
+         viewURL.setParameter("op", ForumsPortlet.OP_SHOWTOPIC);
+         //String absViewURL = response.createAbsoluteURL(viewURL);
+         String absViewURL = viewURL.toString();
+         PortalNodeURL replyURL = response.createActionURL(node);
+         replyURL.setParameter("op", "posting");
+         replyURL.setParameter("mode", "reply");
+         replyURL.setParameter("p", postId.toString());
+         //String absReplyURL = response.createAbsoluteURL(replyURL);
+         String absReplyURL = replyURL.toString();
+
+         throw new UnsupportedOperationException("I need a resource bundle");
+         //ResourceBundle bundle = portlet.getResourceBundle(request.getLocale()); // Too bad for now we support notifications sent in the locale of the poster :-(
+
+         // Create task
+         // NotificationTask task = new NotificationTask(tm, absViewURL, absReplyURL, postID, mode, realm, bundle);
+
+         // Register at the end of the current tx to broadcast notifications
+         // Transaction tx = tm.getTransaction();
+         // tx.registerSynchronization(task);
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   private String getFrom(Post post)
+   {
+      StringBuffer fromBuf = null;
+      if ((post.getPoster().getUser().getGivenName() != null)
+         && (post.getPoster().getUser().getFamilyName() != null))
+      {
+         fromBuf = new StringBuffer(post.getPoster().getUser().getGivenName()
+            + " " + post.getPoster().getUser().getFamilyName() + " <");
+      }
+      else
+      {
+         fromBuf = new StringBuffer(post.getPoster().getUser().getUserName() + " <");
+      }
+      fromBuf.append(from + ">");
+      return fromBuf.toString();
+   }
+
+   /**
+    * The notification task.
+    */
+   class NotificationTask implements Transactions.Runnable, Synchronization
+   {
+
+      private final TransactionManager tm;
+      private final int mode;
+      private final Integer postId;
+      private final ResourceBundle bundle;
+      private final String viewURL;
+      private final String replyURL;
+      // private final AuthorizationRealm realm;
+
+      NotificationTask(TransactionManager tm, String viewURL, String replyURL, final Integer postId, int mode, ResourceBundle bundle)
+      {
+         this.tm = tm;
+         this.mode = mode;
+         this.postId = postId;
+         this.viewURL = viewURL;
+         this.replyURL = replyURL;
+         this.bundle = bundle;
+         // this.realm = realm;
+      }
+
+      public Object run() throws Exception
+      {
+         try
+         {
+            Post post = forumsModule.findPostById(postId);
+            Forum forum = post.getTopic().getForum();
+            Category category = forum.getCategory();
+            Topic topic = post.getTopic();
+            Message message = post.getMessage();
+            String[] test = new String[]{category.getTitle(), forum.getName()};
+
+            // Hold the notified users to avoid duplicated
+            Set notifieds = new HashSet();
+
+            // If this is not an anonymous post, put the user in the notified list
+            // he won't be notified of his own action
+            User poster = post.getPoster().getUser();
+            if (poster != null)
+            {
+               notifieds.add(poster.getId());
+            }
+
+            char[] chars = message.getText().toCharArray();
+            StringWriter out = new StringWriter();
+            ToTextRenderer renderer = new ToTextRenderer();
+            renderer.setWriter(out);
+            renderer.render(chars, 0, chars.length);
+
+            String forumEmbededArgsSubject = "[" + forum.getName() + "] - "
+               + message.getSubject()
+               + (mode == MODE_REPOST ? " (Repost)" : "");
+
+            String forumEmbededArgsText = out.toString() + "\n\n"
+               + bundle.getString("EMAIL_VIEWORIGINAL") + " : "
+               + viewURL.toString() + "#" + post.getId() + "\n\n"
+               + bundle.getString("EMAIL_REPLY") + " : "
+               + replyURL.toString();
+
+            // Notify the forum watchers
+            for (Iterator i = forum.getWatches().iterator(); i.hasNext();)
+            {
+               try
+               {
+                  ForumWatch watch = (ForumWatch)i.next();
+                  User watcher = watch.getPoster().getUser();
+                  Object watcherId = watcher.getId();
+                  if (!notifieds.contains(watcherId))
+                  {
+                     System.out.println("FIXME IN NOTIFICATION INTERCEPTOR, USE SECURITY FROM CONTAINER");
+                     if (/*realm.hasPermission(watcher.getRoleNames(), test, "ReadForum")*/false)
+                     {
+                        notifieds.add(watcherId);
+                        String subject = null;
+                        String text = null;
+                        if (watch.getMode() == ForumsConstants.WATCH_MODE_LINKED)
+                        {
+                        }
+                        else
+                        {
+                           subject = forumEmbededArgsSubject;
+                           text = forumEmbededArgsText;
+                        }
+                        mailModule.send(getFrom(post), watcher.getRealEmail(), subject, text);
+                     }
+                     else
+                     {
+                        // Not authorized anymore, we remove the watch
+                        forumsModule.removeWatch(watch);
+                     }
+                  }
+               }
+               catch (Exception e)
+               {
+                  log.error("Cannot send an email notification", e);
+               }
+            }
+
+            if (mode == MODE_REPLY)
+            {
+               // Notify the reply watchers
+               for (Iterator i = topic.getWatches().iterator(); i.hasNext();)
+               {
+                  try
+                  {
+                     TopicWatch watch = (TopicWatch)i.next();
+                     User watcher = watch.getPoster().getUser();
+                     Object watcherId = watcher.getId();
+                     if (!notifieds.contains(watcherId))
+                     {
+                        System.out.println("FIXME IN NOTIFICATION INTERCEPTOR, USE SECURITY FROM CONTAINER");
+                        if (/*realm.hasPermission(watcher.getRoleNames(), test, "ReadForum")*/false)
+                        {
+                           // Authorized
+                           notifieds.add(watcherId);
+
+                           String mailBody = bundle.getString("TOPICWATCH_MAIL_1") + "\n\n" + post.getTopic().getSubject() + "\n\n"
+                              + bundle.getString("EMAIL_VIEWORIGINAL") + " : " + viewURL.toString() + "#" + post.getId() + "\n\n";
+
+                           mailModule.send((String)getFrom(post),
+                              watcher.getRealEmail(),
+                              "[" + forum.getName() + "] " + bundle.getString("Topic_reply_notification"),
+                              mailBody);
+                        }
+                        else
+                        {
+                           // Not authorized anymore, we remove the watch
+                           forumsModule.removeWatch(watch);
+                        }
+                     }
+                  }
+                  catch (Exception e)
+                  {
+                     log.error("Cannot send email notification", e);
+                  }
+               }
+            }
+         }
+         catch (IllegalArgumentException e)
+         {
+            log.error("", e);
+         }
+
+         return null;
+      }
+
+      public void beforeCompletion()
+      {
+      }
+
+      public void afterCompletion(int status)
+      {
+         // When transaction succesfully commits broadcast the notification
+         if (status == Status.STATUS_COMMITTED)
+         {
+            try
+            {
+               // Do it asynch
+               executor.execute(new Runnable()
+               {
+                  public void run()
+                  {
+                     try
+                     {
+                        // Wrap with a tx
+                        Transactions.required(tm, NotificationTask.this);
+                     }
+                     catch (Exception e)
+                     {
+                        log.error("Cannot broadcast nofication for post id", e);
+                     }
+                  }
+               });
+            }
+            catch (InterruptedException ignored)
+            {
+            }
+         }
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/ResourceCacheInvalidatorInterceptor.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/ResourceCacheInvalidatorInterceptor.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/interceptors/ResourceCacheInvalidatorInterceptor.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,45 +1,45 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.interceptors;
-
-
-/**
- * Todo : add invalidation for the general RSS topic and complete invalidation for other commands
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.3 $
- */
-public class ResourceCacheInvalidatorInterceptor //  extends AbstractCommandFilter
-{
-   /*
-      private ResourceManager mgr;
-      public ResourceManager getManager()
-      {
-         return mgr;
-      }
-      public void setManager(ResourceManager mgr)
-      {
-         this.mgr = mgr;
-      }
-      public Result filter(ServerCommand cmd) throws CommandException
-      {
-         Result result = getNext().filter(cmd);
-         ResultType type = result.getType();
-         if (type == CommandConstants.TYPE_REPLY_POSTED || result.getType() == CommandConstants.TYPE_NEW_TOPIC_POSTED)
-         {
-            String forumId = ((ForumCommand)cmd).forum.getId().toString();
-            mgr.remove(BBTools.computeCacheKey(false, forumId));
-            mgr.remove(BBTools.computeCacheKey(true, forumId));
-         }
-         return result;
-      }
-    */
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.interceptors;
+
+
+/**
+ * Todo : add invalidation for the general RSS topic and complete invalidation for other commands
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.3 $
+ */
+public class ResourceCacheInvalidatorInterceptor //  extends AbstractCommandFilter
+{
+   /*
+      private ResourceManager mgr;
+      public ResourceManager getManager()
+      {
+         return mgr;
+      }
+      public void setManager(ResourceManager mgr)
+      {
+         this.mgr = mgr;
+      }
+      public Result filter(ServerCommand cmd) throws CommandException
+      {
+         Result result = getNext().filter(cmd);
+         ResultType type = result.getType();
+         if (type == CommandConstants.TYPE_REPLY_POSTED || result.getType() == CommandConstants.TYPE_NEW_TOPIC_POSTED)
+         {
+            String forumId = ((ForumCommand)cmd).forum.getId().toString();
+            mgr.remove(BBTools.computeCacheKey(false, forumId));
+            mgr.remove(BBTools.computeCacheKey(true, forumId));
+         }
+         return result;
+      }
+    */
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Attachment.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Attachment.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Attachment.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,35 +1,35 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-
-/**
- * An Attachment.
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface Attachment
-{
-   String getComment();
-
-   void setComment(String comment);
-
-   UploadedFile getFile();
-
-   void setFile(UploadedFile file);
-
-   public Integer getId();
-
-   void setPost(Post post);
-
-   Post getPost();
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+
+/**
+ * An Attachment.
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Attachment
+{
+   String getComment();
+
+   void setComment(String comment);
+
+   UploadedFile getFile();
+
+   void setFile(UploadedFile file);
+
+   public Integer getId();
+
+   void setPost(Post post);
+
+   Post getPost();
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/AuthType.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/AuthType.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/AuthType.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,71 +1,71 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class AuthType
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int VIEW = 0;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int READ = 1;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int POST = 2;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int REPLY = 3;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int EDIT = 4;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int DELETE = 5;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int ANNOUNCE = 6;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int STICKY = 7;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int POLL = 8;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int VOTE = 9;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public static final int ATTACH = 10;
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class AuthType
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int VIEW = 0;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int READ = 1;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int POST = 2;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int REPLY = 3;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int EDIT = 4;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int DELETE = 5;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int ANNOUNCE = 6;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int STICKY = 7;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int POLL = 8;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int VOTE = 9;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public static final int ATTACH = 10;
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Category.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Category.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Category.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,77 +1,77 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-public interface Category
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   List getForums();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   void setForums(List value);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   void addForum(Forum value);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getOrder();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param order DOCUMENT_ME
-    */
-   void setOrder(int order);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   String getTitle();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param title DOCUMENT_ME
-    */
-   void setTitle(String title);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Integer getId();
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.4 $
+ */
+public interface Category
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   List getForums();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   void setForums(List value);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   void addForum(Forum value);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getOrder();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param order DOCUMENT_ME
+    */
+   void setOrder(int order);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   String getTitle();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param title DOCUMENT_ME
+    */
+   void setTitle(String title);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Integer getId();
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Forum.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Forum.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Forum.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,222 +1,222 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.5 $
- */
-public interface Forum
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Category getCategory();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param category DOCUMENT_ME
-    */
-   void setCategory(Category category);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   String getDescription();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param description DOCUMENT_ME
-    */
-   void setDescription(String description);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Integer getId();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Post getLastPost();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param lastpost DOCUMENT_ME
-    */
-   void setLastPost(Post lastpost);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   String getName();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    */
-   void setName(String name);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getOrder();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param order DOCUMENT_ME
-    */
-   void setOrder(int order);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getTopicCount();
-
-   /**
-    * DOCUMENT_ME
-    */
-   void addTopicSize();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param size DOCUMENT_ME
-    */
-   void setTopicCount(int size);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getPostCount();
-
-   /**
-    * DOCUMENT_ME
-    */
-   void addPostSize();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param size DOCUMENT_ME
-    */
-   void setPostCount(int size);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   boolean getPruneEnable();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param enable DOCUMENT_ME
-    */
-   void setPruneEnable(boolean enable);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getPruneNext();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param next DOCUMENT_ME
-    */
-   void setPruneNext(int next);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getStatus();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param status DOCUMENT_ME
-    */
-   void setStatus(int status);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   void setTopics(List value);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   List getTopics();
-
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   void addTopic(Topic value);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   //int getType();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param type DOCUMENT_ME
-    */
-   //void setType(int type);
-
-   /**
-    * @return DOCUMENT_ME
-    */
-   List getWatches();
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+public interface Forum
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Category getCategory();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param category DOCUMENT_ME
+    */
+   void setCategory(Category category);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   String getDescription();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param description DOCUMENT_ME
+    */
+   void setDescription(String description);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Integer getId();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Post getLastPost();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param lastpost DOCUMENT_ME
+    */
+   void setLastPost(Post lastpost);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   String getName();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    */
+   void setName(String name);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getOrder();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param order DOCUMENT_ME
+    */
+   void setOrder(int order);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getTopicCount();
+
+   /**
+    * DOCUMENT_ME
+    */
+   void addTopicSize();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param size DOCUMENT_ME
+    */
+   void setTopicCount(int size);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getPostCount();
+
+   /**
+    * DOCUMENT_ME
+    */
+   void addPostSize();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param size DOCUMENT_ME
+    */
+   void setPostCount(int size);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   boolean getPruneEnable();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param enable DOCUMENT_ME
+    */
+   void setPruneEnable(boolean enable);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getPruneNext();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param next DOCUMENT_ME
+    */
+   void setPruneNext(int next);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getStatus();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param status DOCUMENT_ME
+    */
+   void setStatus(int status);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   void setTopics(List value);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   List getTopics();
+
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   void addTopic(Topic value);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   //int getType();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param type DOCUMENT_ME
+    */
+   //void setType(int type);
+
+   /**
+    * @return DOCUMENT_ME
+    */
+   List getWatches();
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/ForumWatch.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/ForumWatch.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/ForumWatch.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,32 +1,32 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.4 $
- */
-public interface ForumWatch extends Watch
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Forum getForum();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum DOCUMENT_ME
-    */
-   void setForum(Forum forum);
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.4 $
+ */
+public interface ForumWatch extends Watch
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Forum getForum();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum DOCUMENT_ME
+    */
+   void setForum(Forum forum);
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Message.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Message.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Message.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,106 +1,106 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-
-/**
- * An object that groups the message informations for a post.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.2 $
- */
-public interface Message
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public String getSubject();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param subject DOCUMENT_ME
-    */
-   public void setSubject(String subject);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public String getText();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param text DOCUMENT_ME
-    */
-   public void setText(String text);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean getBBCodeEnabled();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param BBCodeEnabled DOCUMENT_ME
-    */
-   public void setBBCodeEnabled(boolean BBCodeEnabled);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean getHTMLEnabled();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param HTMLEnabled DOCUMENT_ME
-    */
-   public void setHTMLEnabled(boolean HTMLEnabled);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean getSmiliesEnabled();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param smiliesEnabled DOCUMENT_ME
-    */
-   public void setSmiliesEnabled(boolean smiliesEnabled);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   public boolean getSignatureEnabled();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param signatureEnabled DOCUMENT_ME
-    */
-   public void setSignatureEnabled(boolean signatureEnabled);
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+
+/**
+ * An object that groups the message informations for a post.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.2 $
+ */
+public interface Message
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String getSubject();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param subject DOCUMENT_ME
+    */
+   public void setSubject(String subject);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String getText();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param text DOCUMENT_ME
+    */
+   public void setText(String text);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean getBBCodeEnabled();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param BBCodeEnabled DOCUMENT_ME
+    */
+   public void setBBCodeEnabled(boolean BBCodeEnabled);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean getHTMLEnabled();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param HTMLEnabled DOCUMENT_ME
+    */
+   public void setHTMLEnabled(boolean HTMLEnabled);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean getSmiliesEnabled();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param smiliesEnabled DOCUMENT_ME
+    */
+   public void setSmiliesEnabled(boolean smiliesEnabled);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean getSignatureEnabled();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param signatureEnabled DOCUMENT_ME
+    */
+   public void setSignatureEnabled(boolean signatureEnabled);
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poll.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poll.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poll.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,95 +1,95 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import java.util.*;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-public interface Poll
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Integer getId();
-
-   /**
-    * @param string
-    */
-   void setTitle(String string);
-
-   /**
-    * @param i
-    */
-   void setLength(int i);
-
-   /**
-    * @param list
-    */
-   void setOptions(List list);
-
-   /**
-    * @param set
-    */
-   void setVoted(Set set);
-
-   /**
-    * @param isEnded
-    */
-   /*void setIsEnded(boolean isEnded);*/
-
-   /**
-    * @param date
-    */
-   void setCreationDate(Date date);
-
-   /**
-    * @return
-    */
-   List getOptions();
-
-   /**
-    * @return
-    */
-   Set getVoted();
-
-   /**
-    * @return
-    */
-   String getTitle();
-
-   /**
-    * @return
-    */
-   int getLength();
-
-   /**
-    * @return
-    */
-   /*boolean getIsEnded();*/
-
-   /**
-    * @return
-    */
-   public int getVotesSum();
-
-   /**
-    * @return
-    */
-   public Date getCreationDate();
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import java.util.*;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.4 $
+ */
+public interface Poll
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Integer getId();
+
+   /**
+    * @param string
+    */
+   void setTitle(String string);
+
+   /**
+    * @param i
+    */
+   void setLength(int i);
+
+   /**
+    * @param list
+    */
+   void setOptions(List list);
+
+   /**
+    * @param set
+    */
+   void setVoted(Set set);
+
+   /**
+    * @param isEnded
+    */
+   /*void setIsEnded(boolean isEnded);*/
+
+   /**
+    * @param date
+    */
+   void setCreationDate(Date date);
+
+   /**
+    * @return
+    */
+   List getOptions();
+
+   /**
+    * @return
+    */
+   Set getVoted();
+
+   /**
+    * @return
+    */
+   String getTitle();
+
+   /**
+    * @return
+    */
+   int getLength();
+
+   /**
+    * @return
+    */
+   /*boolean getIsEnded();*/
+
+   /**
+    * @return
+    */
+   public int getVotesSum();
+
+   /**
+    * @return
+    */
+   public Date getCreationDate();
+
+
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/PollOption.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/PollOption.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/PollOption.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,47 +1,47 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.3 $
- */
-public interface PollOption
-{
-   /**
-    * @param string
-    */
-   void setQuestion(String string);
-
-   /**
-    * @param i
-    */
-   void setVotes(int i);
-
-   /**
-    * @param
-    */
-   void incVotes();
-
-   /**
-    * @return
-    */
-   String getQuestion();
-
-   /**
-    * @return
-    */
-   int getVotes();
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.3 $
+ */
+public interface PollOption
+{
+   /**
+    * @param string
+    */
+   void setQuestion(String string);
+
+   /**
+    * @param i
+    */
+   void setVotes(int i);
+
+   /**
+    * @param
+    */
+   void incVotes();
+
+   /**
+    * @return
+    */
+   String getQuestion();
+
+   /**
+    * @return
+    */
+   int getVotes();
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Post.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Post.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Post.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,116 +1,116 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.4 $
- */
-public interface Post
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Topic getTopic();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topic DOCUMENT_ME
-    */
-   void setTopic(Topic topic);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Poster getPoster();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param user DOCUMENT_ME
-    */
-   void setPoster(Poster user);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Message getMessage();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param message DOCUMENT_ME
-    */
-   void setMessage(Message message);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getEditCount();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param count DOCUMENT_ME
-    */
-   void setEditCount(int count);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Date getEditDate();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param date DOCUMENT_ME
-    */
-   void setEditDate(Date date);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Integer getId();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Date getCreateDate();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param createDate DOCUMENT_ME
-    */
-   void setCreateDate(Date createDate);
-
-   List getAttachments();
-
-   void addAttachment(Attachment attachment);
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.4 $
+ */
+public interface Post
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Topic getTopic();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topic DOCUMENT_ME
+    */
+   void setTopic(Topic topic);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Poster getPoster();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param user DOCUMENT_ME
+    */
+   void setPoster(Poster user);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Message getMessage();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param message DOCUMENT_ME
+    */
+   void setMessage(Message message);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getEditCount();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param count DOCUMENT_ME
+    */
+   void setEditCount(int count);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Date getEditDate();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param date DOCUMENT_ME
+    */
+   void setEditDate(Date date);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Integer getId();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Date getCreateDate();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param createDate DOCUMENT_ME
+    */
+   void setCreateDate(Date createDate);
+
+   List getAttachments();
+
+   void addAttachment(Attachment attachment);
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poster.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poster.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Poster.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,53 +1,53 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import org.jboss.portal.identity.User;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.7 $
- */
-public interface Poster
-{
-   /**
-    * @return Returns the id of the user.
-    */
-   Integer getId();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   User getUser();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   String getUserId();
-
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getPostCount();
-
-   /**
-    * DOCUMENT_ME
-    */
-   void incrementPostCount();
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import org.jboss.portal.identity.User;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.7 $
+ */
+public interface Poster
+{
+   /**
+    * @return Returns the id of the user.
+    */
+   Integer getId();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   User getUser();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   String getUserId();
+
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getPostCount();
+
+   /**
+    * DOCUMENT_ME
+    */
+   void incrementPostCount();
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Topic.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Topic.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Topic.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,253 +1,253 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.6 $
- */
-public interface Topic
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Integer getId();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param value DOCUMENT_ME
-    */
-   void setPosts(List value);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   List getPosts();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   void addPost(Post post);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Forum getForum();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param forum DOCUMENT_ME
-    */
-   void setForum(Forum forum);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getViewCount();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param views DOCUMENT_ME
-    */
-   void setViewCount(int views);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getReplies();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param replies DOCUMENT_ME
-    */
-   void setReplies(int replies);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Post getFirstPost();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param post DOCUMENT_ME
-    */
-   void setFirstPost(Post post);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Post getLastPost();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param id DOCUMENT_ME
-    */
-   void setLastPost(Post id);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Date getLastPostDate();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param lastPostDate DOCUMENT_ME
-    */
-   void setLastPostDate(Date lastPostDate);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-//   Date getCreateDate();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param date DOCUMENT_ME
-    */
-//   void setCreateDate(Date date);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-//   Date getEditDate();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param editDate DOCUMENT_ME
-    */
-//   void setEditDate(Date editDate);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Poster getPoster();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param poster DOCUMENT_ME
-    */
-   void setPoster(Poster poster);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getType();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param type DOCUMENT_ME
-    */
-   void setType(int type);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   int getStatus();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param status DOCUMENT_ME
-    */
-   void setStatus(int status);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   //Topic getTarget();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param target DOCUMENT_ME
-    */
-   //void setTarget(Topic target);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   String getSubject();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param subject DOCUMENT_ME
-    */
-   void setSubject(String subject);
-
-   /**
-    * @return
-    */
-   List getWatches();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Poll getPoll();
-
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param poll DOCUMENT_ME
-    */
-   void setPoll(Poll poll);
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.6 $
+ */
+public interface Topic
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Integer getId();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    */
+   void setPosts(List value);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   List getPosts();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   void addPost(Post post);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Forum getForum();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param forum DOCUMENT_ME
+    */
+   void setForum(Forum forum);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getViewCount();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param views DOCUMENT_ME
+    */
+   void setViewCount(int views);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getReplies();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param replies DOCUMENT_ME
+    */
+   void setReplies(int replies);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Post getFirstPost();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param post DOCUMENT_ME
+    */
+   void setFirstPost(Post post);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Post getLastPost();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param id DOCUMENT_ME
+    */
+   void setLastPost(Post id);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Date getLastPostDate();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param lastPostDate DOCUMENT_ME
+    */
+   void setLastPostDate(Date lastPostDate);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+//   Date getCreateDate();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param date DOCUMENT_ME
+    */
+//   void setCreateDate(Date date);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+//   Date getEditDate();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param editDate DOCUMENT_ME
+    */
+//   void setEditDate(Date editDate);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Poster getPoster();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param poster DOCUMENT_ME
+    */
+   void setPoster(Poster poster);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getType();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param type DOCUMENT_ME
+    */
+   void setType(int type);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   int getStatus();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param status DOCUMENT_ME
+    */
+   void setStatus(int status);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   //Topic getTarget();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param target DOCUMENT_ME
+    */
+   //void setTarget(Topic target);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   String getSubject();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param subject DOCUMENT_ME
+    */
+   void setSubject(String subject);
+
+   /**
+    * @return
+    */
+   List getWatches();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Poll getPoll();
+
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param poll DOCUMENT_ME
+    */
+   void setPoll(Poll poll);
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/TopicWatch.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/TopicWatch.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/TopicWatch.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,32 +1,32 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.2 $
- */
-public interface TopicWatch extends Watch
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @return DOCUMENT_ME
-    */
-   Topic getTopic();
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param topic DOCUMENT_ME
-    */
-   void setTopic(Topic topic);
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.2 $
+ */
+public interface TopicWatch extends Watch
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   Topic getTopic();
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param topic DOCUMENT_ME
+    */
+   void setTopic(Topic topic);
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/UploadedFile.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/UploadedFile.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/UploadedFile.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,41 +1,41 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-import java.sql.Blob;
-
-/**
- * An uploaded file.
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface UploadedFile
-{
-   String getContentType();
-
-   void setContentType(String type);
-
-   byte[] getByteContent();
-
-   void setByteContent(byte[] bytes);
-
-   Blob getContent();
-
-   void setContent(Blob blob);
-
-   long getSize();
-
-   void setSize(long size);
-
-   String getName();
-
-   void setName(String name);
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+import java.sql.Blob;
+
+/**
+ * An uploaded file.
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UploadedFile
+{
+   String getContentType();
+
+   void setContentType(String type);
+
+   byte[] getByteContent();
+
+   void setByteContent(byte[] bytes);
+
+   Blob getContent();
+
+   void setContent(Blob blob);
+
+   long getSize();
+
+   void setSize(long size);
+
+   String getName();
+
+   void setName(String name);
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Watch.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Watch.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/model/Watch.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,44 +1,44 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.model;
-
-/**
- * An abstraction concept of watch which denotes a relationship between a poster and an item.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public interface Watch
-{
-
-   /**
-    * Return the watch ID.
-    */
-   Integer getId();
-
-   /**
-    * Return the poster.
-    */
-   Poster getPoster();
-
-   /**
-    * Set the poster.
-    */
-   void setPoster(Poster poster);
-
-   /**
-    * Return the mode.
-    */
-   int getMode();
-
-   /**
-    * Set the mode.
-    */
-   void setMode(int mode);
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.model;
+
+/**
+ * An abstraction concept of watch which denotes a relationship between a poster and an item.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public interface Watch
+{
+
+   /**
+    * Return the watch ID.
+    */
+   Integer getId();
+
+   /**
+    * Return the poster.
+    */
+   Poster getPoster();
+
+   /**
+    * Set the poster.
+    */
+   void setPoster(Poster poster);
+
+   /**
+    * Return the mode.
+    */
+   int getMode();
+
+   /**
+    * Set the mode.
+    */
+   void setMode(int mode);
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/TCCLXProperties.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/TCCLXProperties.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/TCCLXProperties.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,112 +1,112 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.properties;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portal.common.util.Tools;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.4 $
- */
-public class TCCLXProperties
-   extends XProperties
-{
-   private Map props = new HashMap();
-   private Map urls = new HashMap();
-
-   /**
-    * Creates a new {@link TCCLXProperties} object.
-    *
-    * @param base DOCUMENT_ME
-    * @param name DOCUMENT_ME
-    * @throws IOException DOCUMENT_ME
-    */
-   public TCCLXProperties(String base,
-                          String name)
-      throws IOException
-   {
-      this(Thread.currentThread().getContextClassLoader(), base, name);
-   }
-
-   /**
-    * Creates a new {@link TCCLXProperties} object.
-    *
-    * @param loader DOCUMENT_ME
-    * @param base   DOCUMENT_ME
-    * @param name   DOCUMENT_ME
-    * @throws IOException DOCUMENT_ME
-    */
-   public TCCLXProperties(ClassLoader loader,
-                          String base,
-                          String name)
-      throws IOException
-   {
-      InputStream in = null;
-      try
-      {
-         // load the data
-         in = loader.getResourceAsStream(base + "/" + name);
-
-         // feed the properties
-         Properties temp = new Properties();
-         temp.load(in);
-         props.putAll(temp);
-
-         // feed the URLs
-         //         String resourceBase = base.substring("org.jboss.portlet/forums/".length()) + "/";
-         //         String resourceBase = base + "/";
-         for (Iterator i = props.entrySet().iterator(); i.hasNext();)
-         {
-            Map.Entry entry = (Map.Entry)i.next();
-
-            // TODO: remove hardcoded link
-            urls.put(entry.getKey(),
-               "/portal-forums/" + ForumsConstants.THEMENAME + "/" + entry.getValue());
-         }
-      }
-      finally
-      {
-         Tools.safeClose(in);
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public String getProperty(String name)
-   {
-      Object value = props.get(name);
-      return (value != null) ? (String)value : "";
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public String getResourceURL(String name)
-   {
-      Object value = urls.get(name);
-      return (value != null) ? (String)value : "";
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.properties;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.4 $
+ */
+public class TCCLXProperties
+   extends XProperties
+{
+   private Map props = new HashMap();
+   private Map urls = new HashMap();
+
+   /**
+    * Creates a new {@link TCCLXProperties} object.
+    *
+    * @param base DOCUMENT_ME
+    * @param name DOCUMENT_ME
+    * @throws IOException DOCUMENT_ME
+    */
+   public TCCLXProperties(String base,
+                          String name)
+      throws IOException
+   {
+      this(Thread.currentThread().getContextClassLoader(), base, name);
+   }
+
+   /**
+    * Creates a new {@link TCCLXProperties} object.
+    *
+    * @param loader DOCUMENT_ME
+    * @param base   DOCUMENT_ME
+    * @param name   DOCUMENT_ME
+    * @throws IOException DOCUMENT_ME
+    */
+   public TCCLXProperties(ClassLoader loader,
+                          String base,
+                          String name)
+      throws IOException
+   {
+      InputStream in = null;
+      try
+      {
+         // load the data
+         in = loader.getResourceAsStream(base + "/" + name);
+
+         // feed the properties
+         Properties temp = new Properties();
+         temp.load(in);
+         props.putAll(temp);
+
+         // feed the URLs
+         //         String resourceBase = base.substring("org.jboss.portlet/forums/".length()) + "/";
+         //         String resourceBase = base + "/";
+         for (Iterator i = props.entrySet().iterator(); i.hasNext();)
+         {
+            Map.Entry entry = (Map.Entry)i.next();
+
+            // TODO: remove hardcoded link
+            urls.put(entry.getKey(),
+               "/portal-forums/" + ForumsConstants.THEMENAME + "/" + entry.getValue());
+         }
+      }
+      finally
+      {
+         Tools.safeClose(in);
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public String getProperty(String name)
+   {
+      Object value = props.get(name);
+      return (value != null) ? (String)value : "";
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public String getResourceURL(String name)
+   {
+      Object value = urls.get(name);
+      return (value != null) ? (String)value : "";
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/XProperties.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/XProperties.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/properties/XProperties.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,35 +1,35 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.properties;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public abstract class XProperties
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public abstract String getResourceURL(String name);
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public abstract String getProperty(String name);
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.properties;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public abstract class XProperties
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public abstract String getResourceURL(String name);
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public abstract String getProperty(String name);
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/servlet/DownloadAttachmentsServlet.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/servlet/DownloadAttachmentsServlet.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/servlet/DownloadAttachmentsServlet.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,244 +1,244 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-
-package org.jboss.portlet.forums.servlet;
-
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.helper.AttachmentTokenManager;
-import org.jboss.portlet.forums.helper.AttachmentToken;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portlet.forums.model.Attachment;
-import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portal.common.transaction.TransactionManagerProvider;
-import org.jboss.portal.common.transaction.Transactions;
-import org.jboss.portal.common.transaction.TransactionException; 
-
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.transaction.TransactionManager;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Iterator;
-import java.sql.SQLException;
-
-/**
- * Provides attachments downloading capabilities
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-public class DownloadAttachmentsServlet extends HttpServlet
-{
-
-   private TransactionManager tm;
-
-   ForumsModule forumsModule;
-   int BUF_SIZE = 256;
-
-   public void init()
-   {
-      try
-      {
-         forumsModule = (ForumsModule)new InitialContext().lookup("java:portal/ForumsModule");
-      }
-      catch (NamingException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-      }
-   }
-
-   public void destroy()
-   {
-
-   }
-
-   public void doPost(HttpServletRequest request,
-                      HttpServletResponse response)
-      throws ServletException, IOException
-   {
-      doGet(request,response);
-   }
-
-   public void doGet(HttpServletRequest request,
-                     HttpServletResponse response)
-      throws ServletException, IOException
-   {
-      //check if token id param is present
-      String tokenId = request.getParameter("tokenId");
-      Integer tid;
-      if (tokenId == null)
-      {
-         printMessage("Error - no token param",response);
-         return;
-      }
-      try
-      {
-         //get token Id
-         tid = new Integer(tokenId);
-      }
-      catch (NumberFormatException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         printMessage("invalid token",response);
-         return;
-      }
-      //obtain attachment token manager from session
-      AttachmentTokenManager atm = (AttachmentTokenManager)request.getSession().getAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER);
-      if (atm==null)
-      {
-         printMessage("Can't obtain token - maybe your session isn't valid",response);
-         return;
-      }
-
-      // clean up expired tokens
-      atm.removeExpiredTokens();
-      AttachmentToken at = null;
-      if (atm.hasToken(tid.intValue()) && (at = atm.getToken(tid.intValue()))!= null)
-      {
-         Attachment attachment = getAttachment(at.getAttachmentId());
-         if (attachment == null)
-         {
-            printMessage("No such resource available", response);
-            return;
-         }
-         response.setContentLength((int)attachment.getFile().getSize());
-         response.setContentType(attachment.getFile().getContentType());
-         // Set the headers.
-         response.setHeader("Content-Disposition", "attachment; filename=" + attachment.getFile().getName());
-
-         InputStream in = null;
-         ServletOutputStream os = response.getOutputStream();
-
-         try
-         {
-            in = attachment.getFile().getContent().getBinaryStream();
-         }
-         catch (SQLException e)
-         {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            printMessage("Error downloading data",response);
-            return;
-         }
-         // Transferring the bytes
-				try {
-					byte[] buffer = new byte[BUF_SIZE];
-					int read;
-					while ((read = in.read(buffer)) != -1)
-						os.write(buffer, 0, read);
-				} catch (Exception e2) {
-					// Nothing that we can really do. Just send an incomplete
-					// file.
-				} finally {
-					os.close();
-               in.close();
-				}
-      }
-      //if there is no valid token
-      else
-      {
-         printMessage("You are not autorised to access this resource - login or check if your session is still valid",response);
-         return;
-      }
-
-
-   }
-
-   /**
-    * In portal we don't use hibernate transactions because every request
-    * is surounded with JTA transaction context by portal. So in servlet when we
-    * use ForumsModule we must do the same.
-    * @param id
-    * @return
-    */
-
-   private Attachment getAttachment(Integer id)
-   {
-      Attachment attachment = null;
-      if (tm == null)
-      {
-         try
-         {
-            tm = TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
-         }
-         catch (Exception e)
-         {
-            System.out.println("Obtaining TransactionManagerProvider Problem....");
-         }
-      }
-
-      javax.transaction.Transaction oldTx = null;
-      try
-      {
-         oldTx = Transactions.applyBefore(Transactions.TYPE_REQUIRED, tm);
-         try
-         {
-            attachment = forumsModule.findFindAttachmentById(id);
-         }
-         catch (ModuleException e)
-         {
-            e.printStackTrace();
-         }
-
-      }
-      catch (TransactionException e)
-      {
-         System.out.println("JTA problem...");
-      }
-      finally
-      {
-         try
-         {
-            Transactions.applyAfter(Transactions.TYPE_REQUIRED, tm, oldTx);
-
-         }
-         catch (TransactionException e)
-         {
-            //log.error("", e);
-         }
-      }
-      return attachment;
-
-   }
-
-   /**
-    * this prints dummy message to output writer
-    * @param msg
-    * @param resp
-    */
-   private void printMessage(String msg, HttpServletResponse resp)
-   {
-      PrintWriter out = null;
-      try
-      {
-         out = resp.getWriter();
-      }
-      catch (IOException e)
-      {
-         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-         return;
-      }
-      resp.setContentType("text/html");
-      out.println(msg);
-
-   }
-
-}
-
-
-
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+
+package org.jboss.portlet.forums.servlet;
+
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.helper.AttachmentTokenManager;
+import org.jboss.portlet.forums.helper.AttachmentToken;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portlet.forums.model.Attachment;
+import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.common.transaction.TransactionManagerProvider;
+import org.jboss.portal.common.transaction.Transactions;
+import org.jboss.portal.common.transaction.TransactionException; 
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Iterator;
+import java.sql.SQLException;
+
+/**
+ * Provides attachments downloading capabilities
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+public class DownloadAttachmentsServlet extends HttpServlet
+{
+
+   private TransactionManager tm;
+
+   ForumsModule forumsModule;
+   int BUF_SIZE = 256;
+
+   public void init()
+   {
+      try
+      {
+         forumsModule = (ForumsModule)new InitialContext().lookup("java:portal/ForumsModule");
+      }
+      catch (NamingException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+      }
+   }
+
+   public void destroy()
+   {
+
+   }
+
+   public void doPost(HttpServletRequest request,
+                      HttpServletResponse response)
+      throws ServletException, IOException
+   {
+      doGet(request,response);
+   }
+
+   public void doGet(HttpServletRequest request,
+                     HttpServletResponse response)
+      throws ServletException, IOException
+   {
+      //check if token id param is present
+      String tokenId = request.getParameter("tokenId");
+      Integer tid;
+      if (tokenId == null)
+      {
+         printMessage("Error - no token param",response);
+         return;
+      }
+      try
+      {
+         //get token Id
+         tid = new Integer(tokenId);
+      }
+      catch (NumberFormatException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         printMessage("invalid token",response);
+         return;
+      }
+      //obtain attachment token manager from session
+      AttachmentTokenManager atm = (AttachmentTokenManager)request.getSession().getAttribute(ForumsConstants.ATTACHMENT_TOKENS_MANAGER);
+      if (atm==null)
+      {
+         printMessage("Can't obtain token - maybe your session isn't valid",response);
+         return;
+      }
+
+      // clean up expired tokens
+      atm.removeExpiredTokens();
+      AttachmentToken at = null;
+      if (atm.hasToken(tid.intValue()) && (at = atm.getToken(tid.intValue()))!= null)
+      {
+         Attachment attachment = getAttachment(at.getAttachmentId());
+         if (attachment == null)
+         {
+            printMessage("No such resource available", response);
+            return;
+         }
+         response.setContentLength((int)attachment.getFile().getSize());
+         response.setContentType(attachment.getFile().getContentType());
+         // Set the headers.
+         response.setHeader("Content-Disposition", "attachment; filename=" + attachment.getFile().getName());
+
+         InputStream in = null;
+         ServletOutputStream os = response.getOutputStream();
+
+         try
+         {
+            in = attachment.getFile().getContent().getBinaryStream();
+         }
+         catch (SQLException e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            printMessage("Error downloading data",response);
+            return;
+         }
+         // Transferring the bytes
+				try {
+					byte[] buffer = new byte[BUF_SIZE];
+					int read;
+					while ((read = in.read(buffer)) != -1)
+						os.write(buffer, 0, read);
+				} catch (Exception e2) {
+					// Nothing that we can really do. Just send an incomplete
+					// file.
+				} finally {
+					os.close();
+               in.close();
+				}
+      }
+      //if there is no valid token
+      else
+      {
+         printMessage("You are not autorised to access this resource - login or check if your session is still valid",response);
+         return;
+      }
+
+
+   }
+
+   /**
+    * In portal we don't use hibernate transactions because every request
+    * is surounded with JTA transaction context by portal. So in servlet when we
+    * use ForumsModule we must do the same.
+    * @param id
+    * @return
+    */
+
+   private Attachment getAttachment(Integer id)
+   {
+      Attachment attachment = null;
+      if (tm == null)
+      {
+         try
+         {
+            tm = TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
+         }
+         catch (Exception e)
+         {
+            System.out.println("Obtaining TransactionManagerProvider Problem....");
+         }
+      }
+
+      javax.transaction.Transaction oldTx = null;
+      try
+      {
+         oldTx = Transactions.applyBefore(Transactions.TYPE_REQUIRED, tm);
+         try
+         {
+            attachment = forumsModule.findFindAttachmentById(id);
+         }
+         catch (ModuleException e)
+         {
+            e.printStackTrace();
+         }
+
+      }
+      catch (TransactionException e)
+      {
+         System.out.println("JTA problem...");
+      }
+      finally
+      {
+         try
+         {
+            Transactions.applyAfter(Transactions.TYPE_REQUIRED, tm, oldTx);
+
+         }
+         catch (TransactionException e)
+         {
+            //log.error("", e);
+         }
+      }
+      return attachment;
+
+   }
+
+   /**
+    * this prints dummy message to output writer
+    * @param msg
+    * @param resp
+    */
+   private void printMessage(String msg, HttpServletResponse resp)
+   {
+      PrintWriter out = null;
+      try
+      {
+         out = resp.getWriter();
+      }
+      catch (IOException e)
+      {
+         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         return;
+      }
+      resp.setContentType("text/html");
+      out.println(msg);
+
+   }
+
+}
+
+
+

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/FolderType.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/FolderType.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/FolderType.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,50 +1,50 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.theme;
-
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
- */
-public class FolderType
-{
-   /**
-    * DOCUMENT_ME
-    */
-   public final String folder;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public final String folderNew;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public final String type;
-
-   /**
-    * Creates a new {@link FolderType} object.
-    *
-    * @param folder    DOCUMENT_ME
-    * @param folderNew DOCUMENT_ME
-    * @param type      DOCUMENT_ME
-    */
-   public FolderType(String folder,
-                     String folderNew,
-                     String type)
-   {
-      this.folder = folder;
-      this.folderNew = folderNew;
-      this.type = type;
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.theme;
+
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.2 $
+ */
+public class FolderType
+{
+   /**
+    * DOCUMENT_ME
+    */
+   public final String folder;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public final String folderNew;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public final String type;
+
+   /**
+    * Creates a new {@link FolderType} object.
+    *
+    * @param folder    DOCUMENT_ME
+    * @param folderNew DOCUMENT_ME
+    * @param type      DOCUMENT_ME
+    */
+   public FolderType(String folder,
+                     String folderNew,
+                     String type)
+   {
+      this.folder = folder;
+      this.folderNew = folderNew;
+      this.type = type;
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/ForumsTheme.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/ForumsTheme.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/forums/theme/ForumsTheme.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,436 +1,436 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.forums.theme;
-
-import org.jboss.portlet.forums.ForumsConstants;
-import org.jboss.portlet.forums.properties.XProperties;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @author <a href="mailto:julien at jboss.org">Thomas Heute</a>
- */
-public class ForumsTheme
-{
-   /**
-    * DOCUMENT_ME
-    *
-    * @param type   DOCUMENT_ME
-    * @param status DOCUMENT_ME
-    * @param hot    DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public FolderType getFolderType(int type,
-                                   int status,
-                                   boolean hot)
-   {
-      switch (type)
-      {
-         case ForumsConstants.POST_ANNOUNCE:
-            return FOLDER_ANNOUNCE;
-
-         case ForumsConstants.POST_STICKY:
-            return FOLDER_STICKY;
-
-         default:
-            if (status == ForumsConstants.TOPIC_LOCKED)
-            {
-               return FOLDER_LOCKED;
-            }
-            else
-            {
-               if (hot)
-               {
-                  return FOLDER_HOT;
-               }
-               else
-               {
-                  return FOLDER_NORMAL;
-               }
-            }
-      }
-   }
-
-   /**
-    * DOCUMENT_ME
-    */
-   public FolderType FOLDER_ANNOUNCE;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public FolderType FOLDER_STICKY;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public FolderType FOLDER_LOCKED;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public FolderType FOLDER_NORMAL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public FolderType FOLDER_HOT;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceForumURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceForumNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceForumNewBigURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceForumLockedURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconLatestReplyURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconNewestReplyURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconGotopostURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderAnnounceURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderAnnounceNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderStickyURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderStickyNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderLockedURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderLockedNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderHotURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceFolderHotNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourcePostLockedURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourcePollVotingBar;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourcePollVotingLBar;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourcePollVotingRBar;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourcePostNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceTopicModeDeleteURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceTopicModMoveURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceTopicModLockURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceTopicModUnlockURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceTopicModSplitURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceTopicUnWatchURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceTopicWatchURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceReplyNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceReplyLockedURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconProfileURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconPMURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconEmailURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconWWWURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconICQURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconAIMURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconMSNMURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconSkypeURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconYIMURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconQuoteURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconSearchURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconEditURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconRepostURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconIPURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconDelpostURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconMinipostURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconMinipostNewURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceIconSpacerURL;
-
-   /**
-    * DOCUMENT_ME
-    */
-   public String resourceHeadStylesheetURL;
-   private XProperties xprops;
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param xprops DOCUMENT_ME
-    */
-   public void setExtendedProperties(XProperties xprops)
-   {
-      this.xprops = xprops;
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public String getProperty(String name)
-   {
-      return xprops.getProperty(name);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @param name DOCUMENT_ME
-    * @return DOCUMENT_ME
-    */
-   public String getResourceURL(String name)
-   {
-      return xprops.getResourceURL(name);
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws Exception DOCUMENT_ME
-    */
-   public void start()
-      throws Exception
-   {
-      resourceForumURL = xprops.getResourceURL("forum");
-      resourceForumNewURL = xprops.getResourceURL("forum_new");
-      resourceForumNewBigURL = xprops.getResourceURL("forum_new_big");
-      resourceForumLockedURL = xprops.getResourceURL("forum_locked");
-      resourceIconLatestReplyURL = xprops.getResourceURL("icon_latest_reply");
-      resourceIconNewestReplyURL = xprops.getResourceURL("icon_newest_reply");
-      resourceIconGotopostURL = xprops.getResourceURL("icon_gotopost");
-      resourceFolderURL = xprops.getResourceURL("folder");
-      resourceFolderNewURL = xprops.getResourceURL("folder_new");
-      resourceFolderAnnounceURL = xprops.getResourceURL("folder_announce");
-      resourceFolderAnnounceNewURL = xprops.getResourceURL("folder_announce_new");
-      resourceFolderStickyURL = xprops.getResourceURL("folder_sticky");
-      resourceFolderStickyNewURL = xprops.getResourceURL("folder_sticky_new");
-      resourceFolderLockedURL = xprops.getResourceURL("folder_locked");
-      resourceFolderLockedNewURL = xprops.getResourceURL("folder_locked_new");
-      resourceFolderHotURL = xprops.getResourceURL("folder_hot");
-      resourceFolderHotNewURL = xprops.getResourceURL("folder_hot_new");
-      resourcePollVotingBar = xprops.getResourceURL("voting_graphic_0");
-      resourcePollVotingLBar = xprops.getResourceURL("vote_lcap");
-      resourcePollVotingRBar = xprops.getResourceURL("vote_rcap");
-      resourcePostLockedURL = xprops.getResourceURL("post_locked");
-      resourcePostNewURL = xprops.getResourceURL("post_new");
-      resourceTopicModeDeleteURL = xprops.getResourceURL("topic_mod_delete");
-      resourceTopicModMoveURL = xprops.getResourceURL("topic_mod_move");
-      resourceTopicModLockURL = xprops.getResourceURL("topic_mod_lock");
-      resourceTopicModUnlockURL = xprops.getResourceURL("topic_mod_unlock");
-      resourceTopicModSplitURL = xprops.getResourceURL("topic_mod_split");
-      resourceTopicUnWatchURL = xprops.getResourceURL("topic_un_watch");
-      resourceTopicWatchURL = xprops.getResourceURL("topic_watch");
-      resourceReplyNewURL = xprops.getResourceURL("reply_new");
-      resourceReplyLockedURL = xprops.getResourceURL("reply_locked");
-      resourceIconProfileURL = xprops.getResourceURL("icon_profile");
-      resourceIconPMURL = xprops.getResourceURL("icon_pm");
-      resourceIconEmailURL = xprops.getResourceURL("icon_email");
-      resourceIconWWWURL = xprops.getResourceURL("icon_www");
-      resourceIconICQURL = xprops.getResourceURL("icon_icq");
-      resourceIconAIMURL = xprops.getResourceURL("icon_aim");
-      resourceIconMSNMURL = xprops.getResourceURL("icon_msnm");
-      resourceIconSkypeURL = xprops.getResourceURL("icon_skype");
-      resourceIconYIMURL = xprops.getResourceURL("icon_yim");
-      resourceIconQuoteURL = xprops.getResourceURL("icon_quote");
-      resourceIconSearchURL = xprops.getResourceURL("icon_search");
-      resourceIconEditURL = xprops.getResourceURL("icon_edit");
-      resourceIconRepostURL = xprops.getResourceURL("icon_repost");
-      resourceIconIPURL = xprops.getResourceURL("icon_ip");
-      resourceIconDelpostURL = xprops.getResourceURL("icon_delpost");
-      resourceIconMinipostURL = xprops.getResourceURL("icon_minipost");
-      resourceIconMinipostNewURL = xprops.getResourceURL("icon_minipost_new");
-      resourceHeadStylesheetURL = xprops.getResourceURL("head_stylesheet");
-      resourceIconSpacerURL = xprops.getResourceURL("spacer");
-
-      //
-      FOLDER_ANNOUNCE =
-         new FolderType(resourceFolderAnnounceURL, resourceFolderAnnounceNewURL, "Topic_Announcement");
-      FOLDER_STICKY = new FolderType(resourceFolderStickyURL, resourceFolderStickyNewURL, "Topic_Sticky");
-      FOLDER_LOCKED = new FolderType(resourceFolderLockedURL, resourceFolderLockedNewURL, "");
-      FOLDER_HOT = new FolderType(resourceFolderHotURL, resourceFolderHotNewURL, "");
-      FOLDER_NORMAL = new FolderType(resourceFolderURL, resourceForumNewURL, "");
-   }
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.forums.theme;
+
+import org.jboss.portlet.forums.ForumsConstants;
+import org.jboss.portlet.forums.properties.XProperties;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:julien at jboss.org">Thomas Heute</a>
+ */
+public class ForumsTheme
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @param type   DOCUMENT_ME
+    * @param status DOCUMENT_ME
+    * @param hot    DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public FolderType getFolderType(int type,
+                                   int status,
+                                   boolean hot)
+   {
+      switch (type)
+      {
+         case ForumsConstants.POST_ANNOUNCE:
+            return FOLDER_ANNOUNCE;
+
+         case ForumsConstants.POST_STICKY:
+            return FOLDER_STICKY;
+
+         default:
+            if (status == ForumsConstants.TOPIC_LOCKED)
+            {
+               return FOLDER_LOCKED;
+            }
+            else
+            {
+               if (hot)
+               {
+                  return FOLDER_HOT;
+               }
+               else
+               {
+                  return FOLDER_NORMAL;
+               }
+            }
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   public FolderType FOLDER_ANNOUNCE;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public FolderType FOLDER_STICKY;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public FolderType FOLDER_LOCKED;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public FolderType FOLDER_NORMAL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public FolderType FOLDER_HOT;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceForumURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceForumNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceForumNewBigURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceForumLockedURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconLatestReplyURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconNewestReplyURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconGotopostURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderAnnounceURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderAnnounceNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderStickyURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderStickyNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderLockedURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderLockedNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderHotURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceFolderHotNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourcePostLockedURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourcePollVotingBar;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourcePollVotingLBar;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourcePollVotingRBar;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourcePostNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceTopicModeDeleteURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceTopicModMoveURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceTopicModLockURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceTopicModUnlockURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceTopicModSplitURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceTopicUnWatchURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceTopicWatchURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceReplyNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceReplyLockedURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconProfileURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconPMURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconEmailURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconWWWURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconICQURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconAIMURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconMSNMURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconSkypeURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconYIMURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconQuoteURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconSearchURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconEditURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconRepostURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconIPURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconDelpostURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconMinipostURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconMinipostNewURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceIconSpacerURL;
+
+   /**
+    * DOCUMENT_ME
+    */
+   public String resourceHeadStylesheetURL;
+   private XProperties xprops;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param xprops DOCUMENT_ME
+    */
+   public void setExtendedProperties(XProperties xprops)
+   {
+      this.xprops = xprops;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public String getProperty(String name)
+   {
+      return xprops.getProperty(name);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    * @return DOCUMENT_ME
+    */
+   public String getResourceURL(String name)
+   {
+      return xprops.getResourceURL(name);
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws Exception DOCUMENT_ME
+    */
+   public void start()
+      throws Exception
+   {
+      resourceForumURL = xprops.getResourceURL("forum");
+      resourceForumNewURL = xprops.getResourceURL("forum_new");
+      resourceForumNewBigURL = xprops.getResourceURL("forum_new_big");
+      resourceForumLockedURL = xprops.getResourceURL("forum_locked");
+      resourceIconLatestReplyURL = xprops.getResourceURL("icon_latest_reply");
+      resourceIconNewestReplyURL = xprops.getResourceURL("icon_newest_reply");
+      resourceIconGotopostURL = xprops.getResourceURL("icon_gotopost");
+      resourceFolderURL = xprops.getResourceURL("folder");
+      resourceFolderNewURL = xprops.getResourceURL("folder_new");
+      resourceFolderAnnounceURL = xprops.getResourceURL("folder_announce");
+      resourceFolderAnnounceNewURL = xprops.getResourceURL("folder_announce_new");
+      resourceFolderStickyURL = xprops.getResourceURL("folder_sticky");
+      resourceFolderStickyNewURL = xprops.getResourceURL("folder_sticky_new");
+      resourceFolderLockedURL = xprops.getResourceURL("folder_locked");
+      resourceFolderLockedNewURL = xprops.getResourceURL("folder_locked_new");
+      resourceFolderHotURL = xprops.getResourceURL("folder_hot");
+      resourceFolderHotNewURL = xprops.getResourceURL("folder_hot_new");
+      resourcePollVotingBar = xprops.getResourceURL("voting_graphic_0");
+      resourcePollVotingLBar = xprops.getResourceURL("vote_lcap");
+      resourcePollVotingRBar = xprops.getResourceURL("vote_rcap");
+      resourcePostLockedURL = xprops.getResourceURL("post_locked");
+      resourcePostNewURL = xprops.getResourceURL("post_new");
+      resourceTopicModeDeleteURL = xprops.getResourceURL("topic_mod_delete");
+      resourceTopicModMoveURL = xprops.getResourceURL("topic_mod_move");
+      resourceTopicModLockURL = xprops.getResourceURL("topic_mod_lock");
+      resourceTopicModUnlockURL = xprops.getResourceURL("topic_mod_unlock");
+      resourceTopicModSplitURL = xprops.getResourceURL("topic_mod_split");
+      resourceTopicUnWatchURL = xprops.getResourceURL("topic_un_watch");
+      resourceTopicWatchURL = xprops.getResourceURL("topic_watch");
+      resourceReplyNewURL = xprops.getResourceURL("reply_new");
+      resourceReplyLockedURL = xprops.getResourceURL("reply_locked");
+      resourceIconProfileURL = xprops.getResourceURL("icon_profile");
+      resourceIconPMURL = xprops.getResourceURL("icon_pm");
+      resourceIconEmailURL = xprops.getResourceURL("icon_email");
+      resourceIconWWWURL = xprops.getResourceURL("icon_www");
+      resourceIconICQURL = xprops.getResourceURL("icon_icq");
+      resourceIconAIMURL = xprops.getResourceURL("icon_aim");
+      resourceIconMSNMURL = xprops.getResourceURL("icon_msnm");
+      resourceIconSkypeURL = xprops.getResourceURL("icon_skype");
+      resourceIconYIMURL = xprops.getResourceURL("icon_yim");
+      resourceIconQuoteURL = xprops.getResourceURL("icon_quote");
+      resourceIconSearchURL = xprops.getResourceURL("icon_search");
+      resourceIconEditURL = xprops.getResourceURL("icon_edit");
+      resourceIconRepostURL = xprops.getResourceURL("icon_repost");
+      resourceIconIPURL = xprops.getResourceURL("icon_ip");
+      resourceIconDelpostURL = xprops.getResourceURL("icon_delpost");
+      resourceIconMinipostURL = xprops.getResourceURL("icon_minipost");
+      resourceIconMinipostNewURL = xprops.getResourceURL("icon_minipost_new");
+      resourceHeadStylesheetURL = xprops.getResourceURL("head_stylesheet");
+      resourceIconSpacerURL = xprops.getResourceURL("spacer");
+
+      //
+      FOLDER_ANNOUNCE =
+         new FolderType(resourceFolderAnnounceURL, resourceFolderAnnounceNewURL, "Topic_Announcement");
+      FOLDER_STICKY = new FolderType(resourceFolderStickyURL, resourceFolderStickyNewURL, "Topic_Sticky");
+      FOLDER_LOCKED = new FolderType(resourceFolderLockedURL, resourceFolderLockedNewURL, "");
+      FOLDER_HOT = new FolderType(resourceFolderHotURL, resourceFolderHotNewURL, "");
+      FOLDER_NORMAL = new FolderType(resourceFolderURL, resourceForumNewURL, "");
+   }
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,254 +1,254 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-
-package org.jboss.portlet.test.forums;
-
-import net.sourceforge.jwebunit.WebTestCase;
-import org.jboss.portlet.test.forums.TestConstants;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-public class AdminEditTopicTypeCase extends WebTestCase implements TestConstants
-{
-
-   private String topicName = "new admin edit topic type test topic";
-   private String message = "admin edit topic type test message";
-   private int msgNum = 1;
-   private String replyMessage = "admin edit topic type reply message";
-
-   public AdminEditTopicTypeCase(String name)
-   {
-      super(name);
-      getTestContext().setBaseUrl(PORTAL_URL);
-   }
-
-   public void waitFlood()
-   {
-      try
-      {
-         Thread.sleep(FLOOD_INTERVAL * 1000);
-      }
-      catch (InterruptedException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   public void loginAdminUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void loginStandartUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void logoutUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
-      assertTextPresent("Don't have an account yet?");
-   }
-
-   public void testPostNormalTopic()
-   {
-      loginAdminUser();
-
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      //assert that we're on main category page
-      assertTextPresent("Forum");
-      assertTextPresent("Topics");
-      assertTextPresent("Posts");
-      assertTextPresent("Last Post");
-
-      //go to first forum
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      //so we post new topic
-      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      //set topic as normal type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
-      submit("post");
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-   }
-
-   public void testEditToSickyTypeTopic()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum);
-      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum + "edited");
-      assertTextPresent(topicName + " " + msgNum + "edited");
-
-      //set topic as sticky type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "1");
-      submit("post");
-      //check if its sticky type
-      assertTextPresent("Sticky:");
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-
-   }
-
-   public void testEditToAnnouncementTypeTopic()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum);
-      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum + "edited");
-      assertTextPresent(topicName + " " + msgNum + "edited");
-
-      //set topic as sticky type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "2");
-      submit("post");
-      //check if its sticky type
-      assertTextNotPresent("Sticky:");
-      assertTextPresent("Announcement:");
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-   }
-
-   public void testEditBackToNormalTypeTopic()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum);
-      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum + "edited");
-      assertTextPresent(topicName + " " + msgNum + "edited");
-
-      //set topic as sticky type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
-      submit("post");
-      //check if its sticky type
-      assertTextNotPresent("Sticky:");
-      assertTextNotPresent("Announcement:");
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-   }
-
-   public void testCleanUp()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      for (int i = 1; i <= 1; i++)
-      {
-         assertTextPresent(topicName + " " + i + "edited");
-         clickLinkWithText(topicName + " " + i + "edited");
-         assertTextPresent(topicName + " " + i + "edited");
-         assertTextPresent("Author");
-         assertTextPresent("Message");
-         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
-         submit("confirm");
-         waitFlood();
-         //navigation is broken so after deleting post we go to main forum window
-         clickLinkWithText(FORUM_1_TEXT_LINK);
-         assertTextNotPresent(topicName + " " + i + "edited");
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+
+package org.jboss.portlet.test.forums;
+
+import net.sourceforge.jwebunit.WebTestCase;
+import org.jboss.portlet.test.forums.TestConstants;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+public class AdminEditTopicTypeCase extends WebTestCase implements TestConstants
+{
+
+   private String topicName = "new admin edit topic type test topic";
+   private String message = "admin edit topic type test message";
+   private int msgNum = 1;
+   private String replyMessage = "admin edit topic type reply message";
+
+   public AdminEditTopicTypeCase(String name)
+   {
+      super(name);
+      getTestContext().setBaseUrl(PORTAL_URL);
+   }
+
+   public void waitFlood()
+   {
+      try
+      {
+         Thread.sleep(FLOOD_INTERVAL * 1000);
+      }
+      catch (InterruptedException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   public void loginAdminUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void loginStandartUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void logoutUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
+      assertTextPresent("Don't have an account yet?");
+   }
+
+   public void testPostNormalTopic()
+   {
+      loginAdminUser();
+
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      //assert that we're on main category page
+      assertTextPresent("Forum");
+      assertTextPresent("Topics");
+      assertTextPresent("Posts");
+      assertTextPresent("Last Post");
+
+      //go to first forum
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      //so we post new topic
+      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      //set topic as normal type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
+      submit("post");
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+   }
+
+   public void testEditToSickyTypeTopic()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum);
+      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum + "edited");
+      assertTextPresent(topicName + " " + msgNum + "edited");
+
+      //set topic as sticky type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "1");
+      submit("post");
+      //check if its sticky type
+      assertTextPresent("Sticky:");
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+
+   }
+
+   public void testEditToAnnouncementTypeTopic()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum);
+      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum + "edited");
+      assertTextPresent(topicName + " " + msgNum + "edited");
+
+      //set topic as sticky type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "2");
+      submit("post");
+      //check if its sticky type
+      assertTextNotPresent("Sticky:");
+      assertTextPresent("Announcement:");
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+   }
+
+   public void testEditBackToNormalTypeTopic()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum);
+      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum + "edited");
+      assertTextPresent(topicName + " " + msgNum + "edited");
+
+      //set topic as sticky type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
+      submit("post");
+      //check if its sticky type
+      assertTextNotPresent("Sticky:");
+      assertTextNotPresent("Announcement:");
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+   }
+
+   public void testCleanUp()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      for (int i = 1; i <= 1; i++)
+      {
+         assertTextPresent(topicName + " " + i + "edited");
+         clickLinkWithText(topicName + " " + i + "edited");
+         assertTextPresent(topicName + " " + i + "edited");
+         assertTextPresent("Author");
+         assertTextPresent("Message");
+         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
+         submit("confirm");
+         waitFlood();
+         //navigation is broken so after deleting post we go to main forum window
+         clickLinkWithText(FORUM_1_TEXT_LINK);
+         assertTextNotPresent(topicName + " " + i + "edited");
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminEditTopicTypeTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,258 +1,258 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import net.sourceforge.jwebunit.WebTestCase;
-import org.jboss.portlet.test.forums.TestConstants;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-public class AdminEditTopicTypeTestCase extends WebTestCase implements TestConstants
-{
-
-   private String topicName = "new admin edit topic type test topic";
-   private String message = "admin edit topic type test message";
-   private int msgNum = 1;
-   private String replyMessage = "admin edit topic type reply message";
-
-   public AdminEditTopicTypeTestCase(String name)
-   {
-      super(name);
-      getTestContext().setBaseUrl(PORTAL_URL);
-   }
-
-   public void waitFlood()
-   {
-      try
-      {
-         Thread.sleep(FLOOD_INTERVAL * 1000);
-      }
-      catch (InterruptedException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   public void loginAdminUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void loginStandartUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void logoutUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
-      assertTextPresent("Don't have an account yet?");
-   }
-
-   public void testPostNormalTopic()
-   {
-      loginAdminUser();
-
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      //assert that we're on main category page
-      assertTextPresent("Forum");
-      assertTextPresent("Topics");
-      assertTextPresent("Posts");
-      assertTextPresent("Last Post");
-
-      //go to first forum
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      //so we post new topic
-      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      //set topic as normal type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
-      submit("post");
-      waitFlood();
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-   }
-
-   public void testEditToSickyTypeTopic()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(message + " " + msgNum);
-      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
-      assertTextPresent(topicName + " " + msgNum);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      //assertTextPresent(message + " " + msgNum + "edited");
-      assertTextPresent(topicName + " " + msgNum + "edited");
-
-      //set topic as sticky type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "1");
-      submit("post");
-      waitFlood();
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if its sticky type
-      assertTextPresent("Sticky:");
-      assertTextPresent(topicName + " " + msgNum + "edited");
-      logoutUser();
-
-   }
-
-   public void testEditToAnnouncementTypeTopic()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum + "edited");
-      //assertTextPresent(message + " " + msgNum + "edited");
-      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
-      assertTextPresent(topicName + " " + msgNum + "edited");
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited2");
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited2");
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      //assertTextPresent(message + " " + msgNum + "edited2");
-      assertTextPresent(topicName + " " + msgNum + "edited2");
-
-      //set topic as sticky type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "2");
-      submit("post");
-      waitFlood();
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if its sticky type
-      assertTextNotPresent("Sticky:");
-      assertTextPresent("Announcement:");
-      assertTextPresent(topicName + " " + msgNum + "edited2");
-      logoutUser();
-   }
-
-   public void testEditBackToNormalTypeTopic()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum + "edited2");
-      //assertTextPresent(message + " " + msgNum + "edited2");
-      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
-      assertTextPresent(topicName + " " + msgNum + "edited2");
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited3");
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited3");
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      //assertTextPresent(message + " " + msgNum + "edited3");
-      assertTextPresent(topicName + " " + msgNum + "edited3");
-
-      //set topic as sticky type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
-      submit("post");
-      waitFlood();
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if its sticky type
-      assertTextNotPresent("Sticky:");
-      assertTextNotPresent("Announcement:");
-      assertTextPresent(topicName + " " + msgNum + "edited3");
-      logoutUser();
-   }
-
-   public void testCleanUp()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      for (int i = 1; i <= 1; i++)
-      {
-         assertTextPresent(topicName + " " + i + "edited3");
-         clickLinkWithText(topicName + " " + i + "edited3");
-         assertTextPresent(topicName + " " + i + "edited3");
-         assertTextPresent("Author");
-         assertTextPresent("Message");
-         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
-         submit("confirm");
-         waitFlood();
-         //navigation is broken so after deleting post we go to main forum window
-         clickLinkWithText(FORUM_1_TEXT_LINK);
-         assertTextNotPresent(topicName + " " + i + "edited3");
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import net.sourceforge.jwebunit.WebTestCase;
+import org.jboss.portlet.test.forums.TestConstants;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+public class AdminEditTopicTypeTestCase extends WebTestCase implements TestConstants
+{
+
+   private String topicName = "new admin edit topic type test topic";
+   private String message = "admin edit topic type test message";
+   private int msgNum = 1;
+   private String replyMessage = "admin edit topic type reply message";
+
+   public AdminEditTopicTypeTestCase(String name)
+   {
+      super(name);
+      getTestContext().setBaseUrl(PORTAL_URL);
+   }
+
+   public void waitFlood()
+   {
+      try
+      {
+         Thread.sleep(FLOOD_INTERVAL * 1000);
+      }
+      catch (InterruptedException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   public void loginAdminUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void loginStandartUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void logoutUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
+      assertTextPresent("Don't have an account yet?");
+   }
+
+   public void testPostNormalTopic()
+   {
+      loginAdminUser();
+
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      //assert that we're on main category page
+      assertTextPresent("Forum");
+      assertTextPresent("Topics");
+      assertTextPresent("Posts");
+      assertTextPresent("Last Post");
+
+      //go to first forum
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      //so we post new topic
+      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      //set topic as normal type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
+      submit("post");
+      waitFlood();
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+   }
+
+   public void testEditToSickyTypeTopic()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(message + " " + msgNum);
+      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
+      assertTextPresent(topicName + " " + msgNum);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited");
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited");
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      //assertTextPresent(message + " " + msgNum + "edited");
+      assertTextPresent(topicName + " " + msgNum + "edited");
+
+      //set topic as sticky type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "1");
+      submit("post");
+      waitFlood();
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if its sticky type
+      assertTextPresent("Sticky:");
+      assertTextPresent(topicName + " " + msgNum + "edited");
+      logoutUser();
+
+   }
+
+   public void testEditToAnnouncementTypeTopic()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum + "edited");
+      //assertTextPresent(message + " " + msgNum + "edited");
+      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
+      assertTextPresent(topicName + " " + msgNum + "edited");
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited2");
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited2");
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      //assertTextPresent(message + " " + msgNum + "edited2");
+      assertTextPresent(topicName + " " + msgNum + "edited2");
+
+      //set topic as sticky type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "2");
+      submit("post");
+      waitFlood();
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if its sticky type
+      assertTextNotPresent("Sticky:");
+      assertTextPresent("Announcement:");
+      assertTextPresent(topicName + " " + msgNum + "edited2");
+      logoutUser();
+   }
+
+   public void testEditBackToNormalTypeTopic()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum + "edited2");
+      //assertTextPresent(message + " " + msgNum + "edited2");
+      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
+      assertTextPresent(topicName + " " + msgNum + "edited2");
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum + "edited3");
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum + "edited3");
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      //assertTextPresent(message + " " + msgNum + "edited3");
+      assertTextPresent(topicName + " " + msgNum + "edited3");
+
+      //set topic as sticky type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
+      submit("post");
+      waitFlood();
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if its sticky type
+      assertTextNotPresent("Sticky:");
+      assertTextNotPresent("Announcement:");
+      assertTextPresent(topicName + " " + msgNum + "edited3");
+      logoutUser();
+   }
+
+   public void testCleanUp()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      for (int i = 1; i <= 1; i++)
+      {
+         assertTextPresent(topicName + " " + i + "edited3");
+         clickLinkWithText(topicName + " " + i + "edited3");
+         assertTextPresent(topicName + " " + i + "edited3");
+         assertTextPresent("Author");
+         assertTextPresent("Message");
+         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
+         submit("confirm");
+         waitFlood();
+         //navigation is broken so after deleting post we go to main forum window
+         clickLinkWithText(FORUM_1_TEXT_LINK);
+         assertTextNotPresent(topicName + " " + i + "edited3");
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminFullTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminFullTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminFullTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,375 +1,375 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import net.sourceforge.jwebunit.WebTestCase;
-import org.jboss.portlet.test.forums.TestConstants;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @author <a href="mailto:">Martin Giljohann</a>
- * @version $Revision: 1.3 $
- */
-public class AdminFullTestCase extends WebTestCase implements TestConstants
-{
-
-   public AdminFullTestCase(String name)
-   {
-      super(name);
-      getTestContext().setBaseUrl(PORTAL_URL);
-   }
-
-   public void waitFlood()
-   {
-      try
-      {
-         Thread.sleep(FLOOD_INTERVAL * 1000);
-      }
-      catch (InterruptedException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   public void loginAdminUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void loginStandartUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void logoutUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
-      assertTextPresent("Don't have an account yet?");
-   }
-/*
-   public void testManyPostsAndTopicsAddRemove()
-   {
-      loginAdminUser();
-      //clickLinkWithText(PORTAL_FORUMS_TEXT_LINK);
-      //if window not maximized
-
-
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      //assert that we're on main category page
-      assertTextPresent("Forum");
-      assertTextPresent("Topics");
-      assertTextPresent("Posts");
-      assertTextPresent("Last Post");
-
-      //set Preferences to display max number of topics/posts/per page
-      beginAt(PORTAL_FORUMS_MAIN_EDIT_URL);
-      assertTextPresent("Preferences");
-      assertTextPresent("Information");
-      setFormElement(PREFERENCES_TOPIC_PER_FORUM_FORM_ELEMENT, "30");
-      setFormElement(PREFERENCES_POST_PER_TOPIC_FORM_ELEMENT, "30");
-      //clickButton("submit");
-      submit("submit");
-      
-      //we should be on main forum page:
-      assertTextPresent("Forum");
-      assertTextPresent("Topics");
-      assertTextPresent("Posts");
-      assertTextPresent("Last Post");
-
-      //go to first forum
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      String topicName = "new test topic";
-      String message = "test message";
-      String replyMessage = "test reply message";
-
-      int numOfTopics = 2;
-      int numOfReplies = 2;
-      int topicType = 0;
-      // we do 30 topics and 29 replies for each
-      for (int i = 1; i <= numOfTopics; i++)
-      {
-
-         clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-         setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + i);
-         setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + i);
-         if (topicType > 2)
-         {
-            topicType = 0;
-         }
-         setFormElement(TOPIC_TYPE_FORM_ELEMENT, "" + topicType);
-         topicType++;
-         //clickButton("Submit");
-         submit("post");
-         assertTextPresent(topicName + " " + i);
-         clickLinkWithText(topicName + " " + i);
-         assertTextPresent(FORUM_1_TEXT_LINK);
-         assertTextPresent(message + " " + i);
-         for (int j = 1; j <= numOfReplies; j++)
-         {
-            clickLinkWithImage(POST_REPLY_IMAGE_LINK);
-            setFormElement(POST_MESSAGE_FORM_ELEMENT, replyMessage + " " + j);
-            waitFlood();
-            //clickButton("Submit");
-            submit("preview");
-            assertTextPresent("Preview");
-            assertTextPresent(replyMessage + " " + j);
-            submit("post");
-            assertTextPresent(replyMessage + " " + j);
-         }
-         clickLinkWithText(FORUM_1_TEXT_LINK);
-         waitFlood();
-      }
-      for (int i = 1; i <= numOfTopics; i++)
-      {
-         assertTextPresent(topicName + " " + i);
-         clickLinkWithText(topicName + " " + i);
-         for (int j = 1; j <= numOfReplies + 1; j++)
-         {
-            assertTextPresent(topicName + " " + i);
-            assertTextPresent("Author");
-            assertTextPresent("Message");
-            clickLinkWithImage(POST_DELETE_IMAGE_LINK);
-            submit("confirm");
-            waitFlood();
-            //navigation is broken so after deleting post we go to main forum window
-            clickLinkWithText(FORUM_1_TEXT_LINK);
-            if (j != (numOfReplies + 1))
-            {
-               clickLinkWithText(topicName + " " + i);
-            }
-         }
-         assertTextNotPresent(topicName + " " + i);
-      }
-      logoutUser();
-   }*/
-
-   /*public void testPostInstantReply()
-   {
-      loginAdminUser();
-      //clickLinkWithText(PORTAL_FORUMS_TEXT_LINK);
-      //if window not maximized
-
-
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      //assert that we're on main category page
-      assertTextPresent("Forum");
-      assertTextPresent("Topics");
-      assertTextPresent("Posts");
-      assertTextPresent("Last Post");
-
-      //go to first forum
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      String topicName = "new test topic";
-      String message = "test message";
-      String replyMessage = "test reply message";
-
-      int numOfTopics = 3;
-      int numOfReplies = 2;
-      int topicType = 0;
-      // we do 30 topics and 29 replies for each
-      for (int i = 1; i <= numOfTopics; i++)
-      {
-
-         clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-         setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + i);
-         setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + i);
-         if (topicType > 2)
-         {
-            topicType = 0;
-         }
-         setFormElement(TOPIC_TYPE_FORM_ELEMENT, "" + topicType);
-         topicType++;
-         //clickButton("Submit");
-         submit("post");
-         assertTextPresent(topicName + " " + i);
-         clickLinkWithText(topicName + " " + i);
-         assertTextPresent(FORUM_1_TEXT_LINK);
-         assertTextPresent(message + " " + i);
-         for (int j = 1; j <= numOfReplies; j++)
-         {
-            setFormElement(INSTANT_REPLY_MESSAGE_FORM_ELEMENT, replyMessage + " " + j);
-            waitFlood();
-            //clickButton("Submit");
-            submit("preview");
-            assertTextPresent("Preview");
-            assertTextPresent(replyMessage + " " + j);
-            submit("post");
-            assertTextPresent(replyMessage + " " + j);
-         }
-         clickLinkWithText(FORUM_1_TEXT_LINK);
-         waitFlood();
-      }
-      for (int i = 1; i <= numOfTopics; i++)
-      {
-         assertTextPresent(topicName + " " + i);
-         clickLinkWithText(topicName + " " + i);
-         for (int j = 1; j <= numOfReplies + 1; j++)
-         {
-            assertTextPresent(topicName + " " + i);
-            assertTextPresent("Author");
-            assertTextPresent("Message");
-            clickLinkWithImage(POST_DELETE_IMAGE_LINK);
-            submit("confirm");
-            waitFlood();
-            //navigation is broken so after deleting post we go to main forum window
-            clickLinkWithText(FORUM_1_TEXT_LINK);
-            if (j != (numOfReplies + 1))
-            {
-               clickLinkWithText(topicName + " " + i);
-            }
-         }
-         assertTextNotPresent(topicName + " " + i);
-      }
-
-      logoutUser();
-   }*/
-
-   /** First category cannot be renamed with admin interface */
-   public void testRename1stCat() {
-      String renamed = "yummy demo category";
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText("Admin Panel");
-      assertTextPresent("Forum Administration");
-      // the link to edit the first category
-      beginAt("/auth/index.html?ctrl:cmd=action&ctrl:window=default.forums.ForumsPortletWindow&op=admin_forums&c=1&mode=editcat");
-      assertTextPresent("Edit Category");
-      setFormElement("cat_title", renamed);
-      submit();
-      assertLinkPresentWithText(renamed);
-   }
-
-   /**
-    *
-    * @param subject
-    * @param radioOption:
-    * 		"0" >Normal
-    * 		1"/>Sticky
-    * 		2"/>Announcement
-    */
-   private void fillPost(String subject, String message, String radioOption) {
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText("Forum Index");
-      clickLinkWithText("Second forum");
-      clickLinkWithImage("post.gif");
-      assertTextPresent("Subject");
-      setFormElement("subject", subject);
-      setFormElement("message", message);
-      setFormElement("topictype", radioOption);
-   }
-   /**
-    * After preview of a sticky post, the "post as" normal radio
-    * button is selected rather than the sticky one. Definitely a smaller bug...
-    * TODO probably same issue with annoucements
-    */
-   public void testPreviewStickyPost() {
-      loginAdminUser();
-      String subj = "PreviewStickyPost";
-      String radioOp="1";
-      fillPost(subj, "message", radioOp);
-      submit("preview");
-      assertTextPresent(subj);
-      assertRadioOptionSelected("topictype", radioOp);
-   }
-
-   /**
-    * @see testPreviewStickyPost
-    * if user wants to edit a post, exception is throwm after preview
-    */
-   public void testEditPreviewPost() {
-      String subj = "EditPreviewStickyPost";
-      loginAdminUser();
-      fillPost(subj, "message", "0");
-      submit("post");
-      assertTextPresent("Your message has been entered successfully.");
-      clickLinkWithText("Second forum");
-      clickLinkWithText(subj);
-      assertTextPresent(subj);
-
-      // now change edit and preview
-      clickLinkWithImage("icon_edit.gif");
-      assertTextPresent(subj);
-      submit("preview");
-   }
-
-   /**
-    * adding a 2nd poll option is not considered, if admin clicks
-    * immediately on submit/preview after adding the 2nd option
-    *
-    */
-
-   /*String pollSubj = "It's raining too much here";
-   String pollMessage = "I've definitely had enough now";
-   String pollTitle = "When will I see the sun again?";
-   String pollOption1 = "In 2005";
-   String pollOption2 = "In 2006";*/
-
-   /* public void testCreatePoll() {
-      loginUser();
-      fillPost(pollSubj, pollMessage, "0");
-
-      // fill poll
-      setFormElement("poll_title", pollTitle);
-      setFormElement("add_poll_option_text", pollOption1);
-      submit("add_poll_option");
-      setFormElement("add_poll_option_text", pollOption2);
-      //submit("add_poll_option"); --> this works, but in this case I just want to submit the poll, not a 3rd option
-      submit("post");
-      assertTextPresent("Your message has been entered successfully.");
-      // check poll
-      clickLinkWithText("Second forum");
-      clickLinkWithText(pollSubj);
-      assertTextPresent(pollOption1);
-      assertTextPresent(pollOption2);
-      setFormElement("vote_id", "0");
-      setFormElement("vote_id", "1");
-
-   }*/
-
-   /**
-    * a poll cannot be edited
-    *
-    */
-   /*public void testEditPoll() {
-      loginUser();
-      beginAt("/index.html?ctrl:id=page.default.forums");
-      clickLinkWithText("Forum Index");
-      clickLinkWithText("Second forum");
-      clickLinkWithText(pollSubj);
-      clickLinkWithImage("icon_edit.gif");
-
-      assertTextPresent(pollOption1);
-      assertTextPresent(pollOption2);
-   }*/
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import net.sourceforge.jwebunit.WebTestCase;
+import org.jboss.portlet.test.forums.TestConstants;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @author <a href="mailto:">Martin Giljohann</a>
+ * @version $Revision: 1.3 $
+ */
+public class AdminFullTestCase extends WebTestCase implements TestConstants
+{
+
+   public AdminFullTestCase(String name)
+   {
+      super(name);
+      getTestContext().setBaseUrl(PORTAL_URL);
+   }
+
+   public void waitFlood()
+   {
+      try
+      {
+         Thread.sleep(FLOOD_INTERVAL * 1000);
+      }
+      catch (InterruptedException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   public void loginAdminUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void loginStandartUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void logoutUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
+      assertTextPresent("Don't have an account yet?");
+   }
+/*
+   public void testManyPostsAndTopicsAddRemove()
+   {
+      loginAdminUser();
+      //clickLinkWithText(PORTAL_FORUMS_TEXT_LINK);
+      //if window not maximized
+
+
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      //assert that we're on main category page
+      assertTextPresent("Forum");
+      assertTextPresent("Topics");
+      assertTextPresent("Posts");
+      assertTextPresent("Last Post");
+
+      //set Preferences to display max number of topics/posts/per page
+      beginAt(PORTAL_FORUMS_MAIN_EDIT_URL);
+      assertTextPresent("Preferences");
+      assertTextPresent("Information");
+      setFormElement(PREFERENCES_TOPIC_PER_FORUM_FORM_ELEMENT, "30");
+      setFormElement(PREFERENCES_POST_PER_TOPIC_FORM_ELEMENT, "30");
+      //clickButton("submit");
+      submit("submit");
+      
+      //we should be on main forum page:
+      assertTextPresent("Forum");
+      assertTextPresent("Topics");
+      assertTextPresent("Posts");
+      assertTextPresent("Last Post");
+
+      //go to first forum
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      String topicName = "new test topic";
+      String message = "test message";
+      String replyMessage = "test reply message";
+
+      int numOfTopics = 2;
+      int numOfReplies = 2;
+      int topicType = 0;
+      // we do 30 topics and 29 replies for each
+      for (int i = 1; i <= numOfTopics; i++)
+      {
+
+         clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+         setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + i);
+         setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + i);
+         if (topicType > 2)
+         {
+            topicType = 0;
+         }
+         setFormElement(TOPIC_TYPE_FORM_ELEMENT, "" + topicType);
+         topicType++;
+         //clickButton("Submit");
+         submit("post");
+         assertTextPresent(topicName + " " + i);
+         clickLinkWithText(topicName + " " + i);
+         assertTextPresent(FORUM_1_TEXT_LINK);
+         assertTextPresent(message + " " + i);
+         for (int j = 1; j <= numOfReplies; j++)
+         {
+            clickLinkWithImage(POST_REPLY_IMAGE_LINK);
+            setFormElement(POST_MESSAGE_FORM_ELEMENT, replyMessage + " " + j);
+            waitFlood();
+            //clickButton("Submit");
+            submit("preview");
+            assertTextPresent("Preview");
+            assertTextPresent(replyMessage + " " + j);
+            submit("post");
+            assertTextPresent(replyMessage + " " + j);
+         }
+         clickLinkWithText(FORUM_1_TEXT_LINK);
+         waitFlood();
+      }
+      for (int i = 1; i <= numOfTopics; i++)
+      {
+         assertTextPresent(topicName + " " + i);
+         clickLinkWithText(topicName + " " + i);
+         for (int j = 1; j <= numOfReplies + 1; j++)
+         {
+            assertTextPresent(topicName + " " + i);
+            assertTextPresent("Author");
+            assertTextPresent("Message");
+            clickLinkWithImage(POST_DELETE_IMAGE_LINK);
+            submit("confirm");
+            waitFlood();
+            //navigation is broken so after deleting post we go to main forum window
+            clickLinkWithText(FORUM_1_TEXT_LINK);
+            if (j != (numOfReplies + 1))
+            {
+               clickLinkWithText(topicName + " " + i);
+            }
+         }
+         assertTextNotPresent(topicName + " " + i);
+      }
+      logoutUser();
+   }*/
+
+   /*public void testPostInstantReply()
+   {
+      loginAdminUser();
+      //clickLinkWithText(PORTAL_FORUMS_TEXT_LINK);
+      //if window not maximized
+
+
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      //assert that we're on main category page
+      assertTextPresent("Forum");
+      assertTextPresent("Topics");
+      assertTextPresent("Posts");
+      assertTextPresent("Last Post");
+
+      //go to first forum
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      String topicName = "new test topic";
+      String message = "test message";
+      String replyMessage = "test reply message";
+
+      int numOfTopics = 3;
+      int numOfReplies = 2;
+      int topicType = 0;
+      // we do 30 topics and 29 replies for each
+      for (int i = 1; i <= numOfTopics; i++)
+      {
+
+         clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+         setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + i);
+         setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + i);
+         if (topicType > 2)
+         {
+            topicType = 0;
+         }
+         setFormElement(TOPIC_TYPE_FORM_ELEMENT, "" + topicType);
+         topicType++;
+         //clickButton("Submit");
+         submit("post");
+         assertTextPresent(topicName + " " + i);
+         clickLinkWithText(topicName + " " + i);
+         assertTextPresent(FORUM_1_TEXT_LINK);
+         assertTextPresent(message + " " + i);
+         for (int j = 1; j <= numOfReplies; j++)
+         {
+            setFormElement(INSTANT_REPLY_MESSAGE_FORM_ELEMENT, replyMessage + " " + j);
+            waitFlood();
+            //clickButton("Submit");
+            submit("preview");
+            assertTextPresent("Preview");
+            assertTextPresent(replyMessage + " " + j);
+            submit("post");
+            assertTextPresent(replyMessage + " " + j);
+         }
+         clickLinkWithText(FORUM_1_TEXT_LINK);
+         waitFlood();
+      }
+      for (int i = 1; i <= numOfTopics; i++)
+      {
+         assertTextPresent(topicName + " " + i);
+         clickLinkWithText(topicName + " " + i);
+         for (int j = 1; j <= numOfReplies + 1; j++)
+         {
+            assertTextPresent(topicName + " " + i);
+            assertTextPresent("Author");
+            assertTextPresent("Message");
+            clickLinkWithImage(POST_DELETE_IMAGE_LINK);
+            submit("confirm");
+            waitFlood();
+            //navigation is broken so after deleting post we go to main forum window
+            clickLinkWithText(FORUM_1_TEXT_LINK);
+            if (j != (numOfReplies + 1))
+            {
+               clickLinkWithText(topicName + " " + i);
+            }
+         }
+         assertTextNotPresent(topicName + " " + i);
+      }
+
+      logoutUser();
+   }*/
+
+   /** First category cannot be renamed with admin interface */
+   public void testRename1stCat() {
+      String renamed = "yummy demo category";
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText("Admin Panel");
+      assertTextPresent("Forum Administration");
+      // the link to edit the first category
+      beginAt("/auth/index.html?ctrl:cmd=action&ctrl:window=default.forums.ForumsPortletWindow&op=admin_forums&c=1&mode=editcat");
+      assertTextPresent("Edit Category");
+      setFormElement("cat_title", renamed);
+      submit();
+      assertLinkPresentWithText(renamed);
+   }
+
+   /**
+    *
+    * @param subject
+    * @param radioOption:
+    * 		"0" >Normal
+    * 		1"/>Sticky
+    * 		2"/>Announcement
+    */
+   private void fillPost(String subject, String message, String radioOption) {
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText("Forum Index");
+      clickLinkWithText("Second forum");
+      clickLinkWithImage("post.gif");
+      assertTextPresent("Subject");
+      setFormElement("subject", subject);
+      setFormElement("message", message);
+      setFormElement("topictype", radioOption);
+   }
+   /**
+    * After preview of a sticky post, the "post as" normal radio
+    * button is selected rather than the sticky one. Definitely a smaller bug...
+    * TODO probably same issue with annoucements
+    */
+   public void testPreviewStickyPost() {
+      loginAdminUser();
+      String subj = "PreviewStickyPost";
+      String radioOp="1";
+      fillPost(subj, "message", radioOp);
+      submit("preview");
+      assertTextPresent(subj);
+      assertRadioOptionSelected("topictype", radioOp);
+   }
+
+   /**
+    * @see testPreviewStickyPost
+    * if user wants to edit a post, exception is throwm after preview
+    */
+   public void testEditPreviewPost() {
+      String subj = "EditPreviewStickyPost";
+      loginAdminUser();
+      fillPost(subj, "message", "0");
+      submit("post");
+      assertTextPresent("Your message has been entered successfully.");
+      clickLinkWithText("Second forum");
+      clickLinkWithText(subj);
+      assertTextPresent(subj);
+
+      // now change edit and preview
+      clickLinkWithImage("icon_edit.gif");
+      assertTextPresent(subj);
+      submit("preview");
+   }
+
+   /**
+    * adding a 2nd poll option is not considered, if admin clicks
+    * immediately on submit/preview after adding the 2nd option
+    *
+    */
+
+   /*String pollSubj = "It's raining too much here";
+   String pollMessage = "I've definitely had enough now";
+   String pollTitle = "When will I see the sun again?";
+   String pollOption1 = "In 2005";
+   String pollOption2 = "In 2006";*/
+
+   /* public void testCreatePoll() {
+      loginUser();
+      fillPost(pollSubj, pollMessage, "0");
+
+      // fill poll
+      setFormElement("poll_title", pollTitle);
+      setFormElement("add_poll_option_text", pollOption1);
+      submit("add_poll_option");
+      setFormElement("add_poll_option_text", pollOption2);
+      //submit("add_poll_option"); --> this works, but in this case I just want to submit the poll, not a 3rd option
+      submit("post");
+      assertTextPresent("Your message has been entered successfully.");
+      // check poll
+      clickLinkWithText("Second forum");
+      clickLinkWithText(pollSubj);
+      assertTextPresent(pollOption1);
+      assertTextPresent(pollOption2);
+      setFormElement("vote_id", "0");
+      setFormElement("vote_id", "1");
+
+   }*/
+
+   /**
+    * a poll cannot be edited
+    *
+    */
+   /*public void testEditPoll() {
+      loginUser();
+      beginAt("/index.html?ctrl:id=page.default.forums");
+      clickLinkWithText("Forum Index");
+      clickLinkWithText("Second forum");
+      clickLinkWithText(pollSubj);
+      clickLinkWithImage("icon_edit.gif");
+
+      assertTextPresent(pollOption1);
+      assertTextPresent(pollOption2);
+   }*/
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPollPostEditTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPollPostEditTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPollPostEditTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,241 +1,241 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import net.sourceforge.jwebunit.WebTestCase;
-import org.jboss.portlet.test.forums.TestConstants;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-public class AdminPollPostEditTestCase extends WebTestCase implements TestConstants
-{
-
-   private String topicName = "new admin post edit poll test topic";
-   private String message = "admin post edit poll test message";
-   private int msgNum = 1;
-   private String replyMessage = "admin post edit poll test reply message";
-   private String pollQuestion = "admin post edit poll test poll question";
-   private String pollOption1 = "admin post edit poll test poll option 1";
-   private String pollOption2 = "admin post edit poll test poll option 2";
-   private String pollOption3 = "admin post edit poll test poll option 3";
-   private String pollOption4 = "admin post edit poll test poll option 4";
-
-   public AdminPollPostEditTestCase(String name)
-   {
-      super(name);
-      getTestContext().setBaseUrl(PORTAL_URL);
-   }
-
-   public void waitFlood()
-   {
-      try
-      {
-         Thread.sleep(FLOOD_INTERVAL * 1000);
-      }
-      catch (InterruptedException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   public void loginAdminUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void loginStandartUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void logoutUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
-      assertTextPresent("Don't have an account yet?");
-   }
-
-   public void testPostNormalTopic()
-   {
-      loginAdminUser();
-
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      //assert that we're on main category page
-      assertTextPresent("Forum");
-      assertTextPresent("Topics");
-      assertTextPresent("Posts");
-      assertTextPresent("Last Post");
-
-      //go to first forum
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      //so we post new topic
-      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      //poll
-      setFormElement(POLL_TITLE_FORM_ELEMENT, pollQuestion);
-      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption1);
-      submit(POLL_ADD_OPTION_SUBMIT);
-      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption2);
-      submit(POLL_ADD_OPTION_SUBMIT);
-      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption3);
-      submit(POLL_ADD_OPTION_SUBMIT);
-      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption4);
-      submit(POLL_ADD_OPTION_SUBMIT);
-
-      //set topic as normal type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
-      submit("post");
-      waitFlood();
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(pollQuestion);
-      assertTextPresent(pollOption1);
-      assertTextPresent(pollOption2);
-      assertTextPresent(pollOption3);
-      assertTextPresent(pollOption4);
-      //assertButtonPresent(POLL_VOTE_SUBMIT_SUBMIT);
-      //assertTextInElement(POLL_VOTE_SUBMIT_SUBMIT,"Submit Vote");
-      assertLinkPresentWithText("View Results");
-      logoutUser();
-   }
-
-   public void testPollEdit()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(message + " " + msgNum);
-      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
-      assertTextPresent(topicName + " " + msgNum);
-      setFormElement(POLL_TITLE_FORM_ELEMENT, pollQuestion + "edited");
-
-      //assertFormElementNotPresentWithLabel(POLL_OPTION_4_DELETE_SUBMIT);
-      setFormElement(POLL_OPTION_1_TEXT_FORM_ELEMENT, pollOption1 + "edited");
-      setFormElement(POLL_OPTION_2_TEXT_FORM_ELEMENT, pollOption2 + "edited");
-      setFormElement(POLL_OPTION_3_TEXT_FORM_ELEMENT, pollOption3 + "edited");
-      //do preview - which will submit all changes to poll form
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      //assertTextPresent(message + " " + msgNum + "edited");
-      assertTextPresent(topicName + " " + msgNum);
-      assertFormElementPresent(POLL_OPTION_4_DELETE_SUBMIT);
-      submit(POLL_OPTION_4_DELETE_SUBMIT);
-      submit("post");
-      waitFlood();
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      clickLinkWithText(topicName + " " + msgNum);
-      //assertTextPresent(msgNum + " " + msgNum);
-      assertTextPresent(pollQuestion + "edited");
-      assertTextPresent(pollOption1 + "edited");
-      assertTextPresent(pollOption2 + "edited");
-      assertTextPresent(pollOption3 + "edited");
-      assertTextNotPresent(pollOption4);
-      //assertButtonPresent(POLL_VOTE_SUBMIT_SUBMIT);
-      assertLinkPresentWithText("View Results");
-      logoutUser();
-   }
-
-   public void testPollVote()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(message + " " + msgNum);
-      setFormElement(POLL_VOTE_RADIO_FORM_ELEMENT, "0");
-      submit(POLL_VOTE_SUBMIT_SUBMIT);
-      assertTextPresent(topicName + " " + msgNum);
-      assertTextPresent(pollQuestion + "edited");
-      assertTextPresent(pollOption1 + "edited");
-      assertTextPresent(pollOption2 + "edited");
-      assertTextPresent(pollOption3 + "edited");
-      assertTextNotPresent(pollOption4);
-      //assertTextPresent("1.0  [ 1 ]");
-      assertTextPresent("Total Votes : 1");
-      //assertButtonNotPresent(POLL_VOTE_SUBMIT_SUBMIT);
-      assertLinkNotPresentWithText("View Results");
-      logoutUser();
-   }
-
-   public void testCleanUp()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      for (int i = 1; i <= 1; i++)
-      {
-         assertTextPresent(topicName + " " + i);
-         clickLinkWithText(topicName + " " + i);
-         assertTextPresent(topicName + " " + i);
-         assertTextPresent("Author");
-         assertTextPresent("Message");
-         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
-         submit("confirm");
-         waitFlood();
-         //navigation is broken so after deleting post we go to main forum window
-         clickLinkWithText(FORUM_1_TEXT_LINK);
-         assertTextNotPresent(topicName + " " + i);
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import net.sourceforge.jwebunit.WebTestCase;
+import org.jboss.portlet.test.forums.TestConstants;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+public class AdminPollPostEditTestCase extends WebTestCase implements TestConstants
+{
+
+   private String topicName = "new admin post edit poll test topic";
+   private String message = "admin post edit poll test message";
+   private int msgNum = 1;
+   private String replyMessage = "admin post edit poll test reply message";
+   private String pollQuestion = "admin post edit poll test poll question";
+   private String pollOption1 = "admin post edit poll test poll option 1";
+   private String pollOption2 = "admin post edit poll test poll option 2";
+   private String pollOption3 = "admin post edit poll test poll option 3";
+   private String pollOption4 = "admin post edit poll test poll option 4";
+
+   public AdminPollPostEditTestCase(String name)
+   {
+      super(name);
+      getTestContext().setBaseUrl(PORTAL_URL);
+   }
+
+   public void waitFlood()
+   {
+      try
+      {
+         Thread.sleep(FLOOD_INTERVAL * 1000);
+      }
+      catch (InterruptedException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   public void loginAdminUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void loginStandartUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void logoutUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
+      assertTextPresent("Don't have an account yet?");
+   }
+
+   public void testPostNormalTopic()
+   {
+      loginAdminUser();
+
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      //assert that we're on main category page
+      assertTextPresent("Forum");
+      assertTextPresent("Topics");
+      assertTextPresent("Posts");
+      assertTextPresent("Last Post");
+
+      //go to first forum
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      //so we post new topic
+      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      //poll
+      setFormElement(POLL_TITLE_FORM_ELEMENT, pollQuestion);
+      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption1);
+      submit(POLL_ADD_OPTION_SUBMIT);
+      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption2);
+      submit(POLL_ADD_OPTION_SUBMIT);
+      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption3);
+      submit(POLL_ADD_OPTION_SUBMIT);
+      setFormElement(POLL_ADD_OPTION_FORM_ELEMENT, pollOption4);
+      submit(POLL_ADD_OPTION_SUBMIT);
+
+      //set topic as normal type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
+      submit("post");
+      waitFlood();
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(pollQuestion);
+      assertTextPresent(pollOption1);
+      assertTextPresent(pollOption2);
+      assertTextPresent(pollOption3);
+      assertTextPresent(pollOption4);
+      //assertButtonPresent(POLL_VOTE_SUBMIT_SUBMIT);
+      //assertTextInElement(POLL_VOTE_SUBMIT_SUBMIT,"Submit Vote");
+      assertLinkPresentWithText("View Results");
+      logoutUser();
+   }
+
+   public void testPollEdit()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(message + " " + msgNum);
+      clickLinkWithImage(POST_EDIT_IMAGE_LINK);
+      assertTextPresent(topicName + " " + msgNum);
+      setFormElement(POLL_TITLE_FORM_ELEMENT, pollQuestion + "edited");
+
+      //assertFormElementNotPresentWithLabel(POLL_OPTION_4_DELETE_SUBMIT);
+      setFormElement(POLL_OPTION_1_TEXT_FORM_ELEMENT, pollOption1 + "edited");
+      setFormElement(POLL_OPTION_2_TEXT_FORM_ELEMENT, pollOption2 + "edited");
+      setFormElement(POLL_OPTION_3_TEXT_FORM_ELEMENT, pollOption3 + "edited");
+      //do preview - which will submit all changes to poll form
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      //assertTextPresent(message + " " + msgNum + "edited");
+      assertTextPresent(topicName + " " + msgNum);
+      assertFormElementPresent(POLL_OPTION_4_DELETE_SUBMIT);
+      submit(POLL_OPTION_4_DELETE_SUBMIT);
+      submit("post");
+      waitFlood();
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      clickLinkWithText(topicName + " " + msgNum);
+      //assertTextPresent(msgNum + " " + msgNum);
+      assertTextPresent(pollQuestion + "edited");
+      assertTextPresent(pollOption1 + "edited");
+      assertTextPresent(pollOption2 + "edited");
+      assertTextPresent(pollOption3 + "edited");
+      assertTextNotPresent(pollOption4);
+      //assertButtonPresent(POLL_VOTE_SUBMIT_SUBMIT);
+      assertLinkPresentWithText("View Results");
+      logoutUser();
+   }
+
+   public void testPollVote()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(message + " " + msgNum);
+      setFormElement(POLL_VOTE_RADIO_FORM_ELEMENT, "0");
+      submit(POLL_VOTE_SUBMIT_SUBMIT);
+      assertTextPresent(topicName + " " + msgNum);
+      assertTextPresent(pollQuestion + "edited");
+      assertTextPresent(pollOption1 + "edited");
+      assertTextPresent(pollOption2 + "edited");
+      assertTextPresent(pollOption3 + "edited");
+      assertTextNotPresent(pollOption4);
+      //assertTextPresent("1.0  [ 1 ]");
+      assertTextPresent("Total Votes : 1");
+      //assertButtonNotPresent(POLL_VOTE_SUBMIT_SUBMIT);
+      assertLinkNotPresentWithText("View Results");
+      logoutUser();
+   }
+
+   public void testCleanUp()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      for (int i = 1; i <= 1; i++)
+      {
+         assertTextPresent(topicName + " " + i);
+         clickLinkWithText(topicName + " " + i);
+         assertTextPresent(topicName + " " + i);
+         assertTextPresent("Author");
+         assertTextPresent("Message");
+         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
+         submit("confirm");
+         waitFlood();
+         //navigation is broken so after deleting post we go to main forum window
+         clickLinkWithText(FORUM_1_TEXT_LINK);
+         assertTextNotPresent(topicName + " " + i);
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPostTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPostTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminPostTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,216 +1,216 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import net.sourceforge.jwebunit.WebTestCase;
-import org.jboss.portlet.test.forums.TestConstants;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.2 $
- */
-public class AdminPostTestCase extends WebTestCase implements TestConstants
-{
-
-   private String topicName = "new admin post test topic";
-   private String message = "admin post test message";
-   private int msgNum;
-   private String replyMessage = "admin post test reply message";
-
-   public AdminPostTestCase(String name)
-   {
-      super(name);
-      getTestContext().setBaseUrl(PORTAL_URL);
-   }
-
-   public void waitFlood()
-   {
-      try
-      {
-         Thread.sleep(FLOOD_INTERVAL * 1000);
-      }
-      catch (InterruptedException e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   public void loginAdminUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void loginStandartUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
-      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
-      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
-      submit();
-      assertTextPresent("Edit your profile");
-   }
-
-   public void logoutUser()
-   {
-      beginAt(PORTAL_MAIN_BEGIN);
-      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
-      assertTextPresent("Don't have an account yet?");
-   }
-
-   public void testPostNormalTopic()
-   {
-      msgNum = 1;
-      loginAdminUser();
-
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      //assert that we're on main category page
-      assertTextPresent("Forum");
-      assertTextPresent("Topics");
-      assertTextPresent("Posts");
-      assertTextPresent("Last Post");
-
-      //go to first forum
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      //so we post new topic
-      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      //set topic as normal type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
-      submit("post");
-      waitFlood();
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-   }
-
-   public void testPostSickyTopic()
-   {
-      msgNum = 2;
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      //so we post new topic
-      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
-      //do preview
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-
-      //set topic as sticky type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "1");
-      submit("post");
-      waitFlood();
-      //check if its sticky type
-      assertTextPresent("Sticky:");
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-
-   }
-
-   public void testPostAnnouncementTopic()
-   {
-      msgNum = 3;
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      //so we post new topic
-      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
-      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
-      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
-
-      submit("preview");
-      //check if we have preview frame
-      assertTextPresent("Preview");
-      assertTextPresent("Posted:");
-      assertTextPresent(message + " " + msgNum);
-      assertTextPresent(topicName + " " + msgNum);
-      //set topic as announcement type
-      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "2");
-      submit("post");
-      waitFlood();
-      //check if its sticky type
-      assertTextPresent("Announcement:");
-      clickLinkWithText(topicName + " " + msgNum);
-      assertTextPresent(FORUM_1_TEXT_LINK);
-      assertTextPresent(message + " " + msgNum);
-      logoutUser();
-   }
-
-   public void testCleanUp()
-   {
-      loginAdminUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText(FORUM_1_TEXT_LINK);
-      //check if we are in forum 1 view;
-      assertTextPresent("Topics");
-      assertTextPresent("Replies");
-      assertTextPresent("Author");
-      assertTextPresent("Views");
-      assertTextPresent("Last Post");
-
-      for (int i = 1; i <= 3; i++)
-      {
-         assertTextPresent(topicName + " " + i);
-         clickLinkWithText(topicName + " " + i);
-         assertTextPresent(topicName + " " + i);
-         assertTextPresent("Author");
-         assertTextPresent("Message");
-         assertLinkPresentWithImage(POST_DELETE_IMAGE_LINK);
-         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
-         submit("confirm");
-         waitFlood();
-         //navigation is broken so after deleting post we go to main forum window
-         clickLinkWithText(FORUM_1_TEXT_LINK);
-         assertTextNotPresent(topicName + " " + i);
-      }
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import net.sourceforge.jwebunit.WebTestCase;
+import org.jboss.portlet.test.forums.TestConstants;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.2 $
+ */
+public class AdminPostTestCase extends WebTestCase implements TestConstants
+{
+
+   private String topicName = "new admin post test topic";
+   private String message = "admin post test message";
+   private int msgNum;
+   private String replyMessage = "admin post test reply message";
+
+   public AdminPostTestCase(String name)
+   {
+      super(name);
+      getTestContext().setBaseUrl(PORTAL_URL);
+   }
+
+   public void waitFlood()
+   {
+      try
+      {
+         Thread.sleep(FLOOD_INTERVAL * 1000);
+      }
+      catch (InterruptedException e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   public void loginAdminUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "admin");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "admin");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void loginStandartUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGIN_TEXT_LINK);
+      setFormElement(PORTAL_LOGIN_USERNAME_FORM_ELEMENT, "user");
+      setFormElement(PORTAL_LOGIN_PASSWORD_FORM_ELEMENT, "user");
+      submit();
+      assertTextPresent("Edit your profile");
+   }
+
+   public void logoutUser()
+   {
+      beginAt(PORTAL_MAIN_BEGIN);
+      clickLinkWithText(PORTAL_LOGOUT_TEXT_LINK);
+      assertTextPresent("Don't have an account yet?");
+   }
+
+   public void testPostNormalTopic()
+   {
+      msgNum = 1;
+      loginAdminUser();
+
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      //assert that we're on main category page
+      assertTextPresent("Forum");
+      assertTextPresent("Topics");
+      assertTextPresent("Posts");
+      assertTextPresent("Last Post");
+
+      //go to first forum
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      //so we post new topic
+      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      //set topic as normal type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "0");
+      submit("post");
+      waitFlood();
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+   }
+
+   public void testPostSickyTopic()
+   {
+      msgNum = 2;
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      //so we post new topic
+      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
+      //do preview
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+
+      //set topic as sticky type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "1");
+      submit("post");
+      waitFlood();
+      //check if its sticky type
+      assertTextPresent("Sticky:");
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+
+   }
+
+   public void testPostAnnouncementTopic()
+   {
+      msgNum = 3;
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      //so we post new topic
+      clickLinkWithImage(NEW_TOPIC_IMAGE_LINK);
+      setFormElement(POST_SUBJECT_FORM_ELEMENT, topicName + " " + msgNum);
+      setFormElement(POST_MESSAGE_FORM_ELEMENT, message + " " + msgNum);
+
+      submit("preview");
+      //check if we have preview frame
+      assertTextPresent("Preview");
+      assertTextPresent("Posted:");
+      assertTextPresent(message + " " + msgNum);
+      assertTextPresent(topicName + " " + msgNum);
+      //set topic as announcement type
+      setFormElement(TOPIC_TYPE_FORM_ELEMENT, "2");
+      submit("post");
+      waitFlood();
+      //check if its sticky type
+      assertTextPresent("Announcement:");
+      clickLinkWithText(topicName + " " + msgNum);
+      assertTextPresent(FORUM_1_TEXT_LINK);
+      assertTextPresent(message + " " + msgNum);
+      logoutUser();
+   }
+
+   public void testCleanUp()
+   {
+      loginAdminUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText(FORUM_1_TEXT_LINK);
+      //check if we are in forum 1 view;
+      assertTextPresent("Topics");
+      assertTextPresent("Replies");
+      assertTextPresent("Author");
+      assertTextPresent("Views");
+      assertTextPresent("Last Post");
+
+      for (int i = 1; i <= 3; i++)
+      {
+         assertTextPresent(topicName + " " + i);
+         clickLinkWithText(topicName + " " + i);
+         assertTextPresent(topicName + " " + i);
+         assertTextPresent("Author");
+         assertTextPresent("Message");
+         assertLinkPresentWithImage(POST_DELETE_IMAGE_LINK);
+         clickLinkWithImage(POST_DELETE_IMAGE_LINK);
+         submit("confirm");
+         waitFlood();
+         //navigation is broken so after deleting post we go to main forum window
+         clickLinkWithText(FORUM_1_TEXT_LINK);
+         assertTextNotPresent(topicName + " " + i);
+      }
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AdminTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,205 +1,205 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import java.util.Random;
-
-import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.operation.DatabaseOperation;
-import org.jboss.portal.test.core.Utils;
-
-import net.sourceforge.jwebunit.WebTestCase;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.4 $
- */
-public class AdminTestCase
-   extends WebTestCase implements TestConstants
-{
-
-   public static final int floodtime = 30;
-
-   public AdminTestCase(String name)
-   {
-      super(name);
-      //getTestContext().setBaseUrl("http://localhost.localdomain:8080/portal");
-      getTestContext().setBaseUrl("http://localhost:8080/portal");
-//      getTestContext().setUserAgent("Mozilla");
-   }
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      // initialize your database connection here
-      IDatabaseConnection connection = Utils.getConnection();
-
-      // initialize your dataset here
-      IDataSet dataSet = Utils.getDataSet("resources/test/forums.xml");
-
-      try
-      {
-         Utils.resetAutoIncrement();
-         DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
-      }
-      finally
-      {
-         connection.close();
-      }
-   }
-   
-   protected String getRandomTopicName () {
-       Random random = new Random ();
-       return "test topic"+Long.toString((long)(random.nextFloat()*10000000L));
-   }
-   
-    protected String getRandomMessage () {
-        Random random = new Random ();
-        return "my message"+Long.toString((long)(random.nextFloat()*10000000000L));
-    }
-
-   public void loginUser()
-   {
-      beginAt("/index.html");
-      clickLink("standardlogin");
-      setFormElement("j_username", "admin");
-      setFormElement("j_password", "admin");
-      submit();
-   }
-
-   public void testReadIndex()
-   {
-      loginUser();
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      assertLinkPresent("adminPanel");
-      assertTextPresent("Dummy demo category");
-      assertTextPresent("First forum");
-      assertTextPresent("Second forum");
-      assertLinkNotPresent("newTopic");
-   }
-
-   public void testReadForum()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      assertTextPresent("First forum");
-      assertTextPresent("Page <b>1</b> of");
-      assertLinkPresent("newTopic");
-   }
-
-   public void testPostTopic()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      clickLink("newTopic");
-      String randomTopicName = getRandomTopicName();
-      setFormElement("subject",randomTopicName);
-      String randomMessage = getRandomMessage();
-      setFormElement("message", randomMessage);
-      submit("post");
-      assertTextPresent(randomTopicName);
-      clickLinkWithText(randomTopicName);
-      assertTextPresent(randomMessage);
-   }
-
-   public void testReplyTopic()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      clickLink("newTopic");
-      String randomTopicName = getRandomTopicName();
-      String randomMessage = getRandomMessage();
-      setFormElement("subject", randomTopicName);
-      setFormElement("message", randomMessage);
-      submit("post");
-      clickLinkWithText("First forum");
-      clickLinkWithText(randomTopicName);
-      clickLink("postReply");
-      assertFormElementEquals("subject", "Re: "+randomTopicName);
-      String randomAnswerMessage = "my answer"+getRandomMessage();
-      setFormElement("message", randomAnswerMessage);
-      // For flood control
-      try
-      {
-         Thread.sleep(floodtime * 1000);
-      }
-      catch (InterruptedException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-      submit("post");
-      assertTextPresent("Re: "+randomTopicName);
-      assertTextPresent(randomMessage);
-      assertTextPresent(randomAnswerMessage);
-   }
-
-    /* DOESN'T WORK!! */
-   /*public void testFlood()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      clickLink("newTopic");
-      setFormElement("subject", "test topic");
-      setFormElement("message", "my message");
-      submit("post");
-      //clickLinkWithText("First forum");
-      clickLink("newTopic");
-      setFormElement("subject", "test topic");
-      setFormElement("message", "my message");
-      submit("post");
-      assertTextPresent("You cannot make another post so soon after your last; please try again in a short while");
-   }*/
-
-   public void testAddCategory()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLink("adminPanel");
-      setFormElement("categoryname", "newcategory");
-      submit("addcategory");
-      assertTextPresent("Forum and Category information updated successfully");
-      assertLinkPresentWithText("newcategory");
-   }
-
-   public void testAddForum()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLink("adminPanel");
-      setFormElement("forumname_1", "newforum");
-      submit("addforum_1");
-      assertFormElementEquals("forumname", "newforum");
-      setFormElement("forumname", "mynewforum");
-      setFormElement("forumdesc", "forumdesc");
-      submit();
-      assertTextPresent("Forum and Category information updated successfully");
-      assertLinkPresentWithText("mynewforum");
-      assertTextPresent("forumdesc");
-
-   }
-
-   public void testWatchForum()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("Watched Forums");
-      setFormElement("forum_id", "1");
-      assertLinkNotPresentWithText("First forum");
-      submit();
-      assertLinkPresentWithText("First forum");
-   }
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import java.util.Random;
+
+import org.dbunit.database.IDatabaseConnection;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.operation.DatabaseOperation;
+import org.jboss.portal.test.core.Utils;
+
+import net.sourceforge.jwebunit.WebTestCase;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.4 $
+ */
+public class AdminTestCase
+   extends WebTestCase implements TestConstants
+{
+
+   public static final int floodtime = 30;
+
+   public AdminTestCase(String name)
+   {
+      super(name);
+      //getTestContext().setBaseUrl("http://localhost.localdomain:8080/portal");
+      getTestContext().setBaseUrl("http://localhost:8080/portal");
+//      getTestContext().setUserAgent("Mozilla");
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      // initialize your database connection here
+      IDatabaseConnection connection = Utils.getConnection();
+
+      // initialize your dataset here
+      IDataSet dataSet = Utils.getDataSet("resources/test/forums.xml");
+
+      try
+      {
+         Utils.resetAutoIncrement();
+         DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
+      }
+      finally
+      {
+         connection.close();
+      }
+   }
+   
+   protected String getRandomTopicName () {
+       Random random = new Random ();
+       return "test topic"+Long.toString((long)(random.nextFloat()*10000000L));
+   }
+   
+    protected String getRandomMessage () {
+        Random random = new Random ();
+        return "my message"+Long.toString((long)(random.nextFloat()*10000000000L));
+    }
+
+   public void loginUser()
+   {
+      beginAt("/index.html");
+      clickLink("standardlogin");
+      setFormElement("j_username", "admin");
+      setFormElement("j_password", "admin");
+      submit();
+   }
+
+   public void testReadIndex()
+   {
+      loginUser();
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      assertLinkPresent("adminPanel");
+      assertTextPresent("Dummy demo category");
+      assertTextPresent("First forum");
+      assertTextPresent("Second forum");
+      assertLinkNotPresent("newTopic");
+   }
+
+   public void testReadForum()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      assertTextPresent("First forum");
+      assertTextPresent("Page <b>1</b> of");
+      assertLinkPresent("newTopic");
+   }
+
+   public void testPostTopic()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      clickLink("newTopic");
+      String randomTopicName = getRandomTopicName();
+      setFormElement("subject",randomTopicName);
+      String randomMessage = getRandomMessage();
+      setFormElement("message", randomMessage);
+      submit("post");
+      assertTextPresent(randomTopicName);
+      clickLinkWithText(randomTopicName);
+      assertTextPresent(randomMessage);
+   }
+
+   public void testReplyTopic()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      clickLink("newTopic");
+      String randomTopicName = getRandomTopicName();
+      String randomMessage = getRandomMessage();
+      setFormElement("subject", randomTopicName);
+      setFormElement("message", randomMessage);
+      submit("post");
+      clickLinkWithText("First forum");
+      clickLinkWithText(randomTopicName);
+      clickLink("postReply");
+      assertFormElementEquals("subject", "Re: "+randomTopicName);
+      String randomAnswerMessage = "my answer"+getRandomMessage();
+      setFormElement("message", randomAnswerMessage);
+      // For flood control
+      try
+      {
+         Thread.sleep(floodtime * 1000);
+      }
+      catch (InterruptedException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+      submit("post");
+      assertTextPresent("Re: "+randomTopicName);
+      assertTextPresent(randomMessage);
+      assertTextPresent(randomAnswerMessage);
+   }
+
+    /* DOESN'T WORK!! */
+   /*public void testFlood()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      clickLink("newTopic");
+      setFormElement("subject", "test topic");
+      setFormElement("message", "my message");
+      submit("post");
+      //clickLinkWithText("First forum");
+      clickLink("newTopic");
+      setFormElement("subject", "test topic");
+      setFormElement("message", "my message");
+      submit("post");
+      assertTextPresent("You cannot make another post so soon after your last; please try again in a short while");
+   }*/
+
+   public void testAddCategory()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLink("adminPanel");
+      setFormElement("categoryname", "newcategory");
+      submit("addcategory");
+      assertTextPresent("Forum and Category information updated successfully");
+      assertLinkPresentWithText("newcategory");
+   }
+
+   public void testAddForum()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLink("adminPanel");
+      setFormElement("forumname_1", "newforum");
+      submit("addforum_1");
+      assertFormElementEquals("forumname", "newforum");
+      setFormElement("forumname", "mynewforum");
+      setFormElement("forumdesc", "forumdesc");
+      submit();
+      assertTextPresent("Forum and Category information updated successfully");
+      assertLinkPresentWithText("mynewforum");
+      assertTextPresent("forumdesc");
+
+   }
+
+   public void testWatchForum()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("Watched Forums");
+      setFormElement("forum_id", "1");
+      assertLinkNotPresentWithText("First forum");
+      submit();
+      assertLinkPresentWithText("First forum");
+   }
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AnonymousUserTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AnonymousUserTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/AnonymousUserTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,47 +1,47 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import net.sourceforge.jwebunit.WebTestCase;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.3 $
- */
-public class AnonymousUserTestCase
-   extends WebTestCase implements TestConstants
-{
-   public AnonymousUserTestCase(String name)
-   {
-      super(name);
-      getTestContext().setBaseUrl("http://localhost:8080/portal");
-//      getTestContext().setUserAgent("Mozilla");
-   }
-
-   public void testReadIndex()
-   {
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      assertTextPresent("Dummy demo category");
-      assertTextPresent("First forum");
-      assertTextPresent("Second forum");
-   }
-
-   public void testReadForum()
-   {
-      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
-      clickLinkWithText("First forum");
-      assertTextPresent("First forum");
-      assertTextPresent("Page <b>1</b>");
-      assertLinkNotPresent("newTopic");
-   }
-
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import net.sourceforge.jwebunit.WebTestCase;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.3 $
+ */
+public class AnonymousUserTestCase
+   extends WebTestCase implements TestConstants
+{
+   public AnonymousUserTestCase(String name)
+   {
+      super(name);
+      getTestContext().setBaseUrl("http://localhost:8080/portal");
+//      getTestContext().setUserAgent("Mozilla");
+   }
+
+   public void testReadIndex()
+   {
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      assertTextPresent("Dummy demo category");
+      assertTextPresent("First forum");
+      assertTextPresent("Second forum");
+   }
+
+   public void testReadForum()
+   {
+      beginAt(PORTAL_FORUMS_MAIN_MAXIMIZED_URL);
+      clickLinkWithText("First forum");
+      assertTextPresent("First forum");
+      assertTextPresent("Page <b>1</b>");
+      assertLinkNotPresent("newTopic");
+   }
+
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,162 +1,156 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.security.ForumItemImpl;
-import org.jboss.portlet.forums.impl.TopicImpl;
-import org.jboss.portlet.forums.impl.PostImpl;
-import org.jboss.portlet.forums.impl.MessageImpl;
-import org.jboss.portlet.forums.impl.ForumImpl;
-import org.jboss.portlet.forums.impl.CategoryImpl;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portal.core.modules.ModuleException;
-
-
-import java.util.Date;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-
-public class CategoryModelTestCase extends ForumsModelTestCase
-{
-   public CategoryModelTestCase(String name)
-   {
-      super(name);
-   }
-
-   public void testCategorySavedTestCase()
-   {
-      Set namesSet = new HashSet();
-      try
-      {
-         List categories = forumsModule.findCategories();
-         for (Iterator ci = categories.iterator(); ci.hasNext();)
-         {
-            Category category = (Category)ci.next();
-            namesSet.add(category.getTitle());
-            List forums = category.getForums();
-            for (Iterator fi = forums.iterator(); fi.hasNext();)
-            {
-               Forum forum = (Forum)fi.next();
-               namesSet.add(forum.getName());
-               System.out.println("There are : " + forums.size() + " topics found");
-               List topics = forum.getTopics();
-               System.out.println("There are : " + topics.size() + " topics found");
-               for (Iterator ti = topics.iterator(); ti.hasNext();)
-               {
-                  Topic topic = (Topic)ti.next();
-                  System.out.println("Processing topic subject: " + topic.getSubject());
-                  Iterator pi = topic.getPosts().iterator();
-                  System.out.println("Number of posts in topic: " + topic.getPosts().size());
-                  for (; pi.hasNext();)
-                  {
-                     System.out.println("Processing post");
-
-                     Post post = (Post)pi.next();
-                     namesSet.add(post.getMessage().getSubject());
-                  }
-               }
-            }
-         }
-
-         Set expectedSubjectSet = new HashSet();
-         expectedSubjectSet.add("Sample Category");
-         expectedSubjectSet.add("Sample Forum");
-         expectedSubjectSet.add("subject1");
-         expectedSubjectSet.add("subject2");
-         assertEquals(expectedSubjectSet, namesSet);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   public void testCategoryDeleteTestCase()
-   {
-
-      try
-      {
-         List categories = forumsModule.findCategories();
-         System.out.println("There are : " + categories.size() + " categories found");
-         for (Iterator ti = categories.iterator(); ti.hasNext();)
-         {
-            Category category = (Category)ti.next();
-            forumsModule.removeCategory(category);
-         }
-         categories = forumsModule.findForums();
-         assertEquals(categories.size(), 0);
-         List forums = forumsModule.findForums();
-         assertEquals(forums.size(), 0);
-         List topics = forumsModule.findTopics();
-         assertEquals(topics.size(), 0);
-         List posts = forumsModule.findPosts();
-         assertEquals(posts.size(), 0);
-
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   protected void populate() throws Exception
-   {
-      Topic topic1 = new TopicImpl();
-      //topic1.setPosts(new ArrayList());
-      topic1.setSubject("sample subject");
-
-      //topic1.set
-      Post post1 = new PostImpl();
-      post1.setCreateDate(new Date());
-      post1.setMessage(new MessageImpl());
-      Message message1 = new MessageImpl();
-      message1.setSubject("subject1");
-      post1.setMessage(message1);
-      Post post2 = new PostImpl();
-      post2.setCreateDate(new Date());
-      Message message2 = new MessageImpl();
-      message2.setSubject("subject2");
-      post2.setMessage(message2);
-
-      topic1.addPost(post1);
-      topic1.addPost(post2);
-
-      Forum forum1 = new ForumImpl();
-
-      forum1.addTopic(topic1);
-      forum1.setName("Sample Forum");
-
-      Category category1 = new CategoryImpl();
-      category1.addForum(forum1);
-      category1.setTitle("Sample Category");
-
-
-      session.save(category1);
-   }
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import org.jboss.portlet.forums.impl.TopicImpl;
+import org.jboss.portlet.forums.impl.PostImpl;
+import org.jboss.portlet.forums.impl.MessageImpl;
+import org.jboss.portlet.forums.impl.ForumImpl;
+import org.jboss.portlet.forums.impl.CategoryImpl;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portal.core.modules.ModuleException;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+
+public class CategoryModelTestCase extends ForumsModelTestCase
+{
+   public CategoryModelTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testCategorySavedTestCase()
+   {
+      Set namesSet = new HashSet();
+      try
+      {
+         List categories = forumsModule.findCategories();
+         for (Iterator ci = categories.iterator(); ci.hasNext();)
+         {
+            Category category = (Category)ci.next();
+            namesSet.add(category.getTitle());
+            List forums = category.getForums();
+            for (Iterator fi = forums.iterator(); fi.hasNext();)
+            {
+               Forum forum = (Forum)fi.next();
+               namesSet.add(forum.getName());
+               System.out.println("There are : " + forums.size() + " topics found");
+               List topics = forum.getTopics();
+               System.out.println("There are : " + topics.size() + " topics found");
+               for (Iterator ti = topics.iterator(); ti.hasNext();)
+               {
+                  Topic topic = (Topic)ti.next();
+                  System.out.println("Processing topic subject: " + topic.getSubject());
+                  Iterator pi = topic.getPosts().iterator();
+                  System.out.println("Number of posts in topic: " + topic.getPosts().size());
+                  for (; pi.hasNext();)
+                  {
+                     System.out.println("Processing post");
+
+                     Post post = (Post)pi.next();
+                     namesSet.add(post.getMessage().getSubject());
+                  }
+               }
+            }
+         }
+
+         Set expectedSubjectSet = new HashSet();
+         expectedSubjectSet.add("Sample Category");
+         expectedSubjectSet.add("Sample Forum");
+         expectedSubjectSet.add("subject1");
+         expectedSubjectSet.add("subject2");
+         assertEquals(expectedSubjectSet, namesSet);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   public void testCategoryDeleteTestCase()
+   {
+
+      try
+      {
+         List categories = forumsModule.findCategories();
+         System.out.println("There are : " + categories.size() + " categories found");
+         for (Iterator ti = categories.iterator(); ti.hasNext();)
+         {
+            Category category = (Category)ti.next();
+            forumsModule.removeCategory(category);
+         }
+         categories = forumsModule.findForums();
+         assertEquals(categories.size(), 0);
+         List forums = forumsModule.findForums();
+         assertEquals(forums.size(), 0);
+         List topics = forumsModule.findTopics();
+         assertEquals(topics.size(), 0);
+         List posts = forumsModule.findPosts();
+         assertEquals(posts.size(), 0);
+
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   protected void populate() throws Exception
+   {
+      Topic topic1 = new TopicImpl();
+      //topic1.setPosts(new ArrayList());
+      topic1.setSubject("sample subject");
+
+      //topic1.set
+      Post post1 = new PostImpl();
+      post1.setCreateDate(new Date());
+      post1.setMessage(new MessageImpl());
+      Message message1 = new MessageImpl();
+      message1.setSubject("subject1");
+      post1.setMessage(message1);
+      Post post2 = new PostImpl();
+      post2.setCreateDate(new Date());
+      Message message2 = new MessageImpl();
+      message2.setSubject("subject2");
+      post2.setMessage(message2);
+
+      topic1.addPost(post1);
+      topic1.addPost(post2);
+
+      Forum forum1 = new ForumImpl();
+
+      forum1.addTopic(topic1);
+      forum1.setName("Sample Forum");
+
+      Category category1 = new CategoryImpl();
+      category1.addForum(forum1);
+      category1.setTitle("Sample Category");
+
+
+      session.save(category1);
+   }
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumModelTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumModelTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumModelTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,147 +1,142 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.security.ForumItemImpl;
-import org.jboss.portlet.forums.impl.TopicImpl;
-import org.jboss.portlet.forums.impl.PostImpl;
-import org.jboss.portlet.forums.impl.MessageImpl;
-import org.jboss.portlet.forums.impl.ForumImpl;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portal.core.modules.ModuleException;
-
-
-import java.util.Date;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-
-public class ForumModelTestCase extends ForumsModelTestCase
-{
-   public ForumModelTestCase(String name)
-   {
-      super(name);
-   }
-
-   public void testForumSavedTestCase()
-   {
-      Set namesSet = new HashSet();
-      try
-      {
-         List forums = forumsModule.findForums();
-
-         for (Iterator fi = forums.iterator(); fi.hasNext();)
-         {
-            Forum forum = (Forum)fi.next();
-            namesSet.add(forum.getName());
-            System.out.println("There are : " + forums.size() + " topics found");
-            List topics = forum.getTopics();
-            System.out.println("There are : " + topics.size() + " topics found");
-            for (Iterator ti = topics.iterator(); ti.hasNext();)
-            {
-               Topic topic = (Topic)ti.next();
-               System.out.println("Processing topic subject: " + topic.getSubject());
-               Iterator pi = topic.getPosts().iterator();
-               System.out.println("Number of posts in topic: " + topic.getPosts().size());
-               for (; pi.hasNext();)
-               {
-                  System.out.println("Processing post");
-
-                  Post post = (Post)pi.next();
-                  namesSet.add(post.getMessage().getSubject());
-               }
-            }
-         }
-         Set expectedSubjectSet = new HashSet();
-         expectedSubjectSet.add("Sample Forum");
-         expectedSubjectSet.add("subject1");
-         expectedSubjectSet.add("subject2");
-         assertEquals(expectedSubjectSet, namesSet);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   public void testForumDeleteTestCase()
-   {
-
-      try
-      {
-         List forums = forumsModule.findForums();
-         System.out.println("There are : " + forums.size() + " forums found");
-         for (Iterator ti = forums.iterator(); ti.hasNext();)
-         {
-            Forum forum = (Forum)ti.next();
-            forumsModule.removeForum(forum);
-         }
-         forums = forumsModule.findForums();
-         assertEquals(forums.size(), 0);
-         List topics = forumsModule.findTopics();
-         assertEquals(topics.size(), 0);
-         List posts = forumsModule.findPosts();
-         assertEquals(posts.size(), 0);
-
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   protected void populate() throws Exception
-   {
-      Topic topic1 = new TopicImpl();
-      //topic1.setPosts(new ArrayList());
-      topic1.setSubject("sample subject");
-
-      //topic1.set
-      Post post1 = new PostImpl();
-      post1.setCreateDate(new Date());
-      post1.setMessage(new MessageImpl());
-      Message message1 = new MessageImpl();
-      message1.setSubject("subject1");
-      post1.setMessage(message1);
-      Post post2 = new PostImpl();
-      post2.setCreateDate(new Date());
-      Message message2 = new MessageImpl();
-      message2.setSubject("subject2");
-      post2.setMessage(message2);
-
-      topic1.addPost(post1);
-      topic1.addPost(post2);
-
-      Forum forum1 = new ForumImpl();
-
-      forum1.addTopic(topic1);
-      forum1.setName("Sample Forum");
-
-
-      session.save(forum1);
-   }
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import org.jboss.portlet.forums.impl.TopicImpl;
+import org.jboss.portlet.forums.impl.PostImpl;
+import org.jboss.portlet.forums.impl.MessageImpl;
+import org.jboss.portlet.forums.impl.ForumImpl;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portal.core.modules.ModuleException;
+
+
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+
+public class ForumModelTestCase extends ForumsModelTestCase
+{
+   public ForumModelTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testForumSavedTestCase()
+   {
+      Set namesSet = new HashSet();
+      try
+      {
+         List forums = forumsModule.findForums();
+
+         for (Iterator fi = forums.iterator(); fi.hasNext();)
+         {
+            Forum forum = (Forum)fi.next();
+            namesSet.add(forum.getName());
+            System.out.println("There are : " + forums.size() + " topics found");
+            List topics = forum.getTopics();
+            System.out.println("There are : " + topics.size() + " topics found");
+            for (Iterator ti = topics.iterator(); ti.hasNext();)
+            {
+               Topic topic = (Topic)ti.next();
+               System.out.println("Processing topic subject: " + topic.getSubject());
+               Iterator pi = topic.getPosts().iterator();
+               System.out.println("Number of posts in topic: " + topic.getPosts().size());
+               for (; pi.hasNext();)
+               {
+                  System.out.println("Processing post");
+
+                  Post post = (Post)pi.next();
+                  namesSet.add(post.getMessage().getSubject());
+               }
+            }
+         }
+         Set expectedSubjectSet = new HashSet();
+         expectedSubjectSet.add("Sample Forum");
+         expectedSubjectSet.add("subject1");
+         expectedSubjectSet.add("subject2");
+         assertEquals(expectedSubjectSet, namesSet);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   public void testForumDeleteTestCase()
+   {
+
+      try
+      {
+         List forums = forumsModule.findForums();
+         System.out.println("There are : " + forums.size() + " forums found");
+         for (Iterator ti = forums.iterator(); ti.hasNext();)
+         {
+            Forum forum = (Forum)ti.next();
+            forumsModule.removeForum(forum);
+         }
+         forums = forumsModule.findForums();
+         assertEquals(forums.size(), 0);
+         List topics = forumsModule.findTopics();
+         assertEquals(topics.size(), 0);
+         List posts = forumsModule.findPosts();
+         assertEquals(posts.size(), 0);
+
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   protected void populate() throws Exception
+   {
+      Topic topic1 = new TopicImpl();
+      //topic1.setPosts(new ArrayList());
+      topic1.setSubject("sample subject");
+
+      //topic1.set
+      Post post1 = new PostImpl();
+      post1.setCreateDate(new Date());
+      post1.setMessage(new MessageImpl());
+      Message message1 = new MessageImpl();
+      message1.setSubject("subject1");
+      post1.setMessage(message1);
+      Post post2 = new PostImpl();
+      post2.setCreateDate(new Date());
+      Message message2 = new MessageImpl();
+      message2.setSubject("subject2");
+      post2.setMessage(message2);
+
+      topic1.addPost(post1);
+      topic1.addPost(post2);
+
+      Forum forum1 = new ForumImpl();
+
+      forum1.addTopic(topic1);
+      forum1.setName("Sample Forum");
+
+
+      session.save(forum1);
+   }
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumsModelTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumsModelTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/ForumsModelTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,137 +1,132 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import java.sql.Connection;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.cfg.Configuration;
-
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.impl.ForumsModuleImpl;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-public abstract class ForumsModelTestCase
-   extends TestCase
-{
-   public ForumsModelTestCase(String name)
-   {
-      super(name);
-   }
-
-   protected SessionFactory factory;
-   protected Session session;
-   protected Transaction tx;
-   protected ForumsModule forumsModule;
-
-
-   public void setUp() throws Exception
-   {
-      Configuration cfg = new Configuration();
-      //Configuration excfg = new Configuration();
-
-      cfg.addResource("org/jboss/portlet/forums/impl/CategoryImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-      cfg.addResource("org/jboss/portlet/forums/impl/ForumImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-      cfg.addResource("org/jboss/portlet/forums/impl/PollImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-      cfg.addResource("org/jboss/portlet/forums/impl/PosterImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-      cfg.addResource("org/jboss/portlet/forums/impl/PostImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-      cfg.addResource("org/jboss/portlet/forums/impl/TopicImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-      cfg.addResource("org/jboss/portlet/forums/impl/WatchImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-      cfg.addResource("org/jboss/portlet/forums/impl/AttachmentImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
-
-      Properties props = new Properties();
-      props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
-      props.setProperty("hibernate.connection.driver_class", "org.gjt.mm.mysql.Driver");
-      props.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/jbossportal?useServerPrepStmts=false");
-      props.setProperty("hibernate.connection.username", "portal");
-      props.setProperty("hibernate.connection.password", "portalpassword");
-      props.setProperty("hibernate.connection.pool_size", "1");
-      props.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider");
-      //props.setProperty("hibernate.hbm2ddl.text", "no");
-      cfg.setProperties(props);
-
-      //
-      SchemaExport export = new SchemaExport(cfg);
-      export.create(false, true);
-
-      factory = cfg.buildSessionFactory();
-
-      /*List lst = new ArrayList();
-      Dialect dialect = Dialect.getDialect(props);
-      lst.addAll(Arrays.asList(cfg.generateDropSchemaScript(dialect)));
-      lst.addAll(Arrays.asList(cfg.generateSchemaCreationScript(dialect)));
-
-      // Open session and execute all create table statements
-      Session tmp = factory.openSession();
-      Connection conn = tmp.connection();
-      Statement st = conn.createStatement();
-      for (int i = 0; i < lst.size(); i++)
-      {
-         String s = (String) lst.get(i);
-         if (!s.startsWith("alter table"))
-         {
-            st.executeQuery(s);
-         }
-      }
-      tmp.close();*/
-
-      // Set up session and tx
-      session = factory.openSession();
-      tx = session.beginTransaction();
-
-      // Populate
-      populate();
-      nextSession();
-
-      // Setup forums module
-      forumsModule = new ForumsModuleImpl()
-      {
-         protected Session getSession()
-         {
-            return session;
-         }
-      };
-
-
-   }
-
-   protected void tearDown() throws Exception
-   {
-      tx.commit();
-      session.close();
-      factory.close();
-   }
-
-   protected void nextSession() throws Exception
-   {
-      tx.commit();
-      session.close();
-      session = factory.openSession();
-      tx = session.beginTransaction();
-   }
-
-   protected void populate() throws Exception
-   {
-   }
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.cfg.Configuration;
+
+import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.impl.ForumsModuleImpl;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+public abstract class ForumsModelTestCase
+   extends TestCase
+{
+   public ForumsModelTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected SessionFactory factory;
+   protected Session session;
+   protected Transaction tx;
+   protected ForumsModule forumsModule;
+
+
+   public void setUp() throws Exception
+   {
+      Configuration cfg = new Configuration();
+      //Configuration excfg = new Configuration();
+
+      cfg.addResource("org/jboss/portlet/forums/impl/CategoryImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+      cfg.addResource("org/jboss/portlet/forums/impl/ForumImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+      cfg.addResource("org/jboss/portlet/forums/impl/PollImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+      cfg.addResource("org/jboss/portlet/forums/impl/PosterImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+      cfg.addResource("org/jboss/portlet/forums/impl/PostImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+      cfg.addResource("org/jboss/portlet/forums/impl/TopicImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+      cfg.addResource("org/jboss/portlet/forums/impl/WatchImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+      cfg.addResource("org/jboss/portlet/forums/impl/AttachmentImpl.hbm.xml", Thread.currentThread().getContextClassLoader());
+
+      Properties props = new Properties();
+      props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
+      props.setProperty("hibernate.connection.driver_class", "org.gjt.mm.mysql.Driver");
+      props.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/jbossportal?useServerPrepStmts=false");
+      props.setProperty("hibernate.connection.username", "portal");
+      props.setProperty("hibernate.connection.password", "portalpassword");
+      props.setProperty("hibernate.connection.pool_size", "1");
+      props.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider");
+      //props.setProperty("hibernate.hbm2ddl.text", "no");
+      cfg.setProperties(props);
+
+      //
+      SchemaExport export = new SchemaExport(cfg);
+      export.create(false, true);
+
+      factory = cfg.buildSessionFactory();
+
+      /*List lst = new ArrayList();
+      Dialect dialect = Dialect.getDialect(props);
+      lst.addAll(Arrays.asList(cfg.generateDropSchemaScript(dialect)));
+      lst.addAll(Arrays.asList(cfg.generateSchemaCreationScript(dialect)));
+
+      // Open session and execute all create table statements
+      Session tmp = factory.openSession();
+      Connection conn = tmp.connection();
+      Statement st = conn.createStatement();
+      for (int i = 0; i < lst.size(); i++)
+      {
+         String s = (String) lst.get(i);
+         if (!s.startsWith("alter table"))
+         {
+            st.executeQuery(s);
+         }
+      }
+      tmp.close();*/
+
+      // Set up session and tx
+      session = factory.openSession();
+      tx = session.beginTransaction();
+
+      // Populate
+      populate();
+      nextSession();
+
+      // Setup forums module
+      forumsModule = new ForumsModuleImpl()
+      {
+         protected Session getSession()
+         {
+            return session;
+         }
+      };
+
+
+   }
+
+   protected void tearDown() throws Exception
+   {
+      tx.commit();
+      session.close();
+      factory.close();
+   }
+
+   protected void nextSession() throws Exception
+   {
+      tx.commit();
+      session.close();
+      session = factory.openSession();
+      tx = session.beginTransaction();
+   }
+
+   protected void populate() throws Exception
+   {
+   }
 }
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/PostModelTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/PostModelTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/PostModelTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,164 +1,159 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.security.ForumItemImpl;
-import org.jboss.portlet.forums.impl.TopicImpl;
-import org.jboss.portlet.forums.impl.PostImpl;
-import org.jboss.portlet.forums.impl.MessageImpl;
-import org.jboss.portlet.forums.impl.ForumImpl;
-import org.jboss.portlet.forums.impl.CategoryImpl;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portlet.forums.model.Forum;
-import org.jboss.portlet.forums.model.Category;
-import org.jboss.portal.core.modules.ModuleException;
-
-
-import java.util.Date;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.4 $
- */
-
-public class PostModelTestCase extends ForumsModelTestCase
-{
-   public PostModelTestCase(String name)
-   {
-      super(name);
-   }
-
-   public void testWholeTreeSavedTestCase()
-   {
-      Set namesSet = new HashSet();
-      try
-      {
-         List categories = forumsModule.findCategories();
-         for (Iterator ci = categories.iterator(); ci.hasNext();)
-         {
-            Category category = (Category)ci.next();
-            namesSet.add(category.getTitle());
-            List forums = category.getForums();
-            for (Iterator fi = forums.iterator(); fi.hasNext();)
-            {
-               Forum forum = (Forum)fi.next();
-               namesSet.add(forum.getName());
-               System.out.println("There are : " + forums.size() + " forums found");
-               List topics = forum.getTopics();
-               System.out.println("There are : " + topics.size() + " topics found");
-               for (Iterator ti = topics.iterator(); ti.hasNext();)
-               {
-                  Topic topic = (Topic)ti.next();
-                  System.out.println("Processing topic subject: " + topic.getSubject());
-                  Iterator pi = topic.getPosts().iterator();
-                  System.out.println("Number of posts in topic: " + topic.getPosts().size());
-                  for (; pi.hasNext();)
-                  {
-                     System.out.println("Processing post");
-
-                     Post post = (Post)pi.next();
-                     namesSet.add(post.getMessage().getSubject());
-                  }
-               }
-            }
-         }
-
-         Set expectedSubjectSet = new HashSet();
-         expectedSubjectSet.add("Sample Category");
-         expectedSubjectSet.add("Sample Forum");
-         expectedSubjectSet.add("subject1");
-         expectedSubjectSet.add("subject2");
-         assertEquals(expectedSubjectSet, namesSet);
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-
-   public void testOnlyPostDeleteTestCase()
-   {
-
-      try
-      {
-         List posts = forumsModule.findPosts();
-         System.out.println("There are : " + posts.size() + " posts found");
-         for (Iterator ti = posts.iterator(); ti.hasNext();)
-         {
-            Post post = (Post)ti.next();
-            forumsModule.removePost(post);
-         }
-         posts = forumsModule.findPosts();
-         assertEquals(posts.size(), 0);
-         //clean up
-         List categories = forumsModule.findCategories();
-         for (Iterator ci = categories.iterator(); ci.hasNext();)
-         {
-            Category category = (Category)ci.next();
-            forumsModule.removeCategory(category);
-         }
-
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   protected void populate() throws Exception
-   {
-      Topic topic1 = new TopicImpl();
-      //topic1.setPosts(new ArrayList());
-      topic1.setSubject("sample subject");
-
-      //topic1.set
-      Post post1 = new PostImpl();
-      post1.setCreateDate(new Date());
-      post1.setMessage(new MessageImpl());
-      Message message1 = new MessageImpl();
-      message1.setSubject("subject1");
-      post1.setMessage(message1);
-      Post post2 = new PostImpl();
-      post2.setCreateDate(new Date());
-      Message message2 = new MessageImpl();
-      message2.setSubject("subject2");
-      post2.setMessage(message2);
-
-      topic1.addPost(post1);
-      topic1.addPost(post2);
-
-      Forum forum1 = new ForumImpl();
-
-      forum1.addTopic(topic1);
-      forum1.setName("Sample Forum");
-
-      Category category1 = new CategoryImpl();
-      category1.addForum(forum1);
-      category1.setTitle("Sample Category");
-
-
-      session.save(category1);
-   }
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import org.jboss.portlet.forums.impl.TopicImpl;
+import org.jboss.portlet.forums.impl.PostImpl;
+import org.jboss.portlet.forums.impl.MessageImpl;
+import org.jboss.portlet.forums.impl.ForumImpl;
+import org.jboss.portlet.forums.impl.CategoryImpl;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.model.Category;
+import org.jboss.portal.core.modules.ModuleException;
+
+
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.5 $
+ */
+
+public class PostModelTestCase extends ForumsModelTestCase
+{
+   public PostModelTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testWholeTreeSavedTestCase()
+   {
+      Set namesSet = new HashSet();
+      try
+      {
+         List categories = forumsModule.findCategories();
+         for (Iterator ci = categories.iterator(); ci.hasNext();)
+         {
+            Category category = (Category)ci.next();
+            namesSet.add(category.getTitle());
+            List forums = category.getForums();
+            for (Iterator fi = forums.iterator(); fi.hasNext();)
+            {
+               Forum forum = (Forum)fi.next();
+               namesSet.add(forum.getName());
+               System.out.println("There are : " + forums.size() + " forums found");
+               List topics = forum.getTopics();
+               System.out.println("There are : " + topics.size() + " topics found");
+               for (Iterator ti = topics.iterator(); ti.hasNext();)
+               {
+                  Topic topic = (Topic)ti.next();
+                  System.out.println("Processing topic subject: " + topic.getSubject());
+                  Iterator pi = topic.getPosts().iterator();
+                  System.out.println("Number of posts in topic: " + topic.getPosts().size());
+                  for (; pi.hasNext();)
+                  {
+                     System.out.println("Processing post");
+
+                     Post post = (Post)pi.next();
+                     namesSet.add(post.getMessage().getSubject());
+                  }
+               }
+            }
+         }
+
+         Set expectedSubjectSet = new HashSet();
+         expectedSubjectSet.add("Sample Category");
+         expectedSubjectSet.add("Sample Forum");
+         expectedSubjectSet.add("subject1");
+         expectedSubjectSet.add("subject2");
+         assertEquals(expectedSubjectSet, namesSet);
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+
+   public void testOnlyPostDeleteTestCase()
+   {
+
+      try
+      {
+         List posts = forumsModule.findPosts();
+         System.out.println("There are : " + posts.size() + " posts found");
+         for (Iterator ti = posts.iterator(); ti.hasNext();)
+         {
+            Post post = (Post)ti.next();
+            forumsModule.removePost(post);
+         }
+         posts = forumsModule.findPosts();
+         assertEquals(posts.size(), 0);
+         //clean up
+         List categories = forumsModule.findCategories();
+         for (Iterator ci = categories.iterator(); ci.hasNext();)
+         {
+            Category category = (Category)ci.next();
+            forumsModule.removeCategory(category);
+         }
+
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   protected void populate() throws Exception
+   {
+      Topic topic1 = new TopicImpl();
+      //topic1.setPosts(new ArrayList());
+      topic1.setSubject("sample subject");
+
+      //topic1.set
+      Post post1 = new PostImpl();
+      post1.setCreateDate(new Date());
+      post1.setMessage(new MessageImpl());
+      Message message1 = new MessageImpl();
+      message1.setSubject("subject1");
+      post1.setMessage(message1);
+      Post post2 = new PostImpl();
+      post2.setCreateDate(new Date());
+      Message message2 = new MessageImpl();
+      message2.setSubject("subject2");
+      post2.setMessage(message2);
+
+      topic1.addPost(post1);
+      topic1.addPost(post2);
+
+      Forum forum1 = new ForumImpl();
+
+      forum1.addTopic(topic1);
+      forum1.setName("Sample Forum");
+
+      Category category1 = new CategoryImpl();
+      category1.addForum(forum1);
+      category1.setTitle("Sample Category");
+
+
+      session.save(category1);
+   }
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TestConstants.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TestConstants.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TestConstants.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,128 +1,128 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @author <a href="mailto:">Martin Giljohann</a>
- * @version $Revision: 1.3 $
- */
-
-public interface TestConstants
-{
-   int FLOOD_INTERVAL = 30;
-
-   String PORTAL_URL = "http://localhost:8080/portal";
-
-   String PORTAL_MAIN_BEGIN = "/index.html";
-
-   String PORTAL_LOGIN_TEXT_LINK = "Standard Login";
-
-   String PORTAL_LOGOUT_TEXT_LINK = "Logout";
-
-   String PORTAL_FORUMS_TEXT_LINK = "forums";
-   
-   String PORTAL_FORUMS_MAIN_MAXIMIZED_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:windowstate=maximized&ctrl:window=default.forums.ForumsPortletWindow";
-   
-   String PORTAL_FORUMS_MAIN_MINIMIZED_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:windowstate=minimized&ctrl:window=default.forums.ForumsPortletWindow";
-   
-   String PORTAL_FORUMS_MAIN_EDIT_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:mode=edit&ctrl:window=default.forums.ForumsPortletWindow";
-   
-   String PORTAL_FORUMS_MAIN_NORMAL_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:windowstate=normal&ctrl:window=default.forums.ForumsPortletWindow";
-
-   String PORTAL_LOGIN_USERNAME_FORM_ELEMENT = "j_username";
-
-   String PORTAL_LOGIN_PASSWORD_FORM_ELEMENT = "j_password";
-
-   String ADMIN_PANEL_TEXT_LINK = "Go to Administration Panel";
-
-   String FORUM_1_TEXT_LINK = "First forum";
-
-   String FORUM_2_TEXT_LINK = "Second forum";
-
-   String MODE_EDIT_IMAGE_LINK = "edit.gif";
-
-   String MODE_VIEW_IMAGE_LINK = "view.gif";
-
-   String MODE_NORMAL_IMAGE_LINK = "normal.gif";
-
-   String MODE_MAXIMIZE_IMAGE_LINK = "maximize.gif";
-
-   String MODE_MINIMIZE_IMAGE_LINK = "minimize.gif";
-
-   String PREFERENCES_POST_PER_TOPIC_FORM_ELEMENT = "postspertopic";
-
-   String PREFERENCES_TOPIC_PER_FORUM_FORM_ELEMENT = "topicsperforum";
-
-   String WATCHED_FORUMS_TEXT_LINK = "Watched Forums";
-
-   String CATEGORY_1_TEXT_LINK = "Dummy demo category";
-
-   String NEW_TOPIC_IMAGE_LINK = "post.gif";
-
-   String POST_REPLY_IMAGE_LINK = "reply.gif";
-
-   String POST_QUOTE_IMAGE_LINK = "icon_quote.gif";
-
-   String POST_EDIT_IMAGE_LINK = "icon_edit.gif";
-
-   String POST_DELETE_IMAGE_LINK = "icon_delete.gif";
-
-   String POST_SUBJECT_FORM_ELEMENT = "subject";
-
-   String POST_MESSAGE_FORM_ELEMENT = "message";
-
-   String POST_SUBMIT = "post";
-
-   String TOPIC_TYPE_FORM_ELEMENT = "topictype";
-
-   String INSTANT_REPLY_MESSAGE_FORM_ELEMENT = "message";
-
-   String POLL_TITLE_FORM_ELEMENT = "poll_title";
-
-   String POLL_ADD_OPTION_FORM_ELEMENT = "add_poll_option_text";
-
-   String POLL_ADD_OPTION_SUBMIT = "add_poll_option";
-
-   String POLL_OPTION_UPDATE_SUBMIT = "edit_poll_option";
-
-   String POLL_OPTION_1_DELETE_SUBMIT = "del_poll_option[0]";
-
-   String POLL_OPTION_2_DELETE_SUBMIT = "del_poll_option[1]";
-
-   String POLL_OPTION_3_DELETE_SUBMIT = "del_poll_option[2]";
-
-   String POLL_OPTION_4_DELETE_SUBMIT = "del_poll_option[3]";
-
-   String POLL_OPTION_1_TEXT_FORM_ELEMENT = "poll_option_text[0]";
-
-   String POLL_OPTION_2_TEXT_FORM_ELEMENT = "poll_option_text[1]";
-
-   String POLL_OPTION_3_TEXT_FORM_ELEMENT = "poll_option_text[2]";
-
-   String POLL_OPTION_4_TEXT_FORM_ELEMENT = "poll_option_text[3]";
-
-   String POLL_VOTE_RADIO_FORM_ELEMENT = "vote_id";
-
-   String POLL_VIEW_RESULTS_TEXT_LING = "View Results";
-
-   String POLL_VOTE_SUBMIT_SUBMIT = "submit";
-
-   String ADMIN_CATEGORY_1_EDIT_URL = PORTAL_URL + "/auth/index.html?ctrl:id=window.default.ForumsPortletWindow&ctrl:type=action&op=admin_forums&c=1&mode=editcat";
-
-   String ADMIN_CATEGORY_EDIT_SUBMIT = "submit";
-
-   String ADMIN_CATEGORY_EDIT_NAME_FORM_ELEMENT = "cat_title";
-
-   String ADMIN_FORUM_1_EDIT_URL = PORTAL_URL + "/auth/index.html?ctrl:id=window.default.ForumsPortletWindow&ctrl:type=render&op=showAddEditForum&f=1&mode=editforum";
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @author <a href="mailto:">Martin Giljohann</a>
+ * @version $Revision: 1.3 $
+ */
+
+public interface TestConstants
+{
+   int FLOOD_INTERVAL = 30;
+
+   String PORTAL_URL = "http://localhost:8080/portal";
+
+   String PORTAL_MAIN_BEGIN = "/index.html";
+
+   String PORTAL_LOGIN_TEXT_LINK = "Standard Login";
+
+   String PORTAL_LOGOUT_TEXT_LINK = "Logout";
+
+   String PORTAL_FORUMS_TEXT_LINK = "forums";
+   
+   String PORTAL_FORUMS_MAIN_MAXIMIZED_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:windowstate=maximized&ctrl:window=default.forums.ForumsPortletWindow";
+   
+   String PORTAL_FORUMS_MAIN_MINIMIZED_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:windowstate=minimized&ctrl:window=default.forums.ForumsPortletWindow";
+   
+   String PORTAL_FORUMS_MAIN_EDIT_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:mode=edit&ctrl:window=default.forums.ForumsPortletWindow";
+   
+   String PORTAL_FORUMS_MAIN_NORMAL_URL = PORTAL_URL +"/index.html?ctrl:cmd=nav&ctrl:windowstate=normal&ctrl:window=default.forums.ForumsPortletWindow";
+
+   String PORTAL_LOGIN_USERNAME_FORM_ELEMENT = "j_username";
+
+   String PORTAL_LOGIN_PASSWORD_FORM_ELEMENT = "j_password";
+
+   String ADMIN_PANEL_TEXT_LINK = "Go to Administration Panel";
+
+   String FORUM_1_TEXT_LINK = "First forum";
+
+   String FORUM_2_TEXT_LINK = "Second forum";
+
+   String MODE_EDIT_IMAGE_LINK = "edit.gif";
+
+   String MODE_VIEW_IMAGE_LINK = "view.gif";
+
+   String MODE_NORMAL_IMAGE_LINK = "normal.gif";
+
+   String MODE_MAXIMIZE_IMAGE_LINK = "maximize.gif";
+
+   String MODE_MINIMIZE_IMAGE_LINK = "minimize.gif";
+
+   String PREFERENCES_POST_PER_TOPIC_FORM_ELEMENT = "postspertopic";
+
+   String PREFERENCES_TOPIC_PER_FORUM_FORM_ELEMENT = "topicsperforum";
+
+   String WATCHED_FORUMS_TEXT_LINK = "Watched Forums";
+
+   String CATEGORY_1_TEXT_LINK = "Dummy demo category";
+
+   String NEW_TOPIC_IMAGE_LINK = "post.gif";
+
+   String POST_REPLY_IMAGE_LINK = "reply.gif";
+
+   String POST_QUOTE_IMAGE_LINK = "icon_quote.gif";
+
+   String POST_EDIT_IMAGE_LINK = "icon_edit.gif";
+
+   String POST_DELETE_IMAGE_LINK = "icon_delete.gif";
+
+   String POST_SUBJECT_FORM_ELEMENT = "subject";
+
+   String POST_MESSAGE_FORM_ELEMENT = "message";
+
+   String POST_SUBMIT = "post";
+
+   String TOPIC_TYPE_FORM_ELEMENT = "topictype";
+
+   String INSTANT_REPLY_MESSAGE_FORM_ELEMENT = "message";
+
+   String POLL_TITLE_FORM_ELEMENT = "poll_title";
+
+   String POLL_ADD_OPTION_FORM_ELEMENT = "add_poll_option_text";
+
+   String POLL_ADD_OPTION_SUBMIT = "add_poll_option";
+
+   String POLL_OPTION_UPDATE_SUBMIT = "edit_poll_option";
+
+   String POLL_OPTION_1_DELETE_SUBMIT = "del_poll_option[0]";
+
+   String POLL_OPTION_2_DELETE_SUBMIT = "del_poll_option[1]";
+
+   String POLL_OPTION_3_DELETE_SUBMIT = "del_poll_option[2]";
+
+   String POLL_OPTION_4_DELETE_SUBMIT = "del_poll_option[3]";
+
+   String POLL_OPTION_1_TEXT_FORM_ELEMENT = "poll_option_text[0]";
+
+   String POLL_OPTION_2_TEXT_FORM_ELEMENT = "poll_option_text[1]";
+
+   String POLL_OPTION_3_TEXT_FORM_ELEMENT = "poll_option_text[2]";
+
+   String POLL_OPTION_4_TEXT_FORM_ELEMENT = "poll_option_text[3]";
+
+   String POLL_VOTE_RADIO_FORM_ELEMENT = "vote_id";
+
+   String POLL_VIEW_RESULTS_TEXT_LING = "View Results";
+
+   String POLL_VOTE_SUBMIT_SUBMIT = "submit";
+
+   String ADMIN_CATEGORY_1_EDIT_URL = PORTAL_URL + "/auth/index.html?ctrl:id=window.default.ForumsPortletWindow&ctrl:type=action&op=admin_forums&c=1&mode=editcat";
+
+   String ADMIN_CATEGORY_EDIT_SUBMIT = "submit";
+
+   String ADMIN_CATEGORY_EDIT_NAME_FORM_ELEMENT = "cat_title";
+
+   String ADMIN_FORUM_1_EDIT_URL = PORTAL_URL + "/auth/index.html?ctrl:id=window.default.ForumsPortletWindow&ctrl:type=render&op=showAddEditForum&f=1&mode=editforum";
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TopicModelTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TopicModelTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/TopicModelTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,146 +1,141 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under LGPL license.   *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import org.jboss.portlet.forums.ForumsModule;
-import org.jboss.portlet.forums.impl.TopicImpl;
-import org.jboss.portlet.forums.impl.PostImpl;
-import org.jboss.portlet.forums.impl.MessageImpl;
-import org.jboss.portlet.forums.model.Post;
-import org.jboss.portlet.forums.model.Topic;
-import org.jboss.portlet.forums.model.Message;
-import org.jboss.portal.core.modules.ModuleException;
-
-
-import java.util.Date;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.3 $
- */
-
-public class TopicModelTestCase extends ForumsModelTestCase
-{
-   public TopicModelTestCase(String name)
-   {
-      super(name);
-   }
-
-   public void testTopicSavedTestCase()
-   {
-      Set subjectSet = new HashSet();
-      try
-      {
-         List topics = forumsModule.findTopics();
-         System.out.println("There are : " + topics.size() + " topics found");
-         for (Iterator ti = topics.iterator(); ti.hasNext();)
-         {
-            Topic topic = (Topic)ti.next();
-            System.out.println("Processing topic subject: " + topic.getSubject());
-            Iterator pi = topic.getPosts().iterator();
-            System.out.println("Number of posts in topic: " + topic.getPosts().size());
-            for (; pi.hasNext();)
-            {
-               System.out.println("Processing post");
-
-               Post post = (Post)pi.next();
-               subjectSet.add(post.getMessage().getSubject());
-            }
-
-         }
-         Set expectedSubjectSet = new HashSet();
-         expectedSubjectSet.add("subject1");
-         expectedSubjectSet.add("subject2");
-         assertEquals(expectedSubjectSet, subjectSet);
-
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   public void testLastPostTestCase()
-   {
-      try
-      {
-         List topics = forumsModule.findTopics();
-         //won't do it cleanl as there should be only one topic in db
-         Topic topic = (Topic)topics.iterator().next();
-         String subject = topic.getLastPost().getMessage().getSubject();
-         String expectedSubject = "subject2";
-         assertEquals(subject, expectedSubject);
-
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   public void testTopicDeleteTestCase()
-   {
-
-      try
-      {
-         List topics = forumsModule.findTopics();
-         System.out.println("There are : " + topics.size() + " topics found");
-         for (Iterator ti = topics.iterator(); ti.hasNext();)
-         {
-            Topic topic = (Topic)ti.next();
-            forumsModule.removeTopic(topic);
-         }
-         topics = forumsModule.findTopics();
-         assertEquals(topics.size(), 0);
-
-      }
-      catch (ModuleException e)
-      {
-         e.printStackTrace();
-      }
-
-   }
-
-   protected void populate() throws Exception
-   {
-      Topic topic1 = new TopicImpl();
-      //topic1.setPosts(new ArrayList());
-      topic1.setSubject("sample subject");
-
-      //topic1.set
-      Post post1 = new PostImpl();
-      post1.setCreateDate(new Date());
-      post1.setMessage(new MessageImpl());
-      Message message1 = new MessageImpl();
-      message1.setSubject("subject1");
-      post1.setMessage(message1);
-      Post post2 = new PostImpl();
-      post2.setCreateDate(new Date());
-      Message message2 = new MessageImpl();
-      message2.setSubject("subject2");
-      post2.setMessage(message2);
-
-      topic1.addPost(post1);
-      topic1.addPost(post2);
-
-      session.save(topic1);
-   }
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under LGPL license.   *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import org.jboss.portlet.forums.impl.TopicImpl;
+import org.jboss.portlet.forums.impl.PostImpl;
+import org.jboss.portlet.forums.impl.MessageImpl;
+import org.jboss.portlet.forums.model.Post;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Message;
+import org.jboss.portal.core.modules.ModuleException;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.comboleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.4 $
+ */
+
+public class TopicModelTestCase extends ForumsModelTestCase
+{
+   public TopicModelTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testTopicSavedTestCase()
+   {
+      Set subjectSet = new HashSet();
+      try
+      {
+         List topics = forumsModule.findTopics();
+         System.out.println("There are : " + topics.size() + " topics found");
+         for (Iterator ti = topics.iterator(); ti.hasNext();)
+         {
+            Topic topic = (Topic)ti.next();
+            System.out.println("Processing topic subject: " + topic.getSubject());
+            Iterator pi = topic.getPosts().iterator();
+            System.out.println("Number of posts in topic: " + topic.getPosts().size());
+            for (; pi.hasNext();)
+            {
+               System.out.println("Processing post");
+
+               Post post = (Post)pi.next();
+               subjectSet.add(post.getMessage().getSubject());
+            }
+
+         }
+         Set expectedSubjectSet = new HashSet();
+         expectedSubjectSet.add("subject1");
+         expectedSubjectSet.add("subject2");
+         assertEquals(expectedSubjectSet, subjectSet);
+
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   public void testLastPostTestCase()
+   {
+      try
+      {
+         List topics = forumsModule.findTopics();
+         //won't do it cleanl as there should be only one topic in db
+         Topic topic = (Topic)topics.iterator().next();
+         String subject = topic.getLastPost().getMessage().getSubject();
+         String expectedSubject = "subject2";
+         assertEquals(subject, expectedSubject);
+
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   public void testTopicDeleteTestCase()
+   {
+
+      try
+      {
+         List topics = forumsModule.findTopics();
+         System.out.println("There are : " + topics.size() + " topics found");
+         for (Iterator ti = topics.iterator(); ti.hasNext();)
+         {
+            Topic topic = (Topic)ti.next();
+            forumsModule.removeTopic(topic);
+         }
+         topics = forumsModule.findTopics();
+         assertEquals(topics.size(), 0);
+
+      }
+      catch (ModuleException e)
+      {
+         e.printStackTrace();
+      }
+
+   }
+
+   protected void populate() throws Exception
+   {
+      Topic topic1 = new TopicImpl();
+      //topic1.setPosts(new ArrayList());
+      topic1.setSubject("sample subject");
+
+      //topic1.set
+      Post post1 = new PostImpl();
+      post1.setCreateDate(new Date());
+      post1.setMessage(new MessageImpl());
+      Message message1 = new MessageImpl();
+      message1.setSubject("subject1");
+      post1.setMessage(message1);
+      Post post2 = new PostImpl();
+      post2.setCreateDate(new Date());
+      Message message2 = new MessageImpl();
+      message2.setSubject("subject2");
+      post2.setMessage(message2);
+
+      topic1.addPost(post1);
+      topic1.addPost(post2);
+
+      session.save(topic1);
+   }
+
+}

Modified: labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/UserTestCase.java
===================================================================
--- labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/UserTestCase.java	2006-09-11 21:50:28 UTC (rev 6156)
+++ labs/jbossforums/trunk/forums/portal-forums-src-readonly/main/org/jboss/portlet/test/forums/UserTestCase.java	2006-09-11 22:04:18 UTC (rev 6157)
@@ -1,186 +1,186 @@
-/*****************************************
- *                                       *
- *  JBoss Portal: The OpenSource Portal  *
- *                                       *
- *       Forums JBoss Portlet            *
- *                                       *
- *   Distributable under GPL license.    *
- *   See terms of license at gnu.org.    *
- *                                       *
- *****************************************/
-package org.jboss.portlet.test.forums;
-
-import java.util.Random;
-
-import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.operation.DatabaseOperation;
-import org.jboss.portal.test.core.Utils;
-
-import net.sourceforge.jwebunit.WebTestCase;
-
-/**
- * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.5 $
- */
-public class UserTestCase
-   extends WebTestCase implements TestConstants
-{
-   public UserTestCase(String name)
-   {
-      super(name);
-      getTestContext().setBaseUrl("http://localhost:8080/portal");
-//      getTestContext().setUserAgent("Mozilla");
-   }
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      // initialize your database connection here
-      IDatabaseConnection connection = Utils.getConnection();
-
-      // initialize your dataset here
-      IDataSet dataSet = Utils.getDataSet("resources/test/forums.xml");
-
-      try
-      {
-         Utils.resetAutoIncrement();
-         DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
-      }
-      finally
-      {
-         connection.close();
-      }
-   }
-
-    protected String getRandomSubject () {
-        Random random = new Random ();
-        return "test topic"+Long.toString((long)(random.nextFloat()*10000000L));
-    }
-    
-     protected String getRandomMessage () {
-         Random random = new Random ();
-         return "my message"+Long.toString((long)(random.nextFloat()*10000000000L));
-     }
-
-   public void loginUser()
-   {
-      beginAt("/index.html");
-      clickLink("standardlogin");
-      setFormElement("j_username", "user");
-      setFormElement("j_password", "user");
-      submit();
-   }
-
-   public void testReadIndex()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      assertTextPresent("Dummy demo category");
-      assertTextPresent("First forum");
-      assertTextPresent("Second forum");
-      assertLinkNotPresent("newTopic");
-   }
-
-   public void testReadForum()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      assertTextPresent("First forum");
-      assertTextPresent("Page <b>1</b> of");
-      assertLinkPresent("newTopic");
-   }
-
-   public void testPostTopic()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      clickLink("newTopic");
-      String newRandomSubject = getRandomSubject();
-      String newRandomMessage = getRandomMessage();
-      setFormElement("subject", newRandomSubject);
-      setFormElement("message", newRandomMessage);
-      submit("post");
-      assertLinkPresentWithText(newRandomSubject);
-      clickLinkWithText(newRandomSubject);
-      assertTextPresent(newRandomMessage);
-   }
-
-   /**
-    * Test page navigation
-    * This test suppose that there are 10 topics per page
-    */
-   public void testPost11Topics()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      clickLink("newTopic");
-      String newRandomSubject = getRandomSubject();
-      String newRandomMessage = getRandomMessage();
-      setFormElement("subject", newRandomSubject);
-      setFormElement("message", newRandomMessage);
-      submit("post");
-      
-      for (int i = 0; i < 10; i++)
-      {
-         String newRandomSubjectT =  getRandomSubject();
-         String newRandomMessageT = getRandomMessage();
-         clickLink("newTopic");
-         setFormElement("subject", newRandomSubjectT);
-         setFormElement("message", newRandomMessageT);
-         /*try  IT DOESN'T WORK WITH FLOOD INTERCEPTOR TURNED ON
-         {
-            Thread.sleep(30 * 1000);
-         }
-         catch (InterruptedException e)
-         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }*/
-         submit("post");
-         
-      }
-      assertLinkPresentWithText("Next");
-      clickLinkWithText("Next");
-      assertTextPresent(newRandomSubject);
-      clickLinkWithText(newRandomSubject);
-      assertTextPresent(newRandomMessage);
-
-   }
-
-   public void testReplyTopic()
-   {
-      loginUser();
-      clickLinkWithText("forums");
-      clickLinkWithText("First forum");
-      clickLink("newTopic");
-      String newRandomSubject = getRandomSubject();
-      String newRandomMessage = getRandomMessage();
-      setFormElement("subject", newRandomSubject);
-      setFormElement("message", newRandomMessage);
-      submit("post");
-      clickLinkWithText(newRandomSubject);
-      clickLink("postReply");
-      newRandomMessage = getRandomMessage();
-      assertFormElementEquals("subject", "Re: "+newRandomSubject);
-      setFormElement("message", newRandomMessage);
-      // For flood control
-      /*try
-      {
-         Thread.sleep(30 * 1000);
-      }
-      catch (InterruptedException e)
-      {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }*/
-      submit("post");
-      assertTextPresent("Re: "+newRandomSubject);
-      assertTextPresent(newRandomMessage);
-   }
-
-
-}
+/*****************************************
+ *                                       *
+ *  JBoss Portal: The OpenSource Portal  *
+ *                                       *
+ *       Forums JBoss Portlet            *
+ *                                       *
+ *   Distributable under GPL license.    *
+ *   See terms of license at gnu.org.    *
+ *                                       *
+ *****************************************/
+package org.jboss.portlet.test.forums;
+
+import java.util.Random;
+
+import org.dbunit.database.IDatabaseConnection;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.operation.DatabaseOperation;
+import org.jboss.portal.test.core.Utils;
+
+import net.sourceforge.jwebunit.WebTestCase;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.5 $
+ */
+public class UserTestCase
+   extends WebTestCase implements TestConstants
+{
+   public UserTestCase(String name)
+   {
+      super(name);
+      getTestContext().setBaseUrl("http://localhost:8080/portal");
+//      getTestContext().setUserAgent("Mozilla");
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      // initialize your database connection here
+      IDatabaseConnection connection = Utils.getConnection();
+
+      // initialize your dataset here
+      IDataSet dataSet = Utils.getDataSet("resources/test/forums.xml");
+
+      try
+      {
+         Utils.resetAutoIncrement();
+         DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
+      }
+      finally
+      {
+         connection.close();
+      }
+   }
+
+    protected String getRandomSubject () {
+        Random random = new Random ();
+        return "test topic"+Long.toString((long)(random.nextFloat()*10000000L));
+    }
+    
+     protected String getRandomMessage () {
+         Random random = new Random ();
+         return "my message"+Long.toString((long)(random.nextFloat()*10000000000L));
+     }
+
+   public void loginUser()
+   {
+      beginAt("/index.html");
+      clickLink("standardlogin");
+      setFormElement("j_username", "user");
+      setFormElement("j_password", "user");
+      submit();
+   }
+
+   public void testReadIndex()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      assertTextPresent("Dummy demo category");
+      assertTextPresent("First forum");
+      assertTextPresent("Second forum");
+      assertLinkNotPresent("newTopic");
+   }
+
+   public void testReadForum()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      assertTextPresent("First forum");
+      assertTextPresent("Page <b>1</b> of");
+      assertLinkPresent("newTopic");
+   }
+
+   public void testPostTopic()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      clickLink("newTopic");
+      String newRandomSubject = getRandomSubject();
+      String newRandomMessage = getRandomMessage();
+      setFormElement("subject", newRandomSubject);
+      setFormElement("message", newRandomMessage);
+      submit("post");
+      assertLinkPresentWithText(newRandomSubject);
+      clickLinkWithText(newRandomSubject);
+      assertTextPresent(newRandomMessage);
+   }
+
+   /**
+    * Test page navigation
+    * This test suppose that there are 10 topics per page
+    */
+   public void testPost11Topics()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      clickLink("newTopic");
+      String newRandomSubject = getRandomSubject();
+      String newRandomMessage = getRandomMessage();
+      setFormElement("subject", newRandomSubject);
+      setFormElement("message", newRandomMessage);
+      submit("post");
+      
+      for (int i = 0; i < 10; i++)
+      {
+         String newRandomSubjectT =  getRandomSubject();
+         String newRandomMessageT = getRandomMessage();
+         clickLink("newTopic");
+         setFormElement("subject", newRandomSubjectT);
+         setFormElement("message", newRandomMessageT);
+         /*try  IT DOESN'T WORK WITH FLOOD INTERCEPTOR TURNED ON
+         {
+            Thread.sleep(30 * 1000);
+         }
+         catch (InterruptedException e)
+         {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+         }*/
+         submit("post");
+         
+      }
+      assertLinkPresentWithText("Next");
+      clickLinkWithText("Next");
+      assertTextPresent(newRandomSubject);
+      clickLinkWithText(newRandomSubject);
+      assertTextPresent(newRandomMessage);
+
+   }
+
+   public void testReplyTopic()
+   {
+      loginUser();
+      clickLinkWithText("forums");
+      clickLinkWithText("First forum");
+      clickLink("newTopic");
+      String newRandomSubject = getRandomSubject();
+      String newRandomMessage = getRandomMessage();
+      setFormElement("subject", newRandomSubject);
+      setFormElement("message", newRandomMessage);
+      submit("post");
+      clickLinkWithText(newRandomSubject);
+      clickLink("postReply");
+      newRandomMessage = getRandomMessage();
+      assertFormElementEquals("subject", "Re: "+newRandomSubject);
+      setFormElement("message", newRandomMessage);
+      // For flood control
+      /*try
+      {
+         Thread.sleep(30 * 1000);
+      }
+      catch (InterruptedException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }*/
+      submit("post");
+      assertTextPresent("Re: "+newRandomSubject);
+      assertTextPresent(newRandomMessage);
+   }
+
+
+}




More information about the jboss-svn-commits mailing list