RSE
Release 1.0

org.eclipse.rse.services.files
Interface IFileService

All Superinterfaces:
IService
All Known Implementing Classes:
AbstractFileService, DStoreFileService, FTPService, LocalFileService, SftpFileService

public interface IFileService
extends IService

A IFileService is an abstraction of a file service that runs over some sort of connection. It can be shared among multiple instances of a subsystem. At some point this file service layer may become official API but for now it is experimental. Each subsystem is currently responsible for layering an abstraction over whatever it wants to construct as a service.

This is a very bare bones definition. A real definition would probably have changed terminology, use URI's rather than Strings, and have much more robust error handling.

Implementers of this interface will have to either be instantiated, initialized, or somehow derive a connection as part of its state.


Method Summary
 boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
          Copy the file or folder to the specified destination
 boolean copyBatch(IProgressMonitor monitor, String[] srcParents, String[] srcNames, String tgtParent)
          Copy a set of files or folders to the specified destination
 IHostFile createFile(IProgressMonitor monitor, String remoteParent, String fileName)
          Create a file on the host
 IHostFile createFolder(IProgressMonitor monitor, String remoteParent, String folderName)
          Create a folder on the host
 boolean delete(IProgressMonitor monitor, String remoteParent, String fileName)
          Deletes a file or folder on the host
 boolean deleteBatch(IProgressMonitor monitor, String[] remoteParents, String[] fileNames)
          Deletes a set of files or folders on the host.
 boolean download(IProgressMonitor monitor, String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding)
          Copy a file from the remote file system to the local system.
 IHostFile getFile(IProgressMonitor monitor, String remoteParent, String name)
           
 IHostFile[] getFiles(IProgressMonitor monitor, String remoteParent, String fileFilter)
           
 IHostFile[] getFilesAndFolders(IProgressMonitor monitor, String remoteParent, String fileFilter)
           
 IHostFile[] getFolders(IProgressMonitor monitor, String remoteParent, String fileFilter)
           
 IHostFile[] getRoots(IProgressMonitor monitor)
           
 IHostFile getUserHome()
           
 boolean isCaseSensitive()
          Indicates whether the file system is case sensitive
 boolean move(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
          Move the file or folder specified
 boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName)
          Renames a file or folder on the host
 boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName, IHostFile oldFile)
          Renames a file or folder on the host
 boolean upload(IProgressMonitor monitor, File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding)
          Copy a file to the remote file system.
 boolean upload(IProgressMonitor monitor, InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding)
          Copy a file to the remote file system.
 
Methods inherited from interface org.eclipse.rse.services.IService
getDescription, getMessage, getName, initService, uninitService
 

Method Detail

upload

public boolean upload(IProgressMonitor monitor,
                      InputStream stream,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String hostEncoding)
               throws SystemMessageException
Copy a file to the remote file system. The remote target is denoted by a string representing the parent and a string representing the file.

Parameters:
monitor - the monitor for this potentially long running operation
stream - input stream to transfer
remoteParent - - a string designating the parent folder of the target for this file.
remoteFile - - a string designating the name of the file to be written on the remote system.
isBinary - - indicates whether the file is text or binary
hostEncoding - - the tgt encoding of the file (if text)
Returns:
true if the file was uploaded
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

upload

public boolean upload(IProgressMonitor monitor,
                      File localFile,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String srcEncoding,
                      String hostEncoding)
               throws SystemMessageException
Copy a file to the remote file system. The remote target is denoted by a string representing the parent and a string representing the file.

Parameters:
monitor - the monitor for this potentially long running operation
localFile - - a real file in the local file system.
remoteParent - - a string designating the parent folder of the target for this file.
remoteFile - - a string designating the name of the file to be written on the remote system.
isBinary - - indicates whether the file is text or binary
srcEncoding - - the src encoding of the file (if text)
hostEncoding - - the tgt encoding of the file (if text)
Returns:
true if the file was uploaded
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

download

public boolean download(IProgressMonitor monitor,
                        String remoteParent,
                        String remoteFile,
                        File localFile,
                        boolean isBinary,
                        String hostEncoding)
                 throws SystemMessageException
Copy a file from the remote file system to the local system.

Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - a String designating the remote parent.
remoteFile - - a String designating the remote file residing in the parent.
localFile - - The file that is to be written. If the file exists it is overwritten.
isBinary - - indicates whether the file is text on binary
hostEncoding - - the encoding on the host (if text)
Returns:
true if the file was copied from the remote system.
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getFile

public IHostFile getFile(IProgressMonitor monitor,
                         String remoteParent,
                         String name)
                  throws SystemMessageException
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent -
name -
Returns:
the host file given the parent path and file name
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getFilesAndFolders

public IHostFile[] getFilesAndFolders(IProgressMonitor monitor,
                                      String remoteParent,
                                      String fileFilter)
                               throws SystemMessageException
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - the name of the parent directory on the remote file system from which to retrieve the child list.
fileFilter - - a string that can be used to filter the children. Only those files matching the filter make it into the list. The interface does not dictate where the filtering occurs.
Returns:
the list of host files.
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getFiles

public IHostFile[] getFiles(IProgressMonitor monitor,
                            String remoteParent,
                            String fileFilter)
                     throws SystemMessageException
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - the name of the parent directory on the remote file system from which to retrieve the child list.
fileFilter - - a string that can be used to filter the children. Only those files matching the filter make it into the list. The interface does not dictate where the filtering occurs.
Returns:
the list of host files.
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getFolders

public IHostFile[] getFolders(IProgressMonitor monitor,
                              String remoteParent,
                              String fileFilter)
                       throws SystemMessageException
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - the name of the parent directory on the remote file system from which to retrieve the child list.
fileFilter - - a string that can be used to filter the children. Only those files matching the filter make it into the list. The interface does not dictate where the filtering occurs.
Returns:
the list of host files.
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getRoots

public IHostFile[] getRoots(IProgressMonitor monitor)
                     throws SystemMessageException
Parameters:
monitor - the monitor for this potentially long running operation Return the list of roots for this system
Returns:
the list of host files.
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getUserHome

public IHostFile getUserHome()
Returns:
the String containing the name of the user's home directory on this connection that would be contained in implementations of this service.

createFile

public IHostFile createFile(IProgressMonitor monitor,
                            String remoteParent,
                            String fileName)
                     throws SystemMessageException
Create a file on the host

Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - the parent directory
fileName - the name of the new file
Returns:
the newly created file
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

createFolder

public IHostFile createFolder(IProgressMonitor monitor,
                              String remoteParent,
                              String folderName)
                       throws SystemMessageException
Create a folder on the host

Parameters:
monitor - the progress monitor
remoteParent - the parent directory
folderName - the name of the new folder
Returns:
the newly created folder
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

delete

public boolean delete(IProgressMonitor monitor,
                      String remoteParent,
                      String fileName)
               throws SystemMessageException
Deletes a file or folder on the host

Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to delete
fileName - the name of the file or folder to delete
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

deleteBatch

public boolean deleteBatch(IProgressMonitor monitor,
                           String[] remoteParents,
                           String[] fileNames)
                    throws SystemMessageException
Deletes a set of files or folders on the host. Should throw an exception if some files and folders were deleted and others were not due to an exception during the operation. Without an exception thrown in such cases, views may not be refreshed correctly to account for deleted resources.

Parameters:
monitor - the progress monitor
remoteParents - the array of folders containing the files to delete
fileNames - the names of the files or folders to delete
Returns:
true iff all deletes are successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

rename

public boolean rename(IProgressMonitor monitor,
                      String remoteParent,
                      String oldName,
                      String newName)
               throws SystemMessageException
Renames a file or folder on the host

Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to rename
oldName - the old name of the file or folder to rename
newName - the new name for the file
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

rename

public boolean rename(IProgressMonitor monitor,
                      String remoteParent,
                      String oldName,
                      String newName,
                      IHostFile oldFile)
               throws SystemMessageException
Renames a file or folder on the host

Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to rename
oldName - the old name of the file or folder to rename
newName - the new name for the file
oldFile - the file to update with the change
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

move

public boolean move(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Move the file or folder specified

Parameters:
monitor - the progress monitor
srcParent - the folder containing the file or folder to move
srcName - the new of the file or folder to move
tgtParent - the destination folder for the move
tgtName - the name of the moved file or folder
Returns:
true if the file was moved
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

copy

public boolean copy(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Copy the file or folder to the specified destination

Parameters:
monitor - the progress monitor
srcParent - the folder containing the file or folder to copy
srcName - the new of the file or folder to copy
tgtParent - the destination folder for the copy
tgtName - the name of the copied file or folder
Returns:
true if the file was copied successfully
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

copyBatch

public boolean copyBatch(IProgressMonitor monitor,
                         String[] srcParents,
                         String[] srcNames,
                         String tgtParent)
                  throws SystemMessageException
Copy a set of files or folders to the specified destination

Parameters:
monitor - the progress monitor
srcParents - the folders containing each file or folder to copy
srcNames - the names of the files or folders to copy
tgtParent - the destination folder for the copy
Returns:
true if all files were copied
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

isCaseSensitive

public boolean isCaseSensitive()
Indicates whether the file system is case sensitive

Returns:
true if the file system has case sensitive file names

RSE
Release 1.0

Copyright (c) IBM Corporation and others 2000, 2006. All Rights Reserved.