Commit 758b9306 authored by guus's avatar guus

* The Roster implementation accessed the value of a Map entry, using a key...

* The Roster implementation accessed the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup. (thank you FindBugs);
* Applied Generics to a couple of methods.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10835 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3cb8d51a
......@@ -107,9 +107,9 @@ public class Roster implements Cacheable, Externalizable {
// Add RosterItems that belong to the personal roster
rosterItemProvider = RosterItemProvider.getInstance();
Iterator items = rosterItemProvider.getItems(username);
Iterator<RosterItem> items = rosterItemProvider.getItems(username);
while (items.hasNext()) {
RosterItem item = (RosterItem)items.next();
RosterItem item = items.next();
// Check if the item (i.e. contact) belongs to a shared group of the user. Add the
// shared group (if any) to this item
for (Group group : sharedGroups) {
......@@ -123,14 +123,16 @@ public class Roster implements Cacheable, Externalizable {
}
// Add RosterItems that belong only to shared groups
Map<JID,List<Group>> sharedUsers = getSharedUsers(sharedGroups);
for (JID jid : sharedUsers.keySet()) {
for (Map.Entry<JID, List<Group>> entry : sharedUsers.entrySet()) {
JID jid = entry.getKey();
List<Group> groups = entry.getValue();
try {
Collection<Group> itemGroups = new ArrayList<Group>();
String nickname = "";
RosterItem item = new RosterItem(jid, RosterItem.SUB_TO, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, nickname , null);
// Add the shared groups to the new roster item
for (Group group : sharedUsers.get(jid)) {
for (Group group : groups) {
if (group.isUser(jid)) {
item.addSharedGroup(group);
itemGroups.add(group);
......@@ -148,7 +150,7 @@ public class Roster implements Cacheable, Externalizable {
// Set subscription type to FROM if the contact does not belong to any of
// the associated shared groups
boolean belongsToGroup = false;
for (Group group : sharedUsers.get(jid)) {
for (Group group : groups) {
if (group.isUser(jid)) {
belongsToGroup = true;
}
......@@ -174,7 +176,7 @@ public class Roster implements Cacheable, Externalizable {
}
}
catch (UserNotFoundException e) {
Log.error("Groups (" + sharedUsers.get(jid) + ") include non-existent username (" +
Log.error("Groups (" + groups + ") include non-existent username (" +
jid.getNode() +
")");
}
......
......@@ -494,7 +494,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
* @param newUser the newly created user.
* @param params event parameters.
*/
public void userCreated(User newUser, Map params) {
public void userCreated(User newUser, Map<String,Object> params) {
JID newUserJID = server.createJID(newUser.getUsername(), null);
// Shared public groups that are public should have a presence subscription
// of type FROM for the new user
......@@ -530,7 +530,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
}
}
public void userDeleting(User user, Map params) {
public void userDeleting(User user, Map<String,Object> params) {
// Shared public groups that have a presence subscription of type FROM
// for the deleted user should no longer have a reference to the deleted user
JID userJID = server.createJID(user.getUsername(), null);
......@@ -570,7 +570,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
deleteRoster(userJID);
}
public void userModified(User user, Map params) {
public void userModified(User user, Map<String,Object> params) {
//Do nothing
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment