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