Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Matthias Jobst
How to get all available permissions?
August 8, 2013 11:07 PM

Matthias Jobst

Rank: New Member

Posts: 2

Join Date: June 26, 2013

Recent Posts

i'm trying to make a portlet which allows admins to

1) select an user
2) display all permissions that exist in the portal, highlighting all permission the selected user already has.

For example:


* ACCESS (MyPortlet)
* ACCESS (MySecondPortlet)

There is no need to change those permissions or give them to users. Just display them.

But it seems like something prevents me from getting a list of permissions. I tried some different solutions but none of them seem to work:

* PermissionLocalServiceUtil.getPermissionsCount(): Allways returns "0". Doesn't matter if i'm logged in as ADMIN / ROOT oder a newly created user. Doesn't matter if i use this in my .jsp files or in java files.

* PermissionLocalServiceUtil.getUserPermissions(userId): Allways empty (seems to be right if permissionsCount is also 0 emoticon )

* Other methods that give back a List<Permission> (getGroupPermissions(...) etc.) also return empty lists

At the same time i am able to use permissions / custom permissions inside my portlets! themeDisplay.getPermissionChecker().hasPermission(groupId, name, primKey, actionKey); returns true or false depending on logged-in-user having the required permission.

I got the same results on 2 different servers, using 4 different logins (different roles), 3 different portlets (custom Vaadin portlet, custom portlet with .jsps, modifiing a built-in portlet).

What am i doing wrong? Is there any other way to get a list of all permissions?

Thanks a lot!

I'm using "6.1 CE GA2 bundled with tomcat"
Matthias Jobst
RE: How to get all available permissions?
August 12, 2013 11:07 PM

Matthias Jobst

Rank: New Member

Posts: 2

Join Date: June 26, 2013

Recent Posts

Any ideas?
Do you need more information?

I'm still working on this and still cant get a single permission...
2System.out.println("PermissionCount: " + PermissionLocalServiceUtil.getPermissionsCount());
3    System.out.println("Permissions: ");
4    for (Permission p : PermissionLocalServiceUtil.getUserPermissions(this.userId)) {
5        System.out.println(p.getPermissionId() + " - " + p.getName());
6    }
7    System.out.println("User has permission: " + themeDisplay.getPermissionChecker().hasPermission(groupId, name, primKey, actionKey));

Console (while logged in as Admin):
PermissionCount: 0
User has permission: true
Tomas Polesovsky
RE: How to get all available permissions?
August 13, 2013 2:07 AM

Tomas Polesovsky


Rank: Liferay Master

Posts: 650

Join Date: February 13, 2009

Recent Posts

Hi Matthias

PermissionLocalServiceUtil is very old and is there only for backwards compatibility.

Currently Liferay uses permissions.user.check.algorithm=6 and you need to query ResourcePermission table. There you'll find "permissions", but it's a performance optimized table, so let me know if you need deeper description.

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!