[jboss-svn-commits] JBL Code SVN: r7828 - in labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums: impl ui/action

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Nov 25 13:49:12 EST 2006


Author: unibrew
Date: 2006-11-25 13:49:09 -0500 (Sat, 25 Nov 2006)
New Revision: 7828

Modified:
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
Log:
[JBFORUMS-145] I solved problem with NPE showing after deleting of empty forum.

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2006-11-25 14:01:17 UTC (rev 7827)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2006-11-25 18:49:09 UTC (rev 7828)
@@ -195,7 +195,7 @@
              Session session = getSession();
              Query query = session.createQuery("select f " +
                                                "from ForumImpl f " +
-                                               "join f.topics " +
+                                               "left outer join fetch f.topics " +
                                                "where f.id = :forumId ");
              query.setParameter("forumId",id);
              List forumList = query.list();

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java	2006-11-25 14:01:17 UTC (rev 7827)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java	2006-11-25 18:49:09 UTC (rev 7828)
@@ -434,33 +434,34 @@
        try
        { 
             int forumId = -1;
-	        String cour = ForumUtil.getParameter(Constants.p_forumId);
-	        if(cour!=null && cour.trim().length()>0)
-	        {
-	            forumId = Integer.parseInt(cour);
-	        }
-	        
-	        Forum source = BaseController.getForumsModule().findForumByIdFetchTopics(new Integer(forumId));
-	        
-	        //move all the topics/posts of this forum to the specified target forum
-	        if(this.selectedForum!=-1)
-	        {
-	            Forum target = BaseController.getForumsModule().findForumByIdFetchTopics(new Integer(selectedForum));
-	            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);
-	            }
-	            
-	            //clear the source out before delete
-	            source.setTopics(new ArrayList());
-	        }
-	        
-	        
-	        //means delete all topic/posts on this forum            
+	    String cour = ForumUtil.getParameter(Constants.p_forumId);
+	    if(cour!=null && cour.trim().length()>0)
+	    {
+	        forumId = Integer.parseInt(cour);
+	    }
+	    Forum source = null;
+	    //move all the topics/posts of this forum to the specified target forum
+            if(this.selectedForum!=-1)
+            {
+                source = BaseController.getForumsModule().findForumByIdFetchTopics(new Integer(forumId));
+                Forum target = BaseController.getForumsModule().findForumByIdFetchTopics(new Integer(selectedForum));
+                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);
+                }
+                
+                //clear the source out before delete
+                source.setTopics(new ArrayList());
+            } else {
+                source = BaseController.getForumsModule().findForumById(new Integer(forumId));
+            }
+            
+            
+            //means delete all topic/posts on this forum            
             BaseController.getForumsModule().removeForum(source);
 	        
             String start = JSFUtil.getBundleMessage("ResourceJSF","Forum_deleted_0");




More information about the jboss-svn-commits mailing list