ALF-2126 - more updates for the FileFolderService.

- bug fix 
   - unit test expansion
   - have now deprecated the search methods

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19947 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2010-04-22 11:57:07 +00:00
parent 3d3460241d
commit ebc24ad0e0
3 changed files with 64 additions and 13 deletions

View File

@@ -485,7 +485,7 @@ public class FileFolderServiceImpl implements FileFolderService
// This is a folder search only;
query = XPATH_QUERY_DEEP_FOLDERS;
}
else if(fileSearch && folderSearch)
else if(fileSearch && !folderSearch)
{
// This is a folder search only;
query = XPATH_QUERY_DEEP_FILES;
@@ -617,18 +617,22 @@ public class FileFolderServiceImpl implements FileFolderService
for (ChildAssociationRef folderRef : folderAssocRefs)
{
// Add the folders in the currentDir
toSearch.push(folderRef.getChildRef());
if(folders)
{
result.add(folderRef.getChildRef());
}
if(files)
}
if(files)
{
// Add the files in the current dir
List<ChildAssociationRef> fileAssocRefs = nodeService.getChildAssocs(currentDir, fileTypeQNames);
for (ChildAssociationRef fileRef : fileAssocRefs)
{
List<ChildAssociationRef> fileAssocRefs = nodeService.getChildAssocs(currentDir, fileTypeQNames);
for (ChildAssociationRef fileRef : fileAssocRefs)
{
result.add(fileRef.getChildRef());
}
result.add(fileRef.getChildRef());
}
}
}

View File

@@ -219,11 +219,46 @@ public class FileFolderServiceImplTest extends TestCase
public void testDeepFilesAndFoldersSearch() throws Exception
{
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, "?1-*", true, true, true);
// check
String[] expectedNames = new String[]
{ NAME_L1_FOLDER_A, NAME_L1_FOLDER_B, NAME_L1_FILE_A, NAME_L1_FILE_B, NAME_L1_FILE_C };
checkFileList(files, 3, 2, expectedNames);
// Seach for pattern <Any char>-<AnyChars>
{
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, "?1-*", true, true, true);
// check
String[] expectedNames = new String[]
{ NAME_L1_FOLDER_A, NAME_L1_FOLDER_B, NAME_L1_FILE_A, NAME_L1_FILE_B, NAME_L1_FILE_C };
checkFileList(files, 3, 2, expectedNames);
}
// Search for a particular file
{
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, NAME_L1_FILE_B, true, true, true);
// check
String[] expectedNames = new String[]
{ NAME_L1_FILE_B };
checkFileList(files, 1, 0, expectedNames);
}
// Search for all files with wildcard
{
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, "*", true, true, true);
// check
String[] expectedNames = new String[]
{
NAME_CHECK_FOLDER,
NAME_L0_FOLDER_A,
NAME_L0_FOLDER_B,
NAME_L0_FOLDER_C,
NAME_L1_FOLDER_A,
NAME_L1_FOLDER_B,
NAME_CHECK_FILE,
NAME_L0_FILE_A,
NAME_L0_FILE_B,
NAME_L1_FILE_A,
NAME_L1_FILE_B,
NAME_L1_FILE_C
};
checkFileList(files, 6, 6, expectedNames);
}
}
public void testDeepFilesOnlySearch() throws Exception