0

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

Diego
  • 31
  • 1
  • 5

1 Answers1

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);

see: DLFolderLocalServiceUtil

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