Search in sources :

Example 41 with Reference

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

the class ApplyTemplateMethodTest method testExecute_virtualSysClasspath.

@Test
public void testExecute_virtualSysClasspath() throws Exception {
    ApplyTemplateMethod applyTemplateMethod = new ApplyTemplateMethod(environment);
    NewVirtualReferenceMethod newVirtualReferenceMethod = new NewVirtualReferenceMethod(TEST_TEMPLATE_1_JS_SYS_PATH, "/", rootNodeRef, null);
    Reference ref = Protocols.VIRTUAL.protocol.dispatch(newVirtualReferenceMethod, null);
    VirtualFolderDefinition structure = ref.execute(applyTemplateMethod);
    String templateName = structure.getName();
    assertEquals("template1_name", templateName);
    List<VirtualFolderDefinition> children = structure.getChildren();
    assertEquals(3, children.size());
    VirtualFolderDefinition child1 = structure.findChildByName("My Documents");
    assertTrue(child1 != null);
    VirtualFolderDefinition child2 = structure.findChildByName("Recent Documents");
    assertTrue(child2 != null);
    VirtualFolderDefinition child3 = structure.findChildByName("Other Documents");
    assertTrue(child3 != null);
}
Also used : Reference(org.alfresco.repo.virtual.ref.Reference) NewVirtualReferenceMethod(org.alfresco.repo.virtual.ref.NewVirtualReferenceMethod) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 42 with Reference

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

the class VirtualStoreImplTest method createAndCheckNodeId.

private void createAndCheckNodeId(String nodeId, String nodeName) {
    Map<QName, Serializable> props = new HashMap<>(1);
    props.put(ContentModel.PROP_NODE_UUID, nodeId);
    props.put(ContentModel.PROP_NAME, nodeName);
    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(nodeName));
    NodeRef nfileNodeRef = nodeService.createNode(companyHomeNodeRef, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CONTENT, props).getChildRef();
    Reference reference = Reference.fromNodeRef(nfileNodeRef);
    assertNull(reference);
    assertTrue(nodeService.exists(nfileNodeRef));
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 43 with Reference

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

the class VirtualStoreImplTest method testResolveVirtualFolderDefinition_inactiveSynchronization.

@Test
public void testResolveVirtualFolderDefinition_inactiveSynchronization() throws Exception {
    txnTamperHint = "VirtualStoreImplTest::testResolveVirtualFolderDefinition_inactiveSynchronization";
    txn.rollback();
    NodeRef ntVirtualizedFolder = null;
    NodeRef jsonTemplateContent = null;
    try {
        final String templateName = "template1.json";
        jsonTemplateContent = nodeService.getChildByName(companyHomeNodeRef, ContentModel.ASSOC_CONTAINS, templateName);
        if (jsonTemplateContent == null) {
            ChildAssociationRef templateChild = createContent(companyHomeNodeRef, templateName, ApplyTemplateMethodTest.class.getResourceAsStream(TEST_TEMPLATE_1_JSON_NAME), MimetypeMap.MIMETYPE_JSON, StandardCharsets.UTF_8.name());
            jsonTemplateContent = templateChild.getChildRef();
        }
        final String folderName = "testCanVirtualize_nonTransactional";
        ntVirtualizedFolder = nodeService.getChildByName(companyHomeNodeRef, ContentModel.ASSOC_CONTAINS, folderName);
        if (ntVirtualizedFolder == null) {
            ChildAssociationRef folderChild = createFolder(companyHomeNodeRef, folderName);
            ntVirtualizedFolder = folderChild.getChildRef();
        }
        Reference aVanillaRef = ((VanillaProtocol) Protocols.VANILLA.protocol).newReference(VANILLA_PROCESSOR_JS_CLASSPATH, "/1", ntVirtualizedFolder, jsonTemplateContent);
        // We use transactional-synchronized resources for caching. In
        // non-transactional contexts they might not be available.
        smartStore.resolveVirtualFolderDefinition(aVanillaRef);
    } finally {
        txn = transactionService.getUserTransaction();
        txn.begin();
        if (ntVirtualizedFolder != null) {
            nodeService.deleteNode(ntVirtualizedFolder);
        }
        if (jsonTemplateContent != null) {
            nodeService.deleteNode(jsonTemplateContent);
        }
        txn.commit();
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ApplyTemplateMethodTest(org.alfresco.repo.virtual.template.ApplyTemplateMethodTest) VanillaProtocol(org.alfresco.repo.virtual.ref.VanillaProtocol) Reference(org.alfresco.repo.virtual.ref.Reference) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ApplyTemplateMethodTest(org.alfresco.repo.virtual.template.ApplyTemplateMethodTest) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 44 with Reference

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

the class VirtualStoreImplTest method testCanCreateFolderNamedV.

@Test
public void testCanCreateFolderNamedV() throws Exception {
    // note: see Reference.VIRTUAL_TOKEN
    String v = "v";
    Reference reference = Reference.fromNodeRef(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, v));
    assertNull(reference);
    ChildAssociationRef folderChild = createFolder(companyHomeNodeRef, v);
    assertNotNull(folderChild);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ApplyTemplateMethodTest(org.alfresco.repo.virtual.template.ApplyTemplateMethodTest) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 45 with Reference

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

the class TemplateFilingRuleTest method testFilingSubPath_specialCharacters.

@Test
public void testFilingSubPath_specialCharacters() throws Exception {
    NodeRef vfNodeRef = createVirtualizedFolder(testRootFolder.getNodeRef(), "Template 6 With Spaces", TEST_TEMPLATE_5_JSON_SYS_PATH);
    NodeRef sfpNodeRef = nodeService.getChildByName(vfNodeRef, ContentModel.ASSOC_CONTAINS, "SpecialFilingPath5");
    Reference sfpReference = Reference.fromNodeRef(sfpNodeRef);
    ApplyTemplateMethod applyTemplateMethod = new ApplyTemplateMethod(environment);
    VirtualFolderDefinition structure = sfpReference.execute(applyTemplateMethod);
    FilingRule filingRule = structure.getFilingRule();
    assertTrue(filingRule instanceof TemplateFilingRule);
    NodeRef fn = filingRule.filingNodeRefFor(new FilingParameters(sfpReference));
    assertNull(fn);
    createFolder(vfNodeRef, "Space Sub Folder");
    fn = filingRule.filingNodeRefFor(new FilingParameters(sfpReference));
    assertNotNull(fn);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Reference(org.alfresco.repo.virtual.ref.Reference) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest) Test(org.junit.Test)

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