Search in sources :

Example 51 with Reference

use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.

the class VirtualCheckOutCheckInServiceExtension method virtualizeVersionIfNeeded.

private NodeRef virtualizeVersionIfNeeded(NodeRef originalNodeRef, NodeRef materialVersion) {
    Reference reference = Reference.fromNodeRef(originalNodeRef);
    if ((materialVersion != null) && (reference != null) && (Reference.fromNodeRef(materialVersion) == null)) {
        Reference parentReference = reference.execute(new GetParentReferenceMethod());
        Reference workingCopyReference = NodeProtocol.newReference(materialVersion, parentReference);
        return workingCopyReference.toNodeRef(materialVersion.getStoreRef());
    } else {
        return materialVersion;
    }
}
Also used : GetParentReferenceMethod(org.alfresco.repo.virtual.ref.GetParentReferenceMethod) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 52 with Reference

use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.

the class VirtualFileFolderServiceExtension method search.

@Override
public List<FileInfo> search(NodeRef contextNodeRef, String namePattern, boolean fileSearch, boolean folderSearch, boolean includeSubFolders) {
    if (namePattern == null || namePattern.equals("*")) {
        if (canVirtualize(contextNodeRef)) {
            Reference reference = smartStore.virtualize(contextNodeRef);
            List<Reference> virtualNodes = Collections.emptyList();
            if (!includeSubFolders) {
                virtualNodes = smartStore.search(reference, namePattern, fileSearch, folderSearch, false);
            }
            List<FileInfo> searchResult = asFileInfos(virtualNodes, smartStore, environment);
            if (mergeActualNode(reference)) {
                List<FileInfo> actualSearch = getTrait().search(actualNodeFrom(reference), namePattern, fileSearch, folderSearch, includeSubFolders);
                searchResult.addAll(actualSearch);
            }
            return searchResult;
        }
    }
    return getTrait().search(contextNodeRef, namePattern, fileSearch, folderSearch, includeSubFolders);
}
Also used : FileInfo(org.alfresco.service.cmr.model.FileInfo) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 53 with Reference

use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.

the class VirtualFileFolderServiceExtension method list.

@Override
public List<FileInfo> list(NodeRef contextNodeRef) {
    if (canVirtualize(contextNodeRef)) {
        Reference reference = smartStore.virtualize(contextNodeRef);
        List<Reference> virtualNodes = smartStore.list(reference);
        List<FileInfo> searchResult = asFileInfos(virtualNodes, smartStore, environment);
        if (mergeActualNode(reference)) {
            List<FileInfo> actualSearch = getTrait().list(actualNodeFrom(reference));
            searchResult.addAll(actualSearch);
        }
        return searchResult;
    } else {
        return getTrait().list(contextNodeRef);
    }
}
Also used : FileInfo(org.alfresco.service.cmr.model.FileInfo) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 54 with Reference

use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.

the class VirtualPermissionServiceExtension method hasPermission.

public AccessStatus hasPermission(NodeRef nodeRef, PermissionReference perm) {
    PermissionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.hasPermission(nodeRef, perm);
    } else {
        AccessStatus virtualAccessStatus = smartStore.hasPermission(reference, perm);
        if (!AccessStatus.UNDETERMINED.equals(virtualAccessStatus)) {
            return virtualAccessStatus;
        } else {
            NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
            if (nodeToAdhereTo == null) {
                return AccessStatus.UNDETERMINED;
            } else {
                return theTrait.hasPermission(nodeToAdhereTo, perm);
            }
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) PermissionServiceTrait(org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait) AccessStatus(org.alfresco.service.cmr.security.AccessStatus)

Example 55 with Reference

use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.

the class VirtualPermissionServiceExtension method hasPermission.

public AccessStatus hasPermission(NodeRef nodeRef, String perm) {
    PermissionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.hasPermission(nodeRef, perm);
    } else {
        AccessStatus virtualAccessStatus = smartStore.hasPermission(reference, perm);
        if (!AccessStatus.UNDETERMINED.equals(virtualAccessStatus)) {
            return virtualAccessStatus;
        } else {
            NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
            if (nodeToAdhereTo == null) {
                return AccessStatus.UNDETERMINED;
            } else {
                return theTrait.hasPermission(nodeToAdhereTo, perm);
            }
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) PermissionServiceTrait(org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait) AccessStatus(org.alfresco.service.cmr.security.AccessStatus)

Aggregations

Reference (org.alfresco.repo.virtual.ref.Reference)81 NodeRef (org.alfresco.service.cmr.repository.NodeRef)59 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)23 VersionServiceTrait (org.alfresco.repo.version.traitextender.VersionServiceTrait)16 LinkedList (java.util.LinkedList)15 VirtualizationIntegrationTest (org.alfresco.repo.virtual.VirtualizationIntegrationTest)15 Test (org.junit.Test)15 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)13 NodeServiceTrait (org.alfresco.repo.node.db.traitextender.NodeServiceTrait)12 QName (org.alfresco.service.namespace.QName)10 Serializable (java.io.Serializable)9 GetParentReferenceMethod (org.alfresco.repo.virtual.ref.GetParentReferenceMethod)9 Version (org.alfresco.service.cmr.version.Version)9 GetActualNodeRefMethod (org.alfresco.repo.virtual.ref.GetActualNodeRefMethod)8 VirtualFolderDefinition (org.alfresco.repo.virtual.template.VirtualFolderDefinition)6 FileInfo (org.alfresco.service.cmr.model.FileInfo)6 PermissionServiceTrait (org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait)5 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4