Package org.apache.vysper.xmpp.modules.extension.xep0060_pubsub.model

Examples of org.apache.vysper.xmpp.modules.extension.xep0060_pubsub.model.LeafNode


        assertNotNull(identity);
        assertNotNull(feature);
    }
   
    public void testInfoRequestForANode() throws Exception {
        root.add(new LeafNode(serviceConfiguration, "news", "News", client));

        DefaultDiscoInfoStanzaGenerator sg = (DefaultDiscoInfoStanzaGenerator)getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService.getBareJID(), "id123","news");

        ResponseStanzaContainer result = sendStanza(stanza, true);
View Full Code Here


    @Override
    public void setUp() throws Exception {
        super.setUp();
       
        n1 = new LeafNode(serviceConfiguration, "Node1", "Node 1 used for testing purposes", client);
        n2 = new LeafNode(serviceConfiguration, "Node2", "Node 2 used for testing purposes", client);
        n3 = new LeafNode(serviceConfiguration, "Node3", "Node 3 used for testing purposes", client);
       
        root.add(n1);
        root.add(n2);
        root.add(n3);
    }
View Full Code Here

        if(nodeName == null) { // all subscriptions for all nodes
            NodeSubscriberVisitor nodeSubscriptionVisitor = new NodeSubscriberVisitor(sender);
            root.acceptNodes(nodeSubscriptionVisitor);
            subscriptions = nodeSubscriptionVisitor.getSubscriptions();
        } else { // only the subscriptions for the requested node
            LeafNode node = root.find(nodeName);

            if(node == null) {
                // done - this is only a filter - no error conditions are defined
                subscriptions = Collections.emptyList();
            } else {
                SubscriberSubscriptionVisitor subscriptionVisitor = new SubscriberSubscriptionVisitor(sender);
                node.acceptSubscribers(subscriptionVisitor);
                subscriptions = subscriptionVisitor.getSubscriptions();
            }
        }
        return subscriptions;
    }
View Full Code Here

        List<InfoElement> infoElements = new ArrayList<InfoElement>();
        if(request.getNode() == null || request.getNode().length() == 0) {
            infoElements.add(new Identity("pubsub", "service"));
            infoElements.add(new Feature(NamespaceURIs.XEP0060_PUBSUB));
        } else {
            LeafNode node = root.find(request.getNode());
            infoElements.addAll(node.getNodeInfosFor(request));
        }
        return infoElements;
    }
View Full Code Here

        if(request.getNode() == null || request.getNode().length() == 0) {
            ServiceDiscoItemsVisitor nv = new ServiceDiscoItemsVisitor(serviceConfiguration);
            root.acceptNodes(nv);
            items = nv.getNodeItemList();
        } else {
            LeafNode node = root.find(request.getNode());
            NodeDiscoItemsVisitor iv = new NodeDiscoItemsVisitor(request.getTo());
            node.acceptItems(iv);
            items = iv.getItemList();
        }
       
        return items;
    }
View Full Code Here

        if(root.find(nodeName) != null) {
            return errorStanzaGenerator.generateDuplicateNodeErrorStanza(sender, serverJID, stanza);
        }

        LeafNode node = new LeafNode(serviceConfiguration, nodeName, sender);
        root.add(node);

        return new IQStanza(sb.build());
    }
View Full Code Here

    public void setUp() throws Exception {
        super.setUp();
        client2 = new EntityImpl("user1", "vysper.org", null);
        client3 = new EntityImpl("user2", "vysper.org", null);

        n1 = new LeafNode(serviceConfiguration, "Node1", "Node 1 used for testing purposes", client);
        n1.setAffiliation(client2, PubSubAffiliation.MEMBER);
       
        root.add(n1);
    }
View Full Code Here

        String nodeName = publish.getAttributeValue("node"); // MUST

        XMLElement item = publish.getFirstInnerElement();
        String strID = item.getAttributeValue("id"); // MAY

        LeafNode node = root.find(nodeName);

        if(node == null) {
            // node does not exist - error condition 3 (7.1.3)
            return errorStanzaGenerator.generateNoNodeErrorStanza(sender, serverJID, stanza);
        }

        if(!node.isAuthorized(sender, PubSubPrivilege.PUBLISH)) {
            // not enough privileges to publish - error condition 1 (7.1.3)
            return errorStanzaGenerator.generateInsufficientPrivilegesErrorStanza(sender, serverJID, stanza);
        }

        if(strID == null) {
            strID = idGenerator.create();
            // wrap a new item element with the id attribute
            StanzaBuilder itemBuilder = new StanzaBuilder("item");
            itemBuilder.addAttribute("id", strID);
            itemBuilder.addPreparedElement(item.getFirstInnerElement());
            item = itemBuilder.build();
        }

        StanzaRelay relay = serverRuntimeContext.getStanzaRelay();
        node.publish(sender, relay, strID, item);

        buildSuccessStanza(sb, nodeName, strID);

        sb.endInnerElement(); // pubsub
        return new IQStanza(sb.build());
View Full Code Here

    protected String testNode = "news";

    @Override
    public void setUp() throws Exception {
        super.setUp();
        node = new LeafNode(serviceConfiguration, "news", "Node used for testing purposes", client);
        root.add(node);
    }
View Full Code Here

        Entity sender = extractSenderJID(stanza, sessionContext);
       
        String iqStanzaID = stanza.getAttributeValue("id");
        StanzaBuilder sb = StanzaBuilder.createIQStanza(serverJID, sender, IQStanzaType.RESULT, iqStanzaID);
        String nodeName = extractNodeName(stanza);
        LeafNode node = root.find(nodeName);
       
        if(node == null) {
            return errorStanzaGenerator.generateNoNodeErrorStanza(sender, serverJID, stanza);
        }
       
        if(!node.isAuthorized(sender, PubSubPrivilege.DELETE)) {
            return errorStanzaGenerator.generateInsufficientPrivilegesErrorStanza(sender, serverJID, stanza);
        }
       
        sendDeleteNotifications(serverRuntimeContext, sender, nodeName, node);
        root.deleteNode(nodeName);
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.modules.extension.xep0060_pubsub.model.LeafNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.