public void createNodeToAllowComments(String blogPostId) { String nodeName = PublishCommentExtension.NODE + "/" + blogPostId; PubSubManager pubSubManager = PubSubManager.getInstance(XMPPSession.getInstance().getXMPPConnection()); try { // create node ConfigureForm configureForm = new ConfigureForm(DataForm.Type.submit); configureForm.setPublishModel(PublishModel.open); configureForm.setAccessModel(AccessModel.open); Node node = pubSubManager.createNode(nodeName, configureForm); // subscribe to comments String myJIDString = getUser().toString(); node.subscribe(myJIDString); } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) { e.printStackTrace(); } }
@Override protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content) { if (content.size() == 0) return new ConfigurationEvent(attMap.get("node")); else return new ConfigurationEvent(attMap.get("node"), new ConfigureForm((DataForm)content.iterator().next())); }
protected LeafNode getRandomPubnode(PubSubManager pubMgr, boolean persistItems, boolean deliverPayload) throws XMPPException { ConfigureForm form = new ConfigureForm(FormType.submit); form.setPersistentItems(persistItems); form.setDeliverPayloads(deliverPayload); form.setAccessModel(AccessModel.open); return (LeafNode)pubMgr.createNode("/test/Pubnode" + System.currentTimeMillis(), form); }
@Override protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content) { if (content.size() == 0) return new ConfigurationEvent(attMap.get("node")); else return new ConfigurationEvent(attMap.get("node"), new ConfigureForm((DataForm)content.iterator().next())); }
/** * Get a {@link ConfigureForm} from a packet. * * @param packet * @param elem * @return The configuration form */ public static ConfigureForm getFormFromPacket(Packet packet, PubSubElementType elem) { FormNode config = (FormNode)packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); Form formReply = config.getForm(); return new ConfigureForm(formReply); }
@Override protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content) { if (content.size() == 0) return new ConfigurationEvent(attMap.get("node")); else return new ConfigurationEvent(attMap.get("node"), new ConfigureForm((DataForm) content.iterator().next())); }
/** * Get a {@link ConfigureForm} from a packet. * * @param packet * @param elem * @return The configuration form */ public static ConfigureForm getFormFromPacket(Packet packet, PubSubElementType elem) { FormNode config = (FormNode) packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); Form formReply = config.getForm(); return new ConfigureForm(formReply); }
/** * Get a {@link ConfigureForm} from a packet. * * @param packet * @param elem * @return The configuration form */ public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) { FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); Form formReply = config.getForm(); return new ConfigureForm(formReply); }