Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hubert Felber
How to clone/copy permissions of a role?
February 8, 2011 8:10 AM
Answer

Hubert Felber

Rank: Regular Member

Posts: 157

Join Date: November 23, 2009

Recent Posts

Hello,

We import Roles from LDAP to Liferay (PortalLdapImporterImpl). In our system we have a "quasi Administrator" role, which should be able to administrate the liferay Portal.

I could elevate persons in that role to Liferay Administrator role, but I don't want to do that. Instead I want to create a new role with initially the same permissions as the Liferay Administrator role.

How can I extract (make a copy) permissions out of a role and assign it to a new created role?

Thank you
Hubert
Minhchau Dang
RE: How to clone/copy permissions of a role?
February 9, 2011 8:50 PM
Answer

Minhchau Dang

LIFERAY STAFF

Rank: Expert

Posts: 349

Join Date: October 22, 2007

Recent Posts

Hubert Felber:
How can I extract (make a copy) permissions out of a role and assign it to a new created role?

Ordinarily, you would copy all the entries in the Roles_Permissions table and just change the roleId.

However, the administrator role is a special role that is handled in the permission checker and therefore (usually) has no entries in that table. Therefore, your only real way to do it would be to create a new permission checker that recognizes your new quasi-administrator role for what it is able to do.
Hubert Felber
RE: How to clone/copy permissions of a role?
February 9, 2011 11:51 PM
Answer

Hubert Felber

Rank: Regular Member

Posts: 157

Join Date: November 23, 2009

Recent Posts

Thank you Minhchau
Meera Prince
RE: How to clone/copy permissions of a role?
January 24, 2013 11:07 PM
Answer

Meera Prince

Rank: Liferay Legend

Posts: 1110

Join Date: February 8, 2011

Recent Posts

java.util.List<com.liferay.portal.model.ResourcePermission> resourcePermissionList= ResourcePermissionLocalServiceUtil. getRoleResourcePermissions(
long roleId);
Use above method and pass role and get all ResourcePermission objects.
for(int i=0;i< resourcePermissionList.size();i++){
ResourcePermissionLocalServiceUtil. addResourcePermission (
resourcePermissionList.get(i).setRoleId(newRoleId));
}
Mohammad Azharuddin
RE: How to clone/copy permissions of a role?
April 14, 2014 4:28 AM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 471

Join Date: September 17, 2012

Recent Posts

Hi prince


It seems that method is not available..I am working liferay 6.1