Forums de discussion

LIferay 6.2 Add a role using RoleServiceUtil.addRole

thumbnail
William Gosse, modifié il y a 6 années.

LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Master Publications: 533 Date d'inscription: 04/07/10 Publications récentes
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, modifié il y a 6 années.

RE: LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
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, modifié il y a 6 années.

RE: LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Master Publications: 533 Date d'inscription: 04/07/10 Publications récentes
What would the classname be for a regular role?
thumbnail
David H Nebinger, modifié il y a 6 années.

RE: LIferay 6.2 Add a role using RoleServiceUtil.addRole

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
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!