public void removeContact()

in server/storage/jcr/src/main/java/org/apache/vysper/storage/jcr/roster/JcrRosterManager.java [221:256]


    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 {
            nodes = rosterNode.getNodes("contact");
        } catch (RepositoryException e) {
            return; // failed to find any contacts, done.
        }
        boolean foundOne = false;
        while (nodes != null && nodes.hasNext()) {
            Node node = nodes.nextNode();
            String contactJidString = readAttribute(node, "jid");
            if (contactJidString != null && contactJidString.equals(jidContact.getFullQualifiedName())) {
                foundOne = true;
                try {
                    node.remove();
                } catch (RepositoryException e) {
                    logger.warn("failed to remove from roster for user {} the contact jid " + jidContact, jidUser, e);
                }
            }
        }
        if (!foundOne)
            logger.warn("failed to remove from roster for user " + jidUser + " the contact jid " + jidContact);
    }