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 theBinaryManagerandBlobProviderinterface using MongoDB GridFS.This implementation does not use local caching.
This implementation may not always be ideal regarding streaming because of the usage of
Binaryinterface that exposes aFile.- Since:
- 7.10
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classGridFSBinaryManager.GridFSBinaryA binary backed by GridFS.classGridFSBinaryManager.GridFSBinaryGarbageCollector
-
Field Summary
Fields Modifier and Type Field Description static StringBLOB_PROVIDER_CONNECTION_PREFIXPrefix used to retrieve a MongoDB connection fromMongoDBConnectionService.protected Stringbucketstatic StringBUCKET_PROPERTYstatic StringDBNAME_PROPERTYDeprecated.since 9.3 useMongoDBConnectionServiceto provide access insteadprotected com.mongodb.client.MongoCollection<org.bson.Document>filesCollprotected com.mongodb.client.gridfs.GridFSBucketgridFSBucketstatic StringSERVER_PROPERTYDeprecated.since 9.3 useMongoDBConnectionServiceto 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 voidclose()Closes this blob provider and releases resources that may be held by it.protected BinarygetBinary(InputStream in)Creates a binary value from the given input stream.BinarygetBinary(String digest)Returns aBinarycorresponding to the given digest.BinarygetBinary(Blob blob)Saves the given blob into aBinary.BinaryManagergetBinaryManager()Gets the associated binary manager, if any.protected com.mongodb.client.MongoCollection<org.bson.Document>getFilesColl()protected com.mongodb.client.gridfs.GridFSBucketgetGridFSBucket()Map<String,String>getProperties()Returns the properties of the blob provider.voidinitialize(String blobProviderId, Map<String,String> properties)Initializes the binary manager.booleanisTransient()Checks whether this blob provider is transient: blobs may disappear after a while, so a caller should not rely on them being available forever.BlobreadBlob(BlobInfo blobInfo)Reads aBlobfrom storage.booleansupportsUserUpdate()Checks if user update is supported.StringwriteBlob(Blob blob)Writes aBlobto 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 useMongoDBConnectionServiceto provide access instead- See Also:
- Constant Field Values
-
DBNAME_PROPERTY
@Deprecated public static final String DBNAME_PROPERTY
Deprecated.since 9.3 useMongoDBConnectionServiceto 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:BinaryManagerInitializes the binary manager.- Specified by:
initializein interfaceBinaryManager- Specified by:
initializein interfaceBlobProvider- Overrides:
initializein classAbstractBinaryManager- Parameters:
blobProviderId- the blob provider id for this binary managerproperties- initialization properties- Throws:
IOException
-
close
public void close()
Description copied from interface:BlobProviderCloses this blob provider and releases resources that may be held by it.- Specified by:
closein interfaceBinaryManager- Specified by:
closein interfaceBlobProvider
-
getBinaryManager
public BinaryManager getBinaryManager()
Description copied from interface:BlobProviderGets the associated binary manager, if any.- Specified by:
getBinaryManagerin 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:BinaryManagerSaves the given blob into aBinary.Returns a
Binaryrepresenting the stream. TheBinaryincludes 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:
getBinaryin interfaceBinaryManager- Overrides:
getBinaryin classAbstractBinaryManager- Parameters:
blob- the blob- Returns:
- the corresponding binary
- Throws:
IOException
-
getBinary
protected Binary getBinary(InputStream in) throws IOException
Description copied from class:AbstractBinaryManagerCreates a binary value from the given input stream.- Specified by:
getBinaryin classAbstractBinaryManager- Throws:
IOException
-
getBinary
public Binary getBinary(String digest)
Description copied from interface:BinaryManagerReturns aBinarycorresponding to the given digest.A
nullis returned if the digest could not be found.- Specified by:
getBinaryin interfaceBinaryManager- Specified by:
getBinaryin classAbstractBinaryManager- Parameters:
digest- the digest, ornull- Returns:
- the corresponding binary
-
readBlob
public Blob readBlob(BlobInfo blobInfo) throws IOException
Description copied from interface:BlobProviderReads aBlobfrom storage.- Specified by:
readBlobin interfaceBlobProvider- Parameters:
blobInfo- the blob information- Returns:
- the blob
- Throws:
IOException
-
writeBlob
public String writeBlob(Blob blob) throws IOException
Description copied from interface:BlobProviderWrites aBlobto storage and returns information about it.Called to store a user-created blob.
- Specified by:
writeBlobin interfaceBlobProvider- Parameters:
blob- the blob- Returns:
- the blob key
- Throws:
IOException
-
supportsUserUpdate
public boolean supportsUserUpdate()
Description copied from interface:BlobProviderChecks 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:
supportsUserUpdatein interfaceBlobProvider- Returns:
trueif user update is supported
-
isTransient
public boolean isTransient()
Description copied from interface:BlobProviderChecks 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:
isTransientin interfaceBlobProvider
-
getProperties
public Map<String,String> getProperties()
Description copied from interface:BlobProviderReturns the properties of the blob provider.- Specified by:
getPropertiesin interfaceBlobProvider
-
-