Fórum

permission to view a portlet

Selva kumar, modificado 7 Anos atrás.

permission to view a portlet

Junior Member Postagens: 39 Data de Entrada: 23/07/15 Postagens Recentes
Am embedding a portlet inside another portlet using <liferay-portlet:runtime> tag. I want to check whether the logged in user has "VIEW" permission for this embedding portlet.

<! -- check permission -->
<liferay-portlet:runtime portletName="1_WAR_calenderportlet" />
<! -- check permission -->

if user doesn't have permission, this embedded portlet should not be rendered. only main portlet should be rendered.

I have tried below code, but not worked.

ThemeDisplay td = ((ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY));
PermissionChecker pc = td.getPermissionChecker();
User loginUser = td.getUser();
String p_id = "1_WAR_calenderportlet";
boolean hasPermission = pc.hasPermission(loginUser.getUserId(), p_id, p_id, "VIEW");

if(hasPermission ){
<liferay-portlet:runtime portletName="1_WAR_calenderportlet" />
}

any suggestions?
thumbnail
Antoine Comble, modificado 7 Anos atrás.

RE: permission to view a portlet

Regular Member Postagens: 232 Data de Entrada: 07/09/12 Postagens Recentes
Hi,

You need to pass the groupId and not the userId as parameter for the method pc.hasPermission.

Regards,
thumbnail
Devang Patel, modificado 7 Anos atrás.

RE: permission to view a portlet

Regular Member Postagens: 247 Data de Entrada: 19/01/15 Postagens Recentes
Hi Selva kumar,

Antoine Comble:

You need to pass the groupId and not the userId as parameter for the method pc.hasPermission.


I agree with Antoine you have to pass groupId.
pc.hasPermission(long groupId,String name,String primKey,String actionId)
.
You can pass primKey as long/String.

Regards,
Devang Patel