掲示板

Set permissions for a portlet with code

thumbnail
8年前 に Andreas Lecerof によって更新されました。

Set permissions for a portlet with code

Junior Member 投稿: 36 参加年月日: 13/02/14 最新の投稿
Hi,
I'm trying to set permissions for a Web form portlet (with code) that was added to a layout (with code) but without success.
The layout is added by LayoutLocalServiceUtil.addLayout(...)
Then the portlet is added to the layout by
LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
String WEB_FORM_PORTLET_ID = "1_WAR_webformportlet";
String uniqueFormPortletId =layoutTypePortlet.addPortletId(themeDisplay.getUserId(), WEB_FORM_PORTLET_ID, "column-2", 2);
which works fine.
Then I'm creating a team:
Team editorTeam = TeamLocalServiceUtil.addTeam(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), "WebFormEditorTeam_" + layout.getPlid(), "Web form editors on " + friendlyUrl);
The team should be able to View and Configure the web form portlet, I'm trying to accomplish this with setResourcePermissions:
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, WEB_FORM_PORTLET_ID, ResourceConstants.SCOPE_INDIVIDUAL,
uniqueFormPortletId, editorTeam.getRole().getRoleId(), new String[] {ActionKeys.VIEW, ActionKeys.CONFIGURATION });
But nothing happens to the teams permissions after setResourcePermissions is run....
I've also tried with the User role but nothing happens.
Is this the correct way to use setResourcePermissions? Or is there some other way I can achieve my goal, i.e. to set permissions for a portlet (with code) that was added (with code) to a page.
Any help is appreciated (I'm using Liferay 6.2).
thumbnail
8年前 に Andrew Jardine によって更新されました。

RE: Set permissions for a portlet with code

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi Andreas,

How are you executing this code? is it through a hook?
thumbnail
8年前 に Marcus Hjortzén によって更新されました。

RE: Set permissions for a portlet with code

Junior Member 投稿: 45 参加年月日: 12/05/02 最新の投稿
Andrew Jardine:
Hi Andreas,

How are you executing this code? is it through a hook?


He's executing within the context of a portlet.