Merged DEV/CHECK_EXISTS to HEAD

svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/DEV/CHECK_EXISTS@3442 svn://www.alfresco.org:3691/alfresco/BRANCHES/DEV/CHECK_EXISTS@3590 .

TODO: Fix bug raising incorrect exception during UI paste of same-named file
Note:
- Added a new method to NodeService to get child by name
- Added a new method to FileFolderService to perform fast, direct lookups based on name


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3591 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-08-23 16:50:12 +00:00
parent 3c9f179571
commit 4e4e342409
39 changed files with 1577 additions and 637 deletions

View File

@@ -66,7 +66,8 @@ public class FileFolderServiceImplTest extends TestCase
private static final String NAME_L1_FILE_A = "L1- File A";
private static final String NAME_L1_FILE_B = "L1- File B";
private static final String NAME_L1_FILE_C = "L1- File C (%_)";
private static final String NAME_DUPLICATE = "DUPLICATE";
private static final String NAME_CHECK_FILE = "CHECK_FILE";
private static final String NAME_CHECK_FOLDER = "CHECK_FOLDER";
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
@@ -258,11 +259,11 @@ public class FileFolderServiceImplTest extends TestCase
*/
public void testGetByName() throws Exception
{
FileInfo fileInfo = getByName(NAME_DUPLICATE, true);
FileInfo fileInfo = getByName(NAME_CHECK_FOLDER, true);
assertNotNull(fileInfo);
assertTrue(fileInfo.isFolder());
fileInfo = getByName(NAME_DUPLICATE, false);
fileInfo = getByName(NAME_CHECK_FILE, false);
assertNotNull(fileInfo);
assertFalse(fileInfo.isFolder());
}
@@ -308,6 +309,10 @@ public class FileFolderServiceImplTest extends TestCase
// make sure that it is an immediate child of the root
List<FileInfo> checkFileInfos = fileFolderService.search(workingRootNodeRef, NAME_L1_FOLDER_A, false);
assertEquals("Folder not moved to root", 1, checkFileInfos.size());
// rename properly
FileInfo checkFileInfo = fileFolderService.move(folderToMoveRef, null, "new name");
checkFileInfos = fileFolderService.search(workingRootNodeRef, checkFileInfo.getName(), false);
assertEquals("Folder not renamed in root", 1, checkFileInfos.size());
// attempt illegal rename (existing)
try
{
@@ -318,10 +323,6 @@ public class FileFolderServiceImplTest extends TestCase
{
// expected
}
// rename properly
FileInfo checkFileInfo = fileFolderService.move(folderToMoveRef, null, "new name");
checkFileInfos = fileFolderService.search(workingRootNodeRef, checkFileInfo.getName(), false);
assertEquals("Folder not renamed in root", 1, checkFileInfos.size());
}
public void testCopy() throws Exception
@@ -495,6 +496,22 @@ public class FileFolderServiceImplTest extends TestCase
}
}
public void testSearchSimple() throws Exception
{
FileInfo folderInfo = getByName(NAME_L0_FOLDER_A, true);
assertNotNull(folderInfo);
NodeRef folderNodeRef = folderInfo.getNodeRef();
// search for a file that is not there
NodeRef phantomNodeRef = fileFolderService.searchSimple(folderNodeRef, "aaaaaaa");
assertNull("Found non-existent node by name", phantomNodeRef);
// search for a file that is there
NodeRef fileNodeRef = fileFolderService.searchSimple(folderNodeRef, NAME_L1_FILE_A);
assertNotNull("Didn't find file", fileNodeRef);
// double check
FileInfo checkInfo = getByName(NAME_L1_FILE_A, false);
assertEquals("Incorrect node found", checkInfo.getNodeRef(), fileNodeRef);
}
public void testResolveNamePath() throws Exception
{
FileInfo fileInfo = getByName(NAME_L1_FILE_A, false);
@@ -546,4 +563,20 @@ public class FileFolderServiceImplTest extends TestCase
String checkContent = reader.getContentString();
assertEquals("Content mismatch", content, checkContent);
}
public void testLongFileNames() throws Exception
{
String fileName =
"12345678901234567890123456789012345678901234567890" +
"12345678901234567890123456789012345678901234567890" +
"12345678901234567890123456789012345678901234567890" +
"12345678901234567890123456789012345678901234567890" +
"12345678901234567890123456789012345678901234567890" +
"12345678901234567890123456789012345678901234567890";
FileInfo fileInfo = fileFolderService.create(workingRootNodeRef, fileName, ContentModel.TYPE_CONTENT);
// see if we can get it again
NodeRef fileNodeRef = fileFolderService.searchSimple(workingRootNodeRef, fileName);
assertNotNull("Long filename not found", fileNodeRef);
assertEquals(fileInfo.getNodeRef(), fileNodeRef);
}
}