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

JIRA API: How can I find out if the current user is an administrator of a project?

James Dumay
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.
May 26, 2011

I am writing a xwork plugin module where I need to check if the current user has a admin permissions for a specific project. How can I do this?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

9 votes
Answer accepted
spuddy ಠ_ಠ
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 26, 2011

David's answer on this page describes how to find the "Administrators" role (read more about Project Roles). Project roles are configurable, and not all Projects will have a role named "Administrators".

You are probably referring to the "Administer Projects" permission (read more about Project Permissions). This permission controls who can administer a given project, and may be configured to consider the "Administrators" project role, but also may be assigned to other groups or users or roles.

You can check this permission using the PermissionManager.

User user = ...;
Project project = ...;
PermissionManager permissionManager = ComponentAccessor.getComponent(PermissionManager.class);
permissionManager.hasPermission(Permissions.PROJECT_ADMIN, project, user);

DavidV May 26, 2011

Ah - thats cool - this is really useful. Thanks for the info Matt.

Nick
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2011

Thanks Matt! Exactly what I needed. Saved me an afternoon. Cheers, nick

0 votes
DavidV May 26, 2011

In code you can do this using:

JiraAuthenticationContext jiraAuthenticationContext = ComponentManager.getComponentInstanceOfType(JiraAuthenticationContext.class);

ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class);

User user = jiraAuthenticationContext.getUser();

ProjectRole administratorProjectRole = projectRoleManager.getProjectRole("Administrators");

projectRoleManager.isUserInProjectRole(user, administratorProjectRole, project);

The APIs are available here:

http://docs.atlassian.com/jira/4.3.3/index.html (see ProjectRoleManager)

TAGS
AUG Leaders

Atlassian Community Events