Commit c4af3a75 authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

Changed occurences of HashSet to the more abstact Set in declarations where appropriate.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/pep@8942 b35dd754-fafc-0310-a699-88a17e54d16e
parent ccc6da6b
...@@ -60,6 +60,7 @@ import java.util.ArrayList; ...@@ -60,6 +60,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
...@@ -90,10 +91,12 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -90,10 +91,12 @@ import java.util.concurrent.ConcurrentHashMap;
* @author Armando Jagucki * @author Armando Jagucki
* *
*/ */
public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ServerFeaturesProvider, UserIdentitiesProvider, UserItemsProvider, public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ServerFeaturesProvider,
PresenceEventListener, RosterEventListener, PacketInterceptor { UserIdentitiesProvider, UserItemsProvider, PresenceEventListener, RosterEventListener, PacketInterceptor {
// Map of PEP services. Table, Key: bare JID (String); Value: PEPService /**
* Map of PEP services. Table, Key: bare JID (String); Value: PEPService
*/
private Map<String, PEPService> pepServices; private Map<String, PEPService> pepServices;
/** /**
...@@ -103,7 +106,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -103,7 +106,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
* of a user is associated with a set of PEP node IDs they are interested in receiving notifications * of a user is associated with a set of PEP node IDs they are interested in receiving notifications
* for. * for.
*/ */
private Map<String, HashSet<String>> filteredNodesMap = new ConcurrentHashMap<String, HashSet<String>>(); private Map<String, Set<String>> filteredNodesMap = new ConcurrentHashMap<String, Set<String>>();
private IQHandlerInfo info; private IQHandlerInfo info;
...@@ -111,12 +114,12 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -111,12 +114,12 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
/** /**
* A map of all known full JIDs that have sent presences from a remote server. * A map of all known full JIDs that have sent presences from a remote server.
* table: key Bare JID (String); value HashSet of JIDs * table: key Bare JID (String); value Set of JIDs
* *
* This map is convenient for sending notifications to the full JID of remote users * This map is convenient for sending notifications to the full JID of remote users
* that have sent available presences to the PEP service. * that have sent available presences to the PEP service.
*/ */
private Map<String, HashSet<JID>> knownRemotePresences = new ConcurrentHashMap<String, HashSet<JID>>(); private Map<String, Set<JID>> knownRemotePresences = new ConcurrentHashMap<String, Set<JID>>();
private static final String GET_PEP_SERVICES = "SELECT DISTINCT serviceID FROM pubsubNode"; private static final String GET_PEP_SERVICES = "SELECT DISTINCT serviceID FROM pubsubNode";
...@@ -555,7 +558,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -555,7 +558,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
// If none of the feature variables contain the node ID ending in "+notify", // If none of the feature variables contain the node ID ending in "+notify",
// remove it from the set of filtered nodes that jidFrom is interested in being // remove it from the set of filtered nodes that jidFrom is interested in being
// notified about. // notified about.
HashSet<String> supportedNodesSet = new HashSet<String>(); Set<String> supportedNodesSet = new HashSet<String>();
while (featuresIterator.hasNext()) { while (featuresIterator.hasNext()) {
Element featureElement = (Element) featuresIterator.next(); Element featureElement = (Element) featuresIterator.next();
...@@ -570,7 +573,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -570,7 +573,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
for (String nodeID : supportedNodesSet) { for (String nodeID : supportedNodesSet) {
if (nodeID.endsWith("+notify")) { if (nodeID.endsWith("+notify")) {
// Add the nodeID to the sender's filteredNodesSet. // Add the nodeID to the sender's filteredNodesSet.
HashSet<String> filteredNodesSet = filteredNodesMap.get(jidFrom); Set<String> filteredNodesSet = filteredNodesMap.get(jidFrom);
if (filteredNodesSet == null) { if (filteredNodesSet == null) {
filteredNodesSet = new HashSet<String>(); filteredNodesSet = new HashSet<String>();
...@@ -598,7 +601,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -598,7 +601,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
else { else {
// Remove the nodeID from the sender's filteredNodesSet if nodeIDPlusNotify // Remove the nodeID from the sender's filteredNodesSet if nodeIDPlusNotify
// is not in supportedNodesSet. // is not in supportedNodesSet.
HashSet<String> filteredNodesSet = filteredNodesMap.get(jidFrom); Set<String> filteredNodesSet = filteredNodesMap.get(jidFrom);
if (filteredNodesSet == null) { if (filteredNodesSet == null) {
return; return;
} }
...@@ -628,7 +631,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -628,7 +631,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
Log.debug("PEP: received presence from: " + jidFrom + " to: " + jidTo); Log.debug("PEP: received presence from: " + jidFrom + " to: " + jidTo);
} }
HashSet<JID> remotePresenceSet = knownRemotePresences.get(jidTo.toBareJID()); Set<JID> remotePresenceSet = knownRemotePresences.get(jidTo.toBareJID());
Presence.Type type = ((Presence) packet).getType(); Presence.Type type = ((Presence) packet).getType();
if (type != null && type == Presence.Type.unavailable) { if (type != null && type == Presence.Type.unavailable) {
...@@ -668,7 +671,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -668,7 +671,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
* *
* @return the filteredNodesMap * @return the filteredNodesMap
*/ */
public Map<String, HashSet<String>> getFilteredNodesMap() { public Map<String, Set<String>> getFilteredNodesMap() {
return filteredNodesMap; return filteredNodesMap;
} }
...@@ -677,7 +680,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -677,7 +680,7 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
* *
* @return the knownRemotePresences map * @return the knownRemotePresences map
*/ */
public Map<String, HashSet<JID>> getKnownRemotePresenes() { public Map<String, Set<JID>> getKnownRemotePresenes() {
return knownRemotePresences; return knownRemotePresences;
} }
......
...@@ -47,6 +47,7 @@ import java.util.Collection; ...@@ -47,6 +47,7 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.Timer; import java.util.Timer;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -326,7 +327,7 @@ public class PEPService implements PubSubService { ...@@ -326,7 +327,7 @@ public class PEPService implements PubSubService {
// If the recipient subscribed with a bare JID and this PEPService can retrieve // If the recipient subscribed with a bare JID and this PEPService can retrieve
// presence information for the recipient, collect all of their full JIDs and // presence information for the recipient, collect all of their full JIDs and
// send the notification to each below. // send the notification to each below.
HashSet<JID> recipientFullJIDs = new HashSet<JID>(); Set<JID> recipientFullJIDs = new HashSet<JID>();
if (recipientJID.getResource() == null && XMPPServer.getInstance().isLocal(recipientJID)) { if (recipientJID.getResource() == null && XMPPServer.getInstance().isLocal(recipientJID)) {
for (ClientSession clientSession : SessionManager.getInstance().getSessions(recipientJID.getNode())) { for (ClientSession clientSession : SessionManager.getInstance().getSessions(recipientJID.getNode())) {
recipientFullJIDs.add(clientSession.getAddress()); recipientFullJIDs.add(clientSession.getAddress());
...@@ -335,10 +336,10 @@ public class PEPService implements PubSubService { ...@@ -335,10 +336,10 @@ public class PEPService implements PubSubService {
else { else {
// Since recipientJID is not local, try to get presence info from cached known remote // Since recipientJID is not local, try to get presence info from cached known remote
// presences. // presences.
Map<String, HashSet<JID>> knownRemotePresences = Map<String, Set<JID>> knownRemotePresences =
XMPPServer.getInstance().getIQPEPHandler().getKnownRemotePresenes(); XMPPServer.getInstance().getIQPEPHandler().getKnownRemotePresenes();
HashSet<JID> remotePresenceSet = knownRemotePresences.get(getAddress().toBareJID()); Set<JID> remotePresenceSet = knownRemotePresences.get(getAddress().toBareJID());
if (remotePresenceSet != null) { if (remotePresenceSet != null) {
for (JID remotePresence : remotePresenceSet) { for (JID remotePresence : remotePresenceSet) {
if (recipientJID.toBareJID().equals(remotePresence.toBareJID())) { if (recipientJID.toBareJID().equals(remotePresence.toBareJID())) {
...@@ -380,8 +381,8 @@ public class PEPService implements PubSubService { ...@@ -380,8 +381,8 @@ public class PEPService implements PubSubService {
// Check if the recipientFullJID is interested in notifications for this node. // Check if the recipientFullJID is interested in notifications for this node.
// If the recipient has not yet requested any notification filtering, continue and send // If the recipient has not yet requested any notification filtering, continue and send
// the notification. // the notification.
Map<String, HashSet<String>> filteredNodesMap = XMPPServer.getInstance().getIQPEPHandler().getFilteredNodesMap(); Map<String, Set<String>> filteredNodesMap = XMPPServer.getInstance().getIQPEPHandler().getFilteredNodesMap();
HashSet<String> filteredNodesSet = filteredNodesMap.get(recipientFullJID.toString()); Set<String> filteredNodesSet = filteredNodesMap.get(recipientFullJID.toString());
if (filteredNodesSet != null && !filteredNodesSet.contains(nodeID + "+notify")) { if (filteredNodesSet != null && !filteredNodesSet.contains(nodeID + "+notify")) {
return; return;
} }
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<p>Implementation of Personal Eventing via Pubsub (XEP-0163).</p>
</body>
</html>
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