mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -485,7 +485,7 @@ public class FileFolderServiceImpl implements FileFolderService
|
|||||||
// This is a folder search only;
|
// This is a folder search only;
|
||||||
query = XPATH_QUERY_DEEP_FOLDERS;
|
query = XPATH_QUERY_DEEP_FOLDERS;
|
||||||
}
|
}
|
||||||
else if(fileSearch && folderSearch)
|
else if(fileSearch && !folderSearch)
|
||||||
{
|
{
|
||||||
// This is a folder search only;
|
// This is a folder search only;
|
||||||
query = XPATH_QUERY_DEEP_FILES;
|
query = XPATH_QUERY_DEEP_FILES;
|
||||||
@@ -617,13 +617,18 @@ public class FileFolderServiceImpl implements FileFolderService
|
|||||||
|
|
||||||
for (ChildAssociationRef folderRef : folderAssocRefs)
|
for (ChildAssociationRef folderRef : folderAssocRefs)
|
||||||
{
|
{
|
||||||
|
// Add the folders in the currentDir
|
||||||
toSearch.push(folderRef.getChildRef());
|
toSearch.push(folderRef.getChildRef());
|
||||||
|
|
||||||
if(folders)
|
if(folders)
|
||||||
{
|
{
|
||||||
result.add(folderRef.getChildRef());
|
result.add(folderRef.getChildRef());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(files)
|
if(files)
|
||||||
{
|
{
|
||||||
|
// Add the files in the current dir
|
||||||
List<ChildAssociationRef> fileAssocRefs = nodeService.getChildAssocs(currentDir, fileTypeQNames);
|
List<ChildAssociationRef> fileAssocRefs = nodeService.getChildAssocs(currentDir, fileTypeQNames);
|
||||||
for (ChildAssociationRef fileRef : fileAssocRefs)
|
for (ChildAssociationRef fileRef : fileAssocRefs)
|
||||||
{
|
{
|
||||||
@@ -631,7 +636,6 @@ public class FileFolderServiceImpl implements FileFolderService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("search deep finished size:" + result.size());
|
logger.debug("search deep finished size:" + result.size());
|
||||||
|
|
||||||
|
@@ -218,6 +218,8 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testDeepFilesAndFoldersSearch() throws Exception
|
public void testDeepFilesAndFoldersSearch() throws Exception
|
||||||
|
{
|
||||||
|
// Seach for pattern <Any char>-<AnyChars>
|
||||||
{
|
{
|
||||||
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, "?1-*", true, true, true);
|
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, "?1-*", true, true, true);
|
||||||
// check
|
// check
|
||||||
@@ -226,6 +228,39 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
checkFileList(files, 3, 2, expectedNames);
|
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
|
public void testDeepFilesOnlySearch() throws Exception
|
||||||
{
|
{
|
||||||
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, "?1-*", true, false, true);
|
List<FileInfo> files = fileFolderService.search(workingRootNodeRef, "?1-*", true, false, true);
|
||||||
|
@@ -79,6 +79,9 @@ public interface FileFolderService
|
|||||||
* Searches for all files and folders with the matching name pattern,
|
* Searches for all files and folders with the matching name pattern,
|
||||||
* using wildcard characters <b>*</b> and <b>?</b>.
|
* using wildcard characters <b>*</b> and <b>?</b>.
|
||||||
*
|
*
|
||||||
|
* Warning: Please avoid using this method with any "namePattern" other than "*".
|
||||||
|
* Although it works, its performance is poor, which is why this method is deprecated.
|
||||||
|
*
|
||||||
* @param contextNodeRef the context of the search. This node will never be returned
|
* @param contextNodeRef the context of the search. This node will never be returned
|
||||||
* as part of the search results.
|
* as part of the search results.
|
||||||
* @param namePattern the name of the file or folder to search for, or a
|
* @param namePattern the name of the file or folder to search for, or a
|
||||||
@@ -88,6 +91,9 @@ public interface FileFolderService
|
|||||||
* @return Returns a list of file or folder matches
|
* @return Returns a list of file or folder matches
|
||||||
*
|
*
|
||||||
* @see #search(NodeRef, String, boolean, boolean, boolean)
|
* @see #search(NodeRef, String, boolean, boolean, boolean)
|
||||||
|
* @deprecated for shallow search use list, listFolders, listFiles, searchSimple, alternatives
|
||||||
|
* for deep search will be provided in later releases. Avoid calling this method with any
|
||||||
|
* name pattern except for "*".
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"contextNodeRef", "namePattern", "includeSubFolders"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"contextNodeRef", "namePattern", "includeSubFolders"})
|
||||||
public List<FileInfo> search(
|
public List<FileInfo> search(
|
||||||
@@ -99,6 +105,9 @@ public interface FileFolderService
|
|||||||
* Perform a search against the name of the files or folders within a hierarchy.
|
* Perform a search against the name of the files or folders within a hierarchy.
|
||||||
* Wildcard characters are <b>*</b> and <b>?</b>.
|
* Wildcard characters are <b>*</b> and <b>?</b>.
|
||||||
*
|
*
|
||||||
|
* Warning: Please avoid using this method with any "namePattern" other than "*".
|
||||||
|
* Although it works, its performance is poor which is why this method is deprecated.
|
||||||
|
*
|
||||||
* @param contextNodeRef the context of the search. This node will never be returned
|
* @param contextNodeRef the context of the search. This node will never be returned
|
||||||
* as part of the search results.
|
* as part of the search results.
|
||||||
* @param namePattern the name of the file or folder to search for, or a
|
* @param namePattern the name of the file or folder to search for, or a
|
||||||
@@ -108,6 +117,9 @@ public interface FileFolderService
|
|||||||
* @param folderSearch true if folder types are to be included in the search results
|
* @param folderSearch true if folder types are to be included in the search results
|
||||||
* @param includeSubFolders true to search the entire hierarchy below the search context
|
* @param includeSubFolders true to search the entire hierarchy below the search context
|
||||||
* @return Returns a list of file or folder matches
|
* @return Returns a list of file or folder matches
|
||||||
|
* @deprecated for shallow search use list, listFolders, listFiles, searchSimple, alternatives
|
||||||
|
* for deep search will be provided in later releases. Avoid calling this method with any
|
||||||
|
* name pattern except for "*".
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"contextNodeRef", "namePattern", "fileSearch", "folderSearch", "includeSubFolders"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"contextNodeRef", "namePattern", "fileSearch", "folderSearch", "includeSubFolders"})
|
||||||
public List<FileInfo> search(
|
public List<FileInfo> search(
|
||||||
|
Reference in New Issue
Block a user