1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

"not connected" is now a checked Exception thrown by sendPacket()

There is a unsolveable race condition between the connection state and
sendPacket(), i.e. the connection could go down, right after the
method calling sendPacket is called, but before sendPacket() is
invoked. Before this change, sendPacket() has thrown an unchecked
IllegalStateException, which could be ignored by the Smack user, who
would also not notice the race condition. We have decided to throw a
checked Exception in this case now, to make the Smack user aware of
this situation.

SMACK-426
This commit is contained in:
Florian Schmaus 2014-03-19 14:22:20 +01:00
parent d8c656270e
commit fcc8414a92
101 changed files with 845 additions and 382 deletions

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.address;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Message;
@ -70,8 +71,9 @@ public class MultipleRecipientManager {
* @throws XMPPErrorException if server does not support JEP-33: Extended Stanza Addressing and
* some JEP-33 specific features were requested.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException
public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException
{
send(connection, packet, to, cc, bcc, null, null, false);
}
@ -98,9 +100,10 @@ public class MultipleRecipientManager {
* @throws NoResponseException if there was no response from the server.
* @throws FeatureNotSupportedException if special XEP-33 features where requested, but the
* server does not support them.
* @throws NotConnectedException
*/
public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc,
String replyTo, String replyRoom, boolean noReply) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException {
String replyTo, String replyRoom, boolean noReply) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException {
String serviceAddress = getMultipleRecipienServiceAddress(connection);
if (serviceAddress != null) {
// Send packet to target users using multiple recipient service provided by the server
@ -206,7 +209,7 @@ public class MultipleRecipientManager {
}
private static void sendToIndividualRecipients(XMPPConnection connection, Packet packet,
List<String> to, List<String> cc, List<String> bcc) {
List<String> to, List<String> cc, List<String> bcc) throws NotConnectedException {
if (to != null) {
for (Iterator<String> it = to.iterator(); it.hasNext();) {
String jid = it.next();
@ -232,7 +235,7 @@ public class MultipleRecipientManager {
private static void sendThroughService(XMPPConnection connection, Packet packet, List<String> to,
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
String serviceAddress) {
String serviceAddress) throws NotConnectedException {
// Create multiple recipient extension
MultipleAddresses multipleAddresses = new MultipleAddresses();
if (to != null) {
@ -285,8 +288,9 @@ public class MultipleRecipientManager {
* @return the address of the multiple recipients service or <tt>null</tt> if none was found.
* @throws NoResponseException if there was no response from the server.
* @throws XMPPErrorException
* @throws NotConnectedException
*/
private static String getMultipleRecipienServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
private static String getMultipleRecipienServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
String serviceName = connection.getServiceName();
String serviceAddress = (String) services.get(serviceName);
if (serviceAddress == null) {

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.amp.packet.AMPExtension;
@ -31,8 +32,9 @@ public class AMPDeliverCondition implements AMPExtension.Condition {
* @return true if deliver condition is supported.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return AMPManager.isConditionSupported(connection, NAME);
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.util.XmppDateTime;
@ -35,8 +36,9 @@ public class AMPExpireAtCondition implements AMPExtension.Condition {
* @return true if expire-at condition is supported.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return AMPManager.isConditionSupported(connection, NAME);
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -86,8 +87,9 @@ public class AMPManager {
* @return true if this action is supported.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isActionSupported(XMPPConnection connection, AMPExtension.Action action) throws NoResponseException, XMPPErrorException {
public static boolean isActionSupported(XMPPConnection connection, AMPExtension.Action action) throws NoResponseException, XMPPErrorException, NotConnectedException {
String featureName = AMPExtension.NAMESPACE + "?action=" + action.toString();
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
}
@ -99,16 +101,17 @@ public class AMPManager {
* @return true if this condition is supported.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @see AMPDeliverCondition
* @see AMPExpireAtCondition
* @see AMPMatchResourceCondition
*/
public static boolean isConditionSupported(XMPPConnection connection, String conditionName) throws NoResponseException, XMPPErrorException {
public static boolean isConditionSupported(XMPPConnection connection, String conditionName) throws NoResponseException, XMPPErrorException, NotConnectedException {
String featureName = AMPExtension.NAMESPACE + "?condition=" + conditionName;
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
}
private static boolean isFeatureSupportedByServer(XMPPConnection connection, String featureName, String node) throws NoResponseException, XMPPErrorException {
private static boolean isFeatureSupportedByServer(XMPPConnection connection, String featureName, String node) throws NoResponseException, XMPPErrorException, NotConnectedException {
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverInfo info = discoveryManager.discoverInfo(connection.getServiceName(), node);
Iterator<DiscoverInfo.Feature> it = info.getFeatures();

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.amp;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.amp.packet.AMPExtension;
@ -31,8 +32,9 @@ public class AMPMatchResourceCondition implements AMPExtension.Condition {
* @return true if match-resource condition is supported.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return AMPManager.isConditionSupported(connection, NAME);
}

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.bookmarks;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -92,9 +93,10 @@ public class BookmarkManager {
* @return returns all currently bookmarked conferences
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @see BookmarkedConference
*/
public Collection<BookmarkedConference> getBookmarkedConferences() throws NoResponseException, XMPPErrorException {
public Collection<BookmarkedConference> getBookmarkedConferences() throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks();
return Collections.unmodifiableCollection(bookmarks.getBookmarkedConferences());
}
@ -110,9 +112,10 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown when there is an issue retrieving the current bookmarks from
* the server.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void addBookmarkedConference(String name, String jid, boolean isAutoJoin,
String nickname, String password) throws NoResponseException, XMPPErrorException
String nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException
{
retrieveBookmarks();
BookmarkedConference bookmark
@ -141,10 +144,11 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown when there is a problem with the connection attempting to
* retrieve the bookmarks or persist the bookmarks.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @throws IllegalArgumentException thrown when the conference being removed is a shared
* conference
*/
public void removeBookmarkedConference(String jid) throws NoResponseException, XMPPErrorException {
public void removeBookmarkedConference(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks();
Iterator<BookmarkedConference> it = bookmarks.getBookmarkedConferences().iterator();
while(it.hasNext()) {
@ -166,8 +170,9 @@ public class BookmarkManager {
* @return returns an unmodifiable collection of all bookmarked urls.
* @throws XMPPErrorException thrown when there is a problem retriving bookmarks from the server.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Collection<BookmarkedURL> getBookmarkedURLs() throws NoResponseException, XMPPErrorException {
public Collection<BookmarkedURL> getBookmarkedURLs() throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks();
return Collections.unmodifiableCollection(bookmarks.getBookmarkedURLS());
}
@ -181,8 +186,9 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown when there is an error retriving or saving bookmarks from or to
* the server
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void addBookmarkedURL(String URL, String name, boolean isRSS) throws NoResponseException, XMPPErrorException {
public void addBookmarkedURL(String URL, String name, boolean isRSS) throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks();
BookmarkedURL bookmark = new BookmarkedURL(URL, name, isRSS);
List<BookmarkedURL> urls = bookmarks.getBookmarkedURLS();
@ -207,8 +213,9 @@ public class BookmarkManager {
* @throws XMPPErrorException thrown if there is an error retriving or saving bookmarks from or to
* the server.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void removeBookmarkedURL(String bookmarkURL) throws NoResponseException, XMPPErrorException {
public void removeBookmarkedURL(String bookmarkURL) throws NoResponseException, XMPPErrorException, NotConnectedException {
retrieveBookmarks();
Iterator<BookmarkedURL> it = bookmarks.getBookmarkedURLS().iterator();
while(it.hasNext()) {
@ -224,7 +231,7 @@ public class BookmarkManager {
}
}
private Bookmarks retrieveBookmarks() throws NoResponseException, XMPPErrorException {
private Bookmarks retrieveBookmarks() throws NoResponseException, XMPPErrorException, NotConnectedException {
synchronized(bookmarkLock) {
if(bookmarks == null) {
bookmarks = (Bookmarks) privateDataManager.getPrivateData("storage",

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.bytestreams;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
@ -60,7 +61,8 @@ public interface BytestreamRequest {
/**
* Rejects the bytestream request by sending a reject error to the initiator.
* @throws NotConnectedException
*/
public void reject();
public void reject() throws NotConnectedException;
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -52,7 +53,7 @@ class CloseListener implements PacketListener {
this.manager = manager;
}
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
Close closeRequest = (Close) packet;
InBandBytestreamSession ibbSession = this.manager.getSessions().get(
closeRequest.getSessionID());

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -55,7 +56,7 @@ class DataListener implements PacketListener {
this.manager = manager;
}
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
Data data = (Data) packet;
InBandBytestreamSession ibbSession = this.manager.getSessions().get(
data.getDataPacketExtension().getSessionID());

View file

@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException;
@ -425,9 +426,10 @@ public class InBandBytestreamManager implements BytestreamManager {
* @throws XMPPErrorException if the user doesn't support or accept in-band bytestreams, or if the
* user prefers smaller block sizes
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
byteStreamRequest.setTo(targetJID);
@ -446,8 +448,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* not accepted.
*
* @param request IQ packet that should be answered with a not-acceptable error
* @throws NotConnectedException
*/
protected void replyRejectPacket(IQ request) {
protected void replyRejectPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.no_acceptable);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);
@ -458,8 +461,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* request is rejected because its block size is greater than the maximum allowed block size.
*
* @param request IQ packet that should be answered with a resource-constraint error
* @throws NotConnectedException
*/
protected void replyResourceConstraintPacket(IQ request) {
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);
@ -470,8 +474,9 @@ public class InBandBytestreamManager implements BytestreamManager {
* session could not be found.
*
* @param request IQ packet that should be answered with a item-not-found error
* @throws NotConnectedException
*/
protected void replyItemNotFoundPacket(IQ request) {
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
IQ error = IQ.createErrorResponse(request, xmppError);
this.connection.sendPacket(error);

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
@ -66,8 +67,9 @@ public class InBandBytestreamRequest implements BytestreamRequest {
* send/receive data.
*
* @return the session to send/receive data
* @throws NotConnectedException
*/
public InBandBytestreamSession accept() {
public InBandBytestreamSession accept() throws NotConnectedException {
XMPPConnection connection = this.manager.getConnection();
// create In-Band Bytestream session and store it
@ -85,8 +87,9 @@ public class InBandBytestreamRequest implements BytestreamRequest {
/**
* Rejects the In-Band Bytestream request by sending a reject error to the
* initiator.
* @throws NotConnectedException
*/
public void reject() {
public void reject() throws NotConnectedException {
this.manager.replyRejectPacket(this.byteStreamRequest);
}

View file

@ -24,6 +24,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.filter.AndFilter;
@ -159,8 +160,9 @@ public class InBandBytestreamSession implements BytestreamSession {
* This method is invoked if a request to close the In-Band Bytestream has been received.
*
* @param closeRequest the close request from the remote peer
* @throws NotConnectedException
*/
protected void closeByPeer(Close closeRequest) {
protected void closeByPeer(Close closeRequest) throws NotConnectedException {
/*
* close streams without flushing them, because stream is already considered closed on the
@ -445,7 +447,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private long lastSequence = -1;
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
// get data packet extension
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
DataPacketExtension.ELEMENT_NAME,
@ -607,8 +609,9 @@ public class InBandBytestreamSession implements BytestreamSession {
*
* @param data the data packet
* @throws IOException if an I/O error occurred while sending or if the stream is closed
* @throws NotConnectedException
*/
protected abstract void writeToXML(DataPacketExtension data) throws IOException;
protected abstract void writeToXML(DataPacketExtension data) throws IOException, NotConnectedException;
public synchronized void write(int b) throws IOException {
if (this.isClosed) {
@ -709,7 +712,14 @@ public class InBandBytestreamSession implements BytestreamSession {
this.seq, enc);
// write to XMPP stream
writeToXML(data);
try {
writeToXML(data);
}
catch (NotConnectedException e) {
IOException ioException = new IOException();
ioException.initCause(e);
throw ioException;
}
// reset buffer pointer
bufferPointer = 0;
@ -790,7 +800,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private class MessageIBBOutputStream extends IBBOutputStream {
@Override
protected synchronized void writeToXML(DataPacketExtension data) {
protected synchronized void writeToXML(DataPacketExtension data) throws NotConnectedException {
// create message stanza containing data packet
Message message = new Message(remoteJID);
message.addExtension(data);

View file

@ -18,8 +18,11 @@ package org.jivesoftware.smackx.bytestreams.ibb;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -29,6 +32,7 @@ import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
/**
* InitiationListener handles all incoming In-Band Bytestream open requests. If there are no
* listeners for a In-Band Bytestream request InitiationListener will always refuse the request and
@ -42,6 +46,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
* @author Henning Staib
*/
class InitiationListener implements PacketListener {
private static final Logger LOGGER = Logger.getLogger(InitiationListener.class.getName());
/* manager containing the listeners and the XMPP connection */
private final InBandBytestreamManager manager;
@ -67,12 +72,17 @@ class InitiationListener implements PacketListener {
initiationListenerExecutor.execute(new Runnable() {
public void run() {
processRequest(packet);
try {
processRequest(packet);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "proccessRequest", e);
}
}
});
}
private void processRequest(Packet packet) {
private void processRequest(Packet packet) throws NotConnectedException {
Open ibbRequest = (Open) packet;
// validate that block size is within allowed range

View file

@ -18,8 +18,11 @@ package org.jivesoftware.smackx.bytestreams.socks5;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -38,6 +41,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
* @author Henning Staib
*/
final class InitiationListener implements PacketListener {
private static final Logger LOGGER = Logger.getLogger(InitiationListener.class.getName());
/* manager containing the listeners and the XMPP connection */
private final Socks5BytestreamManager manager;
@ -63,12 +67,17 @@ final class InitiationListener implements PacketListener {
initiationListenerExecutor.execute(new Runnable() {
public void run() {
processRequest(packet);
try {
processRequest(packet);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "process request", e);
}
}
});
}
private void processRequest(Packet packet) {
private void processRequest(Packet packet) throws NotConnectedException {
Bytestream byteStreamRequest = (Bytestream) packet;
// ignore request if in ignore list

View file

@ -33,6 +33,7 @@ import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPException;
@ -536,8 +537,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* otherwise <code>false</code>
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException {
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(targetJID, NAMESPACE);
}
@ -548,8 +550,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @return list of JIDs of SOCKS5 proxies
* @throws XMPPErrorException if there was an error querying the XMPP server for SOCKS5 proxies
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
private List<String> determineProxies() throws NoResponseException, XMPPErrorException {
private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>();
@ -708,8 +711,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* accepted.
*
* @param packet Packet that should be answered with a not-acceptable error
* @throws NotConnectedException
*/
protected void replyRejectPacket(IQ packet) {
protected void replyRejectPacket(IQ packet) throws NotConnectedException {
XMPPError xmppError = new XMPPError(XMPPError.Condition.no_acceptable);
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
this.connection.sendPacket(errorIQ);

View file

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.concurrent.TimeoutException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -264,8 +265,9 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
/**
* Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator.
* @throws NotConnectedException
*/
public void reject() {
public void reject() throws NotConnectedException {
this.manager.replyRejectPacket(this.bytestreamRequest);
}
@ -273,8 +275,9 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
* Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a
* XMPP exception.
* @throws XMPPErrorException
* @throws NotConnectedException
*/
private void cancelRequest() throws XMPPErrorException {
private void cancelRequest() throws XMPPErrorException, NotConnectedException {
String errorMessage = "Could not establish socket with any provided host";
XMPPError error = new XMPPError(XMPPError.Condition.item_not_found, errorMessage);
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);

View file

@ -22,6 +22,7 @@ import java.util.concurrent.TimeoutException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -102,9 +103,10 @@ class Socks5ClientForInitiator extends Socks5Client {
* SOCKS5 proxy.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws SmackException if there was no response from the server.
*/
private void activate() throws NoResponseException, XMPPErrorException {
private void activate() throws NoResponseException, XMPPErrorException, NotConnectedException {
Bytestream activate = createStreamHostActivation();
// if activation fails #nextResultOrThrow() throws an exception
connection.createPacketCollectorAndSend(activate).nextResultOrThrow();

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.caps;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -59,6 +60,8 @@ import java.util.SortedSet;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -70,6 +73,7 @@ import java.security.NoSuchAlgorithmException;
* @see <a href="http://www.xmpp.org/extensions/xep-0115.html">XEP-0115: Entity Capabilities</a>
*/
public class EntityCapsManager extends Manager {
private static final Logger LOGGER = Logger.getLogger(EntityCapsManager.class.getName());
public static final String NAMESPACE = "http://jabber.org/protocol/caps";
public static final String ELEMENT = "c";
@ -351,7 +355,7 @@ public class EntityCapsManager extends Manager {
return entityCapsEnabled;
}
public void setEntityNode(String entityNode) {
public void setEntityNode(String entityNode) throws NotConnectedException {
this.entityNode = entityNode;
updateLocalEntityCaps();
}
@ -394,8 +398,9 @@ public class EntityCapsManager extends Manager {
* @return true if the entity supports Entity Capabilities.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean areEntityCapsSupported(String jid) throws NoResponseException, XMPPErrorException {
public boolean areEntityCapsSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
return sdm.supportsFeature(jid, NAMESPACE);
}
@ -405,8 +410,9 @@ public class EntityCapsManager extends Manager {
* @return true if the user's server supports Entity Capabilities.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean areEntityCapsSupportedByServer() throws NoResponseException, XMPPErrorException {
public boolean areEntityCapsSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException {
return areEntityCapsSupported(connection().getServiceName());
}
@ -415,6 +421,7 @@ public class EntityCapsManager extends Manager {
*
* If we are connected and there was already a presence send, another
* presence is send to inform others about your new Entity Caps node string.
* @throws NotConnectedException
*
*/
public void updateLocalEntityCaps() {
@ -472,7 +479,12 @@ public class EntityCapsManager extends Manager {
// to respect ConnectionConfiguration.isSendPresence()
if (connection != null && connection.isAuthenticated() && presenceSend) {
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
try {
connection.sendPacket(presence);
}
catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "Could could not update presence with caps info", e);
}
}
}

View file

@ -23,6 +23,7 @@ import java.util.WeakHashMap;
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.ChatManagerListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.MessageListener;
@ -101,8 +102,9 @@ public class ChatStateManager extends Manager {
*
* @param newState the new state of the chat
* @param chat the chat.
* @throws NotConnectedException
*/
public void setCurrentState(ChatState newState, Chat chat) {
public void setCurrentState(ChatState newState, Chat chat) throws NotConnectedException {
if(chat == null || newState == null) {
throw new IllegalArgumentException("Arguments cannot be null.");
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.commands;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
@ -209,8 +210,9 @@ public abstract class AdHocCommand {
* the command it throws an XMPPException.
*
* @throws XMPPErrorException if there is an error executing the command.
* @throws NotConnectedException
*/
public abstract void execute() throws NoResponseException, XMPPErrorException;
public abstract void execute() throws NoResponseException, XMPPErrorException, NotConnectedException;
/**
* Executes the next action of the command with the information provided in
@ -221,8 +223,9 @@ public abstract class AdHocCommand {
*
* @param response the form answer of the previous stage.
* @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/
public abstract void next(Form response) throws NoResponseException, XMPPErrorException;
public abstract void next(Form response) throws NoResponseException, XMPPErrorException, NotConnectedException;
/**
* Completes the command execution with the information provided in the
@ -233,8 +236,9 @@ public abstract class AdHocCommand {
*
* @param response the form answer of the previous stage.
* @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/
public abstract void complete(Form response) throws NoResponseException, XMPPErrorException;
public abstract void complete(Form response) throws NoResponseException, XMPPErrorException, NotConnectedException;
/**
* Goes to the previous stage. The requester is asking to re-send the
@ -243,8 +247,9 @@ public abstract class AdHocCommand {
* an XMPPException.
*
* @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/
public abstract void prev() throws NoResponseException, XMPPErrorException;
public abstract void prev() throws NoResponseException, XMPPErrorException, NotConnectedException;
/**
* Cancels the execution of the command. This can be invoked on any stage of
@ -252,8 +257,9 @@ public abstract class AdHocCommand {
* XMPPException.
*
* @throws XMPPErrorException if there is a problem executing the command.
* @throws NotConnectedException
*/
public abstract void cancel() throws NoResponseException, XMPPErrorException;
public abstract void cancel() throws NoResponseException, XMPPErrorException, NotConnectedException;
/**
* Returns a collection with the allowed actions based on the current stage.

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.commands;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -591,9 +592,10 @@ public class AdHocCommandManager extends Manager {
*
* @param response the response to send.
* @param condition the condition of the error.
* @throws NotConnectedException
*/
private void respondError(AdHocCommandData response,
XMPPError.Condition condition) {
XMPPError.Condition condition) throws NotConnectedException {
respondError(response, new XMPPError(condition));
}
@ -603,9 +605,10 @@ public class AdHocCommandManager extends Manager {
* @param response the response to send.
* @param condition the condition of the error.
* @param specificCondition the adhoc command error condition.
* @throws NotConnectedException
*/
private void respondError(AdHocCommandData response, XMPPError.Condition condition,
AdHocCommand.SpecificErrorCondition specificCondition)
AdHocCommand.SpecificErrorCondition specificCondition) throws NotConnectedException
{
XMPPError error = new XMPPError(condition);
error.addExtension(new AdHocCommandData.SpecificError(specificCondition));
@ -617,8 +620,9 @@ public class AdHocCommandManager extends Manager {
*
* @param response the response to send.
* @param error the error to send.
* @throws NotConnectedException
*/
private void respondError(AdHocCommandData response, XMPPError error) {
private void respondError(AdHocCommandData response, XMPPError error) throws NotConnectedException {
response.setType(IQ.Type.ERROR);
response.setError(error);
connection().sendPacket(response);

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.commands;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -80,17 +81,17 @@ public class RemoteCommand extends AdHocCommand {
}
@Override
public void cancel() throws NoResponseException, XMPPErrorException {
public void cancel() throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.cancel, packetReplyTimeout);
}
@Override
public void complete(Form form) throws NoResponseException, XMPPErrorException {
public void complete(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.complete, form, packetReplyTimeout);
}
@Override
public void execute() throws NoResponseException, XMPPErrorException {
public void execute() throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.execute, packetReplyTimeout);
}
@ -102,22 +103,23 @@ public class RemoteCommand extends AdHocCommand {
* @param form the form anwser of the previous stage.
* @throws XMPPErrorException if an error occurs.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void execute(Form form) throws NoResponseException, XMPPErrorException {
public void execute(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.execute, form, packetReplyTimeout);
}
@Override
public void next(Form form) throws NoResponseException, XMPPErrorException {
public void next(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.next, form, packetReplyTimeout);
}
@Override
public void prev() throws NoResponseException, XMPPErrorException {
public void prev() throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(Action.prev, packetReplyTimeout);
}
private void executeAction(Action action, long packetReplyTimeout) throws NoResponseException, XMPPErrorException {
private void executeAction(Action action, long packetReplyTimeout) throws NoResponseException, XMPPErrorException, NotConnectedException {
executeAction(action, null, packetReplyTimeout);
}
@ -131,8 +133,9 @@ public class RemoteCommand extends AdHocCommand {
* @param timeout the amount of time to wait for a reply.
* @throws XMPPErrorException if there is a problem executing the command.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
private void executeAction(Action action, Form form, long timeout) throws NoResponseException, XMPPErrorException {
private void executeAction(Action action, Form form, long timeout) throws NoResponseException, XMPPErrorException, NotConnectedException {
// TODO: Check that all the required fields of the form were filled, if
// TODO: not throw the corresponding exeption. This will make a faster response,
// TODO: since the request is stoped before it's sent.

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.disco;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -115,7 +116,7 @@ public class ServiceDiscoveryManager extends Manager {
// Listen for disco#items requests and answer with an empty result
PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class);
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
XMPPConnection connection = connection();
if (connection == null) return;
DiscoverItems discoverItems = (DiscoverItems) packet;
@ -152,7 +153,7 @@ public class ServiceDiscoveryManager extends Manager {
// To add a new feature as supported use the #addFeature message
packetFilter = new PacketTypeFilter(DiscoverInfo.class);
packetListener = new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
XMPPConnection connection = connection();
if (connection == null) return;
DiscoverInfo discoverInfo = (DiscoverInfo) packet;
@ -496,8 +497,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException {
public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (entityID == null)
return discoverInfo(null, null);
@ -540,8 +542,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information.
* @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public DiscoverInfo discoverInfo(String entityID, String node) throws NoResponseException, XMPPErrorException {
public DiscoverInfo discoverInfo(String entityID, String node) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Discover the entity's info
DiscoverInfo disco = new DiscoverInfo();
disco.setType(IQ.Type.GET);
@ -560,8 +563,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered information.
* @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public DiscoverItems discoverItems(String entityID) throws NoResponseException, XMPPErrorException {
public DiscoverItems discoverItems(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
return discoverItems(entityID, null);
}
@ -575,8 +579,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return the discovered items.
* @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public DiscoverItems discoverItems(String entityID, String node) throws NoResponseException, XMPPErrorException {
public DiscoverItems discoverItems(String entityID, String node) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Discover the entity's items
DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET);
@ -597,8 +602,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return true if the server supports publishing of items.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean canPublishItems(String entityID) throws NoResponseException, XMPPErrorException {
public boolean canPublishItems(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo info = discoverInfo(entityID);
return canPublishItems(info);
}
@ -626,8 +632,9 @@ public class ServiceDiscoveryManager extends Manager {
* @param discoverItems the DiscoveryItems to publish.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void publishItems(String entityID, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException {
public void publishItems(String entityID, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException, NotConnectedException {
publishItems(entityID, null, discoverItems);
}
@ -642,8 +649,9 @@ public class ServiceDiscoveryManager extends Manager {
* @param discoverItems the DiscoveryItems to publish.
* @throws XMPPErrorException if the operation failed for some reason.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void publishItems(String entityID, String node, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException
public void publishItems(String entityID, String node, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException, NotConnectedException
{
discoverItems.setType(IQ.Type.SET);
discoverItems.setTo(entityID);
@ -660,8 +668,9 @@ public class ServiceDiscoveryManager extends Manager {
* @return true if the entity supports the feature, false otherwise
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean supportsFeature(String jid, String feature) throws NoResponseException, XMPPErrorException {
public boolean supportsFeature(String jid, String feature) throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo result = discoverInfo(jid);
return result.containsFeature(feature);
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.filetransfer;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
@ -167,7 +168,7 @@ public class FileTransferManager {
return transfer;
}
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
protected void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException {
StreamInitiation initiation = request.getStreamInitiation();
IQ rejection = FileTransferNegotiator.createIQ(

View file

@ -28,6 +28,7 @@ import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -241,9 +242,10 @@ public class FileTransferNegotiator {
* @return The file transfer object that handles the transfer
* @throws XMPPErrorException If there are either no stream methods contained in the packet, or
* there is not an appropriate stream method.
* @throws NotConnectedException
*/
public StreamNegotiator selectStreamNegotiator(
FileTransferRequest request) throws XMPPErrorException {
FileTransferRequest request) throws XMPPErrorException, NotConnectedException {
StreamInitiation si = request.getStreamInitiation();
FormField streamMethodField = getStreamMethodField(si
.getFeatureNegotiationForm());
@ -328,8 +330,9 @@ public class FileTransferNegotiator {
* Reject a stream initiation request from a remote user.
*
* @param si The Stream Initiation request to reject.
* @throws NotConnectedException
*/
public void rejectStream(final StreamInitiation si) {
public void rejectStream(final StreamInitiation si) throws NotConnectedException {
XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined");
IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
IQ.Type.ERROR);
@ -380,10 +383,11 @@ public class FileTransferNegotiator {
* user to respond. If they do not respond in time, this
* @return Returns the stream negotiator selected by the peer.
* @throws XMPPErrorException Thrown if there is an error negotiating the file transfer.
* @throws NotConnectedException
*/
public StreamNegotiator negotiateOutgoingTransfer(final String userID,
final String streamID, final String fileName, final long size,
final String desc, int responseTimeout) throws XMPPErrorException {
final String desc, int responseTimeout) throws XMPPErrorException, NotConnectedException {
StreamInitiation si = new StreamInitiation();
si.setSessionID(streamID);
si.setMimeType(URLConnection.guessContentTypeFromName(fileName));

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.filetransfer;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
/**
@ -127,8 +128,9 @@ public class FileTransferRequest {
/**
* Rejects the file transfer request.
* @throws NotConnectedException
*/
public void reject() {
public void reject() throws NotConnectedException {
manager.rejectIncomingFileTransfer(this);
}

View file

@ -20,6 +20,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
@ -61,14 +62,14 @@ public class IBBTransferNegotiator extends StreamNegotiator {
}
public OutputStream createOutgoingStream(String streamID, String initiator,
String target) throws NoResponseException, XMPPErrorException {
String target) throws NoResponseException, XMPPErrorException, NotConnectedException {
InBandBytestreamSession session = this.manager.establishSession(target, streamID);
session.setCloseBothStreamsEnabled(true);
return session.getOutputStream();
}
public InputStream createIncomingStream(StreamInitiation initiation)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
/*
* In-Band Bytestream initiation listener must ignore next in-band bytestream request with
* given session ID
@ -94,7 +95,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
return new String[] { InBandBytestreamManager.NAMESPACE };
}
InputStream negotiateIncomingStream(Packet streamInitiation) {
InputStream negotiateIncomingStream(Packet streamInitiation) throws NotConnectedException {
// build In-Band Bytestream request
InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
(Open) streamInitiation);

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.filetransfer;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -80,7 +81,7 @@ public abstract class StreamNegotiator {
return iq;
}
Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException {
Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException {
StreamInitiation response = createInitiationAccept(initiation,
getNamespaces());

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.iqlast;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener;
@ -137,7 +138,7 @@ public class LastActivityManager {
// Register a listener for a last activity query
connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
LastActivity message = new LastActivity();
message.setType(IQ.Type.RESULT);
message.setTo(packet.getFrom());
@ -195,9 +196,10 @@ public class LastActivityManager {
* @throws XMPPErrorException
* thrown if a server error has occured.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public static LastActivity getLastActivity(XMPPConnection con, String jid)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
LastActivity activity = new LastActivity();
activity.setTo(jid);

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.iqprivate;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -170,8 +171,9 @@ public class PrivateDataManager {
* @return the private data.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivateData getPrivateData(final String elementName, final String namespace) throws NoResponseException, XMPPErrorException
public PrivateData getPrivateData(final String elementName, final String namespace) throws NoResponseException, XMPPErrorException, NotConnectedException
{
// Create an IQ packet to get the private data.
IQ privateDataGet = new IQ() {
@ -202,8 +204,9 @@ public class PrivateDataManager {
* @param privateData the private data.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void setPrivateData(final PrivateData privateData) throws NoResponseException, XMPPErrorException {
public void setPrivateData(final PrivateData privateData) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Create an IQ packet to set the private data.
IQ privateDataSet = new IQ() {
public String getChildElementXML() {

View file

@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener;
@ -64,8 +65,9 @@ public class VersionManager extends Manager {
connection.addPacketListener(new PacketListener() {
/**
* Sends a Version reply on request
* @throws NotConnectedException
*/
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
if (own_version == null)
return;

View file

@ -43,6 +43,7 @@ import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -181,9 +182,10 @@ public class MultiUserChat {
* @return a boolean indicating whether the specified user supports the MUC protocol.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isServiceEnabled(XMPPConnection connection, String user)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(user,
discoNamespace);
}
@ -214,9 +216,10 @@ public class MultiUserChat {
* @return an Iterator on the rooms where the requested user has joined.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
ArrayList<String> answer = new ArrayList<String>();
// Send the disco packet to the user
DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
@ -238,9 +241,10 @@ public class MultiUserChat {
* @return the discovered information of a given room without actually having to join the room.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static RoomInfo getRoomInfo(XMPPConnection connection, String room)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room);
return new RoomInfo(info);
}
@ -252,8 +256,9 @@ public class MultiUserChat {
* @return a collection with the XMPP addresses of the Multi-User Chat services.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static Collection<String> getServiceNames(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public static Collection<String> getServiceNames(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
final List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
@ -277,9 +282,10 @@ public class MultiUserChat {
* @return a collection of HostedRooms.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static Collection<HostedRoom> getHostedRooms(XMPPConnection connection,
String serviceName) throws NoResponseException, XMPPErrorException {
String serviceName) throws NoResponseException, XMPPErrorException, NotConnectedException {
List<HostedRoom> answer = new ArrayList<HostedRoom>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(serviceName);
@ -385,8 +391,9 @@ public class MultiUserChat {
* 407 error can occur if user is not on the member list; or a
* 409 error can occur if someone is already in the group chat with the same nickname.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void join(String nickname) throws NoResponseException, XMPPErrorException {
public void join(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException {
join(nickname, null, null, SmackConfiguration.getDefaultPacketReplyTimeout());
}
@ -439,13 +446,14 @@ public class MultiUserChat {
* 407 error can occur if user is not on the member list; or a
* 409 error can occur if someone is already in the group chat with the same nickname.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public synchronized void join(
String nickname,
String password,
DiscussionHistory history,
long timeout)
throws XMPPErrorException, NoResponseException {
throws XMPPErrorException, NoResponseException, NotConnectedException {
if (nickname == null || nickname.equals("")) {
throw new IllegalArgumentException("Nickname must not be null or blank.");
}
@ -503,8 +511,9 @@ public class MultiUserChat {
/**
* Leave the chat room.
* @throws NotConnectedException
*/
public synchronized void leave() {
public synchronized void leave() throws NotConnectedException {
// If not joined already, do nothing.
if (!joined) {
return;
@ -534,8 +543,9 @@ public class MultiUserChat {
* <tt>null</tt> if no configuration is possible.
* @throws XMPPErrorException if an error occurs asking the configuration form for the room.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Form getConfigurationForm() throws NoResponseException, XMPPErrorException {
public Form getConfigurationForm() throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.GET);
@ -552,8 +562,9 @@ public class MultiUserChat {
* @param form the form with the new settings.
* @throws XMPPErrorException if an error occurs setting the new rooms' configuration.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException {
public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -576,8 +587,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if an error occurs asking the registration form for the room or a
* 405 error if the user is not allowed to register with the room.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Form getRegistrationForm() throws NoResponseException, XMPPErrorException {
public Form getRegistrationForm() throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration();
reg.setType(IQ.Type.GET);
reg.setTo(room);
@ -600,8 +612,9 @@ public class MultiUserChat {
* 409 error can occur if the desired room nickname is already reserved for that room;
* or a 503 error can occur if the room does not support registration.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void sendRegistrationForm(Form form) throws NoResponseException, XMPPErrorException {
public void sendRegistrationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(room);
@ -622,8 +635,9 @@ public class MultiUserChat {
* XMPP error code 403. The error code can be used to present more
* appropiate error messages to end-users.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void destroy(String reason, String alternateJID) throws NoResponseException, XMPPErrorException {
public void destroy(String reason, String alternateJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -652,8 +666,9 @@ public class MultiUserChat {
*
* @param user the user to invite to the room.(e.g. hecate@shakespeare.lit)
* @param reason the reason why the user is being invited.
* @throws NotConnectedException
*/
public void invite(String user, String reason) {
public void invite(String user, String reason) throws NotConnectedException {
invite(new Message(), user, reason);
}
@ -667,8 +682,9 @@ public class MultiUserChat {
* @param message the message to use for sending the invitation.
* @param user the user to invite to the room.(e.g. hecate@shakespeare.lit)
* @param reason the reason why the user is being invited.
* @throws NotConnectedException
*/
public void invite(Message message, String user, String reason) {
public void invite(Message message, String user, String reason) throws NotConnectedException {
// TODO listen for 404 error code when inviter supplies a non-existent JID
message.setTo(room);
@ -692,8 +708,9 @@ public class MultiUserChat {
* @param room the room that sent the original invitation.
* @param inviter the inviter of the declined invitation.
* @param reason the reason why the invitee is declining the invitation.
* @throws NotConnectedException
*/
public static void decline(XMPPConnection conn, String room, String inviter, String reason) {
public static void decline(XMPPConnection conn, String room, String inviter, String reason) throws NotConnectedException {
Message message = new Message(room);
// Create the MUCUser packet that will include the rejection
@ -901,8 +918,9 @@ public class MultiUserChat {
* @param nickname the new nickname within the room.
* @throws XMPPErrorException if the new nickname is already in use by another occupant.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void changeNickname(String nickname) throws NoResponseException, XMPPErrorException {
public void changeNickname(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (nickname == null || nickname.equals("")) {
throw new IllegalArgumentException("Nickname must not be null or blank.");
}
@ -943,8 +961,9 @@ public class MultiUserChat {
*
* @param status a text message describing the presence update.
* @param mode the mode type for the presence update.
* @throws NotConnectedException
*/
public void changeAvailabilityStatus(String status, Presence.Mode mode) {
public void changeAvailabilityStatus(String status, Presence.Mode mode) throws NotConnectedException {
if (nickname == null || nickname.equals("")) {
throw new IllegalArgumentException("Nickname must not be null or blank.");
}
@ -987,8 +1006,9 @@ public class MultiUserChat {
* not have kicking privileges (i.e. Forbidden error); or a
* 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void kickParticipant(String nickname, String reason) throws XMPPErrorException, NoResponseException {
public void kickParticipant(String nickname, String reason) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "none", reason);
}
@ -1003,8 +1023,9 @@ public class MultiUserChat {
* a moderator in this room (i.e. Forbidden error); or a
* 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException {
public void grantVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "participant");
}
@ -1019,8 +1040,9 @@ public class MultiUserChat {
* a moderator in this room (i.e. Forbidden error); or a
* 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantVoice(String nickname) throws XMPPErrorException, NoResponseException {
public void grantVoice(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "participant", null);
}
@ -1035,8 +1057,9 @@ public class MultiUserChat {
* was tried to revoke his voice (i.e. Not Allowed error); or a
* 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException {
public void revokeVoice(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "visitor");
}
@ -1051,8 +1074,9 @@ public class MultiUserChat {
* was tried to revoke his voice (i.e. Not Allowed error); or a
* 400 error can occur if the provided nickname is not present in the room.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeVoice(String nickname) throws XMPPErrorException, NoResponseException {
public void revokeVoice(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "visitor", null);
}
@ -1068,8 +1092,9 @@ public class MultiUserChat {
* 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
* was tried to be banned (i.e. Not Allowed error).
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void banUsers(Collection<String> jids) throws XMPPErrorException, NoResponseException {
public void banUsers(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "outcast");
}
@ -1086,8 +1111,9 @@ public class MultiUserChat {
* 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
* was tried to be banned (i.e. Not Allowed error).
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void banUser(String jid, String reason) throws XMPPErrorException, NoResponseException {
public void banUser(String jid, String reason) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "outcast", reason);
}
@ -1099,8 +1125,9 @@ public class MultiUserChat {
* @param jids the XMPP user IDs of the users to grant membership.
* @throws XMPPErrorException if an error occurs granting membership to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException {
public void grantMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "member");
}
@ -1112,8 +1139,9 @@ public class MultiUserChat {
* @param jid the XMPP user ID of the user to grant membership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs granting membership to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantMembership(String jid) throws XMPPErrorException, NoResponseException {
public void grantMembership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "member", null);
}
@ -1126,8 +1154,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the users to revoke membership.
* @throws XMPPErrorException if an error occurs revoking membership to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException {
public void revokeMembership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "none");
}
@ -1140,8 +1169,9 @@ public class MultiUserChat {
* @param jid the bare XMPP user ID of the user to revoke membership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs revoking membership to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeMembership(String jid) throws XMPPErrorException, NoResponseException {
public void revokeMembership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "none", null);
}
@ -1153,8 +1183,9 @@ public class MultiUserChat {
* @param nicknames the nicknames of the occupants to grant moderator privileges.
* @throws XMPPErrorException if an error occurs granting moderator privileges to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException {
public void grantModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "moderator");
}
@ -1166,8 +1197,9 @@ public class MultiUserChat {
* @param nickname the nickname of the occupant to grant moderator privileges.
* @throws XMPPErrorException if an error occurs granting moderator privileges to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantModerator(String nickname) throws XMPPErrorException, NoResponseException {
public void grantModerator(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "moderator", null);
}
@ -1180,8 +1212,9 @@ public class MultiUserChat {
* @param nicknames the nicknames of the occupants to revoke moderator privileges.
* @throws XMPPErrorException if an error occurs revoking moderator privileges from a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException {
public void revokeModerator(Collection<String> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nicknames, "participant");
}
@ -1194,8 +1227,9 @@ public class MultiUserChat {
* @param nickname the nickname of the occupant to revoke moderator privileges.
* @throws XMPPErrorException if an error occurs revoking moderator privileges from a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeModerator(String nickname) throws XMPPErrorException, NoResponseException {
public void revokeModerator(String nickname) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeRole(nickname, "participant", null);
}
@ -1208,8 +1242,9 @@ public class MultiUserChat {
* @param jids the collection of bare XMPP user IDs of the users to grant ownership.
* @throws XMPPErrorException if an error occurs granting ownership privileges to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException {
public void grantOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "owner");
}
@ -1222,8 +1257,9 @@ public class MultiUserChat {
* @param jid the bare XMPP user ID of the user to grant ownership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs granting ownership privileges to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantOwnership(String jid) throws XMPPErrorException, NoResponseException {
public void grantOwnership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "owner", null);
}
@ -1235,8 +1271,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the users to revoke ownership.
* @throws XMPPErrorException if an error occurs revoking ownership privileges from a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException {
public void revokeOwnership(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jids, "admin");
}
@ -1248,8 +1285,9 @@ public class MultiUserChat {
* @param jid the bare XMPP user ID of the user to revoke ownership (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs revoking ownership privileges from a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeOwnership(String jid) throws XMPPErrorException, NoResponseException {
public void revokeOwnership(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByAdmin(jid, "admin", null);
}
@ -1261,8 +1299,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the users to grant administrator privileges.
* @throws XMPPErrorException if an error occurs granting administrator privileges to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException {
public void grantAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jids, "admin");
}
@ -1275,8 +1314,9 @@ public class MultiUserChat {
* (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs granting administrator privileges to a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void grantAdmin(String jid) throws XMPPErrorException, NoResponseException {
public void grantAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jid, "admin");
}
@ -1288,8 +1328,9 @@ public class MultiUserChat {
* @param jids the bare XMPP user IDs of the user to revoke administrator privileges.
* @throws XMPPErrorException if an error occurs revoking administrator privileges from a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException {
public void revokeAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jids, "member");
}
@ -1302,13 +1343,14 @@ public class MultiUserChat {
* (e.g. "user@host.org").
* @throws XMPPErrorException if an error occurs revoking administrator privileges from a user.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void revokeAdmin(String jid) throws XMPPErrorException, NoResponseException {
public void revokeAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jid, "member");
}
private void changeAffiliationByOwner(String jid, String affiliation)
throws XMPPErrorException, NoResponseException {
throws XMPPErrorException, NoResponseException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1321,7 +1363,7 @@ public class MultiUserChat {
}
private void changeAffiliationByOwner(Collection<String> jids, String affiliation)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1343,8 +1385,9 @@ public class MultiUserChat {
* @param reason the reason for the affiliation change (optional)
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
private void changeAffiliationByAdmin(String jid, String affiliation, String reason) throws NoResponseException, XMPPErrorException
private void changeAffiliationByAdmin(String jid, String affiliation, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException
{
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
@ -1359,7 +1402,7 @@ public class MultiUserChat {
}
private void changeAffiliationByAdmin(Collection<String> jids, String affiliation)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1373,7 +1416,7 @@ public class MultiUserChat {
connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
}
private void changeRole(String nickname, String role, String reason) throws NoResponseException, XMPPErrorException {
private void changeRole(String nickname, String role, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1386,7 +1429,7 @@ public class MultiUserChat {
connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
}
private void changeRole(Collection<String> nicknames, String role) throws NoResponseException, XMPPErrorException {
private void changeRole(Collection<String> nicknames, String role) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.SET);
@ -1491,8 +1534,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room owners.
* @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Collection<Affiliate> getOwners() throws NoResponseException, XMPPErrorException {
public Collection<Affiliate> getOwners() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("owner");
}
@ -1502,8 +1546,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room administrators.
* @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Collection<Affiliate> getAdmins() throws NoResponseException, XMPPErrorException {
public Collection<Affiliate> getAdmins() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("admin");
}
@ -1513,8 +1558,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room members.
* @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Collection<Affiliate> getMembers() throws NoResponseException, XMPPErrorException {
public Collection<Affiliate> getMembers() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("member");
}
@ -1524,8 +1570,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> with the room outcasts.
* @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Collection<Affiliate> getOutcasts() throws NoResponseException, XMPPErrorException {
public Collection<Affiliate> getOutcasts() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getAffiliatesByAdmin("outcast");
}
@ -1537,8 +1584,9 @@ public class MultiUserChat {
* @return a collection of <code>Affiliate</code> that have the specified room affiliation.
* @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
private Collection<Affiliate> getAffiliatesByAdmin(String affiliation) throws NoResponseException, XMPPErrorException {
private Collection<Affiliate> getAffiliatesByAdmin(String affiliation) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.GET);
@ -1562,8 +1610,9 @@ public class MultiUserChat {
* @return a collection of <code>Occupant</code> with the room moderators.
* @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Collection<Occupant> getModerators() throws NoResponseException, XMPPErrorException {
public Collection<Occupant> getModerators() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getOccupants("moderator");
}
@ -1573,8 +1622,9 @@ public class MultiUserChat {
* @return a collection of <code>Occupant</code> with the room participants.
* @throws XMPPErrorException if you don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Collection<Occupant> getParticipants() throws NoResponseException, XMPPErrorException {
public Collection<Occupant> getParticipants() throws NoResponseException, XMPPErrorException, NotConnectedException {
return getOccupants("participant");
}
@ -1586,8 +1636,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if an error occured while performing the request to the server or you
* don't have enough privileges to get this information.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
private Collection<Occupant> getOccupants(String role) throws NoResponseException, XMPPErrorException {
private Collection<Occupant> getOccupants(String role) throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.GET);
@ -1609,8 +1660,9 @@ public class MultiUserChat {
*
* @param text the text of the message to send.
* @throws XMPPException if sending the message fails.
* @throws NotConnectedException
*/
public void sendMessage(String text) throws XMPPException {
public void sendMessage(String text) throws XMPPException, NotConnectedException {
Message message = new Message(room, Message.Type.groupchat);
message.setBody(text);
connection.sendPacket(message);
@ -1645,8 +1697,9 @@ public class MultiUserChat {
*
* @param message the message.
* @throws XMPPException if sending the message fails.
* @throws NotConnectedException
*/
public void sendMessage(Message message) throws XMPPException {
public void sendMessage(Message message) throws XMPPException, NotConnectedException {
connection.sendPacket(message);
}
@ -1724,8 +1777,9 @@ public class MultiUserChat {
* @throws XMPPErrorException if someone without appropriate privileges attempts to change the
* room subject will throw an error with code 403 (i.e. Forbidden)
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException {
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException {
Message message = new Message(room, Message.Type.groupchat);
message.setSubject(subject);
// Wait for an error or confirmation message back from the server.

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.muc;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -74,7 +75,7 @@ class PacketMultiplexListener implements PacketListener {
this.declinesListener = declinesListener;
}
public void processPacket(Packet p) {
public void processPacket(Packet p) throws NotConnectedException {
if (PRESENCE_FILTER.accept(p)) {
presenceListener.processPacket(p);
}

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.muc;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
@ -183,7 +184,7 @@ class RoomListenerMultiplexor extends AbstractConnectionListener {
private Map<String, PacketMultiplexListener> roomListenersByAddress =
new ConcurrentHashMap<String, PacketMultiplexListener>();
public void processPacket(Packet p) {
public void processPacket(Packet p) throws NotConnectedException {
String from = p.getFrom();
if (from == null) {
return;

View file

@ -20,6 +20,7 @@ package org.jivesoftware.smackx.offline;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
@ -78,8 +79,9 @@ public class OfflineMessageManager {
* @return a boolean indicating if the server supports Flexible Offline Message Retrieval.
* @throws XMPPErrorException If the user is not allowed to make this request.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException {
public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(connection.getServiceName(), namespace);
}
@ -90,8 +92,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public int getMessageCount() throws NoResponseException, XMPPErrorException {
public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException {
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null,
namespace);
Form extendedInfo = Form.getFormFrom(info);
@ -112,8 +115,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Iterator<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException {
public Iterator<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException {
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
null, namespace);
@ -136,8 +140,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Iterator<Message> getMessages(final List<String> nodes) throws NoResponseException, XMPPErrorException {
public Iterator<Message> getMessages(final List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException {
List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) {
@ -177,8 +182,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Iterator<Message> getMessages() throws NoResponseException, XMPPErrorException {
public Iterator<Message> getMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest();
request.setFetch(true);
@ -206,8 +212,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void deleteMessages(List<String> nodes) throws NoResponseException, XMPPErrorException {
public void deleteMessages(List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException {
OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) {
OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
@ -223,8 +230,9 @@ public class OfflineMessageManager {
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void deleteMessages() throws NoResponseException, XMPPErrorException {
public void deleteMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
OfflineMessageRequest request = new OfflineMessageRequest();
request.setPurge(true);
connection.createPacketCollectorAndSend(request).nextResultOrThrow();

View file

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -105,8 +106,9 @@ public class PEPManager {
* Publish an event.
*
* @param item the item to publish.
* @throws NotConnectedException
*/
public void publish(PEPItem item) {
public void publish(PEPItem item) throws NotConnectedException {
// Create a new message to publish the event.
PEPPubSub pubSub = new PEPPubSub(item);
pubSub.setType(Type.SET);

View file

@ -29,6 +29,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -129,7 +130,7 @@ public class PingManager extends Manager {
connection.addPacketListener(new PacketListener() {
// Send a Pong for every Ping
@Override
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
Pong pong = new Pong(packet);
connection().sendPacket(pong);
}
@ -163,8 +164,9 @@ public class PingManager extends Manager {
* @param pingTimeout The time to wait for a reply
* @return true if a reply was received from the entity, false otherwise.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public boolean ping(String jid, long pingTimeout) throws NoResponseException {
public boolean ping(String jid, long pingTimeout) throws NoResponseException, NotConnectedException {
Ping ping = new Ping(jid);
try {
connection().createPacketCollectorAndSend(ping).nextResultOrThrow();
@ -194,8 +196,9 @@ public class PingManager extends Manager {
* @return true if it supports ping, false otherwise.
* @throws XMPPErrorException An XMPP related error occurred during the request
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public boolean isPingSupported(String jid) throws NoResponseException, XMPPErrorException {
public boolean isPingSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, PingManager.NAMESPACE);
}

View file

@ -24,6 +24,7 @@ import java.util.Set;
import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -88,7 +89,7 @@ public class PrivacyListManager extends Manager {
connection.addPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
Privacy privacy = (Privacy) packet;
// Notifies the event to the listeners.
@ -142,8 +143,9 @@ public class PrivacyListManager extends Manager {
* @return a new {@link Privacy} with the data received from the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
private Privacy getRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException {
private Privacy getRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request is a get iq type
requestPrivacy.setType(Privacy.Type.GET);
requestPrivacy.setFrom(this.getUser());
@ -161,8 +163,9 @@ public class PrivacyListManager extends Manager {
* @return a new {@link Privacy} with the data received from the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
private Packet setRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException {
private Packet setRequest(Privacy requestPrivacy) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request is a get iq type
requestPrivacy.setType(Privacy.Type.SET);
requestPrivacy.setFrom(this.getUser());
@ -176,8 +179,9 @@ public class PrivacyListManager extends Manager {
* @return a Privacy with the list names.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException {
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an empty privacy message
Privacy request = new Privacy();
@ -191,8 +195,9 @@ public class PrivacyListManager extends Manager {
* @return the privacy list of the active list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException {
public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getActiveName();
boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
@ -208,8 +213,9 @@ public class PrivacyListManager extends Manager {
* @return the privacy list of the default list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException {
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getDefaultName();
boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
@ -226,8 +232,9 @@ public class PrivacyListManager extends Manager {
* @return a list of privacy items under the list listName.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
private List<PrivacyItem> getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException {
private List<PrivacyItem> getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
@ -245,8 +252,9 @@ public class PrivacyListManager extends Manager {
* @return a privacy list under the list listName.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException {
public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
return new PrivacyList(false, false, listName, getPrivacyListItems(listName));
}
@ -256,8 +264,9 @@ public class PrivacyListManager extends Manager {
* @return an array of privacy lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList[] getPrivacyLists() throws NoResponseException, XMPPErrorException {
public PrivacyList[] getPrivacyLists() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
Set<String> names = privacyAnswer.getPrivacyListNames();
PrivacyList[] lists = new PrivacyList[names.size()];
@ -280,8 +289,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list name to set as the active one.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void setActiveListName(String listName) throws NoResponseException, XMPPErrorException {
public void setActiveListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setActiveName(listName);
@ -294,8 +304,9 @@ public class PrivacyListManager extends Manager {
* Client declines the use of active lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void declineActiveList() throws NoResponseException, XMPPErrorException {
public void declineActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineActiveList(true);
@ -310,8 +321,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list name to set as the default one.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void setDefaultListName(String listName) throws NoResponseException, XMPPErrorException {
public void setDefaultListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDefaultName(listName);
@ -324,8 +336,9 @@ public class PrivacyListManager extends Manager {
* Client declines the use of default lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void declineDefaultList() throws NoResponseException, XMPPErrorException {
public void declineDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineDefaultList(true);
@ -341,8 +354,9 @@ public class PrivacyListManager extends Manager {
* @param privacyItems a List with every privacy item in the list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException {
public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException {
updatePrivacyList(listName, privacyItems);
}
@ -355,8 +369,9 @@ public class PrivacyListManager extends Manager {
* @param privacyItems a List with every privacy item in the list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void updatePrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException {
public void updatePrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Build the privacy package to add or update the new list
Privacy request = new Privacy();
request.setPrivacyList(listName, privacyItems);
@ -371,8 +386,9 @@ public class PrivacyListManager extends Manager {
* @param listName the list that has changed its content.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException {
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
@ -401,8 +417,9 @@ public class PrivacyListManager extends Manager {
* @return true, if the server supports privacy lists, false otherwise.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public boolean isSupported() throws NoResponseException, XMPPErrorException{
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException{
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(
connection().getServiceName(), NAMESPACE);
}

View file

@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.List;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ.Type;
@ -49,8 +50,9 @@ public class LeafNode extends Node
* @return The item details in {@link DiscoverItems} format
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException
public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException, NotConnectedException
{
DiscoverItems items = new DiscoverItems();
items.setTo(to);
@ -64,9 +66,10 @@ public class LeafNode extends Node
* @return List of {@link Item} in the node
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException
public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId()));
@ -85,9 +88,10 @@ public class LeafNode extends Node
* @return List of {@link Item} in the node
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException
public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), subscriptionId));
@ -108,9 +112,10 @@ public class LeafNode extends Node
* @return The list of {@link Item} with payload
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException
{
List<Item> itemList = new ArrayList<Item>(ids.size());
@ -133,9 +138,10 @@ public class LeafNode extends Node
* @return List of {@link Item}
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException
public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), maxItems));
@ -155,9 +161,10 @@ public class LeafNode extends Node
* @return List of {@link Item}
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), subscriptionId, maxItems));
@ -177,8 +184,9 @@ public class LeafNode extends Node
* packet has been sent.
*
* For synchronous calls use {@link #send() send()}.
* @throws NotConnectedException
*/
public void publish()
public void publish() throws NotConnectedException
{
PubSub packet = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PUBLISH, getId()));
@ -199,9 +207,10 @@ public class LeafNode extends Node
* For synchronous calls use {@link #send(Item) send(Item))}.
*
* @param item - The item being sent
* @throws NotConnectedException
*/
@SuppressWarnings("unchecked")
public <T extends Item> void publish(T item)
public <T extends Item> void publish(T item) throws NotConnectedException
{
Collection<T> items = new ArrayList<T>(1);
items.add((T)(item == null ? new Item() : item));
@ -220,8 +229,9 @@ public class LeafNode extends Node
* For synchronous calls use {@link #send(Collection) send(Collection))}.
*
* @param items - The collection of items being sent
* @throws NotConnectedException
*/
public <T extends Item> void publish(Collection<T> items)
public <T extends Item> void publish(Collection<T> items) throws NotConnectedException
{
PubSub packet = createPubsubPacket(Type.SET, new PublishItem<T>(getId(), items));
@ -241,9 +251,10 @@ public class LeafNode extends Node
* For asynchronous calls, use {@link #publish() publish()}.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public void send() throws NoResponseException, XMPPErrorException
public void send() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub packet = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PUBLISH, getId()));
@ -270,10 +281,11 @@ public class LeafNode extends Node
* @param item - The item being sent
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
@SuppressWarnings("unchecked")
public <T extends Item> void send(T item) throws NoResponseException, XMPPErrorException
public <T extends Item> void send(T item) throws NoResponseException, XMPPErrorException, NotConnectedException
{
Collection<T> items = new ArrayList<T>(1);
items.add((item == null ? (T)new Item() : item));
@ -294,9 +306,10 @@ public class LeafNode extends Node
* @param items - The collection of {@link Item} objects being sent
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub packet = createPubsubPacket(Type.SET, new PublishItem<T>(getId(), items));
@ -310,8 +323,9 @@ public class LeafNode extends Node
* sent.
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void deleteAllItems() throws NoResponseException, XMPPErrorException
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace());
@ -324,8 +338,9 @@ public class LeafNode extends Node
* @param itemId The id of the item
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException
public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException, NotConnectedException
{
Collection<String> items = new ArrayList<String>(1);
items.add(itemId);
@ -338,8 +353,9 @@ public class LeafNode extends Node
* @param itemIds The list of id's of items to delete
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException
{
List<Item> items = new ArrayList<Item>(itemIds.size());

View file

@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.OrFilter;
@ -94,8 +95,9 @@ abstract public class Node
* @return the configuration form
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException
public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException
{
Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
@ -107,8 +109,9 @@ abstract public class Node
* @param submitForm
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void sendConfigurationForm(Form submitForm) throws NoResponseException, XMPPErrorException
public void sendConfigurationForm(Form submitForm) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub packet = createPubsubPacket(Type.SET, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER);
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
@ -120,8 +123,9 @@ abstract public class Node
* @return The discovery information about the node.
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException
public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException, NotConnectedException
{
DiscoverInfo info = new DiscoverInfo();
info.setTo(to);
@ -135,9 +139,10 @@ abstract public class Node
* @return List of {@link Subscription}
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()));
SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
@ -159,8 +164,9 @@ abstract public class Node
* @return The subscription
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Subscription subscribe(String jid) throws NoResponseException, XMPPErrorException
public Subscription subscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new SubscribeExtension(jid, getId()));
return (Subscription)reply.getExtension(PubSubElementType.SUBSCRIPTION);
@ -182,8 +188,9 @@ abstract public class Node
* @return The subscription
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException
public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(Type.SET, new SubscribeExtension(jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
@ -199,9 +206,10 @@ abstract public class Node
* @param jid The JID used to subscribe to the node
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException
public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException
{
unsubscribe(jid, null);
}
@ -213,8 +221,9 @@ abstract public class Node
* @param subscriptionId The id of the subscription being removed
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException
public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{
sendPubsubPacket(Type.SET, new UnsubscribeExtension(jid, getId(), subscriptionId));
}
@ -226,8 +235,9 @@ abstract public class Node
* @return A subscription options form
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public SubscribeForm getSubscriptionOptions(String jid) throws NoResponseException, XMPPErrorException
public SubscribeForm getSubscriptionOptions(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return getSubscriptionOptions(jid, null);
}
@ -242,9 +252,10 @@ abstract public class Node
* @return The subscription option form
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub packet = (PubSub)sendPubsubPacket(Type.GET, new OptionsExtension(jid, getId(), subscriptionId));
FormNode ext = (FormNode)packet.getExtension(PubSubElementType.OPTIONS);
@ -349,12 +360,12 @@ abstract public class Node
return PubSubManager.createPubsubPacket(to, type, ext, ns);
}
protected Packet sendPubsubPacket(Type type, NodeExtension ext) throws NoResponseException, XMPPErrorException
protected Packet sendPubsubPacket(Type type, NodeExtension ext) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return PubSubManager.sendPubsubPacket(con, to, type, ext);
}
protected Packet sendPubsubPacket(Type type, NodeExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException
protected Packet sendPubsubPacket(Type type, NodeExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return PubSubManager.sendPubsubPacket(con, to, type, ext, ns);
}

View file

@ -21,6 +21,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ.Type;
@ -81,8 +82,9 @@ final public class PubSubManager
* @return The node that was created
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public LeafNode createNode() throws NoResponseException, XMPPErrorException
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE));
NodeExtension elem = (NodeExtension)reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
@ -102,8 +104,9 @@ final public class PubSubManager
* @return The node that was created
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public LeafNode createNode(String id) throws NoResponseException, XMPPErrorException
public LeafNode createNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return (LeafNode)createNode(id, null);
}
@ -119,8 +122,9 @@ final public class PubSubManager
* @return The node that was created
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException
public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name));
boolean isLeafNode = true;
@ -152,9 +156,10 @@ final public class PubSubManager
* @return the node
* @throws XMPPErrorException The node does not exist
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@SuppressWarnings("unchecked")
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException
{
Node node = nodeMap.get(id);
@ -189,8 +194,9 @@ final public class PubSubManager
* @return {@link DiscoverItems} representing the existing nodes
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException
public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException
{
DiscoverItems items = new DiscoverItems();
@ -207,8 +213,9 @@ final public class PubSubManager
* @return List of exceptions
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException
{
Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS));
SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
@ -221,9 +228,10 @@ final public class PubSubManager
* @return List of affiliations
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*
*/
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.AFFILIATIONS));
AffiliationsExtension listElem = (AffiliationsExtension)reply.getExtension(PubSubElementType.AFFILIATIONS);
@ -236,8 +244,9 @@ final public class PubSubManager
* @param nodeId
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void deleteNode(String nodeId) throws NoResponseException, XMPPErrorException
public void deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException
{
sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
nodeMap.remove(nodeId);
@ -249,8 +258,9 @@ final public class PubSubManager
* @return configuration form containing the default settings.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException
{
// Errors will cause exceptions in getReply, so it only returns
// on success.
@ -265,19 +275,20 @@ final public class PubSubManager
* @return The supported features
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException
public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException
{
ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(con);
return mgr.discoverInfo(to);
}
private Packet sendPubsubPacket(Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException
private Packet sendPubsubPacket(Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return sendPubsubPacket(con, to, type, ext, ns);
}
private Packet sendPubsubPacket(Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException
private Packet sendPubsubPacket(Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return sendPubsubPacket(type, ext, null);
}
@ -302,22 +313,22 @@ final public class PubSubManager
return request;
}
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return sendPubsubPacket(con, to, type, ext, null);
}
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return con.createPacketCollectorAndSend(createPubsubPacket(to, type, ext, ns)).nextResultOrThrow();
}
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet) throws NoResponseException, XMPPErrorException
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return sendPubsubPacket(con, to, type, packet, null);
}
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet, PubSubNamespace ns) throws NoResponseException, XMPPErrorException
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{
return con.createPacketCollectorAndSend(packet).nextResultOrThrow();
}

View file

@ -23,6 +23,7 @@ import java.util.Set;
import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -99,7 +100,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
// handle incoming receipts and receipt requests
@Override
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
DeliveryReceipt dr = (DeliveryReceipt)packet.getExtension(
DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE);
if (dr != null) {

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.search;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -61,8 +62,9 @@ public class UserSearch extends IQ {
* @return the search form received by the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Form getSearchForm(XMPPConnection con, String searchService) throws NoResponseException, XMPPErrorException {
public Form getSearchForm(XMPPConnection con, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
UserSearch search = new UserSearch();
search.setType(IQ.Type.GET);
search.setTo(searchService);
@ -80,8 +82,9 @@ public class UserSearch extends IQ {
* @return ReportedData the data found from the query.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public ReportedData sendSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException {
public ReportedData sendSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
UserSearch search = new UserSearch();
search.setType(IQ.Type.SET);
search.setTo(searchService);
@ -100,8 +103,9 @@ public class UserSearch extends IQ {
* @return ReportedData the data found from the query.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public ReportedData sendSimpleSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException {
public ReportedData sendSimpleSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
SimpleUserSearch search = new SimpleUserSearch();
search.setForm(searchForm);
search.setType(IQ.Type.SET);

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.search;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -70,8 +71,9 @@ public class UserSearchManager {
* @return the form to fill out to perform a search.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Form getSearchForm(String searchService) throws NoResponseException, XMPPErrorException {
public Form getSearchForm(String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
return userSearch.getSearchForm(con, searchService);
}
@ -84,8 +86,9 @@ public class UserSearchManager {
* @return the ReportedData returned by the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public ReportedData getSearchResults(Form searchForm, String searchService) throws NoResponseException, XMPPErrorException {
public ReportedData getSearchResults(Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException {
return userSearch.sendSearchForm(con, searchForm, searchService);
}
@ -96,8 +99,9 @@ public class UserSearchManager {
* @return a Collection of search services found on the server.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Collection<String> getSearchServices() throws NoResponseException, XMPPErrorException {
public Collection<String> getSearchServices() throws NoResponseException, XMPPErrorException, NotConnectedException {
final List<String> searchServices = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems items = discoManager.discoverItems(con.getServiceName());

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.sharedgroups;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -42,8 +43,9 @@ public class SharedGroupManager {
* @return collection with the shared groups' name of the logged user.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static List<String> getSharedGroups(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public static List<String> getSharedGroups(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Discover the shared groups of the logged user
SharedGroupsInfo info = new SharedGroupsInfo();
info.setType(IQ.Type.GET);

View file

@ -20,6 +20,7 @@ import java.util.Map;
import java.util.WeakHashMap;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
@ -73,7 +74,7 @@ public class EntityTimeManager extends Manager {
connection.addPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
public void processPacket(Packet packet) throws NotConnectedException {
if (!enabled)
return;
connection().sendPacket(Time.createResponse(packet));
@ -97,11 +98,11 @@ public class EntityTimeManager extends Manager {
enabled = false;
}
public boolean isTimeSupported(String jid) throws NoResponseException, XMPPErrorException {
public boolean isTimeSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, Time.NAMESPACE);
}
public Time getTime(String jid) throws NoResponseException, XMPPErrorException {
public Time getTime(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (!isTimeSupported(jid))
return null;

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.vcardtemp;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -43,8 +44,9 @@ public class VCardManager {
* @return true if the given entity understands the vCard-XML format and exchange.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isSupported(String jid, XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public static boolean isSupported(String jid, XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(jid, NAMESPACE);
}
}

View file

@ -34,6 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -518,8 +519,9 @@ public class VCard extends IQ {
* @param connection the XMPPConnection to use.
* @throws XMPPErrorException thrown if there was an issue setting the VCard in the server.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void save(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public void save(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, true);
setType(IQ.Type.SET);
@ -532,8 +534,9 @@ public class VCard extends IQ {
* and not anonymous.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException {
public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, true);
setFrom(connection.getUser());
@ -544,15 +547,16 @@ public class VCard extends IQ {
* Load VCard information for a given user. XMPPConnection should be authenticated and not anonymous.
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void load(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException {
public void load(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException, NotConnectedException {
checkAuthenticated(connection, false);
setTo(user);
doLoad(connection, user);
}
private void doLoad(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException {
private void doLoad(XMPPConnection connection, String user) throws NoResponseException, XMPPErrorException, NotConnectedException {
setType(Type.GET);
VCard result = (VCard) connection.createPacketCollectorAndSend(this).nextResultOrThrow();
copyFieldsFrom(result);

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.xevent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/**
*
* Default implementation of the MessageEventRequestListener interface.<p>
@ -29,7 +31,7 @@ package org.jivesoftware.smackx.xevent;
public class DefaultMessageEventRequestListener implements MessageEventRequestListener {
public void deliveredNotificationRequested(String from, String packetID,
MessageEventManager messageEventManager)
MessageEventManager messageEventManager) throws NotConnectedException
{
// Send to the message's sender that the message has been delivered
messageEventManager.sendDeliveredNotification(from, packetID);

View file

@ -25,6 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
@ -221,8 +222,9 @@ public class MessageEventManager {
*
* @param to the recipient of the notification.
* @param packetID the id of the message to send.
* @throws NotConnectedException
*/
public void sendDeliveredNotification(String to, String packetID) {
public void sendDeliveredNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message
@ -239,8 +241,9 @@ public class MessageEventManager {
*
* @param to the recipient of the notification.
* @param packetID the id of the message to send.
* @throws NotConnectedException
*/
public void sendDisplayedNotification(String to, String packetID) {
public void sendDisplayedNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message
@ -257,8 +260,9 @@ public class MessageEventManager {
*
* @param to the recipient of the notification.
* @param packetID the id of the message to send.
* @throws NotConnectedException
*/
public void sendComposingNotification(String to, String packetID) {
public void sendComposingNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message
@ -275,8 +279,9 @@ public class MessageEventManager {
*
* @param to the recipient of the notification.
* @param packetID the id of the message to send.
* @throws NotConnectedException
*/
public void sendCancelledNotification(String to, String packetID) {
public void sendCancelledNotification(String to, String packetID) throws NotConnectedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.xevent;
import org.jivesoftware.smack.SmackException.NotConnectedException;
/**
*
* A listener that is fired anytime a message event request is received.
@ -45,9 +47,10 @@ public interface MessageEventRequestListener {
* @param from the user that sent the notification.
* @param packetID the id of the message that was sent.
* @param messageEventManager the messageEventManager that fired the listener.
* @throws NotConnectedException
*/
public void deliveredNotificationRequested(String from, String packetID,
MessageEventManager messageEventManager);
MessageEventManager messageEventManager) throws NotConnectedException;
/**
* Called when a request for message displayed notification is received.

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.xhtmlim;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Message;
@ -128,9 +129,10 @@ public class XHTMLManager {
* @return a boolean indicating whether the specified user handles XHTML messages
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean isServiceEnabled(XMPPConnection connection, String userID)
throws NoResponseException, XMPPErrorException {
throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(userID, namespace);
}
}

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError;
@ -66,9 +67,10 @@ public class InBandBytestreamRequestTest {
/**
* Test reject() method.
* @throws NotConnectedException
*/
@Test
public void shouldReplyWithErrorIfRequestIsRejected() {
public void shouldReplyWithErrorIfRequestIsRejected() throws NotConnectedException {
InBandBytestreamRequest ibbRequest = new InBandBytestreamRequest(
byteStreamManager, initBytestream);