diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java index d7a410cb348..c60574a5cf8 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java @@ -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]; diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java index 266c8bfd82a..6806b0ad93b 100644 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java @@ -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) diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java index 4247644527a..5095659cc35 100644 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java @@ -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 IFileServiceContants + * @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; /** diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java index 8fd9239ee79..b3fb3c26dfa 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java @@ -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. diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java index d1f3c99a321..68a60cdc2d7 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java @@ -117,7 +117,7 @@ public interface IRemoteFileSubSystem extends ISubSystem { * For the default list of available file types see IFileServiceContants * @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 IFileServiceContants * @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 IFileServiceContants + * @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 IFileServiceContants + * @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; diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java index f023a99c609..72d4bfbf211 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java @@ -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); } /** diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java index 470de6fe99d..5234eab6307 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java @@ -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;