Search in sources :

Example 11 with VersionServiceTrait

use of org.alfresco.repo.version.traitextender.VersionServiceTrait in project alfresco-repository by Alfresco.

the class VirtualVersionServiceExtension method restore.

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

Example 12 with VersionServiceTrait

use of org.alfresco.repo.version.traitextender.VersionServiceTrait 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 13 with VersionServiceTrait

use of org.alfresco.repo.version.traitextender.VersionServiceTrait 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 14 with VersionServiceTrait

use of org.alfresco.repo.version.traitextender.VersionServiceTrait 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 15 with VersionServiceTrait

use of org.alfresco.repo.version.traitextender.VersionServiceTrait 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)

Aggregations

VersionServiceTrait (org.alfresco.repo.version.traitextender.VersionServiceTrait)16 Reference (org.alfresco.repo.virtual.ref.Reference)16 NodeRef (org.alfresco.service.cmr.repository.NodeRef)16 Version (org.alfresco.service.cmr.version.Version)7 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 VersionHistory (org.alfresco.service.cmr.version.VersionHistory)1