Search in sources :

Example 61 with Reference

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

the class VirtualVersionServiceExtension method revert.

@Override
public void revert(NodeRef nodeRef, boolean deep) {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        theTrait.revert(nodeRef, deep);
    } else {
        NodeRef materialNode = smartStore.materialize(reference);
        theTrait.revert(materialNode, deep);
    }
}
Also used : VersionServiceTrait(org.alfresco.repo.version.traitextender.VersionServiceTrait) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 62 with Reference

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

the class VirtualVersionServiceExtension method revert.

@Override
public void revert(NodeRef nodeRef, Version version, boolean deep) {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        theTrait.revert(nodeRef, version, deep);
    } else {
        NodeRef materialNode = smartStore.materialize(reference);
        Version actualVersion = VirtualVersionServiceExtension.this.materializeVersionIfReference(version);
        theTrait.revert(materialNode, actualVersion, deep);
    }
}
Also used : VersionServiceTrait(org.alfresco.repo.version.traitextender.VersionServiceTrait) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Version(org.alfresco.service.cmr.version.Version) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 63 with Reference

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

the class VirtualVersionServiceExtension method isAVersion.

@Override
public boolean isAVersion(NodeRef nodeRef) {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.isAVersion(nodeRef);
    } else {
        NodeRef materialNode = smartStore.materialize(reference);
        return theTrait.isAVersion(materialNode);
    }
}
Also used : VersionServiceTrait(org.alfresco.repo.version.traitextender.VersionServiceTrait) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 64 with Reference

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

the class VirtualVersionServiceExtension method createVersion.

@Override
public Collection<Version> createVersion(Collection<NodeRef> nodeRefs, Map<String, Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingException {
    VersionServiceTrait theTrait = getTrait();
    Collection<NodeRef> materialNodeRefs = new LinkedList<>();
    Map<NodeRef, Reference> materializedNodeRefs = new HashMap<>();
    for (NodeRef nodeRef : nodeRefs) {
        Reference reference = Reference.fromNodeRef(nodeRef);
        if (reference == null) {
            materialNodeRefs.add(nodeRef);
        } else {
            NodeRef materialNode = smartStore.materializeIfPossible(nodeRef);
            materialNodeRefs.add(materialNode);
            materializedNodeRefs.put(materialNode, reference);
        }
    }
    Collection<Version> versions = theTrait.createVersion(materialNodeRefs, versionProperties);
    Collection<Version> virtualizedVersions = new LinkedList<>();
    for (Version version : versions) {
        NodeRef versionedNodeRef = version.getVersionedNodeRef();
        Reference reference = materializedNodeRefs.get(versionedNodeRef);
        if (reference != null) {
            Version virtualizedVersion = virtualizeVersion(reference, version);
            virtualizedVersions.add(virtualizedVersion);
        } else {
            virtualizedVersions.add(version);
        }
    }
    return virtualizedVersions;
}
Also used : VersionServiceTrait(org.alfresco.repo.version.traitextender.VersionServiceTrait) NodeRef(org.alfresco.service.cmr.repository.NodeRef) HashMap(java.util.HashMap) Version(org.alfresco.service.cmr.version.Version) Reference(org.alfresco.repo.virtual.ref.Reference) LinkedList(java.util.LinkedList)

Example 65 with Reference

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

the class VirtualVersionServiceExtension method deleteVersionHistory.

@Override
public void deleteVersionHistory(NodeRef nodeRef) throws AspectMissingException {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        theTrait.deleteVersionHistory(nodeRef);
    } else {
        NodeRef materialNode = smartStore.materialize(reference);
        theTrait.deleteVersionHistory(materialNode);
    }
}
Also used : VersionServiceTrait(org.alfresco.repo.version.traitextender.VersionServiceTrait) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference)

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