Class DefaultFileSystemExceptionFactory
- java.lang.Object
-
- com.github.robtimus.filesystems.sftp.DefaultFileSystemExceptionFactory
-
- All Implemented Interfaces:
FileSystemExceptionFactory
public class DefaultFileSystemExceptionFactory extends Object implements FileSystemExceptionFactory
A defaultFileSystemExceptionFactorythat will return aNoSuchFileExceptionif theidof theSftpExceptionisChannelSftp.SSH_FX_NO_SUCH_FILE, anAccessDeniedExceptionif it'sChannelSftp.SSH_FX_PERMISSION_DENIED, or aFileSystemExceptionotherwise, unless specified otherwise.- Author:
- Rob Spoor
-
-
Constructor Summary
Constructors Constructor Description DefaultFileSystemExceptionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileSystemExceptioncreateChangeWorkingDirectoryException(String directory, SftpException exception)Creates aFileSystemExceptionthat indicates a directory cannot be used as the current working directory.FileSystemExceptioncreateCopyException(String file, String other, SftpException exception)Creates aFileSystemExceptionthat indicates a file or directory cannot be copied.FileSystemExceptioncreateCreateDirectoryException(String directory, SftpException exception)Creates aFileSystemExceptionthat indicates a directory cannot be created.FileSystemExceptioncreateDeleteException(String file, SftpException exception, boolean isDirectory)Creates aFileSystemExceptionthat indicates a file or directory cannot be deleted.FileSystemExceptioncreateGetFileException(String file, SftpException exception)Creates aFileSystemExceptionthat indicates a file or directory cannot be retrieved.FileSystemExceptioncreateListFilesException(String directory, SftpException exception)Creates aFileSystemExceptionthat indicates the contents of a directory cannot be retrieved.FileSystemExceptioncreateMoveException(String file, String other, SftpException exception)Creates aFileSystemExceptionthat indicates a file or directory cannot be moved.FileSystemExceptioncreateNewInputStreamException(String file, SftpException exception)Creates aFileSystemExceptionthat indicates a file cannot be opened for reading.FileSystemExceptioncreateNewOutputStreamException(String file, SftpException exception, Collection<? extends OpenOption> options)Creates aFileSystemExceptionthat indicates a file cannot be opened for writing.FileSystemExceptioncreateReadLinkException(String link, SftpException exception)Creates aFileSystemExceptionthat indicates a symbolic link cannot be read.FileSystemExceptioncreateSetGroupException(String file, SftpException exception)Creates aFileSystemExceptionthat indicates the group of a file or directory cannot be set.FileSystemExceptioncreateSetModificationTimeException(String file, SftpException exception)Creates aFileSystemExceptionthat indicates the modification time of a file or directory cannot be set.FileSystemExceptioncreateSetOwnerException(String file, SftpException exception)Creates aFileSystemExceptionthat indicates the owner of a file or directory cannot be set.FileSystemExceptioncreateSetPermissionsException(String file, SftpException exception)Creates aFileSystemExceptionthat indicates the permissions of a file or directory cannot be set.
-
-
-
Method Detail
-
createGetFileException
public FileSystemException createGetFileException(String file, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a file or directory cannot be retrieved.- Specified by:
createGetFileExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createReadLinkException
public FileSystemException createReadLinkException(String link, SftpException exception)
Creates aFileSystemExceptionthat indicates a symbolic link cannot be read.If the
idof theSftpExceptionis notChannelSftp.SSH_FX_NO_SUCH_FILEorChannelSftp.SSH_FX_PERMISSION_DENIED, this default implementation does not return aFileSystemException, but aNotLinkExceptioninstead.- Specified by:
createReadLinkExceptionin interfaceFileSystemExceptionFactory- Parameters:
link- A string identifying the symbolic link.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createListFilesException
public FileSystemException createListFilesException(String directory, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates the contents of a directory cannot be retrieved.- Specified by:
createListFilesExceptionin interfaceFileSystemExceptionFactory- Parameters:
directory- A string identifying the directory.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createChangeWorkingDirectoryException
public FileSystemException createChangeWorkingDirectoryException(String directory, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a directory cannot be used as the current working directory.- Specified by:
createChangeWorkingDirectoryExceptionin interfaceFileSystemExceptionFactory- Parameters:
directory- A string identifying the directory.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createCreateDirectoryException
public FileSystemException createCreateDirectoryException(String directory, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a directory cannot be created.- Specified by:
createCreateDirectoryExceptionin interfaceFileSystemExceptionFactory- Parameters:
directory- A string identifying the directory.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createDeleteException
public FileSystemException createDeleteException(String file, SftpException exception, boolean isDirectory)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a file or directory cannot be deleted.- Specified by:
createDeleteExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory.exception- TheSftpExceptionthat was thrown.isDirectory-trueif a directory cannot be deleted, orfalseif a file cannot be deleted.- Returns:
- The created
FileSystemException.
-
createNewInputStreamException
public FileSystemException createNewInputStreamException(String file, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a file cannot be opened for reading.- Specified by:
createNewInputStreamExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createNewOutputStreamException
public FileSystemException createNewOutputStreamException(String file, SftpException exception, Collection<? extends OpenOption> options)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a file cannot be opened for writing.- Specified by:
createNewOutputStreamExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file.exception- TheSftpExceptionthat was thrown.options- The open options used to open the file.- Returns:
- The created
FileSystemException.
-
createCopyException
public FileSystemException createCopyException(String file, String other, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a file or directory cannot be copied.- Specified by:
createCopyExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory to be copied.other- A string identifying the file or directory to be copied to.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createMoveException
public FileSystemException createMoveException(String file, String other, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates a file or directory cannot be moved.- Specified by:
createMoveExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory to be moved.other- A string identifying the file or directory to be moved to.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createSetOwnerException
public FileSystemException createSetOwnerException(String file, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates the owner of a file or directory cannot be set.- Specified by:
createSetOwnerExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory to set the owner of.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createSetGroupException
public FileSystemException createSetGroupException(String file, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates the group of a file or directory cannot be set.- Specified by:
createSetGroupExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory to set the group of.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createSetPermissionsException
public FileSystemException createSetPermissionsException(String file, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates the permissions of a file or directory cannot be set.- Specified by:
createSetPermissionsExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory to set the permissions of.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
createSetModificationTimeException
public FileSystemException createSetModificationTimeException(String file, SftpException exception)
Description copied from interface:FileSystemExceptionFactoryCreates aFileSystemExceptionthat indicates the modification time of a file or directory cannot be set.- Specified by:
createSetModificationTimeExceptionin interfaceFileSystemExceptionFactory- Parameters:
file- A string identifying the file or directory to set the modification time of.exception- TheSftpExceptionthat was thrown.- Returns:
- The created
FileSystemException.
-
-