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);
}
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));
}
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();
}
}
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);
}
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);
}
Aggregations