use of org.alfresco.query.ListBackedPagingResults in project alfresco-repository by Alfresco.
the class RemoteCredentialsServiceImpl method listRemoteSystems.
private PagingResults<String> listRemoteSystems(boolean people, boolean shared, PagingRequest paging) {
List<NodeRef> search = new ArrayList<NodeRef>();
if (people) {
// Only search if it has the marker aspect
NodeRef person = repositoryHelper.getPerson();
if (nodeService.hasAspect(person, RemoteCredentialsModel.ASPECT_REMOTE_CREDENTIALS_SYSTEM_CONTAINER)) {
search.add(person);
}
}
if (shared) {
NodeRef system = getSharedContainerNodeRef(false);
if (system != null) {
search.add(system);
}
}
// If no suitable nodes were given, bail out
if (search.isEmpty()) {
return new EmptyPagingResults<String>();
}
// Look for nodes
// Because all the information we need is held on the association, we don't
// really need to use a Canned Query for this
Set<String> systems = new HashSet<String>();
for (NodeRef nodeRef : search) {
List<ChildAssociationRef> refs = nodeService.getChildAssocs(nodeRef, RemoteCredentialsModel.ASSOC_CREDENTIALS_SYSTEM, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : refs) {
// System Name is the association name, no namespace
systems.add(ref.getQName().getLocalName());
}
}
// Sort, then wrap as paged results
List<String> sortedSystems = new ArrayList<String>(systems);
Collections.sort(sortedSystems);
return new ListBackedPagingResults<String>(sortedSystems, paging);
}
use of org.alfresco.query.ListBackedPagingResults 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