ServiceContext serviceContext = new ServiceContext();
// Regular roles
for (String name : PortalUtil.getSystemRoles()) {
Role role = RoleLocalServiceUtil.loadGetRole(companyId, name);
Map<Locale, String> descriptionMap = role.getDescriptionMap();
Map<Locale, String> titleMap = role.getTitleMap();
if (name.equals(RoleConstants.ADMINISTRATOR)) {
_putMap(
descriptionMap, languageId, ROLE_ADMINISTRATOR_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_ADMINISTRATOR_NAME);
}
else if (name.equals(RoleConstants.GUEST)) {
_putMap(descriptionMap, languageId, ROLE_GUEST_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_GUEST_NAME);
}
else if (name.equals(RoleConstants.OWNER)) {
_putMap(descriptionMap, languageId, ROLE_OWNER_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_OWNER_NAME);
}
else if (name.equals(RoleConstants.POWER_USER)) {
_putMap(
descriptionMap, languageId, ROLE_POWER_USER_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_POWER_USER_NAME);
}
else if (name.equals(RoleConstants.USER)) {
_putMap(descriptionMap, languageId, ROLE_USER_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_USER_NAME);
}
RoleLocalServiceUtil.updateRole(
role.getRoleId(), name, titleMap, descriptionMap,
RoleConstants.TYPE_REGULAR_LABEL, serviceContext);
}
// Organization roles
for (String name : PortalUtil.getSystemOrganizationRoles()) {
Role role = RoleLocalServiceUtil.loadGetRole(companyId, name);
Map<Locale, String> descriptionMap = role.getDescriptionMap();
Map<Locale, String> titleMap = role.getTitleMap();
if (name.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR)) {
_putMap(
descriptionMap, languageId,
ROLE_ORGANIZATION_ADMINISTRATOR_DESCRIPTION);
_putMap(
titleMap, languageId, ROLE_ORGANIZATION_ADMINISTRATOR_NAME);
}
else if (name.equals(RoleConstants.ORGANIZATION_OWNER)) {
_putMap(
descriptionMap, languageId,
ROLE_ORGANIZATION_OWNER_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_ORGANIZATION_OWNER_NAME);
}
else if (name.equals(RoleConstants.ORGANIZATION_USER)) {
_putMap(
descriptionMap, languageId,
ROLE_ORGANIZATION_USER_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_ORGANIZATION_USER_NAME);
}
RoleLocalServiceUtil.updateRole(
role.getRoleId(), name, titleMap, descriptionMap,
RoleConstants.TYPE_ORGANIZATION_LABEL, serviceContext);
}
// Site roles
for (String name : PortalUtil.getSystemSiteRoles()) {
Role role = RoleLocalServiceUtil.loadGetRole(companyId, name);
Map<Locale, String> descriptionMap = role.getDescriptionMap();
Map<Locale, String> titleMap = role.getTitleMap();
if (name.equals(RoleConstants.SITE_ADMINISTRATOR)) {
_putMap(
descriptionMap, languageId,
ROLE_SITE_ADMINISTRATOR_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_SITE_ADMINISTRATOR_NAME);
}
else if (name.equals(RoleConstants.SITE_MEMBER)) {
_putMap(
descriptionMap, languageId, ROLE_SITE_MEMBER_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_SITE_MEMBER_NAME);
}
else if (name.equals(RoleConstants.SITE_OWNER)) {
_putMap(
descriptionMap, languageId, ROLE_SITE_OWNER_DESCRIPTION);
_putMap(titleMap, languageId, ROLE_SITE_OWNER_NAME);
}
RoleLocalServiceUtil.updateRole(
role.getRoleId(), name, titleMap, descriptionMap,
RoleConstants.TYPE_SITE_LABEL, serviceContext);
}
}