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

How do I get all Groups & Users that have access to a page.

Paul Henry January 7, 2013

I have a plugin that needs to get all the groups, and then any additional individual users that have read access to a page.

I have looked at the permissionManager and it will tell me if a single user can access the page. But i havent been able to find anything that takes a page and returns all users/groups that can access it.

I know i could implement a brute force approach and for the page first generate a list of all users and then ask if each user can access the page. However at its simplest this masks which groups have access. It could im guessing be enhanced to first ask if a group has access then additionally ask all users not in groups with access if they have permission.

However this is clearly the wrong way around and a less than optimal approach if the process needs to be performed over multiple pages... for example all pages in a space.

I am assuming that there is a better and more efficient approach to this. Perhapes the permission manager does something similar internally?

Can someone please point me in the right dirrection.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Paul Henry February 6, 2013

The Solution is to usethe ContentPermissionManager.

Set<ContentPermission> permissions = contentPermissionManager.getViewContentPermissions(page);

0 votes
Matthew J. Horn
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 17, 2013

My guess is that there is no method that's going to return all users who can view a specified page, because it would be innefficient to store that information. It's much more efficient from the database side to take a user name and decide if that user can access it. You can imagine how big a few additional tables in the DB that stores this info would be.

The same logic probably applies to groups. However, since you likely have far fewer groups than users, it might be feasible to brute force them.

TAGS
AUG Leaders

Atlassian Community Events