Package org.frankframework.filesystem
Class LocalFileSystem
java.lang.Object
org.frankframework.filesystem.AbstractFileSystem<Path>
org.frankframework.filesystem.LocalFileSystem
- All Implemented Interfaces:
AutoCloseable
,HasPhysicalDestination
,IBasicFileSystem<Path>
,ISupportsCustomFileAttributes<Path>
,IWritableFileSystem<Path>
public class LocalFileSystem
extends AbstractFileSystem<Path>
implements IWritableFileSystem<Path>, ISupportsCustomFileAttributes<Path>
FileSystem
representation of the local filesystem.- Author:
- Gerrit van Brakel
-
Field Summary
Fields inherited from class org.frankframework.filesystem.AbstractFileSystem
log
Fields inherited from interface org.frankframework.filesystem.ISupportsCustomFileAttributes
FILE_ATTRIBUTE_PARAM_PREFIX
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendFile
(Path f) void
Copies the file to another folder.copyFile
(Path f, String destinationFolder, boolean createFolder, Map<String, String> customFileAttributes) Copies the file to another folder, adding the given custom file attributes to the file in the destination folder.createFile
(Path f) void
createFile
(Path file, InputStream contents, Map<String, String> customFileAttributes) Creates a file with the given custom file attributes.void
createFolder
(String folder) void
deleteFile
(Path f) boolean
boolean
folderExists
(String folder) getCustomFileAttribute
(Path file, String name) Gets the value of the given custom file attribute on the given file.long
getFileSize
(Path f) Get a string representation of an identification of a file.getRoot()
boolean
list
(String folder, TypeFilter filter) Lists files, directories or both, from a 'folder' or in the 'root' of the filesystem (when folder is null).Moves the file to another folder.moveFile
(Path f, String destinationFolder, boolean createFolder, Map<String, String> customFileAttributes) Moves the file to another folder, adding the given custom file attributes to the file in the destination folder.void
open()
void
removeFolder
(String folder, boolean removeNonEmptyFolder) renameFile
(Path source, Path destination) Renames the file to a new name, possibly in another folder.Renames the file to a new name, possibly in another folder.void
setCreateRootFolder
(boolean createRootFolder) Whether the LocalFileSystem tries to create the root folder if it doesn't exist yet.void
Path to the folder that serves as the root of this virtual filesystem.Get a file 'F' representation of an identification of a file.Creates a reference to a file.Methods inherited from class org.frankframework.filesystem.AbstractFileSystem
close, getMaxNumberOfMessagesToList, getNumberOfFilesInFolder, isOpen, setMaxNumberOfMessagesToList
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.frankframework.core.HasPhysicalDestination
getDomain
Methods inherited from interface org.frankframework.filesystem.IBasicFileSystem
close, getCanonicalNameOrErrorMessage, getNumberOfFilesInFolder, isOpen
Methods inherited from interface org.frankframework.filesystem.ISupportsCustomFileAttributes
getCustomFileAttributes, hasCustomFileAttributes
Methods inherited from interface org.frankframework.filesystem.IWritableFileSystem
appendFile, createFile
-
Constructor Details
-
LocalFileSystem
public LocalFileSystem()
-
-
Method Details
-
configure
- Specified by:
configure
in interfaceIBasicFileSystem<Path>
- Throws:
ConfigurationException
-
open
- Specified by:
open
in interfaceIBasicFileSystem<Path>
- Overrides:
open
in classAbstractFileSystem<Path>
- Throws:
FileSystemException
-
toFile
Description copied from interface:IBasicFileSystem
Get a file 'F' representation of an identification of a file. Must pair up with the implementation ofIBasicFileSystem.getName(Object)
.- Specified by:
toFile
in interfaceIBasicFileSystem<Path>
-
toFile
Description copied from interface:IBasicFileSystem
Creates a reference to a file. If filename is not absolute, it will be created in 'defaultFolder'.- Specified by:
toFile
in interfaceIBasicFileSystem<Path>
-
list
Description copied from interface:IBasicFileSystem
Lists files, directories or both, from a 'folder' or in the 'root' of the filesystem (when folder is null). Only lists the objects as defined by the type filter.- Specified by:
list
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
exists
- Specified by:
exists
in interfaceIBasicFileSystem<Path>
-
createFile
- Specified by:
createFile
in interfaceIWritableFileSystem<Path>
- Throws:
IOException
-
createFile
public void createFile(Path file, InputStream contents, Map<String, String> customFileAttributes) throws FileSystemException, IOExceptionDescription copied from interface:ISupportsCustomFileAttributes
Creates a file with the given custom file attributes.- Specified by:
createFile
in interfaceISupportsCustomFileAttributes<Path>
- Parameters:
file
-contents
-customFileAttributes
-- Throws:
FileSystemException
IOException
-
appendFile
- Specified by:
appendFile
in interfaceIWritableFileSystem<Path>
- Throws:
IOException
-
readFile
- Specified by:
readFile
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
deleteFile
- Specified by:
deleteFile
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
isFolder
- Specified by:
isFolder
in interfaceIBasicFileSystem<Path>
-
folderExists
- Specified by:
folderExists
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
createFolder
- Specified by:
createFolder
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
removeFolder
- Specified by:
removeFolder
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
renameFile
Description copied from interface:IWritableFileSystem
Renames the file to a new name, possibly in another folder. Does not need to check for the existence of the source or non-existence of the destination.- Specified by:
renameFile
in interfaceIWritableFileSystem<Path>
- Throws:
FileSystemException
-
renameFile
public Path renameFile(Path source, Path destination, Map<String, String> customFileAttributes) throws FileSystemExceptionDescription copied from interface:ISupportsCustomFileAttributes
Renames the file to a new name, possibly in another folder. Does not need to check for the existence of the source or non-existence of the destination.- Specified by:
renameFile
in interfaceISupportsCustomFileAttributes<Path>
- Throws:
FileSystemException
-
moveFile
public Path moveFile(Path f, String destinationFolder, boolean createFolder) throws FileSystemException Description copied from interface:IBasicFileSystem
Moves the file to another folder. Does not need to check for existence of the source or non-existence of the destination. Returns the moved file, or null if no file was moved or there is no reference to the moved file.- Specified by:
moveFile
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
moveFile
public Path moveFile(Path f, String destinationFolder, boolean createFolder, Map<String, String> customFileAttributes) throws FileSystemExceptionDescription copied from interface:ISupportsCustomFileAttributes
Moves the file to another folder, adding the given custom file attributes to the file in the destination folder. Does not need to check for existence of the source or non-existence of the destination. Returns the moved file, or null if no file was moved or there is no reference to the moved file.- Specified by:
moveFile
in interfaceISupportsCustomFileAttributes<Path>
- Throws:
FileSystemException
-
copyFile
public Path copyFile(Path f, String destinationFolder, boolean createFolder) throws FileSystemException Description copied from interface:IBasicFileSystem
Copies the file to another folder. Does not need to check for existence of the source or non-existence of the destination. Returns the copied file, or null if no file was copied or there is no reference to the copied file.- Specified by:
copyFile
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
copyFile
public Path copyFile(Path f, String destinationFolder, boolean createFolder, Map<String, String> customFileAttributes) throws FileSystemExceptionDescription copied from interface:ISupportsCustomFileAttributes
Copies the file to another folder, adding the given custom file attributes to the file in the destination folder. Does not need to check for existence of the source or non-existence of the destination. Returns the copied file, or null if no file was copied or there is no reference to the copied file.- Specified by:
copyFile
in interfaceISupportsCustomFileAttributes<Path>
- Throws:
FileSystemException
-
getFileSize
- Specified by:
getFileSize
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
getName
Description copied from interface:IBasicFileSystem
Get a string representation of an identification of a file. Must pair up with the implementation ofIBasicFileSystem.toFile(String)
. Can reflect name a file has in its folder, is not expected to be unique over folders.- Specified by:
getName
in interfaceIBasicFileSystem<Path>
-
getParentFolder
- Specified by:
getParentFolder
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
getCanonicalName
- Specified by:
getCanonicalName
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
getModificationTime
- Specified by:
getModificationTime
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
getAdditionalFileProperties
@Nullable public Map<String,Object> getAdditionalFileProperties(Path file) throws FileSystemException - Specified by:
getAdditionalFileProperties
in interfaceIBasicFileSystem<Path>
- Throws:
FileSystemException
-
getCustomFileAttribute
@Nullable public String getCustomFileAttribute(@Nonnull Path file, @Nonnull String name) throws FileSystemException Description copied from interface:ISupportsCustomFileAttributes
Gets the value of the given custom file attribute on the given file. If the attribute does not exist,null
is returned.- Specified by:
getCustomFileAttribute
in interfaceISupportsCustomFileAttributes<Path>
- Parameters:
file
- File object for which to get the extended attribute. Must not benull
.name
- Name of the extended attribute to get. Must not benull
.- Returns:
- Value of the extended attribute or
null
if the attribute does not exist. - Throws:
FileSystemException
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
setRoot
Path to the folder that serves as the root of this virtual filesystem. All specifications of folders or files are relative to this root. When the root is left unspecified, absolute paths to files and folders can be used -
getRoot
-
setCreateRootFolder
Whether the LocalFileSystem tries to create the root folder if it doesn't exist yet.- Parameters:
createRootFolder
-
-