Package nl.knaw.dans.layerstore
Interface LayerDatabase
- All Known Implementing Classes:
LayerDatabaseImpl
public interface LayerDatabase
Provides access to the database that contains a record for every file and directory stored in the layered storage. Contains methods to add, delete and find information about these files and
directories.
-
Method Summary
Modifier and TypeMethodDescriptionaddDirectory
(long layerId, String path) Adds a directory to the database.void
deleteRecordsById
(long... ids) Deletes the records with the given ids.boolean
existsPathLike
(String pathPattern) Returns whether the path pattern matches any path in the database.findLayersContaining
(String path) Finds all the layers that contain the given path.Retrieves a stream of all the records in the database.getRecordsByPath
(String path) Returns the records for the given path in any layer.listDirectory
(String directoryPath) Lists the items indirectoryPath
.listRecursive
(String directoryPath) Lists the items indirectoryPath
recursively.void
saveRecords
(ItemRecord... records) Save records to the database.
-
Method Details
-
saveRecords
Save records to the database. The records may be new or existing. If a record already exists, it is updated.- Parameters:
records
- the records to save
-
deleteRecordsById
void deleteRecordsById(long... ids) Deletes the records with the given ids.- Parameters:
ids
- the ids of the records to delete
-
getAllRecords
Stream<ItemRecord> getAllRecords()Retrieves a stream of all the records in the database.- Returns:
- a list of all the records in the database
-
listDirectory
Lists the items indirectoryPath
. It takes into account the complete stack of layers. If the directory does not exist in any of the layers, an IllegalArgumentException is thrown.- Parameters:
directoryPath
- the directory path relative to the storage root- Returns:
- the items in the directory
- Throws:
IOException
-
listRecursive
Lists the items indirectoryPath
recursively. It takes into account the complete stack of layers.- Parameters:
directoryPath
- the directory path relative to the storage root- Returns:
- the items in the directory and its subdirectories
- Throws:
IOException
-
addDirectory
Adds a directory to the database. Ancestor directories are added automatically, if they do not exist in the same layer yet.- Parameters:
path
- the path of the directory relative to the storage root- Returns:
- the records that were added to the database for directories that did not exist yet
- Throws:
IllegalArgumentException
- if the layerId is lower than the highest layerId in the database
-
findLayersContaining
Finds all the layers that contain the given path.- Parameters:
path
- path relative to the root of the storage- Returns:
- the ids of the layers that contain the path
-
getRecordsByPath
Returns the records for the given path in any layer. The records are ordered by layer id, with the newest layer first.- Parameters:
path
- path relative to the root of the storage- Returns:
- the records for the given path
-
existsPathLike
Returns whether the path pattern matches any path in the database.- Parameters:
pathPattern
- a path pattern that may contain wildcards- Returns:
- true if the pattern matches any path in the database, false otherwise
-