Samstag, 27. Juni 2009

Liferay get all Roles

If you need to get all roles from your liferay portal you can achieve it in this way:



public void listAllRoles()
{
try {
List companies=CompanyLocalServiceUtil.getCompanies();
for(Company company:companies)
{
List roles=RoleLocalServiceUtil.getRoles(company.getCompanyId());
for(Role role:roles)
{
System.out.println(role.getRoleId()+" "+role.getName());
}
}
} catch (SystemException e) {
e.printStackTrace();
}
}