powered by Jive Software

How to create (shared) groups in plugin?

I’‘m currently developing a plugin for user administration (adding, changing, deleting), based on the registration plugin. I want to keep all the functionality in the plugin, rather than in the jsp. I’'m using NetBeans and JDK 5.

I don’‘t know how to create a shared group though. I know about group.getProperties(), but I don’'t know how to deal with the Map…

Any help regarding all the properties pertaining to shared groups is appreciated.

In a related issue: if the plugin does extensive adding and removing, are there any concurrency problems to expect? If so, how should I proceed?

Message was edited by:


I would suggest checking out the group editing JSP to see the logic for creeating and editing shared groups – just copy that logic and you should be good.

In terms of concurrency, you can generally assume that the Wildfire API is thread safe. How many add/remove operations are you talking about?



import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.jivesoftware.util.ParamUtils;

import org.jivesoftware.wildfire.group.Group;

import org.jivesoftware.wildfire.group.GroupAlreadyExistsException;

import org.jivesoftware.wildfire.group.GroupManager;

import org.jivesoftware.wildfire.plugin.click2show.id.IdentifierGenerator;

import org.jivesoftware.wildfire.plugin.click2show.id.UUIDHexGenerator;

public class AddShareGroupHandler implements IHandler {

public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

String description = ParamUtils.getParameter(request,“description”);

String displayname = ParamUtils.getParameter(request,“displayname”);

String showtype = ParamUtils.getParameter(request,“showtype”);


PrintWriter out = response.getWriter();

String groupname = createShareGroup( description, displayname, showtype);



private String createShareGroup(String description,

String displayname, String showtype)

throws GroupAlreadyExistsException {

IdentifierGenerator idGenerator = new UUIDHexGenerator(); //generator group id

String groupname = (String) idGenerator.generate();

Group newGroup = GroupManager.getInstance().createGroup(groupname);

if (newGroup == null) return “-1”; // occur error , return -1

if (description != null) {



if ((!"".equals(showtype)) && (showtype != null) ){

if (“spefgroups”.equals(showtype)) {

newGroup.getProperties().put("sharedRoster.showInRoster ",




else {

newGroup.getProperties().put(“sharedRoster.showInRoster”, “nobody”);


if (displayname != null) {




newGroup.getProperties().put(“sharedRoster.groupList”, “”);

return groupname;






Very nice! Thanks for posting a code example!


Thanks Matt for clearing the concurrency issue up (and the hint to the group editing jsp)!

Matt: Basically, this is to automate user adminsitration. It should occur at night, when noone is using the system. Initially, it will be a lot of creation (200 users to add)… Later on, we expect to mainly do changes to “full name” and “email”, since the user name is linked to our authentication token.

Thanks zhuam for the code! Very helpful!

Message was edited by: