Missed Team ’24? Catch up on announcements here.

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

How to get Project Roles, which have Browse Project permission in a certain project

Holger Schimanski
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.
March 21, 2013

How can I get the Project Roles, which have Browse Project permission in the permission scheme for a certain project in JIRA plugin development?

I did a deep look into JIRA source, but got lost and did not find the right place.

  • Or PermissionSchemeManager using getEntities(org.ofbiz.core.entity.GenericValue scheme, Long permissionId, String type, String parameter) with type = "projectrole"? But what is parameter? Hand how to get scheme?

Kind regards
Holger

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

5 votes
Answer accepted
Holger Schimanski
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.
March 28, 2013

It took me a while to find out. Somewhere I found the hint to look at the JIRA XML export to understand the usage of GenericValue.

The JIRA XML export looks like this concerning permission schemes.

<PermissionScheme id="0" name="Default Permission Scheme" description="This is the default Permission Scheme. Any new projects that are created will be assigned this scheme."/>
    
    <Project id="10000" name="Test Project" url="" lead="admin" description="" key="TEST" counter="1" assigneetype="2" avatar="10011"/>
    
    <NodeAssociation sourceNodeId="10000" sourceNodeEntity="Project" sinkNodeId="0" sinkNodeEntity="PermissionScheme" associationType="ProjectScheme"/>

    <ProjectRole id="10000" name="Users" description="A project role that represents users in a project"/>
    <ProjectRole id="10001" name="Developers" description="A project role that represents developers in a project"/>
    <ProjectRole id="10002" name="Administrators" description="A project role that represents administrators in a project"/>

    <SchemePermissions id="10004" scheme="0" permission="23" type="projectrole" parameter="10002"/>
    <SchemePermissions id="10005" scheme="0" permission="10" type="projectrole" parameter="10000"/>
    <SchemePermissions id="10006" scheme="0" permission="11" type="projectrole" parameter="10000"/>
    <SchemePermissions id="10007" scheme="0" permission="15" type="projectrole" parameter="10000"/>
    <SchemePermissions id="10008" scheme="0" permission="19" type="projectrole" parameter="10000"/>
    <SchemePermissions id="10009" scheme="0" permission="13" type="projectrole" parameter="10001"/>
    <SchemePermissions id="10010" scheme="0" permission="17" type="projectrole" parameter="10001"/>

This means, that there is a PermissionScheme with id="0" is associated to a project id="10000". Then you can see, that the project role 10000 is assigned to the scheme 0 for certain permissions. As you can also assign users and groups you will also find XML nodes with type="user" and type="group" where parameter then is user id resp. group name.

Use PermissionSchemeManager to retrieve the PermissionScheme of the project

GenericValue tmpSchemeGV = permissionSchemeManager.getSchemes(tmpProjectGV).get(0);

Use getEntities to check which project roles are assigned to a certain permission

List<GenericValue> tmpBrowseRoles = permissionSchemeManager.getEntities(tmpSchemeGV, "projectrole", new Long(Permissions.BROWSE));

The generic value now contains the information, which project role it is.

for (Iterator<GenericValue> iterator = tmpBrowseRoles.iterator(); iterator.hasNext();) {
				GenericValue genericValue = (GenericValue) iterator.next();
				ProjectRole tmpRole = projectRoleManager.getProjectRole(new Long(genericValue.getString("parameter")));

				System.out.println(tmpRole.getName());
			}

Best regards
Holger

Thanos Batagiannis [Adaptavist]
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 11, 2016

I wish I could up vote more than once...

Holger Schimanski
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 11, 2016

Thanks for the feedback. Yes, very tricky.

 

mksiva September 22, 2016

Thanks, that is useful.

Sarath July 2, 2018

@Holger Schimanski what ixml export you have taken to analyze? Is it xml export of the project?

Jose Santana
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 15, 2018

Where can i find PermissionSchemeManager?

0 votes
Gerin Abraham March 25, 2015

How do I get the list of users with list of permissions and their project roles in JIRA projects.

Tushar October 5, 2017

Hi Gerin,

Have you got the solution for your problem? Somehow iam also need this information

 

~Tushar

0 votes
tousifs
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.
March 24, 2013

Read below link care fully.

https://confluence.atlassian.com/display/JIRA/Managing+Project+Permissions

i geuss your developing jira plugin.

http://docs.atlassian.com/jira/latest/com/atlassian/jira/security/PermissionManager.html

and you will get the object for

http://docs.atlassian.com/jira/latest/com/atlassian/jira/security/Permissions.html

now all permissions are integer no you can put and get the list of available groups.

all permissions are user specific if you want to make permissions as project specific you can put list of project in "Set" and display it.

regards,

tousif shaikh.

Holger Schimanski
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.
March 27, 2013

What do you mean with "permissions are user specific"? Permissions e.g. Permissions.BROWSE can be assigned to users, groups and project roles.

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.
March 21, 2013
Holger Schimanski
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.
March 23, 2013

Sorry, no. I don't find anything there, to check, if the project role is assoziated with a certain permission.

Any other hint?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events