Lines 21-26
Link Here
|
21 |
* Javier Montalvo Orus (Symbian) - [199773] Default file transfer mode is ignored for some file types |
21 |
* Javier Montalvo Orus (Symbian) - [199773] Default file transfer mode is ignored for some file types |
22 |
* David McKnight (IBM) - [207095] Implicit connect on getRemoteFileObject |
22 |
* David McKnight (IBM) - [207095] Implicit connect on getRemoteFileObject |
23 |
* David McKnight (IBM) - [207100] fire event after upload and download |
23 |
* David McKnight (IBM) - [207100] fire event after upload and download |
|
|
24 |
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems |
24 |
*******************************************************************************/ |
25 |
*******************************************************************************/ |
25 |
|
26 |
|
26 |
package org.eclipse.rse.subsystems.files.core.servicesubsystem; |
27 |
package org.eclipse.rse.subsystems.files.core.servicesubsystem; |
Lines 28-33
Link Here
|
28 |
import java.io.File; |
29 |
import java.io.File; |
29 |
import java.io.InputStream; |
30 |
import java.io.InputStream; |
30 |
import java.io.OutputStream; |
31 |
import java.io.OutputStream; |
|
|
32 |
import java.util.ArrayList; |
33 |
import java.util.List; |
31 |
|
34 |
|
32 |
import org.eclipse.core.runtime.IProgressMonitor; |
35 |
import org.eclipse.core.runtime.IProgressMonitor; |
33 |
import org.eclipse.core.runtime.NullProgressMonitor; |
36 |
import org.eclipse.core.runtime.NullProgressMonitor; |
Lines 56-61
Link Here
|
56 |
import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter; |
59 |
import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter; |
57 |
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; |
60 |
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; |
58 |
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext; |
61 |
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext; |
|
|
62 |
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileContext; |
59 |
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem; |
63 |
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem; |
60 |
import org.eclipse.rse.ui.ISystemMessages; |
64 |
import org.eclipse.rse.ui.ISystemMessages; |
61 |
import org.eclipse.rse.ui.RSEUIPlugin; |
65 |
import org.eclipse.rse.ui.RSEUIPlugin; |
Lines 63-68
Link Here
|
63 |
|
67 |
|
64 |
public final class FileServiceSubSystem extends RemoteFileSubSystem implements IFileServiceSubSystem |
68 |
public final class FileServiceSubSystem extends RemoteFileSubSystem implements IFileServiceSubSystem |
65 |
{ |
69 |
{ |
|
|
70 |
|
66 |
protected ILanguageUtilityFactory _languageUtilityFactory; |
71 |
protected ILanguageUtilityFactory _languageUtilityFactory; |
67 |
protected IFileService _hostFileService; |
72 |
protected IFileService _hostFileService; |
68 |
protected ISearchService _hostSearchService; |
73 |
protected ISearchService _hostSearchService; |
Lines 153-158
Link Here
|
153 |
return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, node); |
158 |
return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, node); |
154 |
} |
159 |
} |
155 |
|
160 |
|
|
|
161 |
|
162 |
|
156 |
/** |
163 |
/** |
157 |
* Constructs and returns an IRemoteFile object given a fully-qualified |
164 |
* Constructs and returns an IRemoteFile object given a fully-qualified |
158 |
* file or folder name. |
165 |
* file or folder name. |
Lines 304-324
Link Here
|
304 |
_userHome = root; |
311 |
_userHome = root; |
305 |
return root; |
312 |
return root; |
306 |
} |
313 |
} |
307 |
|
314 |
protected IHostFile[] internalList(String parentPath, String fileNameFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException |
308 |
protected IHostFile[] getFolders(String parentPath, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException |
|
|
309 |
{ |
310 |
return getFileService().getFolders(parentPath, fileNameFilter, monitor); |
311 |
} |
312 |
|
313 |
protected IHostFile[] getFiles(String parentPath, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException |
314 |
{ |
315 |
{ |
315 |
return getFileService().getFiles(parentPath, fileNameFilter, monitor); |
316 |
return getFileService().list(parentPath, fileNameFilter, fileType, monitor); |
316 |
} |
317 |
} |
317 |
|
318 |
|
318 |
protected IHostFile[] getFilesAndFolders(String parentPath, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException |
319 |
|
319 |
{ |
|
|
320 |
return getFileService().getFilesAndFolders(parentPath, fileNameFilter, monitor); |
321 |
} |
322 |
|
320 |
|
323 |
protected IHostFile getFile(String parentPath, String fileName, IProgressMonitor monitor) throws SystemMessageException |
321 |
protected IHostFile getFile(String parentPath, String fileName, IProgressMonitor monitor) throws SystemMessageException |
324 |
{ |
322 |
{ |
Lines 330-421
Link Here
|
330 |
return getFileService().getRoots(monitor); |
328 |
return getFileService().getRoots(monitor); |
331 |
} |
329 |
} |
332 |
|
330 |
|
333 |
/** |
331 |
public IRemoteFile[] getRemoteFileObjects(String[] folderOrFileNames, |
334 |
* Return a list of remote folders and files in the given folder. |
332 |
IProgressMonitor monitor) throws SystemMessageException |
335 |
* <p> |
|
|
336 |
* The files part of the list is subsetted by the given file name filter. |
337 |
* It can be null for no subsetting. |
338 |
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s). |
339 |
* @param parent The parent folder to list folders and files in |
340 |
* @param fileNameFilter The name pattern to subset the file list by, or null to return all files. |
341 |
* @param context The holder of state information |
342 |
*/ |
343 |
public IRemoteFile[] listFoldersAndFiles(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, IProgressMonitor monitor) throws SystemMessageException |
344 |
{ |
333 |
{ |
345 |
String parentPath = null; |
334 |
String[] parentPaths = new String[folderOrFileNames.length]; |
346 |
if (parent != null) { |
335 |
String[] names = new String[folderOrFileNames.length]; |
347 |
parentPath = parent.getAbsolutePath(); |
336 |
String sep = null; |
348 |
} else { |
337 |
for (int i = 0; i < folderOrFileNames.length; i++) |
349 |
parentPath = "/"; //$NON-NLS-1$ |
338 |
{ |
350 |
} |
339 |
String fofName = folderOrFileNames[i]; |
|
|
340 |
if (sep == null) |
341 |
sep = PathUtility.getSeparator(fofName); |
342 |
|
343 |
String parentPath = null; |
344 |
String name = null; |
345 |
int lastSep = fofName.lastIndexOf(sep); |
351 |
|
346 |
|
352 |
if (parent != null && !parent.canRead()) |
347 |
if (lastSep > -1) |
353 |
{ |
348 |
{ |
354 |
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FOLDER_UNREADABLE).makeSubstitution(parentPath); |
349 |
parentPath = fofName.substring(0, lastSep); |
355 |
throw new SystemMessageException(msg); |
350 |
|
|
|
351 |
if (parentPath.length() == 0) parentPath = "/"; //$NON-NLS-1$ |
352 |
name = fofName.substring(lastSep + 1, fofName.length()); |
353 |
} |
354 |
|
355 |
parentPaths[i] = parentPath; |
356 |
names[i] = name; |
356 |
} |
357 |
} |
357 |
|
358 |
|
358 |
IHostFile[] results = getFilesAndFolders(parentPath, fileNameFilter, monitor); |
359 |
RemoteFileContext context = getDefaultContext(); |
359 |
|
360 |
IHostFile[] nodes = getFileService().getFileMulti(parentPaths, names, monitor); |
360 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
361 |
return getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, nodes); |
361 |
if (parent != null) |
|
|
362 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
363 |
return farr; |
364 |
} |
362 |
} |
365 |
|
363 |
|
|
|
364 |
|
366 |
/** |
365 |
/** |
367 |
* Return the array of IRemoteFile instances, matching the given pattern, |
366 |
* Return a list of remote folders and files in the given folder. Only file names are subsettable |
368 |
* that are contained in the given folder. |
367 |
* by the given file name filter. It can be null for no subsetting. |
369 |
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s) |
368 |
* @param parents The parent folders to list folders and files in |
370 |
* @param parent The parent folder to list files in |
369 |
* @param fileNameFilters The name patterns to subset the file list by, or null to return all files. |
371 |
* @param fileNameFilter The name pattern to subset the list by, or null to return all files. |
370 |
* @param fileType - indicates whether to query files, folders, both or some other type |
372 |
* @param context The holder of state information |
371 |
* @param monitor the progress monitor |
373 |
*/ |
372 |
*/ |
374 |
public IRemoteFile[] listFiles(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context,IProgressMonitor monitor) throws SystemMessageException |
373 |
public IRemoteFile[] listMulti(IRemoteFile[] parents, String[] fileNameFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException |
375 |
{ |
374 |
{ |
376 |
String parentPath = null; |
375 |
String[] parentPaths = new String[parents.length]; |
377 |
if (parent != null) { |
376 |
for (int i = 0; i < parents.length; i++) |
378 |
parentPath = parent.getAbsolutePath(); |
|
|
379 |
} else { |
380 |
parentPath = "/"; //$NON-NLS-1$ |
381 |
} |
382 |
|
383 |
if (parent != null && !parent.canRead()) |
384 |
{ |
377 |
{ |
385 |
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FOLDER_UNREADABLE).makeSubstitution(parentPath); |
378 |
parentPaths[i] = parents[i].getAbsolutePath(); |
386 |
throw new SystemMessageException(msg); |
|
|
387 |
} |
379 |
} |
388 |
|
380 |
|
389 |
IHostFile[] results = null; |
381 |
IHostFile[] results = getFileService().listMulti(parentPaths, fileNameFilters, fileType, monitor); |
390 |
try |
382 |
RemoteFileContext context = getDefaultContext(); |
391 |
{ |
383 |
|
392 |
results = getFiles(parentPath, fileNameFilter, monitor); |
384 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
393 |
} |
385 |
|
394 |
catch (SystemMessageException e) |
386 |
// caching |
|
|
387 |
for (int i = 0; i < parents.length; i++) |
395 |
{ |
388 |
{ |
|
|
389 |
IRemoteFile parent = parents[i]; |
390 |
String parentPath = parentPaths[i]; |
391 |
String filter = fileNameFilters[i]; |
396 |
|
392 |
|
|
|
393 |
List underParent = new ArrayList(); |
394 |
// what files are under this one? |
395 |
for (int j = 0; j < farr.length; j++) |
396 |
{ |
397 |
IRemoteFile child = farr[j]; |
398 |
String childParentPath = child.getParentPath(); |
399 |
|
400 |
if (parentPath.equals(childParentPath)) |
401 |
{ |
402 |
underParent.add(child); |
403 |
} |
404 |
} |
405 |
if (underParent.size() > 0) |
406 |
{ |
407 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); |
408 |
} |
397 |
} |
409 |
} |
398 |
|
410 |
|
399 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
|
|
400 |
|
401 |
if (parent != null) |
402 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
403 |
return farr; |
411 |
return farr; |
404 |
} |
412 |
} |
405 |
|
413 |
|
|
|
414 |
|
415 |
|
406 |
/** |
416 |
/** |
407 |
* Return a subsetted list of remote folders in the given parent folder on the remote system. |
417 |
* Return a list of remote folders and files in the given folder. |
408 |
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s) |
418 |
* <p> |
409 |
* @param parent The parent folder to list folders in |
419 |
* The files part of the list is subsetted by the given file name filter. |
410 |
* @param fileNameFilter The name pattern for subsetting the file list when this folder is subsequently expanded |
420 |
* It can be null for no subsetting. |
|
|
421 |
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s). |
422 |
* @param parent The parent folder to list folders and files in |
423 |
* @param fileNameFilter The name pattern to subset the file list by, or null to return all files. |
411 |
* @param context The holder of state information |
424 |
* @param context The holder of state information |
|
|
425 |
* @param fileType the type of file to query |
426 |
* @param monitor the progress monitor |
412 |
*/ |
427 |
*/ |
413 |
public IRemoteFile[] listFolders(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, IProgressMonitor monitor) throws SystemMessageException |
428 |
public IRemoteFile[] list(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, int fileType, IProgressMonitor monitor) throws SystemMessageException |
414 |
{ |
429 |
{ |
415 |
String parentPath = null; |
430 |
String parentPath = null; |
416 |
if (parent != null) { |
431 |
if (parent != null) { |
417 |
parentPath = parent.getAbsolutePath(); |
432 |
parentPath = parent.getAbsolutePath(); |
418 |
} else { |
433 |
} else { |
419 |
parentPath = "/"; //$NON-NLS-1$ |
434 |
parentPath = "/"; //$NON-NLS-1$ |
420 |
} |
435 |
} |
421 |
|
436 |
|
Lines 425-444
Link Here
|
425 |
throw new SystemMessageException(msg); |
440 |
throw new SystemMessageException(msg); |
426 |
} |
441 |
} |
427 |
|
442 |
|
428 |
IHostFile[] results = null; |
443 |
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); |
429 |
try |
444 |
|
430 |
{ |
|
|
431 |
results = getFolders(parentPath, fileNameFilter, monitor); |
432 |
} |
433 |
catch (SystemMessageException e) |
434 |
{ |
435 |
} |
436 |
|
437 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
445 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
438 |
if (parent != null) |
446 |
if (parent != null) |
439 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
447 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
440 |
return farr; |
448 |
return farr; |
441 |
} |
449 |
} |
|
|
450 |
|
451 |
|
442 |
|
452 |
|
443 |
public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException |
453 |
public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException |
444 |
{ |
454 |
{ |
Lines 830-835
Link Here
|
830 |
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) |
840 |
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) |
831 |
*/ |
841 |
*/ |
832 |
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { |
842 |
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { |
833 |
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this); |
843 |
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this); |
|
|
844 |
} |
845 |
|
846 |
/** |
847 |
* Return the array of IRemoteFile instances, matching the given pattern, |
848 |
* that are contained in the given folder. |
849 |
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s) |
850 |
* @param parent The parent folder to list files in |
851 |
* @param fileNameFilter The name pattern to subset the list by, or null to return all files. |
852 |
* @param context The holder of state information |
853 |
* |
854 |
* @deprecated use list |
855 |
*/ |
856 |
public IRemoteFile[] listFiles(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context,IProgressMonitor monitor) throws SystemMessageException |
857 |
{ |
858 |
String parentPath = null; |
859 |
if (parent != null) { |
860 |
parentPath = parent.getAbsolutePath(); |
861 |
} else { |
862 |
parentPath = "/"; //$NON-NLS-1$ |
863 |
} |
864 |
|
865 |
if (parent != null && !parent.canRead()) |
866 |
{ |
867 |
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FOLDER_UNREADABLE).makeSubstitution(parentPath); |
868 |
throw new SystemMessageException(msg); |
869 |
} |
870 |
|
871 |
IHostFile[] results = null; |
872 |
try |
873 |
{ |
874 |
results = getFiles(parentPath, fileNameFilter, monitor); |
875 |
} |
876 |
catch (SystemMessageException e) |
877 |
{ |
878 |
|
879 |
} |
880 |
|
881 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
882 |
|
883 |
if (parent != null) |
884 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
885 |
return farr; |
886 |
} |
887 |
|
888 |
/** |
889 |
* Return a subsetted list of remote folders in the given parent folder on the remote system. |
890 |
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s) |
891 |
* @param parent The parent folder to list folders in |
892 |
* @param fileNameFilter The name pattern for subsetting the file list when this folder is subsequently expanded |
893 |
* @param context The holder of state information |
894 |
* |
895 |
* @deprecated use list |
896 |
*/ |
897 |
public IRemoteFile[] listFolders(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, IProgressMonitor monitor) throws SystemMessageException |
898 |
{ |
899 |
String parentPath = null; |
900 |
if (parent != null) { |
901 |
parentPath = parent.getAbsolutePath(); |
902 |
} else { |
903 |
parentPath = "/"; //$NON-NLS-1$ |
904 |
} |
905 |
|
906 |
if (parent != null && !parent.canRead()) |
907 |
{ |
908 |
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FOLDER_UNREADABLE).makeSubstitution(parentPath); |
909 |
throw new SystemMessageException(msg); |
910 |
} |
911 |
|
912 |
IHostFile[] results = null; |
913 |
try |
914 |
{ |
915 |
results = getFolders(parentPath, fileNameFilter, monitor); |
916 |
} |
917 |
catch (SystemMessageException e) |
918 |
{ |
919 |
} |
920 |
|
921 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
922 |
if (parent != null) |
923 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
924 |
return farr; |
925 |
} |
926 |
|
927 |
/** |
928 |
* Return a list of remote folders and files in the given folder. |
929 |
* <p> |
930 |
* The files part of the list is subsetted by the given file name filter. |
931 |
* It can be null for no subsetting. |
932 |
* This version is called by RemoteFileSubSystemImpl's resolveFilterString(s). |
933 |
* @param parent The parent folder to list folders and files in |
934 |
* @param fileNameFilter The name pattern to subset the file list by, or null to return all files. |
935 |
* @param context The holder of state information |
936 |
* |
937 |
* @deprecated use list |
938 |
*/ |
939 |
public IRemoteFile[] listFoldersAndFiles(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, IProgressMonitor monitor) throws SystemMessageException |
940 |
{ |
941 |
String parentPath = null; |
942 |
if (parent != null) { |
943 |
parentPath = parent.getAbsolutePath(); |
944 |
} else { |
945 |
parentPath = "/"; //$NON-NLS-1$ |
946 |
} |
947 |
|
948 |
if (parent != null && !parent.canRead()) |
949 |
{ |
950 |
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_FOLDER_UNREADABLE).makeSubstitution(parentPath); |
951 |
throw new SystemMessageException(msg); |
952 |
} |
953 |
|
954 |
IHostFile[] results = getFilesAndFolders(parentPath, fileNameFilter, monitor); |
955 |
|
956 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
957 |
if (parent != null) |
958 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
959 |
return farr; |
960 |
} |
961 |
|
962 |
/** |
963 |
* @deprecated |
964 |
*/ |
965 |
protected IHostFile[] getFolders(String parentPath, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException |
966 |
{ |
967 |
return getFileService().getFolders(parentPath, fileNameFilter, monitor); |
968 |
} |
969 |
|
970 |
/** |
971 |
* @deprecated |
972 |
*/ |
973 |
protected IHostFile[] getFiles(String parentPath, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException |
974 |
{ |
975 |
return getFileService().getFiles(parentPath, fileNameFilter, monitor); |
976 |
} |
977 |
|
978 |
/** |
979 |
* @deprecated |
980 |
*/ |
981 |
protected IHostFile[] getFilesAndFolders(String parentPath, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException |
982 |
{ |
983 |
return getFileService().getFilesAndFolders(parentPath, fileNameFilter, monitor); |
834 |
} |
984 |
} |
835 |
} |
985 |
} |