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 |
BLOB_PROVIDER_CONNECTION_PREFIX
Prefix used to retrieve a MongoDB connection from
MongoDBConnectionService . |
static String |
BUCKET_PROPERTY |
static String |
DBNAME_PROPERTY
Deprecated.
since 9.3 use
MongoDBConnectionService to provide access instead |
protected com.mongodb.client.MongoCollection<org.bson.Document> |
filesColl |
protected com.mongodb.gridfs.GridFS |
gridFS
Deprecated.
|
protected com.mongodb.client.gridfs.GridFSBucket |
gridFSBucket |
protected Map<String,String> |
properties |
static String |
SERVER_PROPERTY
Deprecated.
since 9.3 use
MongoDBConnectionService to provide access instead |
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.
|
protected com.mongodb.client.gridfs.GridFSBucket |
getGridFSBucket() |
void |
initialize(String blobProviderId,
Map<String,String> properties)
Initializes the binary manager.
|
Blob |
readBlob(BlobInfo blobInfo)
Reads a
Blob from storage. |
boolean |
supportsUserUpdate()
Checks if user update is supported.
|
String |
writeBlob(Blob blob)
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
getAppLinks, getAvailableConversions, getStream, getThumbnail, getURI, isVersion, performsExternalAccessControl
public static final String BLOB_PROVIDER_CONNECTION_PREFIX
MongoDBConnectionService
.
The connection id will be blobProvider/[BLOB_PROVIDER_ID]
.@Deprecated public static final String SERVER_PROPERTY
MongoDBConnectionService
to provide access instead@Deprecated public static final String DBNAME_PROPERTY
MongoDBConnectionService
to provide access insteadpublic static final String BUCKET_PROPERTY
protected Map<String,String> properties
@Deprecated protected com.mongodb.gridfs.GridFS gridFS
protected com.mongodb.client.gridfs.GridFSBucket gridFSBucket
protected com.mongodb.client.MongoCollection<org.bson.Document> filesColl
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
protected com.mongodb.client.gridfs.GridFSBucket getGridFSBucket()
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(BlobInfo blobInfo) throws IOException
BlobProvider
Blob
from storage.readBlob
in interface BlobProvider
blobInfo
- the blob informationIOException
public String writeBlob(Blob blob) throws IOException
BlobProvider
Blob
to storage and returns information about it.
Called to store a user-created blob.
writeBlob
in interface BlobProvider
blob
- the blobIOException
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 © 2018 Nuxeo. All rights reserved.