Package nl.knaw.dans.layerstore
Class LayeredItemStore
java.lang.Object
nl.knaw.dans.layerstore.LayeredItemStore
- All Implemented Interfaces:
ItemStore
An implementation of FileStore that stores files and directories as a stack of layers. A layer can be staged or archived. Staged layers can be modified, archived layers are read-only. To transform
the layered file store into a regular file system directory, each layer must be unarchived (if it was archived) to a staging directory and the staging directories must be copied into a single
directory, starting with the oldest layer and ending with the newest layer. Files in newer layers overwrite files in older layers.
The LayeredFileStore is backed by a LayerDatabase to support storage of layers in a way that may not be fast enough for direct access, for example on tape. See the LayerDatabase interface for more information.
- See Also:
-
Constructor Summary
ConstructorDescriptionLayeredItemStore
(LayerDatabase database, LayerManager layerManager) LayeredItemStore
(LayerDatabase database, LayerManager layerManager, DatabaseBackedContentManager databaseBackedContentManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
copyDirectoryOutOf
(String source, Path destination) void
createDirectory
(String path) void
deleteDirectory
(String path) Deletes the directory at the given path, including all its contents.void
deleteFiles
(List<String> paths) Deletes the files at the given paths.boolean
existsPathLike
(String path) Returns whether a path with the given pattern exists in the store.listDirectory
(String directoryPath) Returns the items in the given directory, taking into account the complete stack of layers.listRecursive
(String directoryPath) Returns the files and directories in the given directory and its subdirectories.void
moveDirectoryInternal
(String source, String destination) Moves the directory inside the store to the given destination.void
moveDirectoryInto
(Path source, String destination) Moves the directory outside the store into the given destination.Opens an input stream to the file at the given path.void
writeFile
(String path, InputStream content) Writes the given content to the file at the given path.
-
Constructor Details
-
LayeredItemStore
public LayeredItemStore(LayerDatabase database, LayerManager layerManager, DatabaseBackedContentManager databaseBackedContentManager) -
LayeredItemStore
-
-
Method Details
-
listDirectory
Description copied from interface:ItemStore
Returns the items in the given directory, taking into account the complete stack of layers.- Specified by:
listDirectory
in interfaceItemStore
- Parameters:
directoryPath
- the directory path relative to the storage root- Returns:
- the items in the directory
- Throws:
NoSuchFileException
- if the directory does not exist in any of the layersNotDirectoryException
- if the path exists, but is not a directoryIOException
-
listRecursive
Description copied from interface:ItemStore
Returns the files and directories in the given directory and its subdirectories.- Specified by:
listRecursive
in interfaceItemStore
- Parameters:
directoryPath
- the directory path relative to the storage root- Returns:
- the items in the directory and its subdirectories
- Throws:
NoSuchFileException
- if the directory does not exist in any of the layersNotDirectoryException
- if the path exists, but is not a directoryIOException
-
existsPathLike
Description copied from interface:ItemStore
Returns whether a path with the given pattern exists in the store.- Specified by:
existsPathLike
in interfaceItemStore
- Parameters:
path
- a path, which may contain the SQL wildcard character '%'- Returns:
- true if a path exists that matches the pattern, false otherwise
-
readFile
Description copied from interface:ItemStore
Opens an input stream to the file at the given path.- Specified by:
readFile
in interfaceItemStore
- Parameters:
path
- the path of the file relative to the storage root- Returns:
- an input stream to the file
- Throws:
IOException
- if the file could not be opened
-
writeFile
Description copied from interface:ItemStore
Writes the given content to the file at the given path. If the file does not exist yet, it is created.- Specified by:
writeFile
in interfaceItemStore
- Parameters:
path
- the path of the file relative to the storage rootcontent
- the content to write- Throws:
IOException
-
moveDirectoryInto
Description copied from interface:ItemStore
Moves the directory outside the store into the given destination. The parent of the destination must exist, but the destination itself must not exist yet.- Specified by:
moveDirectoryInto
in interfaceItemStore
- Parameters:
source
- the path of the directory to movedestination
- the path of the destination directory relative to the storage root- Throws:
IOException
-
moveDirectoryInternal
Description copied from interface:ItemStore
Moves the directory inside the store to the given destination. The destination must not exist yet, but its parent must exist.- Specified by:
moveDirectoryInternal
in interfaceItemStore
- Parameters:
source
- the path of the directory to move relative to the storage rootdestination
- the path of the destination directory relative to the storage root- Throws:
IOException
-
deleteDirectory
Description copied from interface:ItemStore
Deletes the directory at the given path, including all its contents.- Specified by:
deleteDirectory
in interfaceItemStore
- Parameters:
path
- the path of the directory relative to the storage root- Throws:
IOException
-
deleteFiles
Description copied from interface:ItemStore
Deletes the files at the given paths.- Specified by:
deleteFiles
in interfaceItemStore
- Parameters:
paths
- the paths of the files relative to the storage root- Throws:
IOException
-
createDirectory
- Specified by:
createDirectory
in interfaceItemStore
- Throws:
IOException
-
copyDirectoryOutOf
- Specified by:
copyDirectoryOutOf
in interfaceItemStore
- Throws:
IOException
-