Search in sources :

Example 1 with VanillaProtocol

use of org.alfresco.repo.virtual.ref.VanillaProtocol 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)

Aggregations

VirtualizationIntegrationTest (org.alfresco.repo.virtual.VirtualizationIntegrationTest)1 Reference (org.alfresco.repo.virtual.ref.Reference)1 VanillaProtocol (org.alfresco.repo.virtual.ref.VanillaProtocol)1 ApplyTemplateMethodTest (org.alfresco.repo.virtual.template.ApplyTemplateMethodTest)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 Test (org.junit.Test)1