use of org.alfresco.repo.virtual.page.PageCollationException in project alfresco-repository by Alfresco.
the class VirtualFileFolderServiceExtension method list.
@Override
public PagingResults<FileInfo> list(final NodeRef rootNodeRef, final Set<QName> searchTypeQNames, final Set<QName> ignoreAspectQNames, final List<Pair<QName, Boolean>> sortProps, final PagingRequest pagingRequest) {
if (canVirtualize(rootNodeRef)) {
final Reference reference = smartStore.virtualize(rootNodeRef);
List<Pair<QName, Boolean>> sortingPropoerties = sortProps;
if (sortingPropoerties == null || sortingPropoerties.isEmpty()) {
sortingPropoerties = Arrays.asList(new Pair<QName, Boolean>(ContentModel.PROP_NAME, true));
}
if (mergeActualNode(reference)) {
PagingResults<Reference> virtualChildren = smartStore.list(reference, false, true, searchTypeQNames, Collections.<QName>emptySet(), ignoreAspectQNames, sortProps, new PagingRequest(0));
PagingResultsSource<FileInfo> superSource = new PagingResultsSource<FileInfo>() {
@Override
public PagingResults<FileInfo> retrieve(PagingRequest pr) throws PageCollationException {
try {
PagingResults<FileInfo> result = getTrait().list(actualNodeFrom(reference), searchTypeQNames, ignoreAspectQNames, sortProps, pr);
return result;
} catch (VirtualizationException e) {
throw new PageCollationException(e);
}
}
};
FileInfoPropsComparator comparator = new FileInfoPropsComparator(sortingPropoerties);
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, searchTypeQNames, Collections.<QName>emptySet(), ignoreAspectQNames, sortingPropoerties, pagingRequest);
return asFileInfoResults(environment, children, smartStore);
}
}
return getTrait().list(rootNodeRef, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
}
use of org.alfresco.repo.virtual.page.PageCollationException 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);
}
}
use of org.alfresco.repo.virtual.page.PageCollationException in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method list.
@Override
public PagingResults<Reference> list(final Reference ref, boolean actual, boolean virtual, final boolean files, final boolean folders, final String pattern, final Set<QName> searchTypeQNames, final Set<QName> ignoreTypeQNames, final Set<QName> ignoreAspectQNames, final List<Pair<QName, Boolean>> sortProps, final PagingRequest pagingRequest) throws VirtualizationException {
VirtualFolderDefinition structure = resolveVirtualFolderDefinition(ref);
List<Reference> virtualRefs = null;
// constraints should handle folder & file filtering
if (virtual && folders) {
virtualRefs = createChildReferences(ref, structure);
} else {
virtualRefs = Collections.emptyList();
}
if (actual) {
final VirtualQuery query = structure.getQuery();
if (query != null) {
// we have a query we must collate results
PagingResultsSource<Reference> querySourc = new PagingResultsSource<Reference>() {
@Override
public PagingResults<Reference> retrieve(PagingRequest pr) throws PageCollationException {
try {
return query.perform(environment, files, folders, pattern, searchTypeQNames, ignoreTypeQNames, ignoreAspectQNames, sortProps, pr, ref);
} catch (VirtualizationException e) {
throw new PageCollationException(e);
}
}
};
PageCollator<Reference> collator = new PageCollator<>();
try {
return collator.collate(virtualRefs, querySourc, pagingRequest, new ReferenceComparator(this, sortProps));
} catch (PageCollationException e) {
throw new VirtualizationException(e);
}
}
}
return new ListBackedPagingResults<>(virtualRefs);
}
Aggregations