Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create Confluence groups using java api

Shravan P January 2, 2014

Is it possible to create a confluence group programmatically from a confluence plugin using java api? I went through confluence api reference but couldn't find the class used to create the group.

Any help/pointers will be appreciated.

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Shravan P January 6, 2014

After looking at confluence source code, I managed to find the right way to do this:

import com.atlassian.spring.container.ContainerManager;
import com.atlassian.user.EntityException;
import com.atlassian.user.GroupManager;

GroupManager groupManager = (GroupManager) ContainerManager.getInstance().getContainerContext().getComponent("groupManager");

groupManager.createGroup("group-name");

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 5, 2014
Shravan P January 6, 2014

That class belongs to test code which cannot be used. In the source code I see this class is located in: "confluence-project/confluence-test/confluence-test-support" directory.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 6, 2014

what do you mean by test code? if they used in test class does it mean we shouldn't use?

it is a public class "DefaultUserManagementHelper" so we can use this in our code!

any how you find working code! gald to hear that!!

Shravan P January 6, 2014

Test code is usually used for internal testing(junit, may be) purposes. Since their api reference doesn't explicitly state/explain anything about these classes or how they are supposed to be used, I prefer to stay away from them.

0 votes
Ryan Goodwin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2014

Hi Shravan,

It is possible to create a group via the api. See here :

https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods#RemoteConfluenceMethods-UserManagement

Look for function addGroup.

Ryan Goodwin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2014

Just an FYI there is already add-ons that make this possible:

https://bobswift.atlassian.net/wiki/display/ACLI/Atlassian+Command+Line+Interface

Shravan P January 5, 2014

I need to create groups from within a plugin. So I don't think using remote api is the best way to do it. Besides, there are a couple of other things we need to do in our plugin apart from creating groups, so I cant use CLI.

TAGS
AUG Leaders

Atlassian Community Events