Package nl.knaw.dans.layerstore
Interface Layer
public interface Layer
-
Method Summary
Modifier and TypeMethodDescriptionvoid
archive()
Turns the layer into an archive file.void
close()
Changes the state of the layer to closed.void
createDirectory
(String path) void
deleteDirectory
(String path) void
deleteFiles
(List<String> paths) Deletes the files pointed to bypaths
.boolean
fileExists
(String path) long
getId()
Returns the id of the layer.long
boolean
Returns whether the layer is archived.boolean
isOpen()
Returns whether the layer is open.void
moveDirectoryInternal
(String source, String destination) void
moveDirectoryInto
(Path source, String destination) void
reopen()
Changes the state of the layer to open.void
writeFile
(String filePath, InputStream content) Writes the content of the given input stream to the file at the given path.
-
Method Details
-
getId
long getId()Returns the id of the layer.- Returns:
- the id of the layer
-
close
void close()Changes the state of the layer to closed.- Throws:
IllegalStateException
- if the layer is already closed
-
reopen
Changes the state of the layer to open. It also stages the archive file in the staging directory. This operation is not allowed when the layer is not closed or not yet archived.- Throws:
IOException
-
isOpen
boolean isOpen()Returns whether the layer is open.- Returns:
- whether the layer is open
-
archive
void archive()Turns the layer into an archive file. -
isArchived
boolean isArchived()Returns whether the layer is archived.- Returns:
- whether the layer is archived
-
createDirectory
- Throws:
IOException
-
deleteDirectory
- Throws:
IOException
-
fileExists
- Throws:
IOException
-
readFile
- Throws:
IOException
-
writeFile
Writes the content of the given input stream to the file at the given path. Not allowed when the layer is closed. If the file already exists, it is overwritten.- Parameters:
filePath
- the path of the file relative to the storage rootcontent
- the content of the file- Throws:
IOException
- if the file cannot be written
-
deleteFiles
Deletes the files pointed to bypaths
. Not allowed when the layer is closed.- Parameters:
paths
- the paths of the files to be deleted- Throws:
IOException
- if the files cannot be deleted
-
moveDirectoryInto
- Throws:
IOException
-
moveDirectoryInternal
- Throws:
IOException
-
getSizeInBytes
- Throws:
IOException
-