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:
parent
3e65cb31c3
commit
a1d4a91fa0
2 changed files with 22 additions and 24 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue