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
public class DocumentBlobManagerComponent extends DefaultComponent implements DocumentBlobManager
- Since:
- 9.2
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
BINARY_GC_TX_TIMEOUT_SEC
protected Deque<BlobDispatcherDescriptor>
blobDispatcherDescriptorsRegistry
protected static BlobDispatcher
DEFAULT_BLOB_DISPATCHER
protected static String
MAIN_BLOB_XPATH
protected static String
XP
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description DocumentBlobManagerComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
deactivate(ComponentContext context)
Deactivates the component.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)
BinaryManagerStatus
garbageCollectBinaries(boolean delete)
Garbage collect the unused binaries.protected BlobDispatcher
getBlobDispatcher()
protected BlobProvider
getBlobProvider(String providerId)
protected BlobProvider
getBlobProvider(String key, String repositoryName)
InputStream
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>
getGarbageCollectors()
protected ManagedBlob
getMainBlob(Document doc)
boolean
isBinariesGarbageCollectionInProgress()
Checks if a garbage collection of the binaries in progress.void
markReferencedBinary(String key, String repositoryName)
INTERNAL.void
notifyAfterCopy(Document doc)
Notifies the blob manager that the document has been copied.void
notifyBeforeRemove(Document doc)
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.Blob
readBlob(BlobInfo blobInfo, String repositoryName)
Deprecated.since 11.1, usereadBlob(BlobInfo, Document, String)
insteadBlob
readBlob(BlobInfo blobInfo, Document doc, String xpath)
Reads aBlob
from storage.protected Blob
readBlob(BlobInfo blobInfo, Document doc, String xpath, String repositoryName)
protected void
registerBlobDispatcher(BlobDispatcherDescriptor descr)
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)
protected void
unregisterBlobDispatcher(BlobDispatcherDescriptor descr)
void
unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
void
updateBlob(Document doc, Consumer<BlobUpdateContext> contextFiller)
String
writeBlob(Blob blob, Document doc, String xpath)
Writes aBlob
to storage and returns its key.-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, 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
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
XP
protected static final String XP
- See Also:
- Constant Field Values
-
DEFAULT_BLOB_DISPATCHER
protected static final BlobDispatcher DEFAULT_BLOB_DISPATCHER
-
BINARY_GC_TX_TIMEOUT_SEC
protected static final int BINARY_GC_TX_TIMEOUT_SEC
- See Also:
- Constant Field Values
-
MAIN_BLOB_XPATH
protected static final String MAIN_BLOB_XPATH
- See Also:
- Constant Field Values
-
blobDispatcherDescriptorsRegistry
protected Deque<BlobDispatcherDescriptor> blobDispatcherDescriptorsRegistry
-
-
Constructor Detail
-
DocumentBlobManagerComponent
public DocumentBlobManagerComponent()
-
-
Method Detail
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
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
-
registerBlobDispatcher
protected void registerBlobDispatcher(BlobDispatcherDescriptor descr)
-
unregisterBlobDispatcher
protected void unregisterBlobDispatcher(BlobDispatcherDescriptor descr)
-
getBlobDispatcher
protected BlobDispatcher getBlobDispatcher()
-
getBlobProvider
protected BlobProvider getBlobProvider(String providerId)
-
getDocumentBlobProvider
protected DocumentBlobProvider getDocumentBlobProvider(Blob blob)
-
readBlob
public Blob readBlob(BlobInfo blobInfo, Document doc, String xpath) throws IOException
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 public Blob readBlob(BlobInfo blobInfo, String repositoryName) throws IOException
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
protected BlobProvider getBlobProvider(String key, String repositoryName)
-
writeBlob
public String writeBlob(Blob blob, Document doc, String xpath) throws IOException
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
-
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
protected void freezeVersion(Document.BlobAccessor accessor, Document doc)
-
freezeVersion
public void freezeVersion(Document doc)
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
public void notifyChanges(Document doc, Set<String> xpaths)
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
public void notifyMakeRecord(Document doc)
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
public void notifyAfterCopy(Document doc)
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
public void notifyBeforeRemove(Document doc)
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
public void notifySetRetainUntil(Document doc, Calendar retainUntil)
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
public void notifySetLegalHold(Document doc, boolean hold)
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
-
updateBlob
public void updateBlob(Document doc, Consumer<BlobUpdateContext> contextFiller)
-
getMainBlob
protected ManagedBlob getMainBlob(Document doc)
-
stripBlobKeyPrefix
protected String stripBlobKeyPrefix(String key)
-
getGarbageCollectors
protected List<BinaryGarbageCollector> getGarbageCollectors()
-
garbageCollectBinaries
public BinaryManagerStatus garbageCollectBinaries(boolean delete)
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
protected <R> R runInTransaction(Supplier<R> supplier, int timeout)
Runs the givenSupplier
in a transaction with the giventimeout
.- Since:
- 11.1
-
markReferencedBinary
public void markReferencedBinary(String key, String repositoryName)
Description copied from interface:DocumentBlobManager
INTERNAL. Marks a binary as referenced during garbage collection. Called back by repository implementations duringDocumentBlobManager.garbageCollectBinaries(boolean)
.- Specified by:
markReferencedBinary
in interfaceDocumentBlobManager
- Parameters:
key
- the binary keyrepositoryName
- the repository name
-
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
-
-