Search in sources :

Example 26 with Reference

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

the class VirtualVersionServiceExtension method getVersionHistory.

@Override
public VersionHistory getVersionHistory(NodeRef nodeRef) throws AspectMissingException {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.getVersionHistory(nodeRef);
    } else {
        NodeRef materialNode = smartStore.materialize(reference);
        VersionHistory actualVersionHistory = theTrait.getVersionHistory(materialNode);
        if (actualVersionHistory == null) {
            return null;
        } else {
            Reference versionedReference = Reference.fromNodeRef(nodeRef);
            return new VirtualVersionHistory(versionedReference, actualVersionHistory);
        }
    }
}
Also used : VersionServiceTrait(org.alfresco.repo.version.traitextender.VersionServiceTrait) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference) VersionHistory(org.alfresco.service.cmr.version.VersionHistory)

Example 27 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) {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        theTrait.revert(nodeRef);
    } else {
        NodeRef materialNode = smartStore.materialize(reference);
        theTrait.revert(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 28 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(NodeRef nodeRef, Map<String, Serializable> versionProperties, boolean versionChildren) throws ReservedVersionNameException, AspectMissingException {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.createVersion(nodeRef, versionProperties, versionChildren);
    } else {
        NodeRef materialNode = smartStore.materializeIfPossible(nodeRef);
        Collection<Version> actualVersions = theTrait.createVersion(materialNode, versionProperties, versionChildren);
        return virtualizeVersions(reference, actualVersions);
    }
}
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 29 with Reference

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

the class VirtualVersionServiceExtension method restore.

@Override
public NodeRef restore(NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName, boolean deep) {
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.restore(nodeRef, parentNodeRef, assocTypeQName, assocQName, deep);
    } else {
        NodeRef materialNode = smartStore.materialize(reference);
        return theTrait.restore(materialNode, parentNodeRef, assocTypeQName, assocQName, 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 30 with Reference

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

the class VirtualNodeServiceExtensionTest method testCreateNode.

@Test
public void testCreateNode() throws Exception {
    assertTrue(smartStore.canVirtualize(virtualFolder1NodeRef));
    Reference semiVirtualFolder = smartStore.virtualize(virtualFolder1NodeRef);
    assertNotNull(semiVirtualFolder);
    assertTrue(semiVirtualFolder.getProtocol() instanceof VirtualProtocol);
    Reference firstChild = smartStore.getChildByName(semiVirtualFolder, ContentModel.ASSOC_CONTAINS, "Node1");
    assertNotNull(firstChild);
    Reference secondChild = smartStore.getChildByName(semiVirtualFolder, ContentModel.ASSOC_CONTAINS, "Node2");
    assertNotNull(secondChild);
    authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
    // add testfile.txt to first virtual child
    String fileName = "testfile.txt";
    uploadNode(firstChild, fileName);
    assertNotNull(nodeService.getChildByName(firstChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile.txt"));
    uploadNode(firstChild, fileName);
    assertNotNull(nodeService.getChildByName(firstChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-1.txt"));
    // add testfile.txt to second virtual child
    uploadNode(secondChild, fileName);
    assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-2.txt"));
    uploadNode(secondChild, fileName);
    assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-3.txt"));
    // add again to first virtual child starting from the last index found
    // (this is the index that comes from
    // upload-post.js)
    fileName = "testfile-2.txt";
    uploadNode(firstChild, fileName);
    assertNotNull(nodeService.getChildByName(firstChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-4.txt"));
    // test create node for actual node starting from the last index found
    // (this is the index that comes from
    // upload-post.js)
    fileName = "testfile-5.txt";
    fileAndFolderService.create(virtualFolder1NodeRef, fileName, ContentModel.TYPE_CONTENT);
    assertNotNull(nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "testfile-5.txt"));
    fileName = "testfile-6.txt";
    fileAndFolderService.create(virtualFolder1NodeRef, fileName, ContentModel.TYPE_CONTENT);
    assertNotNull(nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "testfile-6.txt"));
    // add again to second child starting from the last index found (this is
    // the index that comes from
    // upload-post.js)
    fileName = "testfile-4.txt";
    uploadNode(secondChild, fileName);
    assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-7.txt"));
    // test situation when file name is of form testfile1-1.txt
    fileName = "testfile1-1.txt";
    fileAndFolderService.create(secondChild.toNodeRef(), fileName, ContentModel.TYPE_CONTENT);
    assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile1-1.txt"));
    fileAndFolderService.create(secondChild.toNodeRef(), fileName, ContentModel.TYPE_CONTENT);
    assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile1-1-1.txt"));
}
Also used : VirtualProtocol(org.alfresco.repo.virtual.ref.VirtualProtocol) Reference(org.alfresco.repo.virtual.ref.Reference) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

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