在liferay中如何以编程方式更改DL文件夹的权限

时间:2016-04-23 09:03:50

标签: liferay portlet

我想通过java类更改liferay中创建的DL文件夹的权限:让我们考虑foldername id" temp"

2 个答案:

答案 0 :(得分:3)

您需要获取文件夹'temp':

Folder tempFolder = dlAppLocalService.getFolder(groupId, parentFolderId, "temp");

您必须为'tempFolder'资源设置permisssions。

例如,如果要将VIEW权限设置为GUEST角色:

Role guestRole = roleLocalService.getRole(companyId, RoleConstants.GUEST);

resourcePermissionLocalService.setResourcePermissions(companyId, DLFolder.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(tempFolder.getFolderId()), guestRole.getRoleId(), new String[]{"VIEW"});

您可以在此处查看完整的API

https://docs.liferay.com/portal/6.2/javadocs/com/liferay/portal/service/ResourcePermissionLocalServiceUtil.html

祝你好运

答案 1 :(得分:2)

您可以使用 ResourcePermissionLocalServiceUtil 服务为您的DlFolder授予权限,如下所示:

ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,DLFolder.
class.getName(),ResourceConstants.SCOPE_INDIVIDUAL,""+
folder.getFolderId(), roleId, permissions);

here获取有关它的详细信息!