How to return ALL groups(shared and unshared) from roster

Hello all,

I have a plugin that returns a user’s roster.

Currently it does not return the shared groups , just the groups created in SPark.

I am running Openfire 3.6.2 with postgres and AD integration.

I have one group called users_group in AD and so in openfire console I select this group and select the “Enable contact list group sharing” radio button and I enter a name in the textbox under “Enter contact list group” called shared_group.

I need to return ALL groups including the shared group with the name I gave it and not the AD name which is what I am getting.

My code currently looks like so:

User user = null;
try {
user = userManager.getUser(_user);
}
catch(UserNotFoundException unfe) {

}
try {
roster = user.getRoster();
List rosterItems = new ArrayList(roster.getRosterItems());
Log.info(“rosterItems size=” + rosterItems.size());//returns 12 which is the number of users in the group
for(RosterItem rosterItem : rosterItems) {
List groups = rosterItem.getGroups();
//Shared groups
Collection sGroups = rosterItem.getSharedGroups();
Log.info("The size of the shared groups is " + sGroups.size());//returns 1 so far so good!
if(!sGroups.isEmpty()) {
for(Group sGroup : sGroups) {
groups.add(sGroup.getName());
Log.info("shared groups name is " + sGroup.getName());//this is the name of the AD group (user_group) and not what I named it.
}
}

Is there a better way to return the entire roster including shared groups?

Plus I need the name that gave the “shared group” just like SPark does.

Thanks

I figured out how to get the name.

Map map = sharedGroup.getProperties();
String groupName = map.get(“sharedRoster.displayName”).toString();