Fixes working with server-side readonly groups (shared groups in OF), handles 406 error while editing roster items.

cusax-fix 4912
Damian Minkov 12 years ago
parent e32b56e234
commit 5898ddd57f

Binary file not shown.

@ -1050,9 +1050,6 @@ public void moveContact(Contact contact,
MetaContactImpl currentParentMetaContact
= (MetaContactImpl)this.findMetaContactByContact(contact);
currentParentMetaContact.removeProtoContact(contact);
MetaContactGroup newParentGroup
= findParentMetaContactGroup(newParentMetaContact);
@ -1061,8 +1058,22 @@ public void moveContact(Contact contact,
//if the contact is not currently in the proto group corresponding to
//its new metacontact group parent then move it
if(contact.getParentContactGroup() != parentProtoGroup && opSetPresence != null)
opSetPresence.moveContactToGroup(contact, parentProtoGroup);
try
{
if(contact.getParentContactGroup() != parentProtoGroup
&& opSetPresence != null)
{
opSetPresence.moveContactToGroup(contact, parentProtoGroup);
}
// remove the proto-contact only if move is successful
currentParentMetaContact.removeProtoContact(contact);
}
catch(OperationFailedException ex)
{
throw new MetaContactListException(ex.getMessage(),
MetaContactListException.CODE_MOVE_CONTACT_ERROR);
}
( (MetaContactImpl) newParentMetaContact).addProtoContact(contact);

@ -388,6 +388,7 @@ public boolean isPrivateMessagingContact(String contactAddress)
*/
public void moveContactToGroup(Contact contactToMove,
ContactGroup newParent)
throws OperationFailedException
{
assertConnected();
@ -536,6 +537,7 @@ public PresenceStatus queryContactStatus(String contactIdentifier)
* @param group the group to remove.
*/
public void removeServerStoredContactGroup(ContactGroup group)
throws OperationFailedException
{
assertConnected();
@ -1170,6 +1172,12 @@ public void entriesUpdated(Collection<String> addresses)
public void entriesDeleted(Collection<String> addresses)
{}
/**
* Not used here.
*/
public void rosterError(XMPPError error, Packet packet)
{}
/**
* Received on resource status change.
* @param presence presence that has changed

@ -656,6 +656,7 @@ public void createGroup(String groupName)
* @param groupToRemove the group that we'd like removed.
*/
public void removeGroup(ContactGroupJabberImpl groupToRemove)
throws OperationFailedException
{
try
{
@ -681,6 +682,8 @@ public void removeGroup(ContactGroupJabberImpl groupToRemove)
catch (XMPPException ex)
{
logger.error("Error removing group", ex);
throw new OperationFailedException(
ex.getMessage(), OperationFailedException.GENERAL_ERROR, ex);
}
}
@ -748,6 +751,7 @@ public void renameGroup(ContactGroupJabberImpl groupToRename, String newName)
*/
public void moveContact(ContactJabberImpl contact,
ContactGroupJabberImpl newParent)
throws OperationFailedException
{
// when the contact is not persistent, coming
// from NotInContactList group, we need just to add it to the list
@ -773,11 +777,12 @@ public void moveContact(ContactJabberImpl contact,
catch(OperationFailedException ex)
{
logger.error("Cannot move contact! ", ex);
throw new OperationFailedException(
ex.getMessage(),
OperationFailedException.GENERAL_ERROR, ex);
}
}
newParent.addContact(contact);
try
{
// will create the entry with the new group so it can be removed
@ -790,10 +795,15 @@ public void moveContact(ContactJabberImpl contact,
contact.getDisplayName(),
new String[]{newParent.getGroupName()});
SmackConfiguration.setPacketReplyTimeout(5000);
newParent.addContact(contact);
}
catch (XMPPException ex)
{
logger.error("Cannot move contact! ", ex);
throw new OperationFailedException(
ex.getMessage(),
OperationFailedException.GENERAL_ERROR, ex);
}
}
@ -1195,6 +1205,17 @@ else if(group instanceof RootContactGroupJabberImpl)
private class ChangeListener
implements RosterListener
{
/**
* Notifies for errors in roster packets.
* @param error the error.
* @param packet the source packet containing the error.
*/
public void rosterError(XMPPError error, Packet packet)
{
logger.error("Error received in roster " + error.getCode() + " "
+ error.getMessage());
}
/**
* Received event when entry is added to the server stored list
* @param addresses Collection

@ -139,7 +139,8 @@ public void createServerStoredContactGroup(ContactGroup parent,
* @throws IllegalStateException if the underlying protocol provider is not
* registered/signed on a public service.
*/
public void removeServerStoredContactGroup(ContactGroup group);
public void removeServerStoredContactGroup(ContactGroup group)
throws OperationFailedException;
/**
* Renames the specified group from the server stored contact list. This
@ -167,8 +168,11 @@ public void renameServerStoredContactGroup(ContactGroup group,
* @param contactToMove the <tt>Contact</tt> to move
* @param newParent the <tt>ContactGroup</tt> where <tt>Contact</tt> would
* be placed.
* @throws OperationFailedException when the operation didn't finished
* successfully.
*/
public void moveContactToGroup(Contact contactToMove, ContactGroup newParent);
public void moveContactToGroup(Contact contactToMove, ContactGroup newParent)
throws OperationFailedException;
/**
* Returns the root group of the server stored contact list. Most often this

@ -280,10 +280,17 @@ public void postTestRemoveGroup()
opSetPersPresence1
.addServerStoredGroupChangeListener(groupChangeCollector);
//create the group
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName2));
try
{
// remove the group
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName2));
}
catch(OperationFailedException ex)
{
logger.error("error removing group", ex);
}
groupChangeCollector.waitForEvent(10000);

@ -346,10 +346,17 @@ public void postTestRemoveGroup()
opSetPersPresence
.addServerStoredGroupChangeListener(groupChangeCollector);
//create the group
opSetPersPresence.removeServerStoredContactGroup(
opSetPersPresence.getServerStoredContactListRoot()
.getGroup(testGroupName2));
try
{
// remove the group
opSetPersPresence.removeServerStoredContactGroup(
opSetPersPresence.getServerStoredContactListRoot()
.getGroup(testGroupName2));
}
catch(OperationFailedException ex)
{
logger.error("error removing group", ex);
}
groupChangeCollector.waitForEvent(10000);

@ -276,9 +276,16 @@ public void postTestRemoveGroup()
.addServerStoredGroupChangeListener(groupChangeCollector);
//create the group
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName2));
try
{
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName2));
}
catch(OperationFailedException ex)
{
logger.error("error removing group", ex);
}
groupChangeCollector.waitForEvent(10000);

@ -276,10 +276,17 @@ public void postTestRemoveGroup()
opSetPersPresence1
.addServerStoredGroupChangeListener(groupChangeCollector);
//remove the group
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName));
try
{
//remove the group
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName));
}
catch(OperationFailedException ex)
{
logger.error("error removing group", ex);
}
groupChangeCollector.waitForEvent(10000);

@ -281,10 +281,17 @@ public void postTestRemoveGroup()
this.opSetPersPresence1
.addServerStoredGroupChangeListener(groupChangeCollector);
//create the group
this.opSetPersPresence1.removeServerStoredContactGroup(
try
{
// remove the group
this.opSetPersPresence1.removeServerStoredContactGroup(
this.opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName2));
.getGroup(testGroupName2));
}
catch(OperationFailedException ex)
{
logger.error("error removing group", ex);
}
groupChangeCollector.waitForEvent(10000);

@ -274,10 +274,17 @@ public void postTestRemoveGroup()
opSetPersPresence1
.addServerStoredGroupChangeListener(groupChangeCollector);
//remove the group
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName));
try
{
//remove the group
opSetPersPresence1.removeServerStoredContactGroup(
opSetPersPresence1.getServerStoredContactListRoot()
.getGroup(testGroupName));
}
catch(OperationFailedException ex)
{
logger.error("error removing group", ex);
}
groupChangeCollector.waitForEvent(10000);

Loading…
Cancel
Save