Search in sources :

Example 76 with Reference

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

the class VirtualStoreImplTest method testCanExistNodeIDwithV.

// MNT-17845
@Test
public void testCanExistNodeIDwithV() {
    createAndCheckNodeId("nfile", "specialFile1.txt");
    createAndCheckNodeId("vfile", "specialFile2.txt");
    // v0...
    createAndCheckNodeId("v" + Encodings.ZERO.encoding.token + "file", "specialFile3.txt");
    // vH...
    createAndCheckNodeId("v" + Encodings.HASH.encoding.token + "file", "specialFile4.txt");
    // vp...
    createAndCheckNodeId("v" + Encodings.PLAIN.encoding.token + "file", "specialFile5.txt");
    NodeRef virtualFolder = createVirtualizedFolder(testRootFolder.getNodeRef(), VIRTUAL_FOLDER_3_NAME, TEST_TEMPLATE_4_JSON_SYS_PATH);
    assertTrue(smartStore.canVirtualize(virtualFolder));
    virtualFolder = smartStore.virtualize(virtualFolder).toNodeRef();
    Reference reference = Reference.fromNodeRef(virtualFolder);
    assertNotNull(reference);
    assertTrue(nodeService.exists(virtualFolder));
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference) ApplyTemplateMethodTest(org.alfresco.repo.virtual.template.ApplyTemplateMethodTest) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 77 with Reference

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

the class VirtualVersionServiceExtensionTest method testCreateVersion.

@Test
public void testCreateVersion() throws Exception {
    ChildAssociationRef contentWithVersionsAssocRef = createContent(node2_1, "ContentWithVersions");
    NodeRef contentWithVersionsNodeRef = contentWithVersionsAssocRef.getChildRef();
    Reference reference = Reference.fromNodeRef(contentWithVersionsNodeRef);
    assertNotNull(reference);
    NodeRef actualContentWithVersionsNodeRef = reference.execute(new GetActualNodeRefMethod(environment));
    VersionHistory versionHistory = versionService.getVersionHistory(contentWithVersionsNodeRef);
    assertNull(versionHistory);
    VersionHistory actualVersionHistory = versionService.getVersionHistory(actualContentWithVersionsNodeRef);
    assertNull(actualVersionHistory);
    Version newVersion = versionService.createVersion(contentWithVersionsNodeRef, null);
    NodeRef newVersionNodeRef = newVersion.getVersionedNodeRef();
    assertNotNull(Reference.fromNodeRef(newVersionNodeRef));
    versionHistory = versionService.getVersionHistory(newVersionNodeRef);
    assertNotNull(versionHistory);
    Collection<Version> allVersions = versionHistory.getAllVersions();
    assertEquals(1, allVersions.size());
    actualVersionHistory = versionService.getVersionHistory(actualContentWithVersionsNodeRef);
    assertNotNull(actualVersionHistory);
    Collection<Version> allActualVersions = versionHistory.getAllVersions();
    assertEquals(1, allActualVersions.size());
    Version actualVersion = actualVersionHistory.getHeadVersion();
    NodeRef newActualVersionNodeRef = actualVersion.getVersionedNodeRef();
    assertNull(Reference.fromNodeRef(newActualVersionNodeRef));
    assertEquals(newActualVersionNodeRef, actualContentWithVersionsNodeRef);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Version(org.alfresco.service.cmr.version.Version) Reference(org.alfresco.repo.virtual.ref.Reference) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) VersionHistory(org.alfresco.service.cmr.version.VersionHistory) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 78 with Reference

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

the class SystemVirtualizationMethodTest method testTemplateFromClassPath.

@Test
public void testTemplateFromClassPath() throws Exception {
    NodeRef vf = createVirtualizedFolder(testRootFolder.getNodeRef(), "classpathVirtualizedFolder", TEST_TEMPLATE_1_JSON_SYS_PATH);
    assertTrue(systemVirtualizationMethod.canVirtualize(environment, vf));
    Reference ref = systemVirtualizationMethod.virtualize(environment, vf);
    assertNotNull(ref);
    assertNotNull(nodeService.getChildByName(ref.toNodeRef(), ContentModel.ASSOC_CONTAINS, "Node1"));
    assertNotNull(nodeService.getChildByName(ref.toNodeRef(), ContentModel.ASSOC_CONTAINS, "Node2"));
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 79 with Reference

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

the class VirtualNodeServiceExtensionTest method assertNewVirtualChildAssocRef.

/**
 * Assets that the given {@link ChildAssociationRef} was created within the
 * given container {@link Reference}.
 *
 * @param nodeRef
 * @param childAssocsRef
 */
private void assertNewVirtualChildAssocRef(Reference reference, ChildAssociationRef childAssocsRef) {
    assertNotNull(childAssocsRef);
    NodeRef childNodeRef = childAssocsRef.getChildRef();
    NodeRef parentNodeRef = childAssocsRef.getParentRef();
    Reference parentNodeRefV = Reference.fromNodeRef(parentNodeRef);
    assertNotNull(parentNodeRefV);
    assertEquals(reference, parentNodeRefV);
    Reference childReference = Reference.fromNodeRef(childNodeRef);
    assertNotNull(childReference);
    Reference parent = childReference.execute(new GetParentReferenceMethod());
    assertEquals(reference, parent);
}
Also used : GetParentReferenceMethod(org.alfresco.repo.virtual.ref.GetParentReferenceMethod) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 80 with Reference

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

the class VirtualNodeServiceExtensionTest method findActualAssocPeer.

private ChildAssociationRef findActualAssocPeer(ChildAssociationRef virtualAssoc, NodeRef actualParentNodeRef) {
    List<ChildAssociationRef> actualAssocs = nodeService.getChildAssocs(actualParentNodeRef);
    NodeRef virtualChildNodeRef = virtualAssoc.getChildRef();
    Reference vChildNodeRef = Reference.fromNodeRef(virtualChildNodeRef);
    assertNotNull(vChildNodeRef);
    NodeRef materialNodeRef = smartStore.materialize(vChildNodeRef);
    for (ChildAssociationRef actualAssocRef : actualAssocs) {
        if (materialNodeRef.equals(actualAssocRef.getChildRef())) {
            if (virtualAssoc.getQName().getLocalName().equals(actualAssocRef.getQName().getLocalName()) && virtualAssoc.getTypeQName().equals(actualAssocRef.getTypeQName())) {
                return actualAssocRef;
            }
        }
    }
    return null;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

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