Update of 
/var/cvs/contributions/CMSContainer/cmsc/security/src/java/com/finalist/cmsc/security
In directory 
james.mmbase.org:/tmp/cvs-serv28383/cmsc/security/src/java/com/finalist/cmsc/security

Modified Files:
      Tag: b1_4
        SecurityUtil.java 
Log Message:
CMSC-973, it will now correctly merge the rights of multiple groups.



See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/security/src/java/com/finalist/cmsc/security
See also: http://www.mmbase.org/jira/browse/CMSC-973


Index: SecurityUtil.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/security/src/java/com/finalist/cmsc/security/SecurityUtil.java,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -u -b -r1.11.2.1 -r1.11.2.2
--- SecurityUtil.java   20 Jun 2008 14:37:26 -0000      1.11.2.1
+++ SecurityUtil.java   26 Jun 2008 16:38:22 -0000      1.11.2.2
@@ -154,12 +154,30 @@
                            Node extraGroup = groups.getNode(i);
                            fillChannelsWithRole(extraGroup, extraRoles, 
treeManagers, relationName);
 
+                           // upgrade user role map based on the data of the 
new group data map
+                  for (Map.Entry<String, UserRole> entry : 
channelsWithRole.entrySet()) {
+                     String path = entry.getKey();
+                     UserRole userRole = entry.getValue();
+                     UserRole newGroupRole = getRole(path, extraRoles);
+                     if (newGroupRole != null && userRole.getRole().getId() < 
newGroupRole.getRole().getId()) {
+                         channelsWithRole.put(path, newGroupRole);
+                     }
+                 }
+                 
+                 // add missing data to user role map based on new group data 
map
                            for (Map.Entry<String, UserRole> entry : 
extraRoles.entrySet()) {
                                String extraPath = entry.getKey();
-                               UserRole extraRole = entry.getValue();
+                     UserRole newGroupRole = entry.getValue();
                                UserRole channelRole = getRole(extraPath, 
channelsWithRole);
-                               if (channelRole == null || 
channelRole.getRole().getId() < extraRole.getRole().getId()) {
-                                   channelsWithRole.put(extraPath, extraRole);
+                     Role userRole;
+                     if (channelRole == null) {
+                        userRole = Role.NONE;
+                     }
+                     else {
+                        userRole = channelRole.getRole();
+                     }
+                     if (userRole.getId() < newGroupRole.getRole().getId()) {
+                         channelsWithRole.put(extraPath, newGroupRole);
                                }
                            }
                        }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to