本文整理汇总了Java中com.liferay.portal.model.User.getRoles方法的典型用法代码示例。如果您正苦于以下问题:Java User.getRoles方法的具体用法?Java User.getRoles怎么用?Java User.getRoles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.model.User
的用法示例。
在下文中一共展示了User.getRoles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRole
import com.liferay.portal.model.User; //导入方法依赖的package包/类
/**
* Gets the role.
*
* @param display the display
* @return the role
*/
protected E_Role getRole(final ThemeDisplay display) {
E_Role result = null;
final User user = display.getUser();
if (user != null && user.getEmailAddress() != null) {
List<Role> roles = null;
try {
roles = user.getRoles();
} catch (final SystemException e) {
}
if (roles != null) {
for (final Role role : roles) {
result = CustomPortalServiceHandler.matchesRole(role);
if (result != null) {
break;
}
}
}
}
return result;
}
示例2: isLoggedInMgmt
import com.liferay.portal.model.User; //导入方法依赖的package包/类
/**
* Checks if is logged in mgmt.
*
* @param request the request
* @return true, if is logged in mgmt
*/
protected boolean isLoggedInMgmt(final PortletRequest request) {
boolean result = false;
final ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
if (themeDisplay.isSignedIn()) {
final User user = themeDisplay.getUser();
if (user != null) {
try {
final List<Role> roles = user.getRoles();
String mgmtRoleName = CustomPortalServiceHandler.getConfigValue(E_ConfigKey.ROLE_NAME_MGMT);
for (final Role role : roles) {
if (role.getName().equals(mgmtRoleName)) {
result = true;
break;
}
}
} catch (final Throwable t) {
}
}
}
return result;
}
示例3: isLoggedInOrg
import com.liferay.portal.model.User; //导入方法依赖的package包/类
/**
* Checks if is logged in org.
*
* @param request the request
* @return true, if is logged in org
*/
protected boolean isLoggedInOrg(final PortletRequest request) {
boolean result = false;
final ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
if (themeDisplay.isSignedIn()) {
final User user = themeDisplay.getUser();
if (user != null) {
try {
final List<Role> roles = user.getRoles();
final String orgRoleName = CustomPortalServiceHandler.getConfigValue(E_ConfigKey.ROLE_NAME_ORG);
for (final Role role : roles) {
if (role.getName().equals(orgRoleName)) {
result = true;
break;
}
}
} catch (final Throwable t) {
}
}
}
return result;
}