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 { ...@@ -107,9 +107,9 @@ public class Roster implements Cacheable, Externalizable {
// Add RosterItems that belong to the personal roster // Add RosterItems that belong to the personal roster
rosterItemProvider = RosterItemProvider.getInstance(); rosterItemProvider = RosterItemProvider.getInstance();
Iterator items = rosterItemProvider.getItems(username); Iterator<RosterItem> items = rosterItemProvider.getItems(username);
while (items.hasNext()) { 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 // Check if the item (i.e. contact) belongs to a shared group of the user. Add the
// shared group (if any) to this item // shared group (if any) to this item
for (Group group : sharedGroups) { for (Group group : sharedGroups) {
...@@ -123,14 +123,16 @@ public class Roster implements Cacheable, Externalizable { ...@@ -123,14 +123,16 @@ public class Roster implements Cacheable, Externalizable {
} }
// Add RosterItems that belong only to shared groups // Add RosterItems that belong only to shared groups
Map<JID,List<Group>> sharedUsers = getSharedUsers(sharedGroups); 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 { try {
Collection<Group> itemGroups = new ArrayList<Group>(); Collection<Group> itemGroups = new ArrayList<Group>();
String nickname = ""; String nickname = "";
RosterItem item = new RosterItem(jid, RosterItem.SUB_TO, RosterItem.ASK_NONE, RosterItem item = new RosterItem(jid, RosterItem.SUB_TO, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, nickname , null); RosterItem.RECV_NONE, nickname , null);
// Add the shared groups to the new roster item // Add the shared groups to the new roster item
for (Group group : sharedUsers.get(jid)) { for (Group group : groups) {
if (group.isUser(jid)) { if (group.isUser(jid)) {
item.addSharedGroup(group); item.addSharedGroup(group);
itemGroups.add(group); itemGroups.add(group);
...@@ -148,7 +150,7 @@ public class Roster implements Cacheable, Externalizable { ...@@ -148,7 +150,7 @@ public class Roster implements Cacheable, Externalizable {
// Set subscription type to FROM if the contact does not belong to any of // Set subscription type to FROM if the contact does not belong to any of
// the associated shared groups // the associated shared groups
boolean belongsToGroup = false; boolean belongsToGroup = false;
for (Group group : sharedUsers.get(jid)) { for (Group group : groups) {
if (group.isUser(jid)) { if (group.isUser(jid)) {
belongsToGroup = true; belongsToGroup = true;
} }
...@@ -174,7 +176,7 @@ public class Roster implements Cacheable, Externalizable { ...@@ -174,7 +176,7 @@ public class Roster implements Cacheable, Externalizable {
} }
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
Log.error("Groups (" + sharedUsers.get(jid) + ") include non-existent username (" + Log.error("Groups (" + groups + ") include non-existent username (" +
jid.getNode() + jid.getNode() +
")"); ")");
} }
......
...@@ -494,7 +494,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us ...@@ -494,7 +494,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
* @param newUser the newly created user. * @param newUser the newly created user.
* @param params event parameters. * @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); JID newUserJID = server.createJID(newUser.getUsername(), null);
// Shared public groups that are public should have a presence subscription // Shared public groups that are public should have a presence subscription
// of type FROM for the new user // of type FROM for the new user
...@@ -530,7 +530,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us ...@@ -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 // 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 // for the deleted user should no longer have a reference to the deleted user
JID userJID = server.createJID(user.getUsername(), null); JID userJID = server.createJID(user.getUsername(), null);
...@@ -570,7 +570,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us ...@@ -570,7 +570,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
deleteRoster(userJID); deleteRoster(userJID);
} }
public void userModified(User user, Map params) { public void userModified(User user, Map<String,Object> params) {
//Do nothing //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