Search in sources :

Example 1 with FileFolderServiceTrait

use of org.alfresco.repo.model.filefolder.traitextender.FileFolderServiceTrait in project alfresco-repository by Alfresco.

the class VirtualFileFolderServiceExtension method list.

@Override
public PagingResults<FileInfo> list(final NodeRef contextNodeRef, final boolean files, final boolean folders, final String pattern, final Set<QName> ignoreQNames, final List<Pair<QName, Boolean>> sortProps, final PagingRequest pagingRequest) {
    final FileFolderServiceTrait theTrait = getTrait();
    if (canVirtualize(contextNodeRef)) {
        final Reference reference = smartStore.virtualize(contextNodeRef);
        Set<QName>[] searchAndIgnore = buildSearchAndIgnore(files, folders, ignoreQNames);
        if (mergeActualNode(reference)) {
            PagingResults<Reference> virtualChildren = smartStore.list(reference, false, true, files, folders, pattern, searchAndIgnore[1], searchAndIgnore[2], sortProps, new PagingRequest(0));
            PagingResultsSource<FileInfo> superSource = new PagingResultsSource<FileInfo>() {

                @Override
                public PagingResults<FileInfo> retrieve(PagingRequest pr) throws PageCollationException {
                    try {
                        PagingResults<FileInfo> result = theTrait.list(actualNodeFrom(reference), files, folders, pattern, ignoreQNames, sortProps, pr);
                        return result;
                    } catch (VirtualizationException e) {
                        throw new PageCollationException(e);
                    }
                }
            };
            FileInfoPropsComparator comparator = (sortProps != null && !sortProps.isEmpty()) ? new FileInfoPropsComparator(sortProps) : null;
            try {
                return new PageCollator<FileInfo>().collate(asFileInfoResults(environment, virtualChildren, smartStore).getPage(), superSource, pagingRequest, comparator);
            } catch (PageCollationException error) {
                throw new VirtualizationException(error);
            }
        } else {
            PagingResults<Reference> children = smartStore.list(reference, true, true, files, folders, pattern, searchAndIgnore[1], searchAndIgnore[2], sortProps, pagingRequest);
            return asFileInfoResults(environment, children, smartStore);
        }
    } else {
        return theTrait.list(contextNodeRef, files, folders, pattern, ignoreQNames, sortProps, pagingRequest);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Reference(org.alfresco.repo.virtual.ref.Reference) PagingRequest(org.alfresco.query.PagingRequest) PageCollationException(org.alfresco.repo.virtual.page.PageCollationException) FileInfo(org.alfresco.service.cmr.model.FileInfo) FileFolderServiceTrait(org.alfresco.repo.model.filefolder.traitextender.FileFolderServiceTrait) PagingResultsSource(org.alfresco.repo.virtual.page.PageCollator.PagingResultsSource) VirtualizationException(org.alfresco.repo.virtual.VirtualizationException)

Aggregations

HashSet (java.util.HashSet)1 Set (java.util.Set)1 PagingRequest (org.alfresco.query.PagingRequest)1 FileFolderServiceTrait (org.alfresco.repo.model.filefolder.traitextender.FileFolderServiceTrait)1 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)1 PageCollationException (org.alfresco.repo.virtual.page.PageCollationException)1 PagingResultsSource (org.alfresco.repo.virtual.page.PageCollator.PagingResultsSource)1 Reference (org.alfresco.repo.virtual.ref.Reference)1 FileInfo (org.alfresco.service.cmr.model.FileInfo)1