Hello,
In this post we will see
how to check if a user has a specific permission assigned to him. If you want
to do it in a JSP you can use the below code. In JSP permissionChecker,layout
and portletroot id objects are implicitly available.
boolean showOwnerType =
PortletPermissionUtil.contains(permissionChecker, layout,
portletDisplay.getRootPortletId(), “your permission name”);
Suppose if you want to
do it in a class which does not have these implicit objects or it does not have
access to HttpServletRequest or PortletRequest then you can use the below code.
PermissionChecker permissionChecker=PermissionThreadLocal.getPermissionChecker();
boolean status =
PortletPermissionUtil.contains(permissionChecker, “your portlet root
id”, “your
permission”);
You can find the portlet
root id from Liferay page. Goto the page where the portlet resides and click on
Settings icon- > Look
and Feel -> and goto Advanced Styling tab. There you can see the portlet root id.
Comments