Search in sources :

Example 1 with PageCollationException

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);
}
Also used : 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) PagingResultsSource(org.alfresco.repo.virtual.page.PageCollator.PagingResultsSource) VirtualizationException(org.alfresco.repo.virtual.VirtualizationException) Pair(org.alfresco.util.Pair)

Example 2 with PageCollationException

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

Example 3 with PageCollationException

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);
}
Also used : PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) PagingRequest(org.alfresco.query.PagingRequest) PageCollationException(org.alfresco.repo.virtual.page.PageCollationException) VirtualQuery(org.alfresco.repo.virtual.template.VirtualQuery) PageCollator(org.alfresco.repo.virtual.page.PageCollator) PagingResultsSource(org.alfresco.repo.virtual.page.PageCollator.PagingResultsSource) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) VirtualizationException(org.alfresco.repo.virtual.VirtualizationException) ListBackedPagingResults(org.alfresco.query.ListBackedPagingResults)

Aggregations

PagingRequest (org.alfresco.query.PagingRequest)3 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)3 PageCollationException (org.alfresco.repo.virtual.page.PageCollationException)3 PagingResultsSource (org.alfresco.repo.virtual.page.PageCollator.PagingResultsSource)3 Reference (org.alfresco.repo.virtual.ref.Reference)3 FileInfo (org.alfresco.service.cmr.model.FileInfo)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ListBackedPagingResults (org.alfresco.query.ListBackedPagingResults)1 FileFolderServiceTrait (org.alfresco.repo.model.filefolder.traitextender.FileFolderServiceTrait)1 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)1 PageCollator (org.alfresco.repo.virtual.page.PageCollator)1 VirtualFolderDefinition (org.alfresco.repo.virtual.template.VirtualFolderDefinition)1 VirtualQuery (org.alfresco.repo.virtual.template.VirtualQuery)1 Pair (org.alfresco.util.Pair)1