roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r543386 - in /roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger: business/hibernate/HibernateUserManagerImpl.java ui/struts2/editor/Members.java
Date Fri, 01 Jun 2007 04:40:46 GMT
Author: agilliland
Date: Thu May 31 21:40:45 2007
New Revision: 543386

URL: http://svn.apache.org/viewvc?view=rev&rev=543386
Log:
fix for ROL-1424 where the members and membersInvite actions were making changes to weblog
permissions and the changes weren't being reflected on the page until after a refresh.  it
turns out that the problem was that we are not properly ensuring that both sides of the weblog
-> permissions relationship was being managed.


Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java?view=diff&rev=543386&r1=543385&r2=543386
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java
Thu May 31 21:40:45 2007
@@ -223,6 +223,11 @@
     }
         
     public void removePermissions(WeblogPermission perms) throws RollerException {
+        
+        // make sure associations are broken
+        perms.getWebsite().getPermissions().remove(perms);
+        perms.getUser().getPermissions().remove(perms);
+        
         this.strategy.remove(perms);
     }
         
@@ -383,6 +388,10 @@
         perms.setUser(user);
         perms.setPermissionMask(mask);
         this.strategy.store(perms);
+        
+        // manage associations
+        website.getPermissions().add(perms);
+        user.getPermissions().add(perms);
         
         return perms;
     }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java?view=diff&rev=543386&r1=543385&r2=543386
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java
Thu May 31 21:40:45 2007
@@ -18,6 +18,7 @@
 
 package org.apache.roller.weblogger.ui.struts2.editor;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -76,10 +77,17 @@
         
         List<WeblogPermission> permissions = getActionWeblog().getPermissions();
         
+        // we have to copy the permissions list so that when we remove permissions
+        // below we don't get ConcurrentModificationExceptions
+        List<WeblogPermission> permsList = new ArrayList();
+        for( WeblogPermission perm : permissions ) {
+            permsList.add(perm);
+        }
+        
         int removed = 0;
         int changed = 0;
         try {
-            for( WeblogPermission perms : permissions ) {
+            for( WeblogPermission perms : permsList ) {
                 
                 String sval = getParameter("perm-" + perms.getId());
                 if (sval != null) {



Mime
View raw message