Role is a level of access , sets of predefined permissions that define a particular function within the portal according to a space or according to a particular scope.
Roles can be granted permissions to various functions within a portlet applications, according to scope.
A function is defined as a collection of all permissions.This permission will be inherited by all the user who are placed in this role.
Roles are of 3 types as:-
- Regular Role
- Site Role
- Organization Role
- In regular role the permissions are basically defined at the portal level and are applied at the portal level.
- In Site Role the permissions are basically defined at the site level and are applied to that specific site.
- In Organization Role, permissions are basically defined at the organization level and are applied to that specific organization.
If you navigate to the Control Panel firstly click on Users link and then you will find Roles, click on Roles link , you’ll find a single interface which lets you create roles.
To create a Role, First click on Add button and choose any of role Site,Regular or Organization role as shown in figure
Make a selection of role and fill up the fields as shown in figure:
The name field is compulsory but the title and description fields are optional.Once you finish, click on save Button and it will redirect you to the list of roles.If you enter name and title then the title will be displayed in the list of roles and if title is not entered then the name will be displayed in the list. Action button to the right of each corresponding role can be used to perform various functions.
How to get all these roles?
When we associate any site role to user then association will be stored in UserGroupRole table. Respective service class are required to access those role. Whenever we want get site roles, we need to use UserGroupRoleLocalService.java class and there we can find many service methods corresponding to it.
By using companyId we can find all the role in portal , and by using groupId we can find all the site related role i.e., site role.
Below is an example of getting all the role in liferay
It will display all the roles of a portal shown in given figure