src/net/java/sip/communicator/impl/protocol/jabber/ServerStoredContactListJabberImpl.java
/**
         * Event when an entry is updated. Something for the entry data
         * or have been added to a new group or removed from one
         * @param addresses Collection
         */
Event when an entry is updated. Something for the entry data
or have been added to a new group or removed from one
@param addresses Collection
Event when an entry is updated . Something for the entry data or have been added to a new group or removed from one @param addresses Collection
@Override
        public void entriesUpdated(Collection<Jid> addresses)
        {
            if (logger.isTraceEnabled())
                logger.trace("entriesUpdated  " + addresses);
            for (Jid contactID : addresses)
            {
                RosterEntry entry = roster.getEntry(contactID.asBareJid());
                ContactJabberImpl contact = addEntryToContactList(contactID);
                if (contact == null)
                {
                    continue;
                }
                if(entry.getGroups().size() == 0)
                {
                    checkForRename(entry.getName(), contact);
                    ContactGroup contactGroup =
                        contact.getParentContactGroup();
                    if(!rootGroup.equals(contactGroup))
                    {
                        contactMoved(contactGroup, rootGroup, contact);
                    }
                }
                for (RosterGroup gr : entry.getGroups())
                {
                    ContactGroup cgr = findContactGroup(gr.getName());
                    if(cgr == null)
                    {
                        ContactGroupJabberImpl group =
                            findContactGroupByNameCopy(gr.getName());
                        if(group != null)
                        {
                            group.setSourceGroup(gr);
                            fireGroupEvent(group,
                                   ServerStoredGroupEvent.GROUP_RENAMED_EVENT);
                        }
                        else
                        {
                            ContactGroup currentParentGroup =
                                contact.getParentContactGroup();
                            if(currentParentGroup.countContacts() > 1)
                            {
                                cgr = currentParentGroup;
                            }
                            else
                            {
                                boolean present = false;
                                for (RosterGroup entryGr : entry.getGroups())
                                {
                                    if(entryGr.getName().equals(
                                            currentParentGroup.getGroupName()))
                                    {
                                        present = true;
                                        break;
                                    }
                                }
                                if(!present
                                    && currentParentGroup instanceof
                                            ContactGroupJabberImpl)
                                {
                                    ContactGroupJabberImpl currentGroup =
                                        (ContactGroupJabberImpl)
                                            currentParentGroup;
                                    currentGroup.setSourceGroup(gr);
                                    fireGroupEvent(
                                        currentGroup,
                                        ServerStoredGroupEvent
                                            .GROUP_RENAMED_EVENT);
                                }
                            }
                        }
                    }
                    if(cgr != null)
                    {
                        ContactGroup contactGroup =
                            contact.getParentContactGroup();
                        if(!gr.getName().equals(contactGroup.getGroupName()))
                        {
                            ContactGroupJabberImpl newParentGroup =
                                findContactGroup(gr.getName());
                            if(newParentGroup == null)
                            {
                                newParentGroup =
                                    new ContactGroupJabberImpl(
                                        gr,
                                        new ArrayList<RosterEntry>().iterator(),
                                        ServerStoredContactListJabberImpl.this,
                                        true);
                                rootGroup.addSubGroup(newParentGroup);
                                fireGroupEvent(newParentGroup,
                                    ServerStoredGroupEvent.GROUP_CREATED_EVENT);
                            }
                            contactMoved(contactGroup, newParentGroup, contact);
                        }
                        else
                        {
                            checkForRename(entry.getName(), contact);
                        }
                    }
                }
            }
        }
@ Override public void entriesUpdated ( Collection < Jid > addresses ) { if ( logger . isTraceEnabled ( ) ) logger . trace ( "entriesUpdated  " + addresses ) ; for ( Jid contactID : addresses ) { RosterEntry entry = roster . getEntry ( contactID . asBareJid ( ) ) ; ContactJabberImpl contact = addEntryToContactList ( contactID ) ; if ( contact == null ) { continue ; } if ( entry . getGroups ( ) . size ( ) == 0 ) { checkForRename ( entry . getName ( ) , contact ) ; ContactGroup contactGroup = contact . getParentContactGroup ( ) ; if ( ! rootGroup . equals ( contactGroup ) ) { contactMoved ( contactGroup , rootGroup , contact ) ; } } for ( RosterGroup gr : entry . getGroups ( ) ) { ContactGroup cgr = findContactGroup ( gr . getName ( ) ) ; if ( cgr == null ) { ContactGroupJabberImpl group = findContactGroupByNameCopy ( gr . getName ( ) ) ; if ( group != null ) { group . setSourceGroup ( gr ) ; fireGroupEvent ( group , ServerStoredGroupEvent . GROUP_RENAMED_EVENT ) ; } else { ContactGroup currentParentGroup = contact . getParentContactGroup ( ) ; if ( currentParentGroup . countContacts ( ) > 1 ) { cgr = currentParentGroup ; } else { boolean present = false ; for ( RosterGroup entryGr : entry . getGroups ( ) ) { if ( entryGr . getName ( ) . equals ( currentParentGroup . getGroupName ( ) ) ) { present = true ; break ; } } if ( ! present && currentParentGroup instanceof ContactGroupJabberImpl ) { ContactGroupJabberImpl currentGroup = ( ContactGroupJabberImpl ) currentParentGroup ; currentGroup . setSourceGroup ( gr ) ; fireGroupEvent ( currentGroup , ServerStoredGroupEvent . GROUP_RENAMED_EVENT ) ; } } } } if ( cgr != null ) { ContactGroup contactGroup = contact . getParentContactGroup ( ) ; if ( ! gr . getName ( ) . equals ( contactGroup . getGroupName ( ) ) ) { ContactGroupJabberImpl newParentGroup = findContactGroup ( gr . getName ( ) ) ; if ( newParentGroup == null ) { newParentGroup = new ContactGroupJabberImpl ( gr , new ArrayList < RosterEntry > ( ) . iterator ( ) , ServerStoredContactListJabberImpl . this , true ) ; rootGroup . addSubGroup ( newParentGroup ) ; fireGroupEvent ( newParentGroup , ServerStoredGroupEvent . GROUP_CREATED_EVENT ) ; } contactMoved ( contactGroup , newParentGroup , contact ) ; } else { checkForRename ( entry . getName ( ) , contact ) ; } } } } }
Event when an entry is updated.
Event when an entry is updated .
// will search for group renamed // non-displayable contact, ignore it // check for change in display name // such group does not exist. so it must be // renamed one // just change the source entry // the group was renamed on different location // so we do not have it at our side // now lets find the group for the contact // and rename it, // - if it is the only contact in // the group this is rename, otherwise it is move // make sure this group name is not present // in entry groups // the group is found the contact may be moved from // one group to another // the add it to the new one // the new parent group maybe missing // create the group as it doesn't exist //tell listeners about the added group // check for change in display name