2015-04-01 1 views
0

J'essaye de lister tous les dossiers et dossiers sous le dossier de racine du site de liferay.Comment lister les fichiers et les dossiers ensemble dans liferay?

QueryDefinition queryDefinition = new QueryDefinition(WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); 
List<Object> list = DLFolderLocalServiceUtil.getFoldersAndFileEntriesAndFileShortcuts(groupId, folderId, null, true, queryDefinition); 

Est-ce le bon chemin? Comment différencier les fichiers et les dossiers?

Répondre

0

Il existe un utilitaire appelé: DLAppServiceUtil avec la méthode: getFoldersAndFileEntriesAndFileShortcuts. Consultez ce link (code liferay).

1

Vous pouvez obtenir et différencier tous les fichiers, dossiers et raccourcis comme suit:

List <Object> foldersAndFileEntriesAndFileShortcuts = 
    DLAppServiceUtil.getFoldersAndFileEntriesAndFileShortcuts(
     folder.getGroupId(), folderId, WorkflowConstants.STATUS_ANY, 
     true, QueryUtil.ALL_POS, QueryUtil.ALL_POS); 

for (Object folderAndFileEntryAndFileShortcut: foldersAndFileEntriesAndFileShortcuts) {  
    if (folderAndFileEntryAndFileShortcut instanceof FileEntry) { 
     FileEntry fileEntry = (FileEntry) folderAndFileEntryAndFileShortcut; 
    } else if (folderAndFileEntryAndFileShortcut instanceof Folder) { 
     Folder subFolder = (Folder) folderAndFileEntryAndFileShortcut; 
    } else if (folderAndFileEntryAndFileShortcut instanceof DLFileShortcut) { 
     DLFileShortcut dlFileShorcut = (DLFileShortcut) folderAndFileEntryAndFileShortcut; 
    } 
}