liferay 6如何获取文件夹的文件夹ID

时间:2016-08-05 13:52:12

标签: liferay document-library

拥有文件夹名称,例如“images”,如何获取此文件夹的folderId属性?我需要folderId,然后我可以使用DLFolderLocalServiceUtil接口和方法来查询目录中的文件

1 个答案:

答案 0 :(得分:1)

这应该有效

Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; // if the id of the parent is set to default
DLFolder dir = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, dirName);

请参阅:DLFolderLocalServiceUtil

如果groupId是请求来自的网站的ID,您可以使用themeDisplay获取它:

ThemeDisplay themeDisplay = 
     (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = themeDisplay.getLayout().getGroupId();

parentFolderId是包含您要搜索的文件夹的文件夹的ID,当您使用以下文件添加新文件夹时设置该文件夹:

    DLFolder newFolder=addFolder(long userId, long groupId, long repositoryId, boolean mountPoint, long parentFolderId, String name,
 String description, boolean hidden, ServiceContext serviceContext)