Commit 3df66a4c authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

New interface: UserIdentitiesProvider. Makes IQDiscoInfoHandler more general...

New interface: UserIdentitiesProvider. Makes IQDiscoInfoHandler more general for discovering identities of registered users.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches@8774 b35dd754-fafc-0310-a699-88a17e54d16e
parent ef06d092
......@@ -27,6 +27,7 @@ import org.jivesoftware.openfire.disco.IQDiscoItemsHandler;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.jivesoftware.openfire.disco.ServerIdentitiesProvider;
import org.jivesoftware.openfire.disco.ServerItemsProvider;
import org.jivesoftware.openfire.disco.UserIdentitiesProvider;
import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager;
import org.jivesoftware.openfire.filetransfer.FileTransferManager;
import org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy;
......@@ -1246,6 +1247,21 @@ public class XMPPServer {
}
return answer;
}
/**
* Returns a list with all the modules that provide "discoverable" user identities.
*
* @return a list with all the modules that provide "discoverable" user identities.
*/
public List<UserIdentitiesProvider> getUserIdentitiesProviders() {
List<UserIdentitiesProvider> answer = new ArrayList<UserIdentitiesProvider>();
for (Module module : modules.values()) {
if (module instanceof UserIdentitiesProvider) {
answer.add((UserIdentitiesProvider) module);
}
}
return answer;
}
/**
* Returns the <code>IQDiscoInfoHandler</code> registered with this server. The
......
......@@ -286,21 +286,21 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
for (ServerFeaturesProvider provider : server.getServerFeaturesProviders()) {
addServerFeaturesProvider(provider);
}
// Track the implementors of ServerIdentitiesProvider so that we can collect the identities
// Collect the implementors of ServerIdentitiesProvider so that we can collect the identities
// for protocols supported by the server
for (ServerIdentitiesProvider provider : server.getServerIdentitiesProviders()) {
for (Iterator<Element> it = provider.getIdentities(); it.hasNext();) {
serverIdentities.add(it.next());
}
}
// FIXME: Create a UserIdentityProvider interface
if (server.getIQPEPHandler() != null) {
Element userIdentity = DocumentHelper.createElement("identity");
userIdentity.addAttribute("category", "pubsub");
userIdentity.addAttribute("type", "pep");
registeredUserIdentities.add(0, userIdentity);
// Collect the implementors of UserIdentitiesProvider so that we can collect identities
// for registered users.
for (UserIdentitiesProvider provider : server.getUserIdentitiesProviders()) {
for (Iterator<Element> it = provider.getIdentities(); it.hasNext();) {
registeredUserIdentities.add(it.next());
}
}
setProvider(server.getServerInfo().getName(), getServerInfoProvider());
// Listen to cluster events
ClusterManager.addListener(this);
......
......@@ -17,7 +17,7 @@ import org.dom4j.Element;
/**
* <p>
* A <code>ServerIdentityProvider</code> is responsible for providing the identities
* A <code>ServerIdentitiesProvider</code> is responsible for providing the identities
* of protocols supported by the SERVER. An example of a server identity is that
* for PEP (XEP-0163): <identity category="pubsub" type="pep" />
* <p/>
......
......@@ -18,6 +18,7 @@ import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.jivesoftware.openfire.disco.ServerIdentitiesProvider;
import org.jivesoftware.openfire.disco.UserIdentitiesProvider;
import org.jivesoftware.openfire.handler.IQHandler;
import org.jivesoftware.openfire.pubsub.LeafNode;
import org.jivesoftware.openfire.pubsub.PubSubEngine;
......@@ -59,7 +60,7 @@ import java.util.concurrent.ConcurrentHashMap;
*
*/
public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
ServerFeaturesProvider {
ServerFeaturesProvider, UserIdentitiesProvider {
// Map of PEP services. Table, Key: bare JID (String); Value: PEPService
private Map<String, PEPService> pepServices;
......@@ -164,8 +165,8 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
}
/**
* Implements ServerIdentitiesProvider, adding the PEP identity to the
* server's disco#info result.
* Implements ServerIdentitiesProvider and UserIdentitiesProvider, adding
* the PEP identity to the respective disco#info results.
*/
public Iterator<Element> getIdentities() {
ArrayList<Element> identities = new ArrayList<Element>();
......
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