[cvs] expresso commit by lhamel: change implementation of all group
name
JCorporate Ltd
jcorp at jcorp2.servlets.net
Thu Nov 25 15:16:27 PST 2004
Log Message:
-----------
change implementation of all group name comparisons
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
RowSecuredDBObject.java
Revision Data
-------------
Index: RowSecuredDBObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java -u -r1.39 -r1.40
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java
@@ -590,11 +590,7 @@
if (!result) {
// check groups
- List groups = this.getAdministrateGroups();
-
- // intersection of two groups is retained
- groups.retainAll(user.getGroups());
- result = groups.size() > 0;
+ result = doUsersGroupsIntersect(user, getAdministrateGroups());
}
return result;
@@ -638,26 +634,28 @@
if (!result) {
// check groups
- List groups = this.getReadGroups();
-
- // intersection of two groups is retained
-
/**
* @todo rewrite as a multidbobject join
*/
- for (Iterator iterator = user.getGroups().iterator(); iterator.hasNext();) {
- String userGrpname = (String) iterator.next();
- for (Iterator iterator1 = groups.iterator(); iterator1.hasNext();) {
- String readGrpName = (String) iterator1.next();
- result = readGrpName.equals(userGrpname);
- if ( result ) break;
- }
- }
+ result = doUsersGroupsIntersect(user, getReadGroups());
}
return result;
}
+ private boolean doUsersGroupsIntersect(User user, List groups) throws DBException {
+ boolean result = false;
+ for (Iterator iterator = user.getGroups().iterator(); iterator.hasNext();) {
+ String userGrpname = (String) iterator.next();
+ for (Iterator iterator1 = groups.iterator(); iterator1.hasNext();) {
+ String readGrpName = (String) iterator1.next();
+ result = readGrpName.equals(userGrpname);
+ if ( result ) break;
+ }
+ }
+ return result;
+ }
+
/**
* @return true if requesting id has permission to write
* @throws DBException upon database communication error
@@ -694,11 +692,7 @@
if (!result) {
// check groups
- List groups = this.getWriteGroups();
-
- // intersection of two groups is retained
- groups.retainAll(user.getGroups());
- result = groups.size() > 0;
+ result = doUsersGroupsIntersect(user, getWriteGroups());
}
return result;
More information about the cvs
mailing list