Having a folder name e.g. "images", how can i get the folderId attribute of this folder? I need the folderId so i can then use the DLFolderLocalServiceUtil interface and methods to query for the files in the dir
Asked
Active
Viewed 1,542 times
1 Answers
1
This should work
Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; // if the id of the parent is set to default
DLFolder dir = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, dirName);
Where groupId
is the id of the site the request is coming from, you can get it using themeDisplay
:
ThemeDisplay themeDisplay =
(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = themeDisplay.getLayout().getGroupId();
and parentFolderId
is the id of the folder containg the folder you're searching for and it is set when you add a new folder using:
DLFolder newFolder=addFolder(long userId, long groupId, long repositoryId, boolean mountPoint, long parentFolderId, String name,
String description, boolean hidden, ServiceContext serviceContext)

KlajdPaja
- 959
- 1
- 8
- 17
-
Could you please describe `groupId` and `parentFolderId` as well? Code only answers are harder to understand. – Tobias Liefke Aug 07 '16 at 21:58