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

Make PubSubManager.deleteNode(String) "node did not exists" aware

This commit is contained in:
Florian Schmaus 2018-08-15 17:48:54 +02:00
parent 3e65cb31c3
commit a1d4a91fa0
2 changed files with 22 additions and 24 deletions

View file

@ -471,10 +471,21 @@ public final class PubSubManager extends Manager {
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
* @return <code>true</code> if this node existed and was deleted and <code>false</code> if this node did not exist.
*/
public void deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
boolean res = true;
try {
sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
} catch (XMPPErrorException e) {
if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
res = false;
} else {
throw e;
}
}
nodeMap.remove(nodeId);
return res;
}
/**