use of org.alfresco.repo.node.integrity.IntegrityChecker in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtensionTest method testCopySemivirtualFolder.
@Test
public void testCopySemivirtualFolder() throws Exception {
configuredTemplatesClassPath = constraints.getTemplatesParentClasspath();
constraints.setTemplatesParentClasspath("/org/alfresco/repo/virtual/template");
IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
NodeRef childRef = createFolder(testRootFolder.getNodeRef(), "TT").getChildRef();
CopyService copyService = ctx.getBean("copyService", CopyService.class);
copyService.copyAndRename(virtualFolder1NodeRef, childRef, ContentModel.ASSOC_CONTAINS, null, true);
NodeRef copiedNodeRef = nodeService.getChildByName(childRef, ContentModel.ASSOC_CONTAINS, VIRTUAL_FOLDER_1_NAME);
assertNotNull(copiedNodeRef);
NodeRef node2 = nodeService.getChildByName(copiedNodeRef, ContentModel.ASSOC_CONTAINS, "Node2");
assertNotNull(node2);
NodeRef node2_1 = nodeService.getChildByName(node2, ContentModel.ASSOC_CONTAINS, "Node2_1");
assertNotNull(node2_1);
integrityChecker.checkIntegrity();
}
use of org.alfresco.repo.node.integrity.IntegrityChecker in project alfresco-repository by Alfresco.
the class CopyServiceImplTest method testCopiedFromAspect.
public void testCopiedFromAspect() {
IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
// Create the node used for copying
ChildAssociationRef childAssocRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}test"), TEST_TYPE_QNAME, createTypePropertyBag());
NodeRef nodeRef = childAssocRef.getChildRef();
PagingRequest pageRequest = new PagingRequest(10);
pageRequest.setRequestTotalCountMax(200);
PagingResults<CopyInfo> copies = null;
NodeRef firstCopy = null;
NodeRef secondCopy = null;
for (int i = 1; i <= 100; i++) {
NodeRef copyNodeRef = copyService.copy(nodeRef, rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}copyAssoc"));
if (firstCopy == null) {
firstCopy = copyNodeRef;
} else if (secondCopy == null) {
secondCopy = copyNodeRef;
}
copies = copyService.getCopies(nodeRef, pageRequest);
assertEquals("Total count not correct", new Pair<Integer, Integer>(i, i), copies.getTotalResultCount());
assertEquals("Incorrect number of copies", (i > 10 ? 10 : i), copies.getPage().size());
// Since the results are paged, make sure that we have the correct results while we only have a page
boolean found = (i > 10) ? true : false;
for (CopyInfo copy : copies.getPage()) {
if (// Might not be checking if we are over a page
found) {
break;
}
if (copy.getNodeRef().equals(copyNodeRef)) {
found = true;
}
}
assertTrue("Did not find the copy in the list of copies.", found);
// Run integrity checks to ensure that commit has a chance
integrityChecker.checkIntegrity();
// Now query for copies in current parent location
copies = copyService.getCopies(nodeRef, rootNodeRef, pageRequest);
assertEquals("Total count not correct", new Pair<Integer, Integer>(i, i), copies.getTotalResultCount());
assertEquals("Incorrect number of copies", (i > 10 ? 10 : i), copies.getPage().size());
// Check that the original node can be retrieved
NodeRef originalCheck = copyService.getOriginal(copyNodeRef);
assertEquals("Original is not as expected. ", nodeRef, originalCheck);
// Check that the parent node can be included
copies = copyService.getCopies(nodeRef, rootNodeRef, pageRequest);
assertEquals("Total count not correct", new Pair<Integer, Integer>(i, i), copies.getTotalResultCount());
assertEquals("Incorrect number of copies", (i > 10 ? 10 : i), copies.getPage().size());
// And query against some other parent node
// Some arbitrary parent
copies = copyService.getCopies(nodeRef, sourceNodeRef, pageRequest);
assertEquals("Expected to find no copies", 0, copies.getPage().size());
}
// Should be able to delete the original
nodeService.deleteNode(nodeRef);
// Run integrity checks to ensure that commit has a chance
integrityChecker.checkIntegrity();
// Should be no original
NodeRef originalCheck = copyService.getOriginal(firstCopy);
assertNull("Original should not be present. ", originalCheck);
assertFalse("Copy should not have cm:copiedfrom aspect. ", nodeService.hasAspect(firstCopy, ContentModel.ASPECT_COPIEDFROM));
}
use of org.alfresco.repo.node.integrity.IntegrityChecker in project alfresco-repository by Alfresco.
the class CopyServiceImplTest method testALF11964_part1.
/**
* Tests copying a folder that contains both a node and a copy of that node.
*/
public void testALF11964_part1() {
IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
PropertyMap props = new PropertyMap();
// Need to create a potentially recursive node structure
props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
NodeRef nodeOne = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
NodeRef nodeTwo = nodeService.createNode(nodeOne, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTENT, props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
NodeRef nodeThree = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
copyService.copy(nodeTwo, nodeOne, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
integrityChecker.checkIntegrity();
}
use of org.alfresco.repo.node.integrity.IntegrityChecker in project alfresco-repository by Alfresco.
the class CopyServiceImplTest method testCopyOfCopyOfCopy.
/**
* <a href="https://issues.alfresco.com/jira/browse/MNT-9580">
* MNT-9580: Daisy chained cm:original associations are cascade-deleted when the first original is deleted
* </a>
*/
public void testCopyOfCopyOfCopy() {
IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
// Create the node used for copying
ChildAssociationRef childAssocRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}test"), TEST_TYPE_QNAME, createTypePropertyBag());
NodeRef nodeRef = childAssocRef.getChildRef();
PagingRequest pageRequest = new PagingRequest(10);
pageRequest.setRequestTotalCountMax(200);
PagingResults<CopyInfo> copies = null;
NodeRef currentOriginal = nodeRef;
NodeRef copyNodeRef = null;
for (int i = 1; i <= 5; i++) {
copyNodeRef = copyService.copy(currentOriginal, rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}copyAssoc" + i));
copies = copyService.getCopies(currentOriginal, pageRequest);
assertEquals("Incorrect number of copies on iteration " + i, 1, copies.getPage().size());
// Check that the original node can be retrieved
NodeRef originalCheck = copyService.getOriginal(copyNodeRef);
assertEquals("Original is not as expected. ", currentOriginal, originalCheck);
// Run integrity checks to ensure that commit has a chance
integrityChecker.checkIntegrity();
currentOriginal = copyNodeRef;
}
// Now, delete the nodes starting with the first original
currentOriginal = nodeRef;
copyNodeRef = null;
for (int i = 1; i < 5; i++) {
// Each node must be an original
copies = copyService.getCopies(currentOriginal, pageRequest);
assertEquals("Incorrect number of copies on iteration " + i, 1, copies.getPage().size());
copyNodeRef = copies.getPage().get(0).getNodeRef();
// Delete current original
nodeService.deleteNode(currentOriginal);
// Run integrity checks to ensure that commit has a chance
integrityChecker.checkIntegrity();
currentOriginal = copyNodeRef;
}
}
use of org.alfresco.repo.node.integrity.IntegrityChecker in project alfresco-repository by Alfresco.
the class CopyServiceImplTest method testALF11964_part2.
/**
* Tests copying a folder that contains both a checked-out node and its working copy.
*/
public void testALF11964_part2() {
IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
PropertyMap props = new PropertyMap();
// Need to create a potentially recursive node structure
props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
NodeRef nodeOne = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
NodeRef nodeTwo = nodeService.createNode(nodeOne, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTENT, props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
NodeRef nodeThree = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
cociService.checkout(nodeTwo);
copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
integrityChecker.checkIntegrity();
}
Aggregations