public class FsBlobContainer extends AbstractBlobContainer
BlobContainer
.
All blobs in the container are stored on a file system, the location of which is specified by the BlobPath
.
Note that the methods in this implementation of BlobContainer
may
additionally throw a SecurityException
if the configured SecurityManager
does not permit read and/or write access to the underlying files.Modifier and Type | Field and Description |
---|---|
protected FsBlobStore |
blobStore |
protected java.nio.file.Path |
path |
Constructor and Description |
---|
FsBlobContainer(FsBlobStore blobStore,
BlobPath blobPath,
java.nio.file.Path path) |
Modifier and Type | Method and Description |
---|---|
boolean |
blobExists(java.lang.String blobName)
Tests whether a blob with the given blob name exists in the container.
|
void |
deleteBlob(java.lang.String blobName)
Deletes a blob with giving name, if the blob exists.
|
java.util.Map<java.lang.String,BlobMetaData> |
listBlobs()
Lists all blobs in the container.
|
java.util.Map<java.lang.String,BlobMetaData> |
listBlobsByPrefix(java.lang.String blobNamePrefix)
Lists all blobs in the container that match the specified prefix.
|
void |
move(java.lang.String source,
java.lang.String target)
Atomically renames the source blob into the target blob.
|
java.io.InputStream |
readBlob(java.lang.String name)
Creates a new
InputStream for the given blob name. |
void |
writeBlob(java.lang.String blobName,
java.io.InputStream inputStream,
long blobSize)
Reads blob content from the input stream and writes it to the container in a new blob with the given name.
|
deleteBlobs, deleteBlobsByPrefix, path, writeBlob
protected final FsBlobStore blobStore
protected final java.nio.file.Path path
public FsBlobContainer(FsBlobStore blobStore, BlobPath blobPath, java.nio.file.Path path)
public java.util.Map<java.lang.String,BlobMetaData> listBlobs() throws java.io.IOException
BlobContainer
BlobMetaData
, containing basic information about each blob.java.io.IOException
- if there were any failures in reading from the blob container.public java.util.Map<java.lang.String,BlobMetaData> listBlobsByPrefix(java.lang.String blobNamePrefix) throws java.io.IOException
BlobContainer
blobNamePrefix
- The prefix to match against blob names in the container.BlobMetaData
, containing basic information about each blob.java.io.IOException
- if there were any failures in reading from the blob container.public void deleteBlob(java.lang.String blobName) throws java.io.IOException
BlobContainer
blobName
- The name of the blob to delete.java.io.IOException
- if the blob does not exist, or if the blob exists but could not be deleted.public boolean blobExists(java.lang.String blobName)
BlobContainer
blobName
- The name of the blob whose existence is to be determined.true
if a blob exists in the BlobContainer
with the given name, and false
otherwise.public java.io.InputStream readBlob(java.lang.String name) throws java.io.IOException
BlobContainer
InputStream
for the given blob name.name
- The name of the blob to get an InputStream
for.InputStream
to read the blob.java.io.IOException
- if the blob does not exist or can not be read.public void writeBlob(java.lang.String blobName, java.io.InputStream inputStream, long blobSize) throws java.io.IOException
BlobContainer
IOException
will be thrown.blobName
- The name of the blob to write the contents of the input stream to.inputStream
- The input stream from which to retrieve the bytes to write to the blob.blobSize
- The size of the blob to be written, in bytes. It is implementation dependent whether
this value is used in writing the blob to the repository.java.io.IOException
- if the input stream could not be read, a blob by the same name already exists,
or the target blob could not be written to.public void move(java.lang.String source, java.lang.String target) throws java.io.IOException
BlobContainer
source
- The blob to rename.target
- The name of the blob after the renaming.java.io.IOException
- if the source blob does not exist, the target blob already exists,
or there were any failures in reading from the blob container.