public static org.xmpp.packet.Roster ignoreNonRemoveSubscriptionValues(org.xmpp.packet.Roster stanza)
    {
        final org.xmpp.packet.Roster result = stanza.createCopy();
        final Element query = result.getElement().element(new QName("query", Namespace.get("jabber:iq:roster")));
        if (query != null) {
            for (Iterator<Element> i = query.elementIterator("item"); i.hasNext(); ) {
                final Element item = i.next();
                final Attribute subscription = item.attribute("subscription");
                if (subscription != null && !"remove".equals(subscription.getValue())) {
                    item.remove(subscription);
                }
            }
        }
        return result;
    }
Removes all 'subscription' attributes of which the value is not 'remove'. The input value is not modified. A
defensive copy is created, to which modifications are applied.

@param stanza A roster stanza representation
@return a copy of the input with all offending subscription values removed.
xmppserver/src/main/java/org/jivesoftware/openfire/handler/IQRosterHandler.java