Foren

LIferay 6.2 Add a role using RoleServiceUtil.addRole

thumbnail
William Gosse, geändert vor 6 Jahren.

LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
Does any one have a acode example for creating a new role using RoleServiceUtil.addRole(String className, long classPK, String name, Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, int type, String subtype, ServiceContext serviceContext)

I'm not clear as to what the className and classPK are. It that the user classname and user id?
thumbnail
David H Nebinger, geändert vor 6 Jahren.

RE: LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
William Gosse:
I'm not clear as to what the className and classPK are. It that the user classname and user id?


It's how to distinguish between the different types of roles. For example, a Team role is going to have a Team for the class name and the class pk is team id.

This flexibility actually allows you to bind roles to any Liferay entity, although you're still left to implementing all of the appropriate permission checking logic.








Come meet me at Devcon 2017 or 2017 LSNA!
thumbnail
William Gosse, geändert vor 6 Jahren.

RE: LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
What would the classname be for a regular role?
thumbnail
David H Nebinger, geändert vor 6 Jahren.

RE: LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
No, for a regular role you're going to use null. You still use the REGULAR_TYPE for the type of role, though.

The best source for answers of how to do something is the source itself. If you do a search for, say, addRole(, you can find every point in the code where it is referenced, and therefore you can see how the arguments should be used.

I'm sure you know this already, William, but I'm just pointing this out to newbies who happen onto this thread in the future.









Come meet me at Devcon 2017 or 2017 LSNA!