Search in sources :

Example 81 with Reference

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

the class VirtualNodeServiceExtensionTest method testCreate_NodeProtocolParent.

@Test
public void testCreate_NodeProtocolParent() throws Exception {
    NodeRef assocNode2 = nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "Node2");
    NodeRef assocNode2_1 = nodeService.getChildByName(assocNode2, ContentModel.ASSOC_CONTAINS, "Node2_1");
    ChildAssociationRef childAssocRef = createContent(assocNode2_1, "Content");
    NodeRef node = childAssocRef.getChildRef();
    Reference reference = Reference.fromNodeRef(node);
    assertNotNull(reference);
    assertTrue(reference.getProtocol().equals(Protocols.NODE.protocol));
    QName nodeTypeQName = ContentModel.TYPE_THUMBNAIL;
    QName assocQName = QName.createQName("cm", "contentThumbnail", environment.getNamespacePrefixResolver());
    QName assocTypeQName = RenditionModel.ASSOC_RENDITION;
    ChildAssociationRef assoc = nodeService.createNode(node, assocTypeQName, assocQName, nodeTypeQName);
    NodeRef virtualRenditionNode = assoc.getChildRef();
    NodeRef virtualRenditionParent = assoc.getParentRef();
    assertEquals(node, virtualRenditionParent);
    Reference child = Reference.fromNodeRef(virtualRenditionNode);
    Reference parent = Reference.fromNodeRef(virtualRenditionParent);
    NodeRef physicalRenditionNode = child.execute(new GetActualNodeRefMethod(environment));
    NodeRef physicalRenditionParent = parent.execute(new GetActualNodeRefMethod(environment));
    List<ChildAssociationRef> refs = nodeService.getChildAssocs(physicalRenditionParent);
    // the association exists for the physical nodes
    assertEquals(physicalRenditionNode, refs.get(0).getChildRef());
    List<ChildAssociationRef> virtualRefs = nodeService.getChildAssocs(virtualRenditionParent);
    // the association exists for the virtual nodes
    assertEquals(physicalRenditionNode, virtualRefs.get(0).getChildRef());
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference) QName(org.alfresco.service.namespace.QName) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) 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