use of org.jivesoftware.smack.packet.StanzaError.Condition in project Smack by igniterealtime.
the class Roster method reload.
/**
* Reloads the entire roster from the server. This is an asynchronous operation,
* which means the method will return immediately, and the roster will be
* reloaded at a later point when the server responds to the reload request.
* @throws NotLoggedInException If not logged in.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public void reload() throws NotLoggedInException, NotConnectedException, InterruptedException {
final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
RosterPacket packet = new RosterPacket();
if (rosterStore != null && isRosterVersioningSupported()) {
packet.setVersion(rosterStore.getRosterVersion());
}
rosterState = RosterState.loading;
SmackFuture<IQ, Exception> future = connection.sendIqRequestAsync(packet);
future.onSuccess(new RosterResultListener()).onError(new ExceptionCallback<Exception>() {
@Override
public void processException(Exception exception) {
rosterState = RosterState.uninitialized;
Level logLevel = Level.SEVERE;
if (exception instanceof NotConnectedException) {
logLevel = Level.FINE;
} else if (exception instanceof XMPPErrorException) {
Condition condition = ((XMPPErrorException) exception).getStanzaError().getCondition();
if (condition == Condition.feature_not_implemented || condition == Condition.service_unavailable) {
logLevel = Level.FINE;
}
}
LOGGER.log(logLevel, "Exception reloading roster", exception);
for (RosterLoadedListener listener : rosterLoadedListeners) {
listener.onRosterLoadingFailed(exception);
}
}
});
}
Aggregations