Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Manoj Satyagi
Issue In RoleServiceUtil - Liferay 6.1.0 CE GA1
April 10, 2012 5:24 AM
Answer

Manoj Satyagi

Rank: Junior Member

Posts: 26

Join Date: April 6, 2012

Recent Posts

Hi,

In our portlet we used to retrieve the roles associated to a user using the method given below.

RoleServiceUtil.getUserRoles(userId);

The code was working fine in Liferay 6.0.6 CE. Currently we moved our portlet to Liferay 6.1.0 and this method is returning null. Have anyone faced similar issue ? If so kindly guide me to fix this issue.

Regards,
Manoj-GT
Manoj Satyagi
RE: Issue In RoleServiceUtil - Liferay 6.1.0 CE GA1
April 10, 2012 5:57 AM
Answer

Manoj Satyagi

Rank: Junior Member

Posts: 26

Join Date: April 6, 2012

Recent Posts

Its returning user roles if the user if having Administrator as one of his role.

Example :
If User 1 is having roles (PowerUser, User) then List<Role> is returning null
But if User 1 is having roles (Administrator, PowerUser, User) then List <Role> is returning all the roles (Administrator, PowerUser, User)

This issue is coming only in 6.1 CE not in 6.0 CE & EE
Juan Gonzalez
RE: Issue In RoleServiceUtil - Liferay 6.1.0 CE GA1
April 10, 2012 8:23 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2947

Join Date: October 28, 2008

Recent Posts

You can try using RoleLocalServiceUtil instead, because there permissions won't be checked AFAIK.
Manoj Satyagi
RE: Issue In RoleServiceUtil - Liferay 6.1.0 CE GA1
April 10, 2012 9:34 PM
Answer

Manoj Satyagi

Rank: Junior Member

Posts: 26

Join Date: April 6, 2012

Recent Posts

Thanks Juan.. Its working fine now.

Now I can understand the difference between RoleLocalServiceUtil & RoleServiceUtil and UserLocalServiceUtil & UserServiceUtil.

For using RoleServiceUtil & UserServiceUtil we should have admin right. I am just curious can we impersonate as admin using some java code and access this class ?

Regards,
Manoj-GT
Juan Gonzalez
RE: Issue In RoleServiceUtil - Liferay 6.1.0 CE GA1
April 10, 2012 11:25 PM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2947

Join Date: October 28, 2008

Recent Posts

Manoj GT:
Thanks Juan.. Its working fine now.

Now I can understand the difference between RoleLocalServiceUtil & RoleServiceUtil and UserLocalServiceUtil & UserServiceUtil.

For using RoleServiceUtil & UserServiceUtil we should have admin right. I am just curious can we impersonate as admin using some java code and access this class ?

Regards,
Manoj-GT



Glad it worked.

For easy finding, please can you mark my answer as correct answer?

About your other question, you could try setting values to ServiceContext attribute. I guess there is where authentication values are.