public class DocumentBlobManagerComponent extends DefaultComponent implements DocumentBlobManager
Modifier and Type | Field and Description |
---|---|
protected Deque<BlobDispatcherDescriptor> |
blobDispatcherDescriptorsRegistry |
protected static BlobDispatcher |
DEFAULT_BLOB_DISPATCHER |
protected static String |
XP |
lastModified
Constructor and Description |
---|
DocumentBlobManagerComponent() |
Modifier and Type | Method and Description |
---|---|
void |
deactivate(ComponentContext context)
Deactivates the component.
|
protected void |
freezeVersion(Document.BlobAccessor accessor,
Document doc) |
void |
freezeVersion(Document doc)
Freezes the blobs' versions on a document version when it is created via a check in.
|
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 an
InputStream for a conversion to the given MIME type. |
protected DocumentBlobProvider |
getDocumentBlobProvider(Blob blob) |
protected List<BinaryGarbageCollector> |
getGarbageCollectors() |
boolean |
isBinariesGarbageCollectionInProgress()
Checks if a garbage collection of the binaries in progress.
|
void |
markReferencedBinary(String key,
String repositoryName)
INTERNAL.
|
void |
notifyChanges(Document doc,
Set<String> xpaths)
Notifies the blob manager that a set of xpaths have changed on a document.
|
Blob |
readBlob(BlobInfo blobInfo,
String repositoryName)
Reads a
Blob from storage. |
protected void |
registerBlobDispatcher(BlobDispatcherDescriptor descr) |
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
protected void |
unregisterBlobDispatcher(BlobDispatcherDescriptor descr) |
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
String |
writeBlob(Blob blob,
Document doc,
String xpath)
Writes a
Blob to storage and returns its key. |
activate, getAdapter, getLastModified, registerExtension, setLastModified, setModifiedNow, start, stop, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted, getApplicationStartedOrder
protected static final String XP
protected static BlobDispatcher DEFAULT_BLOB_DISPATCHER
protected Deque<BlobDispatcherDescriptor> blobDispatcherDescriptorsRegistry
public DocumentBlobManagerComponent()
public void deactivate(ComponentContext context)
Component
This method is called by the runtime when a component is deactivated.
deactivate
in interface Component
deactivate
in class DefaultComponent
context
- the runtime contextpublic void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution
in class DefaultComponent
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution
in class DefaultComponent
protected void registerBlobDispatcher(BlobDispatcherDescriptor descr)
protected void unregisterBlobDispatcher(BlobDispatcherDescriptor descr)
protected BlobDispatcher getBlobDispatcher()
protected BlobProvider getBlobProvider(String providerId)
protected DocumentBlobProvider getDocumentBlobProvider(Blob blob)
public Blob readBlob(BlobInfo blobInfo, String repositoryName) throws IOException
Blob
from storage.
The BlobInfo
(coming from the database) contains the blob key, which may or may not be prefixed by a blob
provider id.
readBlob
in interface DocumentBlobManager
blobInfo
- the blob informationrepositoryName
- the repository to which this blob belongsIOException
protected BlobProvider getBlobProvider(String key, String repositoryName)
public String writeBlob(Blob blob, Document doc, String xpath) throws IOException
Blob
to storage and returns its key.
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.
writeBlob
in interface DocumentBlobManager
blob
- the blobdoc
- the document to which this blob belongsxpath
- the xpath of blob in docIOException
public InputStream getConvertedStream(Blob blob, String mimeType, DocumentModel doc) throws IOException
DocumentBlobManager
InputStream
for a conversion to the given MIME type.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
getConvertedStream
in interface DocumentBlobManager
blob
- the blobmimeType
- the MIME type to convert todoc
- the document that holds the blobnull
if no conversion is available for the given MIME typeIOException
protected void freezeVersion(Document.BlobAccessor accessor, Document doc)
public void freezeVersion(Document doc)
DocumentBlobManager
freezeVersion
in interface DocumentBlobManager
doc
- the new document versionpublic void notifyChanges(Document doc, Set<String> xpaths)
DocumentBlobManager
notifyChanges
in interface DocumentBlobManager
doc
- the documentxpaths
- the set of changed xpathsprotected List<BinaryGarbageCollector> getGarbageCollectors()
public BinaryManagerStatus garbageCollectBinaries(boolean delete)
DocumentBlobManager
garbageCollectBinaries
in interface DocumentBlobManager
delete
- if false
don't actually delete the garbage collected binaries (but still return statistics
about them), if true
delete thempublic void markReferencedBinary(String key, String repositoryName)
DocumentBlobManager
DocumentBlobManager.garbageCollectBinaries(boolean)
.markReferencedBinary
in interface DocumentBlobManager
key
- the binary keyrepositoryName
- the repository namepublic boolean isBinariesGarbageCollectionInProgress()
DocumentBlobManager
isBinariesGarbageCollectionInProgress
in interface DocumentBlobManager
true
if a garbage collection of the binaries is in progressCopyright © 2018 Nuxeo. All rights reserved.