powered by Jive Software

Moving users between groups

RosterGroup addEntry method is supposed to remove entry from unfiled group if it exists there, is that right? The following code to move user from g1 to g2 always leaves user in unfiled group. Any ideas?

XMPPConnection con = new XMPPConnection(“jbegley”);

con.login(“user1@jbegley”, “password”);

Roster roster = con.getRoster();

RosterGroup g1 = roster.getGroup(“g1”);

RosterGroup g2 = roster.getGroup(“g2”);

RosterEntry user2 = roster.getEntry(“user2@jbegley”);

g1.removeEntry(user2);

g2.addEntry(user2);[/i]

I am having trouble understanding what you are trying to do. If the entry is in “g1” then it is not unfiled. Unfiled is a special case where a roster entry has no groups.

When I execute

g1.removeEntry(user2);

The user is then moved into the unfield group if it doesn’'t belong to any other group

g2.addEntry(user2) adds to g2 but leaves in Unfiled also. The API says that it will remove it from Unfiled.

Can you confirm that the user has been added to g2? In other words do you catch an XMPPExceptions?

mmm actually it seems when I remove the user the server[/i] is adding the user to an Unfiled group - not sure if that is protocol or not…

So maybe that’‘s the problem. When the API says adding will remove from Unfiled it probably just means it’'s internal representation…?

Anyway if I reverse the calls (add to g2, then remove from g1) it seems to work.

Thanks for your help.

Take a look here. addEntry method doesn’'t work correctly, actually.

http://www.jivesoftware.org/community/click.jspa?searchID=47131&messageID=105061

Sorry, wrong link in my previous post. See

http://www.jivesoftware.org/community/thread.jspa?threadID=16160&tstart=0