Search in sources :

Example 1 with NamePatternPropertyValueConstraint

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;
}
Also used : VirtualQueryConstraint(org.alfresco.repo.virtual.template.VirtualQueryConstraint) VirtualQuery(org.alfresco.repo.virtual.template.VirtualQuery) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) FilesFoldersConstraint(org.alfresco.repo.virtual.template.FilesFoldersConstraint) NamePatternPropertyValueConstraint(org.alfresco.repo.virtual.template.NamePatternPropertyValueConstraint) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)1 Reference (org.alfresco.repo.virtual.ref.Reference)1 FilesFoldersConstraint (org.alfresco.repo.virtual.template.FilesFoldersConstraint)1 NamePatternPropertyValueConstraint (org.alfresco.repo.virtual.template.NamePatternPropertyValueConstraint)1 VirtualFolderDefinition (org.alfresco.repo.virtual.template.VirtualFolderDefinition)1 VirtualQuery (org.alfresco.repo.virtual.template.VirtualQuery)1 VirtualQueryConstraint (org.alfresco.repo.virtual.template.VirtualQueryConstraint)1