[jboss-svn-commits] JBL Code SVN: r38347 - in labs/jbossforums/branches/noejbforums130P27: forums/src/main/org/jboss/portlet/forums and 6 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 12 14:10:23 EDT 2013


Author: sviluppatorefico
Date: 2013-06-12 14:10:23 -0400 (Wed, 12 Jun 2013)
New Revision: 38347

Modified:
   labs/jbossforums/branches/noejbforums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/PostImpl.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java
   labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml
   labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
Log:
bug fixing on create, modify and delete of categories, topics, forums and posts

Modified: labs/jbossforums/branches/noejbforums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -76,20 +76,15 @@
 
 	@Override
 	public User findUserByUserName(String arg0) throws IdentityException,
-			IllegalArgumentException, NoSuchUserException {
-		IdentitySearchCriteria identitySearchCriteria = new IdentitySearchCriteriaImpl();
-		User user = null;
-		try {
-			identitySearchCriteria.nameFilter(arg0);
-			user = new UserPL((org.picketlink.idm.api.User) persistenceManager.findUser(identitySearchCriteria).toArray()[0]);
-		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
-			ie.printStackTrace();
-		} catch (UnsupportedCriterium e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		return user;
-	}
+	IllegalArgumentException, NoSuchUserException {
+        User user = null;
+        try {
+	        user = new UserPL((org.picketlink.idm.api.User) persistenceManager.findUser(arg0));
+        } catch (org.picketlink.idm.common.exception.IdentityException ie) {
+	        ie.printStackTrace();
+        }
+        return user;
+    }
 
 	@Override
 	public Set findUsers(int arg0, int arg1) throws IdentityException,

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ForumsModule.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ForumsModule.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -484,7 +484,7 @@
     * @param post Post to delete
     * @throws ModuleException DOCUMENT_ME
     */
-   void removePost(Post post)
+   void removePost(Post post, boolean isLastPost)
       throws ModuleException;
 
    /**
@@ -779,5 +779,11 @@
     * @return
     */
    public List findPostsAsc(int limit) throws ModuleException;
+   
+   /**
+    * 
+    * @return
+    */
+   public void update(Object object);
 
 }

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -71,16 +71,11 @@
 
 	@Override
 	public User findUserByUserName(String arg0) throws IdentityException, IllegalArgumentException, NoSuchUserException {
-		IdentitySearchCriteria identitySearchCriteria = new IdentitySearchCriteriaImpl();
 		User user = null;
 		try {
-			identitySearchCriteria.nameFilter(arg0);
-			user = new UserPL((org.picketlink.idm.api.User) persistenceManager.findUser(identitySearchCriteria).toArray()[0]);
+			user = new UserPL((org.picketlink.idm.api.User) persistenceManager.findUser(arg0));
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
-		} catch (UnsupportedCriterium e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
 		}
 		return user;
 	}

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -713,7 +713,7 @@
           
 		if (poster.getId() == null || session.get(PosterImpl.class, poster.getId()) == null) 
 		    session.persist(poster);
-			session.merge(poster);
+		 session.merge(poster);
 		 // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
          session.save(poll);
          session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
@@ -833,9 +833,12 @@
       try
       {
          Session session = getSession();
-         session.save(poster);
+		 Poster posterOld = this.findPosterByUserId(poster.getUserId()); 
+		 if (posterOld == null) {
+			session.save(poster);
+		 }
+		 session.merge(poster);
 
-
          PostImpl post = new PostImpl();
          post.setMessage(message);
          post.setCreateDate(creationDate);
@@ -849,20 +852,23 @@
          }
 
 
-         session.save(post);
+         session.persist(post);
          session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
 
-         topic.addPost(post);
+         post.setTopic((TopicImpl) topic);
          //post.setTopic(topic);
 
          //topic.setLastPost(post);
          topic.setLastPostDate(post.getCreateDate());
          topic.setReplies(topic.getReplies() + 1);
-         session.save(topic);
+         session.merge(topic);
          //forum.setLastPost(post);
          forum.addPostSize();
+         session.merge(forum);
          notificationEngine.scheduleForNotification(post.getId(), NotificationEngine.MODE_REPLY);
-         session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
+         try {
+             session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
+         } catch(Exception e) {}
          return post;
       }
       catch (HibernateException e)
@@ -988,7 +994,7 @@
       }
    }
 
-   public void removePost(Post post)
+   public void removePost(Post post, boolean isLastPost)
       throws ModuleException
    {
       Session session = getSession();
@@ -996,16 +1002,24 @@
       {
          //session.flush();
          //session.delete(post);
-         if (post.getTopic() != null)
-         {
-            post.getTopic().getPosts().remove(post);
-            post.setTopic(null);
-         }
-         else
-         {
+		 Topic topic = post.getTopic();
+	     Forum forum = topic.getForum();
+         topic.setReplies(topic.getReplies() - 1);
+         forum.setPostCount(forum.getPostCount() - 1);	
+         topic.getPosts().remove(post);
+		 List posts = topic.getPosts();
+		 PostImpl lastPost = (PostImpl) posts.get(posts.size() - 1);
+		 if (isLastPost) {
+			topic.setLastPostDate(lastPost.getCreateDate());
+		 }
+		 session.merge(topic);
+		 session.merge(forum);
+		 try {
             session.delete(post);
-         }
-         session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
+		 } catch (Exception e) {}
+		 try {
+            session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
+		 } catch (Exception e) {}
       }
       catch (HibernateException e)
       {
@@ -1051,13 +1065,17 @@
             topic.setForum(null);
             forum.setPostCount(forum.getPostCount()-topic.getReplies()-1);
             forum.setTopicCount(forum.getTopicCount()-1);
+            session.merge(forum);
+			session.delete(session.merge(topic));
             //session.delete(topic);
          }
          else
          {
             session.delete(topic);
          }
-         session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
+         try {
+            session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required for clustered versions
+         } catch (Exception e) {}
          //session.flush();
       }
       catch (HibernateException e)
@@ -2169,6 +2187,14 @@
 		}
 	}
 
+	public void update(Object object) {
+		Session session = getSession();
+		session.merge(object);
+		try {
+		   session.flush();
+		} catch (Exception e) {}
+	}
+
 	// Luca Stancapiano end
 }
 

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/PostImpl.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/PostImpl.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/impl/PostImpl.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -77,15 +77,7 @@
    private List attachments;
 
    /**
-    * Creates a new {@link PostImpl} object.
     */
-   public PostImpl()
-   {
-      attachments = new LinkedList();
-   }
-
-   /**
-    */
    public Topic getTopic()
    {
       return topic;

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -148,14 +148,7 @@
 	         }
 	         else
 	         {
-	            getForumsModule().removePost(post);
-	            topic.setReplies(topic.getReplies() - 1);
-	            forum.setPostCount(forum.getPostCount() - 1);	            
-	            if(isLastPost)
-	            {
-	               Post lastPost = topic.getLastPost();
-	               topic.setLastPostDate(lastPost.getCreateDate());
-	            }
+	            getForumsModule().removePost(post, isLastPost);
 	            
 	            //set the proper navigation state
 	            navState = Constants.SUCCESS;

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -333,6 +333,8 @@
             {
                 post.addAttachment((Attachment)itr.next());
             }
+            BaseController.getForumsModule().update(topic);
+            BaseController.getForumsModule().update(post);
                                     	       	        
 	        //set the proper navigation state
 	        navState = Constants.SUCCESS;	        	        

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -208,6 +208,7 @@
            }
            
            //actually post a reply to this topic in the forum
+           poster.incrementPostCount();
            Post post = BaseController.getForumsModule().createPost(topic,
 	           forum,
 	           message,
@@ -215,7 +216,6 @@
 	           poster,
 	           (List)this.produceAttachments(this.attachments) //attachments
            );           
-           poster.incrementPostCount();
            
                                             
            //setup the navigation state           

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewTopic.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -252,6 +252,7 @@
                 this.topic = fm.findTopicById(topicId);
             }
             topic.setViewCount(topic.getViewCount()+1);
+            fm.update(topic);
             
             int postCount = topic.getReplies()+1;
             

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java	2013-06-12 18:10:23 UTC (rev 38347)
@@ -118,7 +118,7 @@
          for (Iterator ti = posts.iterator(); ti.hasNext();)
          {
             Post post = (Post)ti.next();
-            forumsModule.removePost(post);
+            forumsModule.removePost(post, false);
          }
      	 /* Luca Stancapiano - findPosts method need to a forumInstanceId argument 
             to take only categories of a specific forum instance 

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml	2013-06-12 18:10:23 UTC (rev 38347)
@@ -290,7 +290,7 @@
 </div>
 
 <div class="PostviewStyle">
-<h:form id="post" enctype="multipart/form-data">
+<h:form id="post">
 <table border="0" cellpadding="5" cellspacing="0" width="100%" name="table" id="table" >
 
     <!-- keeps the topic where this post is being edited in context, this is a control parameter -->

Modified: labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
===================================================================
--- labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml	2013-06-12 18:07:10 UTC (rev 38346)
+++ labs/jbossforums/branches/noejbforums130P27/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml	2013-06-12 18:10:23 UTC (rev 38347)
@@ -293,7 +293,7 @@
 </div>
 
 <div class="PostviewStyle">
-<h:form id="post" enctype="multipart/form-data">
+<h:form id="post">
 <table border="0" cellpadding="5" cellspacing="0" width="100%" name="table" id="table" >
 
     <!-- keeps the forum where this topic is being created in context, this is a control parameter -->



More information about the jboss-svn-commits mailing list