Class GridFSBinaryManager
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
-
- org.nuxeo.ecm.core.storage.mongodb.GridFSBinaryManager
-
- All Implemented Interfaces:
BinaryManager
,BlobProvider
public class GridFSBinaryManager extends AbstractBinaryManager implements BlobProvider
Implements theBinaryManager
andBlobProvider
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 aFile
.- Since:
- 7.10
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
GridFSBinaryManager.GridFSBinary
A binary backed by GridFS.class
GridFSBinaryManager.GridFSBinaryGarbageCollector
-
Field Summary
Fields Modifier and Type Field Description static String
BLOB_PROVIDER_CONNECTION_PREFIX
Prefix used to retrieve a MongoDB connection fromMongoDBConnectionService
.protected String
bucket
static String
BUCKET_PROPERTY
static String
DBNAME_PROPERTY
Deprecated.since 9.3 useMongoDBConnectionService
to provide access insteadprotected com.mongodb.client.MongoCollection<org.bson.Document>
filesColl
protected com.mongodb.client.gridfs.GridFSBucket
gridFSBucket
static String
SERVER_PROPERTY
Deprecated.since 9.3 useMongoDBConnectionService
to provide access instead-
Fields inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, digestPattern, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, properties, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
-
Fields inherited from interface org.nuxeo.ecm.core.blob.binary.BinaryManager
PROP_KEY, PROP_PATH
-
-
Constructor Summary
Constructors Constructor Description GridFSBinaryManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this blob provider and releases resources that may be held by it.protected Binary
getBinary(InputStream in)
Creates a binary value from the given input stream.Binary
getBinary(String digest)
Returns aBinary
corresponding to the given digest.Binary
getBinary(Blob blob)
Saves the given blob into aBinary
.BinaryManager
getBinaryManager()
Gets the associated binary manager, if any.protected com.mongodb.client.MongoCollection<org.bson.Document>
getFilesColl()
protected com.mongodb.client.gridfs.GridFSBucket
getGridFSBucket()
Map<String,String>
getProperties()
Returns the properties of the blob provider.void
initialize(String blobProviderId, Map<String,String> properties)
Initializes the binary manager.boolean
isTransient()
Checks whether this blob provider is transient: blobs may disappear after a while, so a caller should not rely on them being available forever.Blob
readBlob(BlobInfo blobInfo)
Reads aBlob
from storage.boolean
supportsUserUpdate()
Checks if user update is supported.String
writeBlob(Blob blob)
Writes aBlob
to storage and returns information about it.-
Methods inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
computeDigestPattern, getDefaultDigestAlgorithm, getDescriptor, getDigestAlgorithm, getGarbageCollector, isValidDigest, removeBinaries, setDescriptor, storeAndDigest, toHexString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.blob.BlobProvider
allowByteRange, allowDirectDownload, canConvert, deleteBlob, getAppLinks, getAvailableConversions, getBinaryGarbageCollector, getFile, getStatus, getStream, getStream, getThumbnail, getURI, hasCreateFromKeyPermission, isColdStorageMode, isRecordMode, isTransactional, isVersion, performsExternalAccessControl, readBlob, supportsSync, updateBlob, writeBlob
-
-
-
-
Field Detail
-
BLOB_PROVIDER_CONNECTION_PREFIX
public static final String BLOB_PROVIDER_CONNECTION_PREFIX
Prefix used to retrieve a MongoDB connection fromMongoDBConnectionService
.The connection id will be
blobProvider/[BLOB_PROVIDER_ID]
.- See Also:
- Constant Field Values
-
SERVER_PROPERTY
@Deprecated public static final String SERVER_PROPERTY
Deprecated.since 9.3 useMongoDBConnectionService
to provide access instead- See Also:
- Constant Field Values
-
DBNAME_PROPERTY
@Deprecated public static final String DBNAME_PROPERTY
Deprecated.since 9.3 useMongoDBConnectionService
to provide access instead- See Also:
- Constant Field Values
-
BUCKET_PROPERTY
public static final String BUCKET_PROPERTY
- See Also:
- Constant Field Values
-
gridFSBucket
protected com.mongodb.client.gridfs.GridFSBucket gridFSBucket
-
filesColl
protected com.mongodb.client.MongoCollection<org.bson.Document> filesColl
-
bucket
protected String bucket
-
-
Method Detail
-
initialize
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
Description copied from interface:BinaryManager
Initializes the binary manager.- Specified by:
initialize
in interfaceBinaryManager
- Specified by:
initialize
in interfaceBlobProvider
- Overrides:
initialize
in classAbstractBinaryManager
- Parameters:
blobProviderId
- the blob provider id for this binary managerproperties
- initialization properties- Throws:
IOException
-
close
public void close()
Description copied from interface:BlobProvider
Closes this blob provider and releases resources that may be held by it.- Specified by:
close
in interfaceBinaryManager
- Specified by:
close
in interfaceBlobProvider
-
getBinaryManager
public BinaryManager getBinaryManager()
Description copied from interface:BlobProvider
Gets the associated binary manager, if any.- Specified by:
getBinaryManager
in interfaceBlobProvider
- Returns:
- the binary manager, or
null
-
getGridFSBucket
protected com.mongodb.client.gridfs.GridFSBucket getGridFSBucket()
-
getFilesColl
protected com.mongodb.client.MongoCollection<org.bson.Document> getFilesColl()
-
getBinary
public Binary getBinary(Blob blob) throws IOException
Description copied from interface:BinaryManager
Saves the given blob into aBinary
.Returns a
Binary
representing the stream. TheBinary
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.- Specified by:
getBinary
in interfaceBinaryManager
- Overrides:
getBinary
in classAbstractBinaryManager
- Parameters:
blob
- the blob- Returns:
- the corresponding binary
- Throws:
IOException
-
getBinary
protected Binary getBinary(InputStream in) throws IOException
Description copied from class:AbstractBinaryManager
Creates a binary value from the given input stream.- Specified by:
getBinary
in classAbstractBinaryManager
- Throws:
IOException
-
getBinary
public Binary getBinary(String digest)
Description copied from interface:BinaryManager
Returns aBinary
corresponding to the given digest.A
null
is returned if the digest could not be found.- Specified by:
getBinary
in interfaceBinaryManager
- Specified by:
getBinary
in classAbstractBinaryManager
- Parameters:
digest
- the digest, ornull
- Returns:
- the corresponding binary
-
readBlob
public Blob readBlob(BlobInfo blobInfo) throws IOException
Description copied from interface:BlobProvider
Reads aBlob
from storage.- Specified by:
readBlob
in interfaceBlobProvider
- Parameters:
blobInfo
- the blob information- Returns:
- the blob
- Throws:
IOException
-
writeBlob
public String writeBlob(Blob blob) throws IOException
Description copied from interface:BlobProvider
Writes aBlob
to storage and returns information about it.Called to store a user-created blob.
- Specified by:
writeBlob
in interfaceBlobProvider
- Parameters:
blob
- the blob- Returns:
- the blob key
- Throws:
IOException
-
supportsUserUpdate
public boolean supportsUserUpdate()
Description copied from interface:BlobProvider
Checks if user update is supported.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).
- Specified by:
supportsUserUpdate
in interfaceBlobProvider
- Returns:
true
if user update is supported
-
isTransient
public boolean isTransient()
Description copied from interface:BlobProvider
Checks whether this blob provider is transient: blobs may disappear after a while, so a caller should not rely on them being available forever.- Specified by:
isTransient
in interfaceBlobProvider
-
getProperties
public Map<String,String> getProperties()
Description copied from interface:BlobProvider
Returns the properties of the blob provider.- Specified by:
getProperties
in interfaceBlobProvider
-
-