private List rosterItemRemove()

in server/core/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandler.java [207:252]


    private List<Stanza> rosterItemRemove(IQStanza stanza, SessionContext sessionContext, RosterManager rosterManager,
            Entity user, Entity contactJid, RosterItem existingItem, StanzaBroker stanzaBroker) {
        // rfc3921bis-08/2.5
        Stanza unsubscribedStanza = null;
        Stanza unsubscribeStanza = null;
        if (existingItem != null) {
            if (existingItem.hasFrom()) {
                // send unsubbed
                unsubscribedStanza = StanzaBuilder.createPresenceStanza(user.getBareJID(), contactJid, null,
                        PresenceStanzaType.UNSUBSCRIBED, null, null).build();
            }
            if (existingItem.hasTo()) {
                // send unsub
                unsubscribeStanza = StanzaBuilder.createPresenceStanza(user.getBareJID(), contactJid, null,
                        PresenceStanzaType.UNSUBSCRIBE, null, null).build();
            }
        }
        try {
            rosterManager.removeContact(user.getBareJID(), contactJid);
        } catch (RosterException e) {
            return Collections.singletonList(ServerErrorResponses.getStanzaError(StanzaErrorCondition.ITEM_NOT_FOUND,
                    stanza, StanzaErrorType.CANCEL, "roster item contact not in roster: " + contactJid, null, null));
        }

        if (unsubscribedStanza != null) {
            try {
                stanzaBroker.write(contactJid, unsubscribedStanza, IgnoreFailureStrategy.INSTANCE);
            } catch (DeliveryException e) {
                LOG.warn("failure sending unsubscribed on roster remove", e);
            }
        }
        if (unsubscribeStanza != null) {
            try {
                stanzaBroker.write(contactJid, unsubscribeStanza, IgnoreFailureStrategy.INSTANCE);
            } catch (DeliveryException e) {
                LOG.warn("failure sending unsubscribe on roster remove", e);
            }
        }

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

        // return success
        return Collections
                .singletonList(StanzaBuilder.createIQStanza(null, user, IQStanzaType.RESULT, stanza.getID()).build());
    }