public boolean add(Object member) {
// Do nothing if the provider is read-only.
if (provider.isReadOnly()) {
return false;
}
JID user = (JID) member;
// Find out if the user was already a group user.
boolean alreadyGroupUser;
if (adminCollection) {
alreadyGroupUser = members.contains(user);
}
else {
alreadyGroupUser = administrators.contains(user);
}
if (users.add(user)) {
if (alreadyGroupUser) {
// Update the group user privileges in the backend store.
provider.updateMember(name, user, adminCollection);
}
else {
// Add the group user to the backend store.
provider.addMember(name, user, adminCollection);
}
// Fire event.
if (adminCollection) {
Map<String, String> params = new HashMap<String, String>();
params.put("admin", user.toString());
if (alreadyGroupUser) {
GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.member_removed, params);
}
GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.admin_added, params);
}
else {
Map<String, String> params = new HashMap<String, String>();
params.put("member", user.toString());
if (alreadyGroupUser) {
GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.admin_removed, params);
}
GroupEventDispatcher.dispatchEvent(Group.this,