Examples of MutableRoster


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

    @Override
    protected Roster retrieveRosterInternal(Entity bareJid) {
        final Node rosterNode = retrieveRosterNode(jcrStorage, bareJid);

        MutableRoster roster = new MutableRoster();

        NodeIterator nodes = null;
        try {
            nodes = rosterNode.getNodes();
        } catch (RepositoryException e) {
            return roster; // empty roster object
        }
        while (nodes != null && nodes.hasNext()) {
            Node node = nodes.nextNode();

            String contactJidString = null;
            try {
                contactJidString = node.getName();
            } catch (RepositoryException e) {
                logger.warn("when loading roster for user {} cannot read node name for node id = " + node.toString());
            }
            logger.warn("try now loading contact " + contactJidString + " from node " + node.toString());
            EntityImpl contactJid = null;
            if (contactJidString != null) {
                try {
                    contactJid = EntityImpl.parse(contactJidString);
                } catch (EntityFormatException e) {
                    logger.warn("when loading roster for user {} parsing  contact jid {}", bareJid, contactJidString);
                }
            }
            if (contactJid == null) {
                logger.warn("when loading roster for user {}, skipping a contact due to missing or unparsable jid", bareJid);
                continue;
            }

            String name = readAttribute(node, "name");
            String typeString = readAttribute(node, "type");
            SubscriptionType subscriptionType = null;
            try {
                subscriptionType = SubscriptionType.valueOf(typeString == null ? "NONE" : typeString.toUpperCase());
            } catch (IllegalArgumentException e) {
                logger.warn("when loading roster for user " + bareJid + ", contact " + contactJid + " misses a subscription type", bareJid, contactJid);
            }
            String askTypeString = readAttribute(node, "askType");
            AskSubscriptionType askSubscriptionType = AskSubscriptionType.NOT_SET;
            try {
                if (askTypeString != null) askSubscriptionType = AskSubscriptionType.valueOf(askTypeString);
            } catch (IllegalArgumentException e) {
                logger.warn("when loading roster for user " + bareJid.getFullQualifiedName() + ", contact " + contactJid.getFullQualifiedName() + ", the ask subscription type is unparsable. skipping!");
                continue; // don't return it, don't set a default!
            }

            List<RosterGroup> groups = new ArrayList<RosterGroup>();
            // TODO read groups

            RosterItem item = new RosterItem(contactJid, name, subscriptionType, askSubscriptionType, groups);
            logger.info("item loaded for " + bareJid.getFullQualifiedName() + ": " + item.toString());
            roster.addItem(item);
        }
        return roster;
    }
View Full Code Here

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

        }
    }

    @Override
    protected Roster addNewRosterInternal(Entity jid) {
        return new MutableRoster();
    }
View Full Code Here

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

        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

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

    private Map<Entity, MutableRoster> rosterMap = new HashMap<Entity, MutableRoster>();

    @Override
    protected Roster addNewRosterInternal(Entity jid) {
        MutableRoster mutableRoster = new MutableRoster();
        rosterMap.put(jid.getBareJID(), (MutableRoster) mutableRoster);
        return mutableRoster;
    }
View Full Code Here

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

        return mutableRoster;
    }

    @Override
    protected Roster retrieveRosterInternal(Entity bareJid) {
        if (!rosterMap.containsKey(bareJid)) rosterMap.put(bareJid, new MutableRoster());
        return rosterMap.get(bareJid);
    }
View Full Code Here

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

    @Override
    protected Roster retrieveRosterInternal(Entity bareJid) {
        final Node rosterNode = retrieveRosterNode(jcrStorage, bareJid);

        MutableRoster roster = new MutableRoster();

        NodeIterator nodes = null;
        try {
            nodes = rosterNode.getNodes();
        } catch (RepositoryException e) {
            return roster; // empty roster object
        }
        while (nodes != null && nodes.hasNext()) {
            Node node = nodes.nextNode();

            String contactJidString = null;
            try {
                contactJidString = node.getName();
            } catch (RepositoryException e) {
                logger.warn("when loading roster for user {} cannot read node name for node id = " + node.toString());
            }
            logger.warn("try now loading contact " + contactJidString + " from node " + node.toString());
            EntityImpl contactJid = null;
            if (contactJidString != null) {
                try {
                    contactJid = EntityImpl.parse(contactJidString);
                } catch (EntityFormatException e) {
                    logger.warn("when loading roster for user {} parsing  contact jid {}", bareJid, contactJidString);
                }
            }
            if (contactJid == null) {
                logger.warn("when loading roster for user {}, skipping a contact due to missing or unparsable jid",
                        bareJid);
                continue;
            }

            String name = readAttribute(node, "name");
            String typeString = readAttribute(node, "type");
            SubscriptionType subscriptionType = null;
            try {
                subscriptionType = SubscriptionType.valueOf(typeString == null ? "NONE" : typeString.toUpperCase());
            } catch (IllegalArgumentException e) {
                logger.warn("when loading roster for user " + bareJid + ", contact " + contactJid
                        + " misses a subscription type", bareJid, contactJid);
            }
            String askTypeString = readAttribute(node, "askType");
            AskSubscriptionType askSubscriptionType = AskSubscriptionType.NOT_SET;
            try {
                if (askTypeString != null)
                    askSubscriptionType = AskSubscriptionType.valueOf(askTypeString);
            } catch (IllegalArgumentException e) {
                logger.warn("when loading roster for user " + bareJid.getFullQualifiedName() + ", contact "
                        + contactJid.getFullQualifiedName() + ", the ask subscription type is unparsable. skipping!");
                continue; // don't return it, don't set a default!
            }

            List<RosterGroup> groups = new ArrayList<RosterGroup>();
            // TODO read groups

            RosterItem item = new RosterItem(contactJid, name, subscriptionType, askSubscriptionType, groups);
            logger.info("item loaded for " + bareJid.getFullQualifiedName() + ": " + item.toString());
            roster.addItem(item);
        }
        return roster;
    }
View Full Code Here

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

        }
    }

    @Override
    protected Roster addNewRosterInternal(Entity jid) {
        return new MutableRoster();
    }
View Full Code Here

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

    }

    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

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

    private Map<Entity, MutableRoster> rosterMap = new HashMap<Entity, MutableRoster>();

    @Override
    protected Roster addNewRosterInternal(Entity jid) {
        MutableRoster mutableRoster = new MutableRoster();
        rosterMap.put(jid.getBareJID(), (MutableRoster) mutableRoster);
        return mutableRoster;
    }
View Full Code Here

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

    }

    @Override
    protected Roster retrieveRosterInternal(Entity bareJid) {
        if (!rosterMap.containsKey(bareJid))
            rosterMap.put(bareJid, new MutableRoster());
        return rosterMap.get(bareJid);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.