Package org.nuxeo.ecm.core.blob
Class DocumentBlobManagerComponent
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.ecm.core.blob.DocumentBlobManagerComponent
- All Implemented Interfaces:
DocumentBlobManager,Adaptable,Component,Extensible,TimestampedService
- Since:
- 9.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected BlobDispatcherstatic final StringEvent fired to GC blobs candidates for deletion.static final StringEvent fired to record blob deletion.protected static final Stringstatic final Stringprotected static final StringFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckCanDeleteBlob(String repositoryName) Checks that blobs can be safely deleted for the given repository.booleandeleteBlob(String repositoryName, String key, boolean dryRun) Deletes the blob associated to the given key.protected static voiddenormalizeKeySuffix(Set<String> queryBlobKeys) For any suffixed key in the given set, also add the unsuffixed key.protected voidvoidfreezeVersion(Document doc) Freezes the blobs' versions on a document version when it is created via a check in.protected voidfreezeVersion(Document.BlobAccessor accessor, Document doc) garbageCollectBinaries(boolean delete) Garbage collect the unused binaries.protected ManagedBlobprotected BlobDispatcherprotected StringA key may have been replaced by an async digest computation, use the new one.protected StringgetBlobKeyReplacement(ManagedBlob blob, boolean addPrefix) protected BlobProvidergetBlobProvider(String providerId) protected BlobProvidergetBlobProvider(String key, String repositoryName) getConvertedStream(Blob blob, String mimeType, DocumentModel doc) Gets anInputStreamfor a conversion to the given MIME type.protected DocumentBlobProvidergetDocumentBlobProvider(Blob blob) protected List<BinaryGarbageCollector>protected ManagedBlobgetMainBlob(Document doc) getProviderIds(String repository) Gets the list of the provider ids that are used by the given repository.booleanCompute if there are shared storage.booleanChecks if a garbage collection of the binaries in progress.booleanAre the blobs from a repository stored in a provider with the same name.voidnotifyAfterCopy(Document doc) Notifies the blob manager that the document has been copied.voidNotifies the blob manager that the document is about to be removed.voidnotifyChanges(Document doc, Set<String> xpaths) Notifies the blob manager that a set of xpaths have changed on a document.voidnotifyMakeRecord(Document doc) Notifies the blob manager that the document was made a record.voidnotifySetLegalHold(Document doc, boolean hold) Notifies the blob manager that the document's legal hold status was changed.voidnotifySetRetainUntil(Document doc, Calendar retainUntil) Notifies the blob manager that the document's retention date was changed.Deprecated.Reads aBlobfrom storage.protected BlobvoidregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) protected <R> RrunInTransaction(Supplier<R> supplier, int timeout) Runs the givenSupplierin a transaction with the giventimeout.protected StringstripBlobKeyPrefix(String key) voidunregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) protected voidupdateBlob(ManagedBlob blob, Consumer<BlobUpdateContext> contextFiller) voidupdateBlob(Document doc, Consumer<BlobUpdateContext> contextFiller) Update main blob of the doc.protected voidupdateRetainedBlobs(Document doc, Consumer<BlobUpdateContext> contextFiller) Writes aBlobto storage and returns its key.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterExtensionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.runtime.model.Component
getApplicationStartedOrder
-
Field Details
-
XP
- See Also:
-
BINARY_GC_TX_TIMEOUT_SEC
protected static final int BINARY_GC_TX_TIMEOUT_SEC- See Also:
-
BLOBS_CANDIDATE_FOR_DELETION_EVENT
Event fired to GC blobs candidates for deletion.- Since:
- 2023
- See Also:
-
BLOBS_DELETED_DOMAIN_EVENT
Event fired to record blob deletion.- Since:
- 2023
- See Also:
-
DOC_WITH_BLOB_KEYS_IN_QUERY
- See Also:
-
MAIN_BLOB_XPATH
- See Also:
-
blobDispatcher
-
-
Constructor Details
-
DocumentBlobManagerComponent
public DocumentBlobManagerComponent()
-
-
Method Details
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
registerContributionin classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContributionin classDefaultComponent
-
getBlobDispatcher
-
getBlobProvider
-
getDocumentBlobProvider
-
readBlob
Reads aBlobfrom storage.The
BlobInfo(coming from the database) contains the blob key, which may or may not be prefixed by a blob provider id.- Specified by:
readBlobin interfaceDocumentBlobManager- Parameters:
blobInfo- the blob informationdoc- the document to which this blob belongsxpath- the xpath of the blob in the document- Returns:
- a managed blob
- Throws:
IOException
-
readBlob
protected Blob readBlob(BlobInfo blobInfo, Document doc, String xpath, String repositoryName) throws IOException - Throws:
IOException
-
readBlob
Deprecated.since 11.1, usereadBlob(BlobInfo, Document, String)insteadReads aBlobfrom storage.The
BlobInfo(coming from the database) contains the blob key, which may or may not be prefixed by a blob provider id.- Specified by:
readBlobin interfaceDocumentBlobManager- Parameters:
blobInfo- the blob informationrepositoryName- the repository to which this blob belongs- Returns:
- a managed blob
- Throws:
IOException
-
getBlobProvider
-
writeBlob
Writes aBlobto storage and returns its key.The passed blob may be
null, in which case anullkey is returned after checking that deleting this blob is allowed.If the blob is managed and already uses the provider that's expected for this blob and document, there is no need to recompute a key. Otherwise, go through the blob provider.
- Specified by:
writeBlobin interfaceDocumentBlobManager- Parameters:
blob- the blobdoc- the document to which this blob belongsxpath- the xpath of blob in doc- Returns:
- the blob key
- Throws:
IOException
-
getBlobKeyReplacement
A key may have been replaced by an async digest computation, use the new one. -
getBlobKeyReplacement
-
getConvertedStream
public InputStream getConvertedStream(Blob blob, String mimeType, DocumentModel doc) throws IOException Description copied from interface:DocumentBlobManagerGets anInputStreamfor a conversion to the given MIME type.Like all
InputStream, the result must be closed when done with it to avoid resource leaks.- Specified by:
getConvertedStreamin interfaceDocumentBlobManager- Parameters:
blob- the blobmimeType- the MIME type to convert todoc- the document that holds the blob- Returns:
- the stream, or
nullif no conversion is available for the given MIME type - Throws:
IOException
-
freezeVersion
-
freezeVersion
Description copied from interface:DocumentBlobManagerFreezes the blobs' versions on a document version when it is created via a check in.- Specified by:
freezeVersionin interfaceDocumentBlobManager- Parameters:
doc- the new document version
-
notifyChanges
Description copied from interface:DocumentBlobManagerNotifies the blob manager that a set of xpaths have changed on a document.- Specified by:
notifyChangesin interfaceDocumentBlobManager- Parameters:
doc- the documentxpaths- the set of changed xpaths
-
notifyMakeRecord
Description copied from interface:DocumentBlobManagerNotifies the blob manager that the document was made a record.- Specified by:
notifyMakeRecordin interfaceDocumentBlobManager- Parameters:
doc- the document
-
notifyAfterCopy
Description copied from interface:DocumentBlobManagerNotifies the blob manager that the document has been copied.- Specified by:
notifyAfterCopyin interfaceDocumentBlobManager- Parameters:
doc- the new document, the result of the copy
-
notifyBeforeRemove
Description copied from interface:DocumentBlobManagerNotifies the blob manager that the document is about to be removed.- Specified by:
notifyBeforeRemovein interfaceDocumentBlobManager- Parameters:
doc- the document
-
notifySetRetainUntil
Description copied from interface:DocumentBlobManagerNotifies the blob manager that the document's retention date was changed.- Specified by:
notifySetRetainUntilin interfaceDocumentBlobManager- Parameters:
doc- the document
-
notifySetLegalHold
Description copied from interface:DocumentBlobManagerNotifies the blob manager that the document's legal hold status was changed.- Specified by:
notifySetLegalHoldin interfaceDocumentBlobManager- Parameters:
doc- the document
-
getRetainableBlobs
-
findBlobs
-
updateRetainedBlobs
-
updateBlob
- Since:
- 2023
-
updateBlob
Update main blob of the doc. -
getMainBlob
-
getBlob
-
stripBlobKeyPrefix
-
getGarbageCollectors
-
checkCanDeleteBlob
Description copied from interface:DocumentBlobManagerChecks that blobs can be safely deleted for the given repository. If the call returns without throwing an Exception, blobs can be safely deleted callingDocumentBlobManager.deleteBlob(String, String, boolean).- Specified by:
checkCanDeleteBlobin interfaceDocumentBlobManager- Parameters:
repositoryName- the repositoryName
-
deleteBlob
Description copied from interface:DocumentBlobManagerDeletes the blob associated to the given key. The method checks that the blob key is not referenced by any document of the given repository.The repositories must have the
Repository.CAPABILITY_QUERY_BLOB_KEYScapability (i.e. ecm:blobKeys populated).- Specified by:
deleteBlobin interfaceDocumentBlobManager- Parameters:
repositoryName- the repository where the blob key comes fromkey- the blob keydryRun- if false, effectively deletes the blob, dry run otherwise- Returns:
- true if the blob has been deleted, false if the blob is referenced and cannot be deleted
- Throws:
IOException- when reading/deleting the blob from the underlying blob provider
-
denormalizeKeySuffix
For any suffixed key in the given set, also add the unsuffixed key.["key1@version1"] -> ["key1", "key1@version1"]
-
garbageCollectBinaries
Description copied from interface:DocumentBlobManagerGarbage collect the unused binaries.- Specified by:
garbageCollectBinariesin interfaceDocumentBlobManager- Parameters:
delete- iffalsedon't actually delete the garbage collected binaries (but still return statistics about them), iftruedelete them- Returns:
- a status about the number of garbage collected binaries
-
runInTransaction
Runs the givenSupplierin a transaction with the giventimeout.- Since:
- 11.1
-
isBinariesGarbageCollectionInProgress
public boolean isBinariesGarbageCollectionInProgress()Description copied from interface:DocumentBlobManagerChecks if a garbage collection of the binaries in progress.- Specified by:
isBinariesGarbageCollectionInProgressin interfaceDocumentBlobManager- Returns:
trueif a garbage collection of the binaries is in progress
-
isUseRepositoryName
public boolean isUseRepositoryName()Description copied from interface:DocumentBlobManagerAre the blobs from a repository stored in a provider with the same name.- Specified by:
isUseRepositoryNamein interfaceDocumentBlobManager- Returns:
- true if the blobs are dispatched to the provider with the same name than the repository
-
getProviderIds
Description copied from interface:DocumentBlobManagerGets the list of the provider ids that are used by the given repository.- Specified by:
getProviderIdsin interfaceDocumentBlobManager- Parameters:
repository- the repository name- Returns:
- the list of provider ids where blob can be dispatched for the given repository
-
readBlob(BlobInfo, Document, String)instead