RSE
Release 1.0

org.eclipse.rse.services.files.ftp
Class FTPService

java.lang.Object
  extended byorg.eclipse.rse.services.files.AbstractFileService
      extended byorg.eclipse.rse.services.files.ftp.FTPService
All Implemented Interfaces:
IFileService, IFTPService, IService

public class FTPService
extends AbstractFileService
implements IFileService, IFTPService


Field Summary
 
Fields inherited from class org.eclipse.rse.services.files.AbstractFileService
FILE_TYPE_FILES, FILE_TYPE_FILES_AND_FOLDERS, FILE_TYPE_FOLDERS
 
Constructor Summary
FTPService()
           
 
Method Summary
 void connect()
           
 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
 void disconnect()
           
 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.
 String getDescription()
           
 IHostFile getFile(IProgressMonitor monitor, String remoteParent, String fileName)
           
 FTPClient getFTPClient()
          Returns the commons.net FTPClient for this session.
 String getName()
           
 IHostFile[] getRoots(IProgressMonitor monitor)
           
 String getSeparator()
           
 IHostFile getUserHome()
           
 void initService(IProgressMonitor monitor)
           
protected  IHostFile[] internalFetch(IProgressMonitor monitor, String parentPath, String fileFilter, int fileType)
           
 boolean isCaseSensitive()
          Indicates whether the file system is case sensitive
 boolean isConnected()
           
 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
 void setHostName(String hostname)
           
 void setLoggingStream(OutputStream ftpLoggingOutputStream)
           
 void setPassword(String password)
           
 void setPortNumber(int portNumber)
           
 void setUserId(String userId)
           
 void uninitService(IProgressMonitor monitor)
           
 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 class org.eclipse.rse.services.files.AbstractFileService
deleteBatch, getFiles, getFilesAndFolders, getFolders, getMessage, isRightType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.rse.services.files.IFileService
deleteBatch, getFiles, getFilesAndFolders, getFolders
 
Methods inherited from interface org.eclipse.rse.services.IService
getMessage
 

Constructor Detail

FTPService

public FTPService()
Method Detail

getName

public String getName()
Specified by:
getName in interface IService

getDescription

public String getDescription()
Specified by:
getDescription in interface IService

setHostName

public void setHostName(String hostname)

setPortNumber

public void setPortNumber(int portNumber)

setUserId

public void setUserId(String userId)

setPassword

public void setPassword(String password)

setLoggingStream

public void setLoggingStream(OutputStream ftpLoggingOutputStream)

connect

public void connect()
             throws Exception
Throws:
Exception

disconnect

public void disconnect()

getFTPClient

public FTPClient getFTPClient()
Returns the commons.net FTPClient for this session. As a side effect, it also checks the connection by sending a NOOP to the remote side, and initiates a connect in case the NOOP throws an exception.

Returns:
The commons.net FTPClient.

getFile

public IHostFile getFile(IProgressMonitor monitor,
                         String remoteParent,
                         String fileName)
                  throws SystemMessageException
Specified by:
getFile in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent -
fileName -
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.

isConnected

public boolean isConnected()

internalFetch

protected IHostFile[] internalFetch(IProgressMonitor monitor,
                                    String parentPath,
                                    String fileFilter,
                                    int fileType)
                             throws SystemMessageException
Specified by:
internalFetch in class AbstractFileService
Throws:
SystemMessageException

getSeparator

public String getSeparator()

upload

public boolean upload(IProgressMonitor monitor,
                      File localFile,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String srcEncoding,
                      String hostEncoding)
               throws SystemMessageException
Description copied from interface: IFileService
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.

Specified by:
upload in interface IFileService
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.

upload

public boolean upload(IProgressMonitor monitor,
                      InputStream stream,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String hostEncoding)
               throws SystemMessageException
Description copied from interface: IFileService
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.

Specified by:
upload in interface IFileService
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.

download

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

Specified by:
download in interface IFileService
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.

getUserHome

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

getRoots

public IHostFile[] getRoots(IProgressMonitor monitor)
Specified by:
getRoots in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation Return the list of roots for this system
Returns:
the list of host files.

delete

public boolean delete(IProgressMonitor monitor,
                      String remoteParent,
                      String fileName)
               throws SystemMessageException
Description copied from interface: IFileService
Deletes a file or folder on the host

Specified by:
delete in interface IFileService
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.

rename

public boolean rename(IProgressMonitor monitor,
                      String remoteParent,
                      String oldName,
                      String newName)
               throws SystemMessageException
Description copied from interface: IFileService
Renames a file or folder on the host

Specified by:
rename in interface IFileService
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)
Description copied from interface: IFileService
Renames a file or folder on the host

Specified by:
rename in interface IFileService
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

move

public boolean move(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Description copied from interface: IFileService
Move the file or folder specified

Specified by:
move in interface IFileService
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.

createFolder

public IHostFile createFolder(IProgressMonitor monitor,
                              String remoteParent,
                              String folderName)
                       throws SystemMessageException
Description copied from interface: IFileService
Create a folder on the host

Specified by:
createFolder in interface IFileService
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.

createFile

public IHostFile createFile(IProgressMonitor monitor,
                            String remoteParent,
                            String fileName)
                     throws SystemMessageException
Description copied from interface: IFileService
Create a file on the host

Specified by:
createFile in interface IFileService
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.

copy

public boolean copy(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Description copied from interface: IFileService
Copy the file or folder to the specified destination

Specified by:
copy in interface IFileService
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
Description copied from interface: IFileService
Copy a set of files or folders to the specified destination

Specified by:
copyBatch in interface IFileService
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.

initService

public void initService(IProgressMonitor monitor)
Specified by:
initService in interface IService

uninitService

public void uninitService(IProgressMonitor monitor)
Specified by:
uninitService in interface IService

isCaseSensitive

public boolean isCaseSensitive()
Description copied from interface: IFileService
Indicates whether the file system is case sensitive

Specified by:
isCaseSensitive in interface IFileService
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.