public interface FileSystemExceptionFactory
FileSystemException
s based on replies from an FTP server.
It's not always possible to distinguish different types of errors. For instance, a 550 error code (file unavailable) could indicate that a file
does not exist (which should trigger a NoSuchFileException
), or that a file is inaccessible (which should trigger a
AccessDeniedException
), or possibly another reason.
This interface allows users to provide their own mapping, based on both the reply code and the reply string from an FTP reply.
Ideally implementations return exceptions that implement FTPResponse
, such as FTPNoSuchFileException
,
FTPAccessDeniedException
or FTPFileSystemException
. This way, the original FTP reply code and message will be reserved.
Modifier and Type | Method and Description |
---|---|
FileSystemException |
createChangeWorkingDirectoryException(String directory,
int replyCode,
String replyString)
Creates a
FileSystemException that indicates a directory cannot be used as the current working directory. |
FileSystemException |
createCopyException(String file,
String other,
int replyCode,
String replyString)
Creates a
FileSystemException that indicates a file or directory cannot be copied. |
FileSystemException |
createCreateDirectoryException(String directory,
int replyCode,
String replyString)
Creates a
FileSystemException that indicates a directory cannot be created. |
FileSystemException |
createDeleteException(String file,
int replyCode,
String replyString,
boolean isDirectory)
Creates a
FileSystemException that indicates a file or directory cannot be deleted. |
FileSystemException |
createGetFileException(String file,
int replyCode,
String replyString)
Creates a
FileSystemException that indicates a file or directory cannot be retrieved. |
FileSystemException |
createMoveException(String file,
String other,
int replyCode,
String replyString)
Creates a
FileSystemException that indicates a file or directory cannot be moved. |
FileSystemException |
createNewInputStreamException(String file,
int replyCode,
String replyString)
Creates a
FileSystemException that indicates a file cannot be opened for reading. |
FileSystemException |
createNewOutputStreamException(String file,
int replyCode,
String replyString,
Collection<? extends OpenOption> options)
Creates a
FileSystemException that indicates a file cannot be opened for writing. |
FileSystemException createGetFileException(String file, int replyCode, String replyString)
FileSystemException
that indicates a file or directory cannot be retrieved.
Note that the LIST command is used to retrieve a file or directory. This will often return with a 226 code even if a file or directory cannot be retrieved. This does not mean that the LIST call was actually successful.
file
- A string identifying the file or directory.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.FileSystemException
.FileSystemException createChangeWorkingDirectoryException(String directory, int replyCode, String replyString)
FileSystemException
that indicates a directory cannot be used as the current working directory.directory
- A string identifying the directory.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.FileSystemException
.FileSystemException createCreateDirectoryException(String directory, int replyCode, String replyString)
FileSystemException
that indicates a directory cannot be created.directory
- A string identifying the directory.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.FileSystemException
.FileSystemException createDeleteException(String file, int replyCode, String replyString, boolean isDirectory)
FileSystemException
that indicates a file or directory cannot be deleted.file
- A string identifying the file or directory.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.isDirectory
- true
if a directory cannot be deleted, or false
if a file cannot be deleted.FileSystemException
.FileSystemException createNewInputStreamException(String file, int replyCode, String replyString)
FileSystemException
that indicates a file cannot be opened for reading.file
- A string identifying the file.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.FileSystemException
.FileSystemException createNewOutputStreamException(String file, int replyCode, String replyString, Collection<? extends OpenOption> options)
FileSystemException
that indicates a file cannot be opened for writing.file
- A string identifying the file.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.options
- The open options used to open the file.FileSystemException
.FileSystemException createCopyException(String file, String other, int replyCode, String replyString)
FileSystemException
that indicates a file or directory cannot be copied.file
- A string identifying the file or directory to be copied.other
- A string identifying the file or directory to be copied to.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.FileSystemException
.FileSystemException createMoveException(String file, String other, int replyCode, String replyString)
FileSystemException
that indicates a file or directory cannot be moved.file
- A string identifying the file or directory to be moved.other
- A string identifying the file or directory to be moved to.replyCode
- The integer value of the reply code of the last FTP reply that triggered this method call.replyString
- The entire text from the last FTP response that triggered this method call.FileSystemException
.Copyright © 2016–2024. All rights reserved.