How to create a pubsub node on server side

I know that i can use smack api to create a pubsub node on client side. however, i want to create a pubsub node on server side, but PubSubModule class has no method to do this. Does it mean i cannot do this on server side? or i miss something?

I want to implement that only administrator can create node and manage subscriber, how can i do that by coding?

Solve it by myself.

Create node and save it to db:

PubSubModule pubsub = XMPPServer.getInstance().getPubSubModule();

String nodeID = “testID”;

JID jid = new JID("abc@127.0.0.1");

LeafNode node = new LeafNode(pubsub, null, nodeID, jid);

node.saveToDB();

Delete node:

node.delete();

I would recommend that you simply create an appropriate IQ object and call pubsubModule.process(myIq). This will go through all the appropriate checks and setup.

This is a lot safer then your approach, which could cause all kinds of grief since it bypasses checks (like the node already existing) and, as is currently written, fails to set the node owner.

if i use your approach, how to check whether the node is created successfully? pubsubModule.process(packet) method doesn’t return anything, should i use pubsubModule.getNode(nodeID) to check if the node is created successfully?

That would be one way, another would be to make your plugin a component, so it will have a JID so it will receive the reply. Basically just treat your plugin like a user and make the request and receive the reply.

I haven’t actually done this myself, but I believe it is doable.

OK , thanks. I’ll try.