Search in sources :

Example 6 with VirtualFolderDefinition

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

the class VirtualStoreImpl method createFilingData.

@Override
public FilingData createFilingData(Reference parentReference, QName assocTypeQName, QName assocQName, QName nodeTypeQName, Map<QName, Serializable> properties) throws VirtualizationException {
    VirtualFolderDefinition structure = resolveVirtualFolderDefinition(parentReference);
    FilingRule filingRule = structure.getFilingRule();
    if (filingRule == null) {
        filingRule = new NullFilingRule(environment);
    }
    FilingParameters filingParameters = new FilingParameters(parentReference, assocTypeQName, assocQName, nodeTypeQName, properties);
    FilingData filingData = filingRule.createFilingData(filingParameters);
    return filingData;
}
Also used : NullFilingRule(org.alfresco.repo.virtual.template.NullFilingRule) FilingParameters(org.alfresco.repo.virtual.template.FilingParameters) FilingData(org.alfresco.repo.virtual.template.FilingData) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) FilingRule(org.alfresco.repo.virtual.template.FilingRule) NullFilingRule(org.alfresco.repo.virtual.template.NullFilingRule)

Example 7 with VirtualFolderDefinition

use of org.alfresco.repo.virtual.template.VirtualFolderDefinition 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 8 with VirtualFolderDefinition

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

Example 9 with VirtualFolderDefinition

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

Example 10 with VirtualFolderDefinition

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

the class VirtualStoreImpl method getProperties.

@Override
public Map<QName, Serializable> getProperties(Reference reference) throws VirtualizationException {
    final Protocol protocol = reference.getProtocol();
    if (Protocols.VIRTUAL.protocol.equals(protocol) || Protocols.VANILLA.protocol.equals(protocol)) {
        VirtualFolderDefinition folderDefinition = resolveVirtualFolderDefinition(reference);
        Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
        // We first set default property values. They might be overridden by
        // folder definition properties.
        properties.put(ContentModel.PROP_NAME, folderDefinition.getName());
        StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
        properties.put(ContentModel.PROP_STORE_IDENTIFIER, storeRef.getIdentifier());
        properties.put(ContentModel.PROP_STORE_PROTOCOL, storeRef.getProtocol());
        properties.put(ContentModel.PROP_LOCALE, Locale.UK.toString());
        properties.put(ContentModel.PROP_MODIFIED, new Date());
        properties.put(ContentModel.PROP_MODIFIER, AuthenticationUtil.SYSTEM_USER_NAME);
        properties.put(ContentModel.PROP_CREATED, new Date());
        properties.put(ContentModel.PROP_CREATOR, AuthenticationUtil.SYSTEM_USER_NAME);
        properties.put(ContentModel.PROP_NODE_DBID, 0);
        properties.put(ContentModel.PROP_DESCRIPTION, folderDefinition.getDescription());
        // ACE-5303 : ContentModel.PROP_TITLE remains unset
        // We add virtual folder definition structure properties. They might
        // override the above defaults.
        Map<String, String> nodeProperties = folderDefinition.getProperties();
        if (nodeProperties != null) {
            Set<Entry<String, String>> propertyEntries = nodeProperties.entrySet();
            NamespacePrefixResolver nsPrefixResolver = environment.getNamespacePrefixResolver();
            for (Entry<String, String> propertyValueEntry : propertyEntries) {
                QName propertyQName = QName.createQName(propertyValueEntry.getKey(), nsPrefixResolver);
                properties.put(propertyQName, propertyValueEntry.getValue().toString());
            }
        }
        return properties;
    } else {
        NodeRef actual = reference.execute(new GetActualNodeRefMethod(environment));
        Map<QName, Serializable> properties = environment.getProperties(actual);
        properties.put(VirtualContentModel.PROP_ACTUAL_NODE_REF, actual.toString());
        return properties;
    }
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) Date(java.util.Date) NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) Entry(java.util.Map.Entry) NamespacePrefixResolver(org.alfresco.service.namespace.NamespacePrefixResolver) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod) Protocol(org.alfresco.repo.virtual.ref.Protocol) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition)

Aggregations

VirtualFolderDefinition (org.alfresco.repo.virtual.template.VirtualFolderDefinition)12 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)6 Reference (org.alfresco.repo.virtual.ref.Reference)6 FilesFoldersConstraint (org.alfresco.repo.virtual.template.FilesFoldersConstraint)4 FilingParameters (org.alfresco.repo.virtual.template.FilingParameters)4 FilingRule (org.alfresco.repo.virtual.template.FilingRule)4 VirtualQuery (org.alfresco.repo.virtual.template.VirtualQuery)4 NamePatternPropertyValueConstraint (org.alfresco.repo.virtual.template.NamePatternPropertyValueConstraint)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)2 GetChildByIdMethod (org.alfresco.repo.virtual.ref.GetChildByIdMethod)2 PropertyValueConstraint (org.alfresco.repo.virtual.template.PropertyValueConstraint)2 VirtualQueryConstraint (org.alfresco.repo.virtual.template.VirtualQueryConstraint)2 QName (org.alfresco.service.namespace.QName)2 Serializable (java.io.Serializable)1 Date (java.util.Date)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1