Search in sources :

Example 1 with FilesFoldersConstraint

use of org.alfresco.repo.virtual.template.FilesFoldersConstraint in project alfresco-repository by Alfresco.

the class VirtualStoreImpl method list.

@Override
public List<Reference> list(Reference reference) throws VirtualizationException {
    VirtualFolderDefinition structure = resolveVirtualFolderDefinition(reference);
    List<Reference> result = createChildReferences(reference, structure);
    final VirtualQuery query = structure.getQuery();
    if (query != null) {
        PagingResults<Reference> queryNodes = query.perform(environment, new FilesFoldersConstraint(BasicConstraint.INSTANCE, true, true), null, reference);
        result.addAll(queryNodes.getPage());
    }
    return result;
}
Also used : 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) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition)

Example 2 with FilesFoldersConstraint

use of org.alfresco.repo.virtual.template.FilesFoldersConstraint 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)

Example 3 with FilesFoldersConstraint

use of org.alfresco.repo.virtual.template.FilesFoldersConstraint in project alfresco-repository by Alfresco.

the class VirtualStoreImpl method getChildByName.

@Override
public Reference getChildByName(Reference reference, QName assocTypeQName, String childName) throws VirtualizationException {
    VirtualFolderDefinition structure = resolveVirtualFolderDefinition(reference);
    VirtualFolderDefinition theChild = structure.findChildByName(childName);
    if (theChild != null) {
        return reference.execute(new GetChildByIdMethod(theChild.getId()));
    } else {
        final VirtualQuery query = structure.getQuery();
        if (query != null) {
            PropertyValueConstraint constraint = new PropertyValueConstraint(new FilesFoldersConstraint(BasicConstraint.INSTANCE, true, true), ContentModel.PROP_NAME, childName, environment.getNamespacePrefixResolver());
            PagingResults<Reference> result = query.perform(environment, constraint, null, reference);
            List<Reference> page = result.getPage();
            return page == null || page.isEmpty() ? null : page.get(0);
        } else {
            return null;
        }
    }
}
Also used : VirtualQuery(org.alfresco.repo.virtual.template.VirtualQuery) FilesFoldersConstraint(org.alfresco.repo.virtual.template.FilesFoldersConstraint) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) NamePatternPropertyValueConstraint(org.alfresco.repo.virtual.template.NamePatternPropertyValueConstraint) PropertyValueConstraint(org.alfresco.repo.virtual.template.PropertyValueConstraint) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) GetChildByIdMethod(org.alfresco.repo.virtual.ref.GetChildByIdMethod)

Aggregations

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