public abstract class BaseFileSystemOperations extends Object
| Constructor and Description |
|---|
BaseFileSystemOperations() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doCopy(FileConnectorConfig config,
FileSystem fileSystem,
String sourcePath,
String targetPath,
boolean createParentDirectories,
boolean overwrite,
String renameTo)
Copies the file at the
sourcePath into the targetPath. |
protected void |
doCreateDirectory(FileSystem fileSystem,
String directoryPath)
Creates a new directory on
directoryPath |
protected void |
doDelete(FileSystem fileSystem,
String path)
Deletes the file pointed by
path, provided that it's not locked |
protected List<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FileAttributes>> |
doList(FileConnectorConfig config,
FileSystem fileSystem,
String directoryPath,
boolean recursive,
org.mule.runtime.api.metadata.MediaType mediaType,
FileMatcher matchWith)
Lists all the files in the
directoryPath which match the given matcher. |
protected void |
doMove(FileConnectorConfig config,
FileSystem fileSystem,
String sourcePath,
String targetPath,
boolean createParentDirectories,
boolean overwrite,
String renameTo)
Moves the file at the
sourcePath into the targetPath. |
protected org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FileAttributes> |
doRead(FileConnectorConfig config,
FileSystem fileSystem,
String path,
org.mule.runtime.api.metadata.MediaType mediaType,
boolean lock)
Obtains the content and metadata of a file at a given path.
|
protected void |
doRename(FileSystem fileSystem,
String path,
String to,
boolean overwrite)
Renames the file pointed by
path to the name provided on the to parameter |
protected void |
doWrite(FileConnectorConfig config,
FileSystem fileSystem,
String path,
InputStream content,
String encoding,
boolean createParentDirectories,
boolean lock,
FileWriteMode mode)
Writes the
content into the file pointed by path. |
protected List<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FileAttributes>> doList(FileConnectorConfig config, FileSystem fileSystem, String directoryPath, boolean recursive, org.mule.runtime.api.metadata.MediaType mediaType, FileMatcher matchWith)
directoryPath which match the given matcher.
If the listing encounters a directory, the output list will include its contents depending on the value of the
recursive parameter. If recursive is enabled, then all the files in that directory will be
listed immediately after their parent directory.
If recursive is set to true but a found directory is rejected by the matcher, then there won't be any
recursion into such directory.
config - the config that is parameterizing this operationdirectoryPath - the path to the directory to be listedrecursive - whether to include the contents of sub-directories. Defaults to false.mediaType - The MediaType of the message that on which this operations is being executedmatchWith - a matcher used to filter the output listList of Result objects each one containing each file's content in the payload and metadata in the attributesIllegalArgumentException - if directoryPath points to a file which doesn't exists or is not a directoryprotected org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FileAttributes> doRead(@Config FileConnectorConfig config, @Connection FileSystem fileSystem, @DisplayName(value="File Path") String path, org.mule.runtime.api.metadata.MediaType mediaType, @Optional(defaultValue="false") @Placement(tab="Advanced") boolean lock)
Message which payload is a
InputStream with the file's content, and the metadata is represent as a FileAttributes object that's placed
as the message attributes.
If the lock parameter is set to true, then a file system level lock will be placed on the file until the
input stream this operation returns is closed or fully consumed. Because the lock is actually provided by the host file
system, its behavior might change depending on the mounted drive and the operation system on which mule is running. Take that
into consideration before blindly relying on this lock.
This method also makes a best effort to determine the mime type of the file being read. A MimetypesFileTypeMap will
be used to make an educated guess on the file's mime type. The user also has the chance to force the output encoding and
mimeType through the outputEncoding and outputMimeType optional parameters.
config - the config that is parameterizing this operationfileSystem - a reference to the host FileSystempath - the path to the file to be readmediaType - The MediaType of the message that on which this operations is being executedlock - whether or not to lock the file. Defaults to false.FileAttributes instanceIllegalArgumentException - if the file at the given path doesn't existsprotected void doWrite(FileConnectorConfig config, FileSystem fileSystem, String path, InputStream content, String encoding, boolean createParentDirectories, boolean lock, FileWriteMode mode)
content into the file pointed by path.
If the directory on which the file is attempting to be written doesn't exist, then the operation will either throw
IllegalArgumentException or create such folder depending on the value of the createParentDirectory.
If the file itself already exists, then the behavior depends on the supplied mode.
This operation also supports locking support depending on the value of the lock argument, but following the same
rules and considerations as described in the read operation.
config - the FileConnectorConfig on which the operation is being executedfileSystem - a reference to the host FileSystempath - the path of the file to be writtencontent - the content to be written into the file. Defaults to the current Message payloadencoding - when content is a String, this attribute specifies the encoding to be used when writing. If
not set, then it defaults to FileConnectorConfig.getDefaultWriteEncoding()createParentDirectories - whether or not to attempt creating any parent directories which don't exists.lock - whether or not to lock the file. Defaults to falsemode - a FileWriteMode. Defaults to OVERWRITEIllegalArgumentException - if an illegal combination of arguments is suppliedprotected void doCopy(FileConnectorConfig config, FileSystem fileSystem, String sourcePath, String targetPath, boolean createParentDirectories, boolean overwrite, String renameTo)
sourcePath into the targetPath.
If targetPath doesn't exists, and neither does its parent, then an attempt will be made to create depending on the
value of the createParentFolder argument. If such argument is , then an IllegalArgumentException will
be thrown.
If the target file already exists, then it will be overwritten if the overwrite argument is true. Otherwise,
IllegalArgumentException will be thrown.
As for the sourcePath, it can either be a file or a directory. If it points to a directory, then it will be copied
recursively.
config - the config that is parameterizing this operationfileSystem - a reference to the host FileSystemsourcePath - the path to the file to be copiedtargetPath - the target directory where the file is going to be copiedcreateParentDirectories - whether or not to attempt creating any parent directories which don't exists.overwrite - whether or not overwrite the file if the target destination already exists.renameTo - the new file name, null if the file doesn't need to be renamedIllegalArgumentException - if an illegal combination of arguments is suppliedprotected void doMove(FileConnectorConfig config, FileSystem fileSystem, String sourcePath, String targetPath, boolean createParentDirectories, boolean overwrite, String renameTo)
sourcePath into the targetPath.
If targetPath doesn't exists, and neither does its parent, then an attempt will be made to create depending on the
value of the createParentFolder argument. If such argument is false, then an IllegalArgumentException
will be thrown.
If the target file already exists, then it will be overwritten if the overwrite argument is true. Otherwise,
IllegalArgumentException will be thrown.
As for the sourcePath, it can either be a file or a directory. If it points to a directory, then it will be moved
recursively.
config - the config that is parameterizing this operationfileSystem - a reference to the host FileSystemsourcePath - the path to the file to be copiedtargetPath - the target directorycreateParentDirectories - whether or not to attempt creating any parent directories which don't exists.overwrite - whether or not overwrite the file if the target destination already exists.renameTo - the new file name, null if the file doesn't need to be renamedIllegalArgumentException - if an illegal combination of arguments is suppliedprotected void doDelete(FileSystem fileSystem, @Optional String path)
path, provided that it's not lockedfileSystem - a reference to the host FileSystempath - the path to the file to be deletedIllegalArgumentException - if filePath doesn't exists or is lockedprotected void doRename(@Connection
FileSystem fileSystem,
@Optional
String path,
@DisplayName(value="New Name")
String to,
@Optional(defaultValue="false")
boolean overwrite)
path to the name provided on the to parameter
to argument should not contain any path separator. IllegalArgumentException will be thrown if this
precondition is not honored.
fileSystem - a reference to the host FileSystempath - the path to the file to be renamedto - the file's new nameoverwrite - whether or not overwrite the file if the target destination already exists.protected void doCreateDirectory(@Connection
FileSystem fileSystem,
String directoryPath)
directoryPathfileSystem - a reference to the host FileSystemdirectoryPath - the new directory's nameCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.