Package org.apache.vysper.xmpp.modules.roster

Examples of org.apache.vysper.xmpp.modules.roster.RosterException


        return new MutableRoster();
    }

    @Override
    public void addContact(Entity jid, RosterItem rosterItem) throws RosterException {
        if (jid == null) throw new RosterException("jid not provided");
        if (rosterItem.getJid() == null) throw new RosterException("contact jid not provided");

        // TODO think about concurrent updates

        Entity contactJid = rosterItem.getJid().getBareJID();
        Node contactNode = getOrCreateContactNode(jid, contactJid);
        try {
            setOrRemoveAttribute(contactNode, "name", rosterItem.getName());
            String subscriptionTypeValue = rosterItem.getSubscriptionType() == null ? null : rosterItem.getSubscriptionType().value();
            setOrRemoveAttribute(contactNode, "type", subscriptionTypeValue);
            String askSubscriptionTypeValue = null;
            if (rosterItem.getAskSubscriptionType() != null &&
                rosterItem.getAskSubscriptionType() != AskSubscriptionType.NOT_SET) {
                askSubscriptionTypeValue = rosterItem.getAskSubscriptionType().value();
            }
            setOrRemoveAttribute(contactNode, "askType", askSubscriptionTypeValue);
            contactNode.save();
            logger.info("JCR node created/updated: " + contactNode);
        } catch (RepositoryException e) {
            throw new RosterException("failed to add contact node to roster for user = " + jid.getFullQualifiedName() + " and contact jid = " + rosterItem.getJid().getFullQualifiedName(), e);
        }
    }
View Full Code Here


    private Node getOrCreateContactNode(Entity jid, Entity contactJid) throws RosterException {
        Node entityNode = null;
        try {
            entityNode = jcrStorage.getEntityNode(jid, NamespaceURIs.JABBER_IQ_ROSTER, true);
        } catch (JcrStorageException e) {
            throw new RosterException("failed to create roster store for " + jid.getFullQualifiedName(), e);
        }
        Node contactNode = null;
        try {
            contactNode = entityNode.getNode(contactJid.getFullQualifiedName());
        } catch (RepositoryException e) {
            // not exists, create
            try {
                contactNode = entityNode.addNode(contactJid.getFullQualifiedName());
                entityNode.save();
            } catch (RepositoryException addNodeEx) {
                throw new RosterException("failed to add contact node to roster for user = " + jid.getFullQualifiedName() + " and contact jid = " + contactJid.getFullQualifiedName(), addNodeEx);
            }

        }
        return contactNode;
    }
View Full Code Here

        return contactNode;
    }

    @Override
    public void removeContact(Entity jidUser, Entity jidContact) throws RosterException {
        if (jidUser == null) throw new RosterException("jid not provided");
        if (jidContact == null) throw new RosterException("contact jid not provided");
        Node rosterNode = null;
        try {
            rosterNode = jcrStorage.getEntityNode(jidUser, NamespaceURIs.JABBER_IQ_ROSTER, false);
        } catch (JcrStorageException e) {
            throw new RosterException("failed to retrieve roster store for " + jidUser.getFullQualifiedName(), e);
        }
        if (rosterNode == null) return; // done, no contacts anyway. oops

        NodeIterator nodes = null;
        try {
View Full Code Here

        jid = jid.getBareJID();
        return retrieveRosterInternal(jid);
    }

    public void addContact(Entity jid, RosterItem rosterItem) throws RosterException {
        if (jid == null) throw new RosterException("jid not provided");
        MutableRoster mutableRoster = (MutableRoster) retrieve(jid);
        if (mutableRoster == null) {
            mutableRoster = (MutableRoster) addNewRosterInternal(jid);
        }
        mutableRoster.addItem(rosterItem);
View Full Code Here

        }
        mutableRoster.addItem(rosterItem);
    }

    public RosterItem getContact(Entity jidUser, Entity jidContact) throws RosterException {
        if (jidUser == null) throw new RosterException("jid not provided");
        Roster roster = retrieve(jidUser);
        if (roster == null) throw new RosterException("roster not available for jid = " + jidUser.getFullQualifiedName());
        return roster.getEntry(jidContact);
    }
View Full Code Here

        if (roster == null) throw new RosterException("roster not available for jid = " + jidUser.getFullQualifiedName());
        return roster.getEntry(jidContact);
    }

    public void removeContact(Entity jidUser, Entity jidContact) throws RosterException {
        if (jidUser == null) throw new RosterException("jid not provided");
        Roster roster = retrieve(jidUser);
        if (roster == null) throw new RosterException("roster not available for jid = " + jidUser.getFullQualifiedName());
    }
View Full Code Here

    }

    @Override
    public void addContact(Entity jid, RosterItem rosterItem) throws RosterException {
        if (jid == null)
            throw new RosterException("jid not provided");
        if (rosterItem.getJid() == null)
            throw new RosterException("contact jid not provided");

        // TODO think about concurrent updates

        Entity contactJid = rosterItem.getJid().getBareJID();
        Node contactNode = getOrCreateContactNode(jid, contactJid);
        try {
            setOrRemoveAttribute(contactNode, "name", rosterItem.getName());
            String subscriptionTypeValue = rosterItem.getSubscriptionType() == null ? null : rosterItem
                    .getSubscriptionType().value();
            setOrRemoveAttribute(contactNode, "type", subscriptionTypeValue);
            String askSubscriptionTypeValue = null;
            if (rosterItem.getAskSubscriptionType() != null
                    && rosterItem.getAskSubscriptionType() != AskSubscriptionType.NOT_SET) {
                askSubscriptionTypeValue = rosterItem.getAskSubscriptionType().value();
            }
            setOrRemoveAttribute(contactNode, "askType", askSubscriptionTypeValue);
            contactNode.save();
            logger.info("JCR node created/updated: " + contactNode);
        } catch (RepositoryException e) {
            throw new RosterException("failed to add contact node to roster for user = " + jid.getFullQualifiedName()
                    + " and contact jid = " + rosterItem.getJid().getFullQualifiedName(), e);
        }
    }
View Full Code Here

    private Node getOrCreateContactNode(Entity jid, Entity contactJid) throws RosterException {
        Node entityNode = null;
        try {
            entityNode = jcrStorage.getEntityNode(jid, NamespaceURIs.JABBER_IQ_ROSTER, true);
        } catch (JcrStorageException e) {
            throw new RosterException("failed to create roster store for " + jid.getFullQualifiedName(), e);
        }
        Node contactNode = null;
        try {
            contactNode = entityNode.getNode(contactJid.getFullQualifiedName());
        } catch (RepositoryException e) {
            // not exists, create
            try {
                contactNode = entityNode.addNode(contactJid.getFullQualifiedName());
                entityNode.save();
            } catch (RepositoryException addNodeEx) {
                throw new RosterException("failed to add contact node to roster for user = "
                        + jid.getFullQualifiedName() + " and contact jid = " + contactJid.getFullQualifiedName(),
                        addNodeEx);
            }

        }
View Full Code Here

    }

    @Override
    public void removeContact(Entity jidUser, Entity jidContact) throws RosterException {
        if (jidUser == null)
            throw new RosterException("jid not provided");
        if (jidContact == null)
            throw new RosterException("contact jid not provided");
        Node rosterNode = null;
        try {
            rosterNode = jcrStorage.getEntityNode(jidUser, NamespaceURIs.JABBER_IQ_ROSTER, false);
        } catch (JcrStorageException e) {
            throw new RosterException("failed to retrieve roster store for " + jidUser.getFullQualifiedName(), e);
        }
        if (rosterNode == null)
            return; // done, no contacts anyway. oops

        NodeIterator nodes = null;
View Full Code Here

        return retrieveRosterInternal(jid);
    }

    public void addContact(Entity jid, RosterItem rosterItem) throws RosterException {
        if (jid == null)
            throw new RosterException("jid not provided");
        MutableRoster mutableRoster = (MutableRoster) retrieve(jid);
        if (mutableRoster == null) {
            mutableRoster = (MutableRoster) addNewRosterInternal(jid);
        }
        mutableRoster.addItem(rosterItem);
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.modules.roster.RosterException

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.