public static boolean isJIDonServer(Connection connection, JID jid,
SubMonitor monitor) throws XMPPException {
if (monitor != null)
monitor.beginTask("Performing Service Discovery on JID " + jid, 2);
ServiceDiscoveryManager sdm = ServiceDiscoveryManager
.getInstanceFor(connection);
if (monitor != null) {
monitor.worked(1);
if (monitor.isCanceled())
throw new CancellationException();
}
try {
boolean discovered = sdm.discoverInfo(jid.getRAW()).getIdentities()
.hasNext();
if (!discovered && jid.isBareJID()) // FIXME: removed the hard coded
// suffix
discovered = sdm.discoverInfo(jid.getRAW() + "/Saros")
.getIdentities().hasNext();
/*
* discovery does not change any state, if the user wanted to cancel
* it, we can do that even after the execution finished