/** * Adds a collection of items to the discovered information. Does nothing if itemsToAdd is null * * @param itemsToAdd */ public void addItems(Collection<Item> itemsToAdd) { if (itemsToAdd == null) return; for (Item i : itemsToAdd) { addItem(i); } }
item.setNode(node); item.setAction(action); discoverItems.addItem(item);
item.setNode(node); item.setAction(action); discoverItems.addItem(item);
item.setNode(node); item.setAction(action); discoverItems.addItem(item);
item.setNode(node); item.setAction(action); discoverItems.addItem(item);
public void processPacket(Packet packet) { DiscoverItems discoverItems = (DiscoverItems) packet; // Send back the items defined in the client if the request is of type GET if (discoverItems != null && discoverItems.getType() == IQ.Type.GET) { DiscoverItems response = new DiscoverItems(); response.setType(IQ.Type.RESULT); response.setTo(discoverItems.getFrom()); response.setPacketID(discoverItems.getPacketID()); // Add the defined items related to the requested node. Look for // the NodeInformationProvider associated with the requested node. if (getNodeInformationProvider(discoverItems.getNode()) != null) { Iterator items = getNodeInformationProvider(discoverItems.getNode()).getNodeItems(); while (items.hasNext()) { response.addItem((DiscoverItems.Item) items.next()); } } else if(discoverItems.getNode() != null) { // Return an <item-not-found/> error since the client // doesn't contain the specified node response.setNode(discoverItems.getNode()); response.setType(IQ.Type.ERROR); response.setError(new XMPPError(404, "item-not-found")); } connection.sendPacket(response); } } };
/** * Publish the commands to an specific JID. * * @param jid the full JID to publish the commands to. * @throws XMPPException if the operation failed for some reason. */ public void publishCommands(String jid) throws XMPPException { ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager .getInstanceFor(connection); // Collects the commands to publish as items DiscoverItems discoverItems = new DiscoverItems(); Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands(); for (AdHocCommandInfo info : xCommandsList) { DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID()); item.setName(info.getName()); item.setNode(info.getNode()); discoverItems.addItem(item); } serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems); }
/** * Publish the commands to an specific JID. * * @param jid the full JID to publish the commands to. * @throws XMPPException if the operation failed for some reason. */ public void publishCommands(String jid) throws XMPPException { ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager .getInstanceFor(connection); // Collects the commands to publish as items DiscoverItems discoverItems = new DiscoverItems(); Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands(); for (AdHocCommandInfo info : xCommandsList) { DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID()); item.setName(info.getName()); item.setNode(info.getNode()); discoverItems.addItem(item); } serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems); }
/** * Publish the commands to an specific JID. * * @param jid the full JID to publish the commands to. * @throws XMPPException if the operation failed for some reason. */ public void publishCommands(String jid) throws XMPPException { ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager .getInstanceFor(connection); // Collects the commands to publish as items DiscoverItems discoverItems = new DiscoverItems(); Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands(); for (AdHocCommandInfo info : xCommandsList) { DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID()); item.setName(info.getName()); item.setNode(info.getNode()); discoverItems.addItem(item); } serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems); }
if (items != null) { for (DiscoverItems.Item item : items) { response.addItem(item);
if (items != null) { for (DiscoverItems.Item item : items) { response.addItem(item);