Hi,
I just need a quick verification from someone who knows the database structure that I'm properly publishing my custom LeafNode objects correctly. I'm following some of the previous threads on PEP and PubSub.
I'm using PubSubManager in Smack to publish a node to ( what I think) is the user's individual service.
- Connect with PubSubManager directly to the client's JID like this: mPubSubMgr = new PubSubManager(mConnection, userJid);
- Publish my object to the desired node, creating if necessary:
protected LeafNode getOrCreateNode(String nodeId) { if (!initMgr()) { mLogger.warn("getOrCreateNode() failed when attempting 'initMgr()' call"); returnnull; } LeafNode node = null; try{ node = mPubSubMgr.getNode(nodeId); }catch (XMPPException e1) { mLogger.warn("Unable to get node, creating"); } if (null == node) { try{ ConfigureForm form = new ConfigureForm(FormType.submit); form.setAccessModel(AccessModel.presence); form.setDeliverPayloads(true); form.setNotifyRetract(false); form.setPersistentItems(false); form.setPublishModel(PublishModel.open); node = (LeafNode) mPubSubMgr.createNode(nodeId, form); }catch (XMPPException e2) { mLogger.severe("Could not get node, and could not create either!"); e2.printStackTrace(); } } return node; } /** * * Publishes the user's location to as a PEP event using the PubSub transport. * @param location */ publicvoid publishLocation(LocationType location) { if (!initMgr()) { return; } LeafNode node = getOrCreateNode(UserLocationExtension.ELEMENT_NAME); if (null == node) { mLogger.warn("Not able to recover user's location node... abanoning publishLocation() operation"); return; } UserLocationExtension ext = new UserLocationExtension(location); UserLocationItem item = new UserLocationItem(ext); try{ node.send(item); }catch (XMPPException e) { e.printStackTrace(); } }
This works successfully, and I'm left with nodes in the Postgresql database:
serviceid (PK) | nodeid | leaf |
---|---|---|
testuser4@seattle1.foo.bar | Location | 1 |
testuser4@seattle1.foo.bar | testuser4@seattle1.foo.bar | 0 |
pubsub | SomeOtherNode | 1 |
testuser1@seattle1.foo.bar | Location | 1 |
testuser1@seattle1.foo.bar | http://jabber.org/protocol/tune | 1 |
Does this look correct?
Does the fact that the "serviceid" is qualified as the user's JID ( similar to tune) and NOT as a "pubsub" indicate that I've got the user's PEP node?
Thanks,
DD