src/main/java/org/jivesoftware/smack/RosterGroup.java
public void addEntry(RosterEntry entry) throws XMPPException {
        PacketCollector collector = null;
        // Only add the entry if it isn't already in the list.
        synchronized (entries) {
            if (!entries.contains(entry)) {
                Roster packet = new Roster();
                packet.setType(IQ.Type.set);
                List<String> groupNames = new LinkedList<String>(
                        entry.getGroupNames());
                groupNames.add(getName());
                packet.addItem(new JID(entry.getUser()), entry.getName(),
                        entry.getAsk(), entry.getSubscription(), groupNames);
                // Wait up to a certain number of seconds for a reply from the
                // server.
                collector = connection
                        .createPacketCollector(new PacketIDFilter(packet
                                .getID()));
                connection.sendPacket(packet);
            }
        }
        if (collector != null) {
            IQ response = (IQ) collector.nextResult(SmackConfiguration
                    .getPacketReplyTimeout());
            collector.cancel();
            if (response == null) {
                throw new XMPPException("No response from the server.");
            }
            // If the server replied with an error, throw an exception.
            else if (response.getType() == IQ.Type.error) {
                throw new XMPPException(response.getError());
            }
        }
    }
public void addEntry(RosterEntry entry) throws XMPPException {
        PacketCollector collector = null;
        // Only add the entry if it isn't already in the list.
        synchronized (entries) {
            if (!entries.contains(entry)) {
                Roster packet = new Roster();
                packet.setType(IQ.Type.set);
                List<String> groupNames = new LinkedList<String>(
                        entry.getGroupNames());
                groupNames.add(getName());
                packet.addItem(new JID(entry.getUser()), entry.getName(),
                        entry.getAsk(), entry.getSubscription(), groupNames);
                // Wait up to a certain number of seconds for a reply from the
                // server.
                collector = connection
                        .createPacketCollector(new PacketIDFilter(packet
                                .getID()));
                connection.sendPacket(packet);
            }
        }
        if (collector != null) {
            IQ response = (IQ) collector.nextResult(SmackConfiguration
                    .getPacketReplyTimeout());
            collector.cancel();
            if (response == null) {
                throw new XMPPException("No response from the server.");
            }
            // If the server replied with an error, throw an exception.
            else if (response.getType() == IQ.Type.error) {
                throw new XMPPException(response.getError());
            }
        }
    }
Adds a roster entry to this group. If the entry was unfiled then it will
be removed from the unfiled list and will be added to this group. Note
that this is an asynchronous call -- Smack must wait for the server to
receive the updated roster.

@param entry
a roster entry.
@throws XMPPException
if an error occured while trying to add the entry to the
group.