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