Update of
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms
In directory
james.mmbase.org:/tmp/cvs-serv20684/community/src/java/com/finalist/cmsc/community/forms
Modified Files:
GroupAction.java
Log Message:
removal of user from group works also
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms
Index: GroupAction.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms/GroupAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- GroupAction.java 8 Feb 2008 13:13:28 -0000 1.2
+++ GroupAction.java 8 Feb 2008 15:36:16 -0000 1.3
@@ -38,7 +38,6 @@
String id = groupForm.getName();
// get all users
- // NodeList users = SecurityUtil.getUsers(cloud);
AuthenticationService as = getAuthenticationService();
List<Authentication> users = as.findAuthentications();
@@ -53,7 +52,6 @@
}
// get members and remove them from users
for (String memberName : groupForm.getMembers()) {
- // Node member = cloud.getNode(memberNumber);
String label = memberName;
LabelValueBean beanMember = new
LabelValueBean(label, label);
membersList.add(beanMember);
@@ -66,19 +64,13 @@
// validate
ActionMessages errors = new ActionMessages();
- // Node groupNode = getOrCreateNode(groupForm, cloud,
- // SecurityUtil.GROUP);
if (groupForm.getAction().equalsIgnoreCase(ACTION_ADD))
{
if (id == null || id.length() < 3) {
errors.add("groupname", new
ActionMessage("error.groupname.invalid"));
saveErrors(request, errors);
return actionMapping.getInputForward();
} else {
- String name = id;
- // NodeList list =
- //
MMBaseAction.getCloudFromSession(request).getNodeManager("mmbasegroups").getList(
- // "name='" + name + "'", null, null);
- boolean exist =
aus.authorityExists(name);
+ boolean exist = aus.authorityExists(id);
if (exist) {
errors.add("groupname", new
ActionMessage("error.groupname.alreadyexists"));
saveErrors(request, errors);
@@ -86,22 +78,27 @@
}
}
- // groupNode.setStringValue("name",
groupForm.getName());
aus.createAuthority(null, id);
}
- // groupNode.commit();
- // SecurityUtil.setGroupMembers(cloud, groupNode,
- // groupForm.getMembers());
if (id != null) {
+ List<Authentication> current =
as.findAuthenticationsForAuthority(id);
for (String memberName :
groupForm.getMembers()) {
+ Authentication m =
as.findAuthentication(memberName);
+ if (!current.contains(m)) {
as.addAuthorityToUser(memberName, id);
+ } else {
+ current.remove(m);
+ }
+ }
+ for (Iterator<Authentication> iter =
current.iterator(); iter.hasNext();) {
+ Authentication user = iter.next();
+
as.removeAuthorityFromUser(user.getUserId(), id);
}
}
}
removeFromSession(request, actionForm);
return actionMapping.findForward(SUCCESS);
-
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs