Examples of RosterItem


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

        if (stanza == null)
            return false;
        IQStanza rosterPush = (IQStanza) XMPPCoreStanza.getWrapper(stanza);
        rosterPush.getInnerElementsNamed("query");

        RosterItem rosterItem = null;
        try {
            rosterItem = RosterUtils.parseRosterItemForTesting(rosterPush);
        } catch (Exception e) {
            fail(e.toString());
        }
        assertEquals(rosterPush.getTo().getFullQualifiedName(), entity.getFullQualifiedName());
        assertEquals(contact.getFullQualifiedName(), rosterItem.getJid().getFullQualifiedName());
        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
        assertEquals(askSubscriptionType, rosterItem.getAskSubscriptionType());

        return true;
    }
View Full Code Here

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

            }

            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.RosterItem

                    StanzaErrorType.MODIFY,
                    "sender info insufficient: " + ((user == null) ? "no from" : user.getFullQualifiedName()), null,
                    null);
        }

        RosterItem setRosterItem;
        try {
            setRosterItem = RosterUtils.parseRosterItem(stanza);
        } catch (RosterBadRequestException e) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza,
                    StanzaErrorType.MODIFY, e.getMessage(), null, null);
        } catch (RosterNotAcceptableException e) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.NOT_ACCEPTABLE, stanza,
                    StanzaErrorType.MODIFY, e.getMessage(), null, null);
        }

        Entity contactJid = setRosterItem.getJid().getBareJID();

        RosterItem existingItem;
        try {
            existingItem = rosterManager.getContact(user.getBareJID(), contactJid);
        } catch (RosterException e) {
            existingItem = null;
        }

        if (setRosterItem.getSubscriptionType() == REMOVE) {
            // remove is handled in separate method, return afterwards
            return rosterItemRemove(stanza, sessionContext, rosterManager, user, contactJid, existingItem);
        } /* else: all other subscription types are ignored in a roster set and have been filtered out by RosterUtils.parseRosterItem() */

        // proper set (update, not a remove)
        if (existingItem == null) {
            existingItem = new RosterItem(contactJid, NONE);
        }

        if (setRosterItem.getName() != null) {
            existingItem.setName(setRosterItem.getName());
            logger.debug(user.getBareJID() + " roster: set roster item name to " + setRosterItem.getName());
        }
        existingItem.setGroups(setRosterItem.getGroups());
        logger.debug(user.getBareJID() + " roster: roster item groups set to " + setRosterItem.getGroups());

        try {
            // update contact persistently
            rosterManager.addContact(user.getBareJID(), existingItem);
View Full Code Here

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

                logger.warn("failure sending unsubscribe on roster remove", e);
            }
        }

        // send roster item push to all interested resources
        pushRosterItemToInterestedResources(sessionContext, user, new RosterItem(contactJid, REMOVE));

        // return success
        return StanzaBuilder.createIQStanza(null, user, IQStanzaType.RESULT, stanza.getID()).build();
    }
View Full Code Here

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

        Entity user = stanza.getTo();

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        RosterItem rosterItem;
        try {
            rosterItem = rosterManager.getContact(userBareJid, contactBareJid);
        } catch (RosterException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
View Full Code Here

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

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        relayStanza(contact, stanza, sessionContext);

        RosterItem rosterItem = null;
        try {
            rosterItem = rosterManager.getContact(userBareJid, contactBareJid);
        } catch (RosterException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
View Full Code Here

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

        Entity user = stanza.getTo();

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        RosterItem rosterItem;
        try {
            rosterItem = rosterManager.getContact(userBareJid, contactBareJid);
        } catch (RosterException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
View Full Code Here

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

        Entity contact = stanza.getTo();

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        RosterItem rosterItem = null;
        try {
            rosterItem = rosterManager.getContact(userBareJid, contactBareJid);
        } catch (RosterException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
View Full Code Here

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

        Entity contact = stanza.getTo();

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        RosterItem rosterItem = null;
        try {
            rosterItem = getExistingOrNewRosterItem(rosterManager, userBareJid, contactBareJid);

            RosterSubscriptionMutator.Result result = RosterSubscriptionMutator.getInstance().add(rosterItem, FROM);
            if (result != OK) {
View Full Code Here

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

        }
    }

    private RosterItem getExistingOrNewRosterItem(RosterManager rosterManager, Entity userJid, Entity contactJid)
            throws RosterException {
        RosterItem rosterItem = rosterManager.getContact(userJid, contactJid);
        if (rosterItem == null) {
            rosterItem = new RosterItem(contactJid, NONE);
        }
        return rosterItem;
    }
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.