[jboss-svn-commits] JBL Code SVN: r7829 - in labs/jbossforums/branches/forums26/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:51:58 EST 2006
Author: unibrew
Date: 2006-11-25 13:51:56 -0500 (Sat, 25 Nov 2006)
New Revision: 7829
Modified:
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
labs/jbossforums/branches/forums26/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/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2006-11-25 18:49:09 UTC (rev 7828)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2006-11-25 18:51:56 UTC (rev 7829)
@@ -197,7 +197,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/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-11-25 18:49:09 UTC (rev 7828)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-11-25 18:51:56 UTC (rev 7829)
@@ -433,33 +433,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