use of org.alfresco.repo.virtual.template.NamePatternPropertyValueConstraint in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method search.
@Override
public List<Reference> search(Reference reference, String namePattern, boolean fileSearch, boolean folderSearch, boolean includeSubFolders) throws VirtualizationException {
VirtualFolderDefinition structure = resolveVirtualFolderDefinition(reference);
List<Reference> result = new LinkedList<Reference>();
List<Reference> childReferences = createChildReferences(reference, structure);
if (folderSearch) {
result.addAll(childReferences);
}
if (includeSubFolders) {
for (Reference childRef : childReferences) {
List<Reference> childResults = search(childRef, namePattern, fileSearch, folderSearch, includeSubFolders);
result.addAll(childResults);
}
}
if (fileSearch) {
final VirtualQuery query = structure.getQuery();
if (query != null) {
VirtualQueryConstraint vqConstraint = null;
if (namePattern == null) {
vqConstraint = BasicConstraint.INSTANCE;
} else {
vqConstraint = new NamePatternPropertyValueConstraint(new FilesFoldersConstraint(BasicConstraint.INSTANCE, true, true), ContentModel.PROP_NAME, namePattern, environment.getNamespacePrefixResolver());
}
PagingResults<Reference> queryNodes = query.perform(environment, vqConstraint, null, reference);
result.addAll(queryNodes.getPage());
}
}
return result;
}
Aggregations