F - the generic type of the FileSystem on which the operation is performedpublic abstract class FileCommand<F extends FileSystem> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected F |
fileSystem |
| Modifier | Constructor and Description |
|---|---|
protected |
FileCommand(F fileSystem)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
FileAlreadyExistsException |
alreadyExistsException(Path path)
Returns a
IllegalPathException explaining that an operation is trying to write to the given path but it
already exists and no overwrite instruction was provided. |
protected void |
assureParentFolderExists(Path path,
boolean createParentFolder) |
protected IllegalPathException |
cannotListFileException(Path path)
Returns a
IllegalPathException explaining that a
FileSystem#list(FileConnectorConfig, String, boolean, Message, Predicate) operation was attempted on a path
pointing to a file. |
protected IllegalPathException |
cannotReadDirectoryException(Path path)
Returns an
IllegalPathException explaining that a
FileSystem#read(FileConnectorConfig, Message, String, boolean) operation was attempted on a path pointing to
a directory |
protected abstract void |
doMkDirs(Path directoryPath) |
RuntimeException |
exception(String message)
Returns a properly formatted
MuleRuntimeException for the given message and cause |
RuntimeException |
exception(String message,
Exception cause)
Returns a properly formatted
MuleRuntimeException for the given message and cause |
protected abstract boolean |
exists(Path path)
Returns true if the given
path exists |
protected abstract Path |
getBasePath(FileSystem fileSystem)
Returns a
Path to which all non absolute paths are relative to |
protected boolean |
isVirtualDirectory(String fileName) |
protected void |
mkdirs(Path directoryPath)
Creates the directory pointed by
directoryPath also creating any missing parent directories |
protected IllegalPathException |
pathNotFoundException(Path path)
Returns a
IllegalPathException explaining that a
FileSystem#list(FileConnectorConfig, String, boolean, Message, Predicate) operation was attempted on a path
pointing to a file. |
protected Path |
resolveExistingPath(String filePath)
Similar to
resolvePath(String) only that it throws a IllegalArgumentException if the
given path doesn't exists. |
protected Path |
resolvePath(String filePath)
Returns an absolute
Path to the given filePath |
protected final F extends FileSystem fileSystem
protected FileCommand(F fileSystem)
fileSystem - the FileSystem on which the operation is performedprotected abstract boolean exists(Path path)
path existspath - the Path to testpath existsprotected void assureParentFolderExists(Path path, boolean createParentFolder)
protected final void mkdirs(Path directoryPath)
directoryPath also creating any missing parent directoriesdirectoryPath - the Path to the directory you want to createprotected abstract void doMkDirs(Path directoryPath)
protected Path resolvePath(String filePath)
Path to the given filePathfilePath - the path to a file or directoryPathprotected abstract Path getBasePath(FileSystem fileSystem)
Path to which all non absolute paths are relative tofileSystem - the file system that we're connecting tonull Pathprotected Path resolveExistingPath(String filePath)
resolvePath(String) only that it throws a IllegalArgumentException if the
given path doesn't exists.
The existence of the obtained path is verified by delegating into exists(Path)
filePath - the path to a file or directoryPathpublic RuntimeException exception(String message)
MuleRuntimeException for the given message and causemessage - the exception's messageRuntimeExceptionpublic RuntimeException exception(String message, Exception cause)
MuleRuntimeException for the given message and causemessage - the exception's messagecause - the exception's causeRuntimeExceptionprotected boolean isVirtualDirectory(String fileName)
fileName - the name of a filetrue if fileName equals to "." or ".."protected IllegalPathException cannotReadDirectoryException(Path path)
IllegalPathException explaining that a
FileSystem#read(FileConnectorConfig, Message, String, boolean) operation was attempted on a path pointing to
a directorypath - the Path on which a read was attemptedIllegalPathExceptionprotected IllegalPathException cannotListFileException(Path path)
IllegalPathException explaining that a
FileSystem#list(FileConnectorConfig, String, boolean, Message, Predicate) operation was attempted on a path
pointing to a file.path - the Path on which a list was attemptedIllegalPathExceptionprotected IllegalPathException pathNotFoundException(Path path)
IllegalPathException explaining that a
FileSystem#list(FileConnectorConfig, String, boolean, Message, Predicate) operation was attempted on a path
pointing to a file.path - the Path on which a list was attemptedRuntimeExceptionpublic FileAlreadyExistsException alreadyExistsException(Path path)
IllegalPathException explaining that an operation is trying to write to the given path but it
already exists and no overwrite instruction was provided.path - the Path that the operation tried to modifyIllegalPathExceptionCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.