Example usage for com.liferay.portal.kernel.repository DocumentRepository getFoldersAndFileEntriesAndFileShortcuts

List of usage examples for com.liferay.portal.kernel.repository DocumentRepository getFoldersAndFileEntriesAndFileShortcuts

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository DocumentRepository getFoldersAndFileEntriesAndFileShortcuts.

Prototype

public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(long folderId, int status,
            boolean includeMountFolders, int start, int end, OrderByComparator<?> obc) throws PortalException;

Source Link

Usage

From source file:com.liferay.document.library.internal.trash.DLBaseTrashHandler.java

License:Open Source License

@Override
public List<TrashRenderer> getTrashModelTrashRenderers(long classPK, int start, int end, OrderByComparator obc)
        throws PortalException {

    List<TrashRenderer> trashRenderers = new ArrayList<>();

    DocumentRepository documentRepository = getDocumentRepository(classPK);

    List<RepositoryEntry> repositoryEntries = documentRepository.getFoldersAndFileEntriesAndFileShortcuts(
            classPK, WorkflowConstants.STATUS_IN_TRASH, false, start, end, obc);

    for (RepositoryEntry repositoryEntry : repositoryEntries) {
        TrashRenderer trashRenderer = null;

        if (repositoryEntry instanceof FileShortcut) {
            FileShortcut fileShortcut = (FileShortcut) repositoryEntry;

            TrashHandler trashHandler = TrashHandlerRegistryUtil
                    .getTrashHandler(DLFileShortcutConstants.getClassName());

            trashRenderer = trashHandler.getTrashRenderer(fileShortcut.getPrimaryKey());
        } else if (repositoryEntry instanceof FileEntry) {
            FileEntry fileEntry = (FileEntry) repositoryEntry;

            TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(DLFileEntry.class.getName());

            trashRenderer = trashHandler.getTrashRenderer(fileEntry.getPrimaryKey());
        } else {// w w  w .  j  a va2s  . c  o  m
            Folder folder = (Folder) repositoryEntry;

            TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(DLFolder.class.getName());

            trashRenderer = trashHandler.getTrashRenderer(folder.getPrimaryKey());
        }

        trashRenderers.add(trashRenderer);
    }

    return trashRenderers;
}