We will have a requirement like we need to fetch the files from a specific folder of DLFile then for this type of requirement, the below code will be helpful to you.
Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
DLFolder folder = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, dirName);
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
List fileEntryService = null;
try {
fileEntryService = DLFileEntryLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(),folder.getFolderId(),-1, -1, null);
} catch (SystemException e) {
e.printStackTrace();
}
for(DLFileEntry fileEntryObj : fileEntryService){
System.out.println(fileEntryObj.getTitle());
}
To fetch in VM file we can use this code :-
#set($service = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
#set($fid = $getterUtil.getLong($folderId.getData()))
#set($files = $service.getFileEntries($gid, $fid))
#foreach($doc in $files)
#set($uet = $httpUtil.encodeURL($htmlUtil.unescape($doc.getTitle())))
$doc.getTitle()
#end
No comments:
Post a Comment