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
Modifier and TypeFieldDescriptionprotected static final int
protected BlobDispatcher
static final String
Event fired to GC blobs candidates for deletion.static final String
Event fired to record blob deletion.protected static final String
static final String
protected static final String
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkCanDeleteBlob
(String repositoryName) Checks that blobs can be safely deleted for the given repository.boolean
deleteBlob
(String repositoryName, String key, boolean dryRun) Deletes the blob associated to the given key.protected static void
denormalizeKeySuffix
(Set<String> queryBlobKeys) For any suffixed key in the given set, also add the unsuffixed key.protected void
void
freezeVersion
(Document doc) Freezes the blobs' versions on a document version when it is created via a check in.protected void
freezeVersion
(Document.BlobAccessor accessor, Document doc) garbageCollectBinaries
(boolean delete) Garbage collect the unused binaries.protected ManagedBlob
protected BlobDispatcher
protected String
A key may have been replaced by an async digest computation, use the new one.protected String
getBlobKeyReplacement
(ManagedBlob blob, boolean addPrefix) protected BlobProvider
getBlobProvider
(String providerId) protected BlobProvider
getBlobProvider
(String key, String repositoryName) getConvertedStream
(Blob blob, String mimeType, DocumentModel doc) Gets anInputStream
for a conversion to the given MIME type.protected DocumentBlobProvider
getDocumentBlobProvider
(Blob blob) protected List<BinaryGarbageCollector>
protected ManagedBlob
getMainBlob
(Document doc) getProviderIds
(String repository) Gets the list of the provider ids that are used by the given repository.boolean
Compute if there are shared storage.boolean
Checks if a garbage collection of the binaries in progress.boolean
Are the blobs from a repository stored in a provider with the same name.void
notifyAfterCopy
(Document doc) Notifies the blob manager that the document has been copied.void
Notifies the blob manager that the document is about to be removed.void
notifyChanges
(Document doc, Set<String> xpaths) Notifies the blob manager that a set of xpaths have changed on a document.void
notifyMakeRecord
(Document doc) Notifies the blob manager that the document was made a record.void
notifySetLegalHold
(Document doc, boolean hold) Notifies the blob manager that the document's legal hold status was changed.void
notifySetRetainUntil
(Document doc, Calendar retainUntil) Notifies the blob manager that the document's retention date was changed.Deprecated.Reads aBlob
from storage.protected Blob
void
registerContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) protected <R> R
runInTransaction
(Supplier<R> supplier, int timeout) Runs the givenSupplier
in a transaction with the giventimeout
.protected String
stripBlobKeyPrefix
(String key) void
unregisterContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) protected void
updateBlob
(ManagedBlob blob, Consumer<BlobUpdateContext> contextFiller) void
updateBlob
(Document doc, Consumer<BlobUpdateContext> contextFiller) Update main blob of the doc.protected void
updateRetainedBlobs
(Document doc, Consumer<BlobUpdateContext> contextFiller) Writes aBlob
to 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, unregisterExtension
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContribution
in classDefaultComponent
-
getBlobDispatcher
-
getBlobProvider
-
getDocumentBlobProvider
-
readBlob
Reads aBlob
from 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:
readBlob
in 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 aBlob
from 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:
readBlob
in interfaceDocumentBlobManager
- Parameters:
blobInfo
- the blob informationrepositoryName
- the repository to which this blob belongs- Returns:
- a managed blob
- Throws:
IOException
-
getBlobProvider
-
writeBlob
Writes aBlob
to storage and returns its key.The passed blob may be
null
, in which case anull
key 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:
writeBlob
in 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:DocumentBlobManager
Gets anInputStream
for 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:
getConvertedStream
in interfaceDocumentBlobManager
- Parameters:
blob
- the blobmimeType
- the MIME type to convert todoc
- the document that holds the blob- Returns:
- the stream, or
null
if no conversion is available for the given MIME type - Throws:
IOException
-
freezeVersion
-
freezeVersion
Description copied from interface:DocumentBlobManager
Freezes the blobs' versions on a document version when it is created via a check in.- Specified by:
freezeVersion
in interfaceDocumentBlobManager
- Parameters:
doc
- the new document version
-
notifyChanges
Description copied from interface:DocumentBlobManager
Notifies the blob manager that a set of xpaths have changed on a document.- Specified by:
notifyChanges
in interfaceDocumentBlobManager
- Parameters:
doc
- the documentxpaths
- the set of changed xpaths
-
notifyMakeRecord
Description copied from interface:DocumentBlobManager
Notifies the blob manager that the document was made a record.- Specified by:
notifyMakeRecord
in interfaceDocumentBlobManager
- Parameters:
doc
- the document
-
notifyAfterCopy
Description copied from interface:DocumentBlobManager
Notifies the blob manager that the document has been copied.- Specified by:
notifyAfterCopy
in interfaceDocumentBlobManager
- Parameters:
doc
- the new document, the result of the copy
-
notifyBeforeRemove
Description copied from interface:DocumentBlobManager
Notifies the blob manager that the document is about to be removed.- Specified by:
notifyBeforeRemove
in interfaceDocumentBlobManager
- Parameters:
doc
- the document
-
notifySetRetainUntil
Description copied from interface:DocumentBlobManager
Notifies the blob manager that the document's retention date was changed.- Specified by:
notifySetRetainUntil
in interfaceDocumentBlobManager
- Parameters:
doc
- the document
-
notifySetLegalHold
Description copied from interface:DocumentBlobManager
Notifies the blob manager that the document's legal hold status was changed.- Specified by:
notifySetLegalHold
in 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:DocumentBlobManager
Checks 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:
checkCanDeleteBlob
in interfaceDocumentBlobManager
- Parameters:
repositoryName
- the repositoryName
-
deleteBlob
Description copied from interface:DocumentBlobManager
Deletes 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_KEYS
capability (i.e. ecm:blobKeys populated).- Specified by:
deleteBlob
in 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:DocumentBlobManager
Garbage collect the unused binaries.- Specified by:
garbageCollectBinaries
in interfaceDocumentBlobManager
- Parameters:
delete
- iffalse
don't actually delete the garbage collected binaries (but still return statistics about them), iftrue
delete them- Returns:
- a status about the number of garbage collected binaries
-
runInTransaction
Runs the givenSupplier
in a transaction with the giventimeout
.- Since:
- 11.1
-
isBinariesGarbageCollectionInProgress
public boolean isBinariesGarbageCollectionInProgress()Description copied from interface:DocumentBlobManager
Checks if a garbage collection of the binaries in progress.- Specified by:
isBinariesGarbageCollectionInProgress
in interfaceDocumentBlobManager
- Returns:
true
if a garbage collection of the binaries is in progress
-
isUseRepositoryName
public boolean isUseRepositoryName()Description copied from interface:DocumentBlobManager
Are the blobs from a repository stored in a provider with the same name.- Specified by:
isUseRepositoryName
in interfaceDocumentBlobManager
- Returns:
- true if the blobs are dispatched to the provider with the same name than the repository
-
getProviderIds
Description copied from interface:DocumentBlobManager
Gets the list of the provider ids that are used by the given repository.- Specified by:
getProviderIds
in 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