mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
[207178] listMultiple() instead of listMulti, fileTypes[] as well as fileType param API
This commit is contained in:
parent
92ff8a6a0a
commit
3bd826f5b5
7 changed files with 156 additions and 23 deletions
|
@ -834,7 +834,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
}
|
||||
|
||||
// I think the de should be reused since getElement should find it?
|
||||
getFileMulti(parents, names, monitor);
|
||||
getFileMultiple(parents, names, monitor);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1066,7 +1066,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
/**
|
||||
* Mass query of individual files
|
||||
*/
|
||||
public IHostFile[] getFileMulti(String remoteParents[], String names[], IProgressMonitor monitor)
|
||||
public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor)
|
||||
throws SystemMessageException
|
||||
{
|
||||
DataElement[] subjects = getSubjectsFor(remoteParents, names);
|
||||
|
@ -1612,7 +1612,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
}
|
||||
|
||||
|
||||
public IHostFile[] listMulti(String[] remoteParents,
|
||||
public IHostFile[] listMultiple(String[] remoteParents,
|
||||
String[] fileFilters, int[] fileTypes, IProgressMonitor monitor)
|
||||
throws SystemMessageException
|
||||
{
|
||||
|
@ -1621,6 +1621,22 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
return fetchMulti(remoteParents, fileFilters, queryStrings, monitor);
|
||||
}
|
||||
|
||||
public IHostFile[] listMultiple(String[] remoteParents,
|
||||
String[] fileFilters, int fileType, IProgressMonitor monitor)
|
||||
throws SystemMessageException
|
||||
{
|
||||
String queryString = getQueryString(fileType);
|
||||
|
||||
// create array of the same query string
|
||||
String[] queryStrings = new String[remoteParents.length];
|
||||
for (int i = 0; i < remoteParents.length; i++)
|
||||
{
|
||||
queryStrings[i] = queryString;
|
||||
}
|
||||
|
||||
return fetchMulti(remoteParents, fileFilters, queryStrings, monitor);
|
||||
}
|
||||
|
||||
protected String[] getPathsFor(String[] remoteParents, String[] remoteFiles)
|
||||
{
|
||||
String[] results = new String[remoteParents.length];
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
{
|
||||
protected abstract IHostFile[] internalFetch(String parentPath, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
public IHostFile[] getFileMulti(String remoteParents[], String names[], IProgressMonitor monitor)
|
||||
public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor)
|
||||
throws SystemMessageException
|
||||
{
|
||||
List results = new ArrayList();
|
||||
|
@ -51,7 +51,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
return internalFetch(remoteParent, fileFilter, fileType, monitor);
|
||||
}
|
||||
|
||||
public IHostFile[] listMulti(String[] remoteParents,
|
||||
public IHostFile[] listMultiple(String[] remoteParents,
|
||||
String[] fileFilters, int fileTypes[], IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
|
||||
|
@ -68,6 +68,23 @@ public abstract class AbstractFileService implements IFileService
|
|||
return (IHostFile[])files.toArray(new IHostFile[files.size()]);
|
||||
}
|
||||
|
||||
public IHostFile[] listMultiple(String[] remoteParents,
|
||||
String[] fileFilters, int fileType, IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
|
||||
List files = new ArrayList();
|
||||
for (int i = 0; i < remoteParents.length; i++)
|
||||
{
|
||||
IHostFile[] result = list(remoteParents[i], fileFilters[i], fileType, monitor);
|
||||
for (int j = 0; j < result.length; j++)
|
||||
{
|
||||
files.add(result[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return (IHostFile[])files.toArray(new IHostFile[files.size()]);
|
||||
}
|
||||
|
||||
protected boolean isRightType(int fileType, IHostFile node)
|
||||
{
|
||||
switch (fileType)
|
||||
|
|
|
@ -175,7 +175,7 @@ public interface IFileService extends IService
|
|||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public IHostFile[] getFileMulti(String remoteParents[], String names[], IProgressMonitor monitor) throws SystemMessageException;
|
||||
public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* @param remoteParents - the names of the parent directories on the remote file
|
||||
|
@ -192,7 +192,24 @@ public interface IFileService extends IService
|
|||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public IHostFile[] listMulti(String[] remoteParents, String[] fileFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
|
||||
public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* @param remoteParents - the names of the parent directories on the remote file
|
||||
* system from which to retrieve the collective child list.
|
||||
* @param fileFilters - a set of strings that can be used to filter the children. Only
|
||||
* those files matching the filter corresponding to it's remoteParent make it into the list. The interface
|
||||
* does not dictate where the filtering occurs. For each remoteParent, there must be a corresponding
|
||||
* fileFilter.
|
||||
* @param fileType - indicates whether to query files, folders, both or some other type. For
|
||||
* each remoteParent, there must be a corresponding fileType.
|
||||
* For the default list of available file types see <code>IFileServiceContants</code>
|
||||
* @param monitor the monitor for this potentially long running operation
|
||||
* @return the collective list of host files that reside in each of the remoteParents with it's corresponding filter.
|
||||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -361,7 +361,7 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
|||
}
|
||||
|
||||
RemoteFileContext context = getDefaultContext();
|
||||
IHostFile[] nodes = getFileService().getFileMulti(parentPaths, names, monitor);
|
||||
IHostFile[] nodes = getFileService().getFileMultiple(parentPaths, names, monitor);
|
||||
return getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, nodes);
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
|||
* @param fileTypes - indicates whether to query files, folders, both or some other type
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMulti(IRemoteFile[] parents, String[] fileNameFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, String[] fileNameFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
String[] parentPaths = new String[parents.length];
|
||||
for (int i = 0; i < parents.length; i++)
|
||||
|
@ -382,7 +382,7 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
|||
parentPaths[i] = parents[i].getAbsolutePath();
|
||||
}
|
||||
|
||||
IHostFile[] results = getFileService().listMulti(parentPaths, fileNameFilters, fileTypes, monitor);
|
||||
IHostFile[] results = getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, monitor);
|
||||
RemoteFileContext context = getDefaultContext();
|
||||
|
||||
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
|
||||
|
@ -416,6 +416,55 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of remote folders and files in the given folder. Only file names are subsettable
|
||||
* by the given file name filter. It can be null for no subsetting.
|
||||
* @param parents The parent folders to list folders and files in
|
||||
* @param fileNameFilters The name patterns to subset the file list by, or null to return all files.
|
||||
* @param fileType - indicates whether to query files, folders, both or some other type
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, String[] fileNameFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
String[] parentPaths = new String[parents.length];
|
||||
for (int i = 0; i < parents.length; i++)
|
||||
{
|
||||
parentPaths[i] = parents[i].getAbsolutePath();
|
||||
}
|
||||
|
||||
IHostFile[] results = getFileService().listMultiple(parentPaths, fileNameFilters, fileType, monitor);
|
||||
RemoteFileContext context = getDefaultContext();
|
||||
|
||||
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
|
||||
|
||||
// caching
|
||||
for (int i = 0; i < parents.length; i++)
|
||||
{
|
||||
IRemoteFile parent = parents[i];
|
||||
String parentPath = parentPaths[i];
|
||||
String filter = fileNameFilters[i];
|
||||
|
||||
List underParent = new ArrayList();
|
||||
// what files are under this one?
|
||||
for (int j = 0; j < farr.length; j++)
|
||||
{
|
||||
IRemoteFile child = farr[j];
|
||||
String childParentPath = child.getParentPath();
|
||||
|
||||
if (parentPath.equals(childParentPath))
|
||||
{
|
||||
underParent.add(child);
|
||||
}
|
||||
}
|
||||
if (underParent.size() > 0)
|
||||
{
|
||||
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
return farr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of remote folders and/or files in the given folder.
|
||||
|
|
|
@ -117,7 +117,7 @@ public interface IRemoteFileSubSystem extends ISubSystem {
|
|||
* For the default list of available file types see <code>IFileServiceContants</code>
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMulti(IRemoteFile[] parents, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Return a list of remote folders and/or files in the given folder. Only file names are filtered
|
||||
|
@ -131,9 +131,32 @@ public interface IRemoteFileSubSystem extends ISubSystem {
|
|||
* For the default list of available file types see <code>IFileServiceContants</code>
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMulti(IRemoteFile[] parents, String[] fileNameFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, String[] fileNameFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Return a list of all remote folders and/or files in the given folders. This list is not filtered.
|
||||
*
|
||||
* @param parents The parent folders to list folders and/or files in
|
||||
* @param fileType - indicates whether to query files, folders, both or some other type. This fileType is used for each parent query.
|
||||
* For the default list of available file types see <code>IFileServiceContants</code>
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, int fileType, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Return a list of remote folders and/or files in the given folder. Only file names are filtered
|
||||
* by the given file name filters. It can be null for no sub-setting.
|
||||
*
|
||||
* @param parents The parent folders to list folders and files in
|
||||
* @param fileNameFilters The name patterns to subset the file list by, or null to return all files.
|
||||
* There should be exactly one fileNameFilter per parent.
|
||||
* @param fileType - indicates whether to query files, folders, both or some other type. This fileType is used for each parent query.
|
||||
* For the default list of available file types see <code>IFileServiceContants</code>
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, String[] fileNameFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of all remote folders and/or files in the given folder. The list is not filtered.
|
||||
*
|
||||
|
@ -485,7 +508,7 @@ public interface IRemoteFileSubSystem extends ISubSystem {
|
|||
* Typically this would be one of those in the
|
||||
* {@link RemoteFileException} family.
|
||||
*/
|
||||
public void downloadMulti(IRemoteFile[] sources, String[] destinations, String[] encoding, IProgressMonitor monitor) throws SystemMessageException;
|
||||
public void downloadMulti(IRemoteFile[] sources, String[] destinations, String[] encodings, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -870,7 +870,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
|||
* @param fileTypes - indicates whether to query files, folders, both or some other type
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMulti(IRemoteFile[] parents, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
String[] fileNameFilters = new String[parents.length];
|
||||
for (int i = 0; i < parents.length; i++)
|
||||
|
@ -878,7 +878,24 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
|||
fileNameFilters[i] = "*"; // default filter //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return listMulti(parents, fileNameFilters, fileTypes, monitor);
|
||||
return listMultiple(parents, fileNameFilters, fileTypes, monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all remote folders and files in the given folder. The list is not subsetted.
|
||||
* @param parents The parent folders to list folders and files in
|
||||
* @param fileType - indicates whether to query files, folders, both or some other type
|
||||
* @param monitor the progress monitor
|
||||
*/
|
||||
public IRemoteFile[] listMultiple(IRemoteFile[] parents, int fileType, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
String[] fileNameFilters = new String[parents.length];
|
||||
for (int i = 0; i < parents.length; i++)
|
||||
{
|
||||
fileNameFilters[i] = "*"; // default filter //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return listMultiple(parents, fileNameFilters, fileType, monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -356,14 +356,8 @@ public class FileSubsystemConsistencyTestCase extends RSEBaseConnectionTestCase
|
|||
IRemoteFile[] results = null;
|
||||
long t3 = System.currentTimeMillis();
|
||||
try
|
||||
{
|
||||
int[] types = new int[remoteFiles.length];
|
||||
for (int t = 0; t < remoteFiles.length; t++)
|
||||
{
|
||||
types[t] = IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS;
|
||||
}
|
||||
|
||||
results = ss.listMulti(remoteFiles, types, new NullProgressMonitor());
|
||||
{
|
||||
results = ss.listMultiple(remoteFiles, IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS, new NullProgressMonitor());
|
||||
}
|
||||
catch (Exception e){
|
||||
exception = e;
|
||||
|
|
Loading…
Add table
Reference in a new issue