Reputation: 228
I've got the following code:
PubSubManager manager = new PubSubManager(connection, "pubsub.openfire.local");
LeafNode myNode = (LeafNode) manager.createNode("NewNode", form);
SimplePayload payload = new SimplePayload("session", "pubsub:NewNode:session", "<sessionId>1234</sessionId>");
// putting null for id means you let server generate id
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>(null, payload);
// you could use publish() for asynchronous call
myNode.send(item);
and I continuously get the following error on trying to send the node value:
conflict(409) at >org.jivesoftware.smackx.pubsub.packet.SyncPacketSend.getReply(SyncPacketSend.java:53) at >org.jivesoftware.smackx.pubsub.packet.SyncPacketSend.getReply(SyncPacketSend.java:61) at >org.jivesoftware.smackx.pubsub.PubSubManager.sendPubsubPacket(PubSubManager.java:324) at >org.jivesoftware.smackx.pubsub.PubSubManager.sendPubsubPacket(PubSubManager.java:318) at org.jivesoftware.smackx.pubsub.PubSubManager.createNode(PubSubManager.java:134) at PubSubPublisher.main(PubSubPublisher.java:33)
Would love any ideas about how to debug, or move forward with this. Thanks.
Upvotes: 2
Views: 1250
Reputation: 11385
The node you are trying to create already exists. Call getNode and/or deleteNode first and then createNode
. Wrap your code in a try/catch
block to handle the XMPPException
that may be thrown.
LeafNode myNode = null;
try{
try{
LeafNode existingNode = manager.getNode("NewNode");
//exists, so delete
manager.deleteNode("NewNode");
}catch(XMPPException e){
//'getNode' threw an exception.
//so we know that the node did not exist
}
myNode = (LeafNode) manager.createNode("NewNode", form);
}catch(XMPPException e){
System.err.println(e);
}
Upvotes: 2