@ -962,30 +962,46 @@ public void moveMetaContact(MetaContact metaContact,
( ( MetaContactGroupImpl ) newMetaGroup ) . addMetaContact (
( MetaContactImpl ) metaContact ) ;
//first make sure that the new meta contact group path is resolved
//against all protocols that the MetaContact requires. then move
//the meta contact in there and move all prot contacts inside it.
Iterator contacts = metaContact . getContacts ( ) ;
while ( contacts . hasNext ( ) )
try
{
Contact protoContact = ( Contact ) contacts . next ( ) ;
//first make sure that the new meta contact group path is resolved
//against all protocols that the MetaContact requires. then move
//the meta contact in there and move all prot contacts inside it.
Iterator contacts = metaContact . getContacts ( ) ;
ContactGroup protoGroup = resolveProtoPath ( protoContact
. getProtocolProvider ( ) , ( MetaContactGroupImpl ) newMetaGroup ) ;
while ( contacts . hasNext ( ) )
{
Contact protoContact = ( Contact ) contacts . next ( ) ;
//get a persistent or non persistent presence operation set
OperationSetPersistentPresence opSetPresence
= ( OperationSetPersistentPresence ) protoContact
. getProtocolProvider ( ) . getSupportedOperationSets ( )
. get ( OperationSetPersistentPresence . class . getName ( ) ) ;
ContactGroup protoGroup = resolveProtoPath ( protoContact
. getProtocolProvider ( ) , ( MetaContactGroupImpl ) newMetaGroup ) ;
if ( opSetPresence = = null )
{
/** @todo handle non persistent presence operation sets */
//get a persistent or non persistent presence operation set
OperationSetPersistentPresence opSetPresence
= ( OperationSetPersistentPresence ) protoContact
. getProtocolProvider ( ) . getSupportedOperationSets ( )
. get ( OperationSetPersistentPresence . class . getName ( ) ) ;
if ( opSetPresence = = null )
{
/** @todo handle non persistent presence operation sets */
}
opSetPresence . moveContactToGroup ( protoContact , protoGroup ) ;
}
}
catch ( Exception ex )
{
logger . error ( "Cannot move contact" , ex ) ;
// now move the contact to prevoius parent
( ( MetaContactGroupImpl ) newMetaGroup ) .
removeMetaContact ( ( MetaContactImpl ) metaContact ) ;
opSetPresence . moveContactToGroup ( protoContact , protoGroup ) ;
currentParent . addMetaContact ( ( MetaContactImpl ) metaContact ) ;
throw new MetaContactListException ( ex . getMessage ( ) ,
MetaContactListException . CODE_MOVE_CONTACT_ERROR ) ;
}
//fire the mved event.
@ -1105,27 +1121,35 @@ public void removeMetaContactGroup(
" is not an instance of MetaContactGroupImpl" ) ;
}
//remove all proto groups and then remove the meta group as well.
Iterator protoGroups
= ( ( MetaContactGroupImpl ) groupToRemove ) . getContactGroups ( ) ;
while ( protoGroups . hasNext ( ) )
try
{
ContactGroup protoGroup = ( ContactGroup ) protoGroups . next ( ) ;
//remove all proto groups and then remove the meta group as well.
Iterator protoGroups
= ( ( MetaContactGroupImpl ) groupToRemove ) . getContactGroups ( ) ;
OperationSetPersistentPresence opSetPersPresence
= ( OperationSetPersistentPresence ) protoGroup
. getProtocolProvider ( ) . getSupportedOperationSets ( ) . get (
OperationSetPersistentPresence . class . getName ( ) ) ;
if ( opSetPersPresence = = null )
while ( protoGroups . hasNext ( ) )
{
/** @todo handle removal of non persistent proto groups */
return ;
}
ContactGroup protoGroup = ( ContactGroup ) protoGroups . next ( ) ;
OperationSetPersistentPresence opSetPersPresence
= ( OperationSetPersistentPresence ) protoGroup
. getProtocolProvider ( ) . getSupportedOperationSets ( ) . get (
OperationSetPersistentPresence . class . getName ( ) ) ;
opSetPersPresence . removeServerStoredContactGroup ( protoGroup ) ;
if ( opSetPersPresence = = null )
{
/** @todo handle removal of non persistent proto groups */
return ;
}
opSetPersPresence . removeServerStoredContactGroup ( protoGroup ) ;
}
} catch ( Exception ex )
{
throw new MetaContactListException ( ex . getMessage ( ) ,
MetaContactListException . CODE_REMOVE_GROUP_ERROR ) ;
}
MetaContactGroupImpl parentMetaGroup = ( MetaContactGroupImpl )
findParentMetaContactGroup ( ( MetaContactGroupImpl ) groupToRemove ) ;