public class GridFSBinaryManager extends AbstractBinaryManager implements BlobProvider
BinaryManager
and BlobProvider
interface using MongoDB GridFS.
This implementation does not use local caching.
This implementation may not always be ideal regarding streaming because of the usage of Binary
interface that
exposes a File
.
Modifier and Type | Class and Description |
---|---|
protected class |
GridFSBinaryManager.GridFSBinary
A binary backed by GridFS.
|
class |
GridFSBinaryManager.GridFSBinaryGarbageCollector |
Modifier and Type | Field and Description |
---|---|
static String |
BUCKET_PROPERTY |
protected com.mongodb.MongoClient |
client |
static String |
DBNAME_PROPERTY |
protected com.mongodb.gridfs.GridFS |
gridFS |
protected Map<String,String> |
properties |
static String |
SERVER_PROPERTY |
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
PROP_KEY, PROP_PATH
Constructor and Description |
---|
GridFSBinaryManager() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this blob provider and releases resources that may be held by it.
|
Binary |
getBinary(Blob blob)
Saves the given blob into a
Binary . |
protected Binary |
getBinary(InputStream in)
Creates a binary value from the given input stream.
|
Binary |
getBinary(String digest)
Returns a
Binary corresponding to the given digest. |
BinaryManager |
getBinaryManager()
Gets the associated binary manager, if any.
|
com.mongodb.gridfs.GridFS |
getGridFS() |
void |
initialize(String blobProviderId,
Map<String,String> properties)
Initializes the binary manager.
|
Blob |
readBlob(BlobManager.BlobInfo blobInfo)
Reads a
Blob from storage. |
boolean |
supportsUserUpdate()
Checks if user update is supported.
|
String |
writeBlob(Blob blob,
Document doc)
Writes a
Blob to storage and returns information about it. |
getDefaultDigestAlgorithm, getDescriptor, getDigestAlgorithm, getGarbageCollector, removeBinaries, storeAndDigest, toHexString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
freezeVersion, getAppLinks, getAvailableConversions, getConvertedStream, getStream, getThumbnail, getURI, isVersion, performsExternalAccessControl
public static final String SERVER_PROPERTY
public static final String DBNAME_PROPERTY
public static final String BUCKET_PROPERTY
protected Map<String,String> properties
protected com.mongodb.MongoClient client
protected com.mongodb.gridfs.GridFS gridFS
public GridFSBinaryManager()
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
BinaryManager
initialize
in interface BinaryManager
initialize
in interface BlobProvider
initialize
in class AbstractBinaryManager
blobProviderId
- the blob provider id for this binary managerproperties
- initialization propertiesIOException
public void close()
BlobProvider
close
in interface BinaryManager
close
in interface BlobProvider
public BinaryManager getBinaryManager()
BlobProvider
getBinaryManager
in interface BlobProvider
null
public com.mongodb.gridfs.GridFS getGridFS()
public Binary getBinary(Blob blob) throws IOException
BinaryManager
Binary
.
Returns a Binary
representing the stream. The Binary
includes a digest that is a sufficient
representation to persist it.
If the blob is a temporary FileBlob
, then the temporary file may be reused as the final storage location
after being moved.
getBinary
in interface BinaryManager
getBinary
in class AbstractBinaryManager
blob
- the blobIOException
protected Binary getBinary(InputStream in) throws IOException
AbstractBinaryManager
getBinary
in class AbstractBinaryManager
IOException
public Binary getBinary(String digest)
BinaryManager
Binary
corresponding to the given digest.
A null
is returned if the digest could not be found.
getBinary
in interface BinaryManager
getBinary
in class AbstractBinaryManager
digest
- the digest, or null
public Blob readBlob(BlobManager.BlobInfo blobInfo) throws IOException
BlobProvider
Blob
from storage.readBlob
in interface BlobProvider
blobInfo
- the blob informationIOException
public String writeBlob(Blob blob, Document doc) throws IOException
BlobProvider
Blob
to storage and returns information about it.
Called to store a user-created blob.
writeBlob
in interface BlobProvider
blob
- the blobdoc
- the document to which this blob belongsIOException
public boolean supportsUserUpdate()
BlobProvider
A user update refers to the fact that a blob from this provider may be overwritten with another blob, wherever the original blob may occur (usually in a document property).
supportsUserUpdate
in interface BlobProvider
true
if user update is supportedCopyright © 2017 Nuxeo. All rights reserved.