diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
index 2b92b1d5d..74e705030 100644
--- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
+++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
@@ -471,10 +471,21 @@ public final class PubSubManager extends Manager {
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
+ * @return true
if this node existed and was deleted and false
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;
}
/**
diff --git a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java
index a2c8e6f0a..2cb53c8d3 100644
--- a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java
+++ b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java
@@ -224,20 +224,13 @@ public class OpenPgpPubSubUtil {
* @throws SmackException.NotConnectedException if we are not connected.
* @throws InterruptedException if the thread is interrupted.
* @throws SmackException.NoResponseException if the server doesn't respond.
+ * @return true
if the node existed and was deleted, false
if the node did not exist.
*/
- public static void deletePubkeysListNode(XMPPConnection connection)
+ public static boolean deletePubkeysListNode(XMPPConnection connection)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException {
PubSubManager pm = PubSubManager.getInstance(connection, connection.getUser().asBareJid());
- try {
- pm.deleteNode(PEP_NODE_PUBLIC_KEYS);
- } catch (XMPPException.XMPPErrorException e) {
- if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
- LOGGER.log(Level.FINE, "Node does not exist. No need to delete it.");
- } else {
- throw e;
- }
- }
+ return pm.deleteNode(PEP_NODE_PUBLIC_KEYS);
}
/**
@@ -250,20 +243,13 @@ public class OpenPgpPubSubUtil {
* @throws SmackException.NotConnectedException if we are not connected.
* @throws InterruptedException if the thread gets interrupted.
* @throws SmackException.NoResponseException if the server doesn't respond.
+ * @return true
if the node existed and was deleted, false
if the node did not exist.
*/
- public static void deletePublicKeyNode(XMPPConnection connection, OpenPgpV4Fingerprint fingerprint)
+ public static boolean deletePublicKeyNode(XMPPConnection connection, OpenPgpV4Fingerprint fingerprint)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException {
PubSubManager pm = PubSubManager.getInstance(connection, connection.getUser().asBareJid());
- try {
- pm.deleteNode(PEP_NODE_PUBLIC_KEY(fingerprint));
- } catch (XMPPException.XMPPErrorException e) {
- if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
- LOGGER.log(Level.FINE, "Node does not exist. No need to delete it.");
- } else {
- throw e;
- }
- }
+ return pm.deleteNode(PEP_NODE_PUBLIC_KEY(fingerprint));
}
@@ -404,12 +390,13 @@ public class OpenPgpPubSubUtil {
* @throws SmackException.NotConnectedException if we are not connected
* @throws InterruptedException if the thread gets interrupted
* @throws SmackException.NoResponseException if the server sends no response
+ * @return true
if the node existed and was deleted, false
if the node did not exist.
*/
- public static void deleteSecretKeyNode(XMPPConnection connection)
+ public static boolean deleteSecretKeyNode(XMPPConnection connection)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException {
PubSubManager pm = PubSubManager.getInstance(connection);
- pm.deleteNode(PEP_NODE_SECRET_KEY);
+ return pm.deleteNode(PEP_NODE_SECRET_KEY);
}
/**