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

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


            // error condition 1 (6.1.3)
            return errorStanzaGenerator.generateJIDDontMatchErrorStanza(sender, serverJID, stanza);
        }

        String nodeName = extractNodeName(stanza);
        LeafNode node = root.find(nodeName);

        if (node == null) {
            // no such node (error condition 11 (6.1.3))
            return errorStanzaGenerator.generateNoNodeErrorStanza(sender, serverJID, stanza);
        }

        String id = idGenerator.create();
        node.subscribe(id, subJID);

        buildSuccessStanza(sb, nodeName, strSubJID, id);

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


        StanzaBuilder sb = StanzaBuilder.createDirectReply(stanza, false, IQStanzaType.RESULT);
        sb.startInnerElement("pubsub", NamespaceURIs.XEP0060_PUBSUB_OWNER);

        String nodeName = extractNodeName(stanza);
        LeafNode node = root.find(nodeName);

        if (node == null) {
            return errorStanzaGenerator.generateNoNodeErrorStanza(sender, serverJID, stanza);
        }

        if (!node.isAuthorized(sender, PubSubPrivilege.MANAGE_AFFILIATIONS)) {
            return errorStanzaGenerator.generateInsufficientPrivilegesErrorStanza(sender, serverJID, stanza);
        }

        XMLElement affiliationElement = null;
        try {
            if (stanza.getFirstInnerElement().getFirstInnerElement().getInnerElements().size() != 1) {
                return errorStanzaGenerator.generateNotAcceptableErrorStanza(serverJID, sender, stanza);
            }

            affiliationElement = stanza.getFirstInnerElement().getFirstInnerElement().getFirstInnerElement();

            Entity userJID = null;
            try {
                userJID = EntityImpl.parse(affiliationElement.getAttributeValue("jid"));
            } catch (EntityFormatException e) {
                return errorStanzaGenerator.generateJIDMalformedErrorStanza(serverJID, sender, stanza); // TODO not defined in the standard(?)
            }

            PubSubAffiliation newAffiliation = PubSubAffiliation.get(affiliationElement
                    .getAttributeValue("affiliation"));
            node.setAffiliation(userJID, newAffiliation);
        } catch (LastOwnerResignedException e) {
            // if the last owner tries to resign.
            return errorStanzaGenerator.generateNotAcceptableErrorStanza(serverJID, sender, stanza);
        } catch (Throwable t) { // possible null-pointer
            return errorStanzaGenerator.generateBadRequestErrorStanza(serverJID, sender, stanza); // TODO not defined in the standard(?)
View Full Code Here

        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(), response.getType());

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match

        LeafNode n = root.find(testNode);
        assertEquals(testNode, n.getName());
    }
View Full Code Here

        assertEquals(testNode, n.getName());
    }

    public void testCreateDuplicate() throws Exception {
        String testNode = "test";
        root.add(new LeafNode(serviceConfiguration, testNode, client));
        assertNotNull(root.find(testNode)); // should be there

        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
View Full Code Here

    protected LeafNode node = null;

    @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

    @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

    protected LeafNode node = null;

    @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

    @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

        List<InfoElement> infoElements = new ArrayList<InfoElement>();
        if (request.getNode() == null || request.getNode().length() == 0) {
            infoElements.add(new Identity("pubsub", "service", "Publish-Subscribe"));
            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

            }
            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

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.