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 currentParentMetaContact
= (MetaContactImpl)this.findMetaContactByContact(contact); = (MetaContactImpl)this.findMetaContactByContact(contact);
currentParentMetaContact.removeProtoContact(contact);
MetaContactGroup newParentGroup MetaContactGroup newParentGroup
= findParentMetaContactGroup(newParentMetaContact); = findParentMetaContactGroup(newParentMetaContact);
@ -1061,8 +1058,22 @@ public void moveContact(Contact contact,
//if the contact is not currently in the proto group corresponding to //if the contact is not currently in the proto group corresponding to
//its new metacontact group parent then move it //its new metacontact group parent then move it
if(contact.getParentContactGroup() != parentProtoGroup && opSetPresence != null) try
opSetPresence.moveContactToGroup(contact, parentProtoGroup); {
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); ( (MetaContactImpl) newParentMetaContact).addProtoContact(contact);

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

@ -656,6 +656,7 @@ public void createGroup(String groupName)
* @param groupToRemove the group that we'd like removed. * @param groupToRemove the group that we'd like removed.
*/ */
public void removeGroup(ContactGroupJabberImpl groupToRemove) public void removeGroup(ContactGroupJabberImpl groupToRemove)
throws OperationFailedException
{ {
try try
{ {
@ -681,6 +682,8 @@ public void removeGroup(ContactGroupJabberImpl groupToRemove)
catch (XMPPException ex) catch (XMPPException ex)
{ {
logger.error("Error removing group", 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, public void moveContact(ContactJabberImpl contact,
ContactGroupJabberImpl newParent) ContactGroupJabberImpl newParent)
throws OperationFailedException
{ {
// when the contact is not persistent, coming // when the contact is not persistent, coming
// from NotInContactList group, we need just to add it to the list // from NotInContactList group, we need just to add it to the list
@ -773,11 +777,12 @@ public void moveContact(ContactJabberImpl contact,
catch(OperationFailedException ex) catch(OperationFailedException ex)
{ {
logger.error("Cannot move contact! ", ex); logger.error("Cannot move contact! ", ex);
throw new OperationFailedException(
ex.getMessage(),
OperationFailedException.GENERAL_ERROR, ex);
} }
} }
newParent.addContact(contact);
try try
{ {
// will create the entry with the new group so it can be removed // will create the entry with the new group so it can be removed
@ -790,10 +795,15 @@ public void moveContact(ContactJabberImpl contact,
contact.getDisplayName(), contact.getDisplayName(),
new String[]{newParent.getGroupName()}); new String[]{newParent.getGroupName()});
SmackConfiguration.setPacketReplyTimeout(5000); SmackConfiguration.setPacketReplyTimeout(5000);
newParent.addContact(contact);
} }
catch (XMPPException ex) catch (XMPPException ex)
{ {
logger.error("Cannot move contact! ", 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 private class ChangeListener
implements RosterListener 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 * Received event when entry is added to the server stored list
* @param addresses Collection * @param addresses Collection

@ -139,7 +139,8 @@ public void createServerStoredContactGroup(ContactGroup parent,
* @throws IllegalStateException if the underlying protocol provider is not * @throws IllegalStateException if the underlying protocol provider is not
* registered/signed on a public service. * 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 * 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 contactToMove the <tt>Contact</tt> to move
* @param newParent the <tt>ContactGroup</tt> where <tt>Contact</tt> would * @param newParent the <tt>ContactGroup</tt> where <tt>Contact</tt> would
* be placed. * 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 * Returns the root group of the server stored contact list. Most often this

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

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

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

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

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

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

Loading…
Cancel
Save