use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method getVersionHistory.
@Override
public VersionHistory getVersionHistory(NodeRef nodeRef) throws AspectMissingException {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getVersionHistory(nodeRef);
} else {
NodeRef materialNode = smartStore.materialize(reference);
VersionHistory actualVersionHistory = theTrait.getVersionHistory(materialNode);
if (actualVersionHistory == null) {
return null;
} else {
Reference versionedReference = Reference.fromNodeRef(nodeRef);
return new VirtualVersionHistory(versionedReference, actualVersionHistory);
}
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method revert.
@Override
public void revert(NodeRef nodeRef) {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
theTrait.revert(nodeRef);
} else {
NodeRef materialNode = smartStore.materialize(reference);
theTrait.revert(materialNode);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method createVersion.
@Override
public Collection<Version> createVersion(NodeRef nodeRef, Map<String, Serializable> versionProperties, boolean versionChildren) throws ReservedVersionNameException, AspectMissingException {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.createVersion(nodeRef, versionProperties, versionChildren);
} else {
NodeRef materialNode = smartStore.materializeIfPossible(nodeRef);
Collection<Version> actualVersions = theTrait.createVersion(materialNode, versionProperties, versionChildren);
return virtualizeVersions(reference, actualVersions);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method restore.
@Override
public NodeRef restore(NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName, boolean deep) {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.restore(nodeRef, parentNodeRef, assocTypeQName, assocQName, deep);
} else {
NodeRef materialNode = smartStore.materialize(reference);
return theTrait.restore(materialNode, parentNodeRef, assocTypeQName, assocQName, deep);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtensionTest method testCreateNode.
@Test
public void testCreateNode() throws Exception {
assertTrue(smartStore.canVirtualize(virtualFolder1NodeRef));
Reference semiVirtualFolder = smartStore.virtualize(virtualFolder1NodeRef);
assertNotNull(semiVirtualFolder);
assertTrue(semiVirtualFolder.getProtocol() instanceof VirtualProtocol);
Reference firstChild = smartStore.getChildByName(semiVirtualFolder, ContentModel.ASSOC_CONTAINS, "Node1");
assertNotNull(firstChild);
Reference secondChild = smartStore.getChildByName(semiVirtualFolder, ContentModel.ASSOC_CONTAINS, "Node2");
assertNotNull(secondChild);
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
// add testfile.txt to first virtual child
String fileName = "testfile.txt";
uploadNode(firstChild, fileName);
assertNotNull(nodeService.getChildByName(firstChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile.txt"));
uploadNode(firstChild, fileName);
assertNotNull(nodeService.getChildByName(firstChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-1.txt"));
// add testfile.txt to second virtual child
uploadNode(secondChild, fileName);
assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-2.txt"));
uploadNode(secondChild, fileName);
assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-3.txt"));
// add again to first virtual child starting from the last index found
// (this is the index that comes from
// upload-post.js)
fileName = "testfile-2.txt";
uploadNode(firstChild, fileName);
assertNotNull(nodeService.getChildByName(firstChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-4.txt"));
// test create node for actual node starting from the last index found
// (this is the index that comes from
// upload-post.js)
fileName = "testfile-5.txt";
fileAndFolderService.create(virtualFolder1NodeRef, fileName, ContentModel.TYPE_CONTENT);
assertNotNull(nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "testfile-5.txt"));
fileName = "testfile-6.txt";
fileAndFolderService.create(virtualFolder1NodeRef, fileName, ContentModel.TYPE_CONTENT);
assertNotNull(nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "testfile-6.txt"));
// add again to second child starting from the last index found (this is
// the index that comes from
// upload-post.js)
fileName = "testfile-4.txt";
uploadNode(secondChild, fileName);
assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile-7.txt"));
// test situation when file name is of form testfile1-1.txt
fileName = "testfile1-1.txt";
fileAndFolderService.create(secondChild.toNodeRef(), fileName, ContentModel.TYPE_CONTENT);
assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile1-1.txt"));
fileAndFolderService.create(secondChild.toNodeRef(), fileName, ContentModel.TYPE_CONTENT);
assertNotNull(nodeService.getChildByName(secondChild.toNodeRef(), ContentModel.ASSOC_CONTAINS, "testfile1-1-1.txt"));
}
Aggregations