Created
May 28, 2013 09:36
-
-
Save kimakunc/5661627 to your computer and use it in GitHub Desktop.
Liferay 6.1 create a regular role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void createRegularRole(String roleName, Map<Locale, String> title, Map<Locale, String> description) { | |
long companyId = PortalUtil.getDefaultCompanyId(); | |
int type = RoleConstants.TYPE_REGULAR; | |
try { | |
Role newRole = RoleLocalServiceUtil.addRole(LiferayUtil.getDefaultUserId(companyId), companyId, roleName, | |
title, description, type); | |
LOGGER.info("Added new role with id [" + newRole.getRoleId() + "] and name [" + newRole.getName() + "]."); | |
} catch (Exception e) { | |
if (e instanceof DuplicateRoleException) { | |
LOGGER.debug("Role [" + roleName + "] already exists."); | |
} else { | |
LOGGER.error("Error on creating role with name [" + roleName + "] | |
and title [" + title.get(LocaleUtil.getDefault()) + "].", e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment