src/net/java/sip/communicator/impl/protocol/jabber/ServerStoredContactListJabberImpl.java
/**
         * Adds the entry to our local contactlist.
         * If contact exists and is persistent but not resolved, we resolve it
         * and return it without adding new contact.
         * If the contact exists and is not persistent, we remove it, to
         * avoid duplicate contacts and add the new one.
         * All entries must be displayable before we done anything with them.
         *
         * @param rosterEntryID the entry id.
         * @return the newly created contact.
         */
Adds the entry to our local contactlist.
If contact exists and is persistent but not resolved, we resolve it
and return it without adding new contact.
If the contact exists and is not persistent, we remove it, to
avoid duplicate contacts and add the new one.
All entries must be displayable before we done anything with them.

@param rosterEntryID the entry id.
@return the newly created contact.
Adds the entry to our local contactlist . If contact exists and is persistent but not resolved we resolve it and return it without adding new contact . If the contact exists and is not persistent we remove it to avoid duplicate contacts and add the new one . All entries must be displayable before we done anything with them . @param rosterEntryID the entry id . @return the newly created contact .
private ContactJabberImpl addEntryToContactList(Jid rosterEntryID)
        {
            RosterEntry entry = roster.getEntry(rosterEntryID.asBareJid());
            if(!isEntryDisplayable(entry))
                return null;
            ContactJabberImpl contact = findContactById(entry.getJid());
            if(contact == null)
            {
                contact = findPrivateContactByRealId(entry.getJid());
            }
            if(contact != null)
            {
                if(contact.isPersistent())
                {
                    contact.setResolved(entry);
                    return contact;
                }
                else if(contact instanceof VolatileContactJabberImpl)
                {
                    ContactGroup oldParentGroup =
                        contact.getParentContactGroup();
                    if(oldParentGroup instanceof ContactGroupJabberImpl
                        && !oldParentGroup.isPersistent())
                    {
                        ((ContactGroupJabberImpl)oldParentGroup)
                            .removeContact(contact);
                        fireContactRemoved(oldParentGroup, contact);
                    }
                }
                else
                    return contact;
            }
            contact = new ContactJabberImpl(
                    entry,
                    ServerStoredContactListJabberImpl.this,
                    true,
                    true);
            if(entry.getGroups() == null || entry.getGroups().size() == 0)
            {
                rootGroup.addContact(contact);
                fireContactAdded(rootGroup, contact);
                return contact;
            }
            for (RosterGroup group : entry.getGroups())
            {
                ContactGroupJabberImpl parentGroup =
                    findContactGroup(group.getName());
                if(parentGroup != null)
                {
                    parentGroup.addContact(contact);
                    fireContactAdded(findContactGroup(contact), contact);
                }
                else
                {
                    ContactGroupJabberImpl newGroup =
                        new ContactGroupJabberImpl(
                        group, group.getEntries().iterator(),
                        ServerStoredContactListJabberImpl.this,
                        true);
                    rootGroup.addSubGroup(newGroup);
                    fireGroupEvent(newGroup,
                            ServerStoredGroupEvent.GROUP_CREATED_EVENT);
                }
                return contact;
            }
            return contact;
        }
private ContactJabberImpl addEntryToContactList ( Jid rosterEntryID ) { RosterEntry entry = roster . getEntry ( rosterEntryID . asBareJid ( ) ) ; if ( ! isEntryDisplayable ( entry ) ) return null ; ContactJabberImpl contact = findContactById ( entry . getJid ( ) ) ; if ( contact == null ) { contact = findPrivateContactByRealId ( entry . getJid ( ) ) ; } if ( contact != null ) { if ( contact . isPersistent ( ) ) { contact . setResolved ( entry ) ; return contact ; } else if ( contact instanceof VolatileContactJabberImpl ) { ContactGroup oldParentGroup = contact . getParentContactGroup ( ) ; if ( oldParentGroup instanceof ContactGroupJabberImpl && ! oldParentGroup . isPersistent ( ) ) { ( ( ContactGroupJabberImpl ) oldParentGroup ) . removeContact ( contact ) ; fireContactRemoved ( oldParentGroup , contact ) ; } } else return contact ; } contact = new ContactJabberImpl ( entry , ServerStoredContactListJabberImpl . this , true , true ) ; if ( entry . getGroups ( ) == null || entry . getGroups ( ) . size ( ) == 0 ) { rootGroup . addContact ( contact ) ; fireContactAdded ( rootGroup , contact ) ; return contact ; } for ( RosterGroup group : entry . getGroups ( ) ) { ContactGroupJabberImpl parentGroup = findContactGroup ( group . getName ( ) ) ; if ( parentGroup != null ) { parentGroup . addContact ( contact ) ; fireContactAdded ( findContactGroup ( contact ) , contact ) ; } else { ContactGroupJabberImpl newGroup = new ContactGroupJabberImpl ( group , group . getEntries ( ) . iterator ( ) , ServerStoredContactListJabberImpl . this , true ) ; rootGroup . addSubGroup ( newGroup ) ; fireGroupEvent ( newGroup , ServerStoredGroupEvent . GROUP_CREATED_EVENT ) ; } return contact ; } return contact ; }
Adds the entry to our local contactlist.
Adds the entry to our local contactlist .
// if contact is in 'not in contact list' // we must remove it from there in order to correctly // process adding contact // this happens if we accept subscribe request // not from sip-communicator // no parent group so its in the root group // create the group as it doesn't exist //tell listeners about the added group // FIXME as for now we only support contact only in one group