public class BlobManagerComponent extends DefaultComponent implements BlobManager
Blob
s, through internally-registered
BlobProvider
s.Modifier and Type | Class and Description |
---|---|
protected static class |
BlobManagerComponent.BlobProviderDescriptorRegistry |
BlobManager.BlobInfo, BlobManager.UsageHint
Modifier and Type | Field and Description |
---|---|
protected Deque<BlobDispatcherDescriptor> |
blobDispatcherDescriptorsRegistry |
protected BlobManagerComponent.BlobProviderDescriptorRegistry |
blobProviderDescriptorsRegistry |
protected Map<String,BlobProvider> |
blobProviders |
protected static BlobDispatcher |
DEFAULT_BLOB_DISPATCHER |
protected static String |
XP |
lastModified
Constructor and Description |
---|
BlobManagerComponent() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeOldBlobProvider(String id)
We're about to change something about a contributed blob provider.
|
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.
|
Map<String,URI> |
getAvailableConversions(Blob blob,
BlobManager.UsageHint hint)
Gets a map of available MIME type conversions and corresponding
URI for a blob. |
protected BlobDispatcher |
getBlobDispatcher() |
BlobProvider |
getBlobProvider(Blob blob)
Gets the blob provider for the given blob.
|
BlobProvider |
getBlobProvider(String providerId)
Gets the blob provider with the given id.
|
protected BlobProvider |
getBlobProvider(String key,
String repositoryName) |
Map<String,BlobProvider> |
getBlobProviders()
Get the map of blob providers
|
InputStream |
getConvertedStream(Blob blob,
String mimeType,
DocumentModel doc)
Gets an
InputStream for a conversion to the given MIME type. |
protected List<BinaryGarbageCollector> |
getGarbageCollectors() |
InputStream |
getStream(Blob blob)
INTERNAL - Gets an
InputStream for the data of a managed blob. |
InputStream |
getThumbnail(Blob blob)
Gets an
InputStream for a thumbnail of a blob. |
URI |
getURI(Blob blob,
BlobManager.UsageHint hint,
javax.servlet.http.HttpServletRequest servletRequest)
Gets an
URI for the content of a blob. |
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(BlobManager.BlobInfo blobInfo,
String repositoryName)
Reads a
Blob from storage. |
protected void |
registerBlobDispatcher(BlobDispatcherDescriptor descr) |
void |
registerBlobProvider(BlobProviderDescriptor descr) |
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
protected void |
unregisterBlobDispatcher(BlobDispatcherDescriptor descr) |
void |
unregisterBlobProvider(BlobProviderDescriptor descr) |
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
String |
writeBlob(Blob blob,
Document doc)
Writes a
Blob to storage and returns its key. |
activate, applicationStarted, getAdapter, getApplicationStartedOrder, getLastModified, registerExtension, setLastModified, setModifiedNow, unregisterExtension
protected static final String XP
protected static BlobDispatcher DEFAULT_BLOB_DISPATCHER
protected Deque<BlobDispatcherDescriptor> blobDispatcherDescriptorsRegistry
protected BlobManagerComponent.BlobProviderDescriptorRegistry blobProviderDescriptorsRegistry
protected Map<String,BlobProvider> blobProviders
public BlobManagerComponent()
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()
public void registerBlobProvider(BlobProviderDescriptor descr)
public void unregisterBlobProvider(BlobProviderDescriptor descr)
protected void closeOldBlobProvider(String id)
public BlobProvider getBlobProvider(String providerId)
BlobManager
getBlobProvider
in interface BlobManager
providerId
- the blob provider idpublic Blob readBlob(BlobManager.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 BlobManager
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) 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 BlobManager
blob
- the blobdoc
- the document to which this blob belongsIOException
public BlobProvider getBlobProvider(Blob blob)
BlobManager
getBlobProvider
in interface BlobManager
public InputStream getStream(Blob blob) throws IOException
BlobManager
InputStream
for the data of a managed blob. Used by internal implementations, regular
callers should call Blob.getStream()
.getStream
in interface BlobManager
blob
- the blobIOException
public InputStream getThumbnail(Blob blob) throws IOException
BlobManager
InputStream
for a thumbnail of a blob.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
getThumbnail
in interface BlobManager
blob
- the blobIOException
public URI getURI(Blob blob, BlobManager.UsageHint hint, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
BlobManager
URI
for the content of a blob.getURI
in interface BlobManager
blob
- the blobhint
- BlobManager.UsageHint
servletRequest
- the servlet request, or null
URI
, or null
if none availableIOException
public Map<String,URI> getAvailableConversions(Blob blob, BlobManager.UsageHint hint) throws IOException
BlobManager
URI
for a blob.getAvailableConversions
in interface BlobManager
URI
, which may be emptyIOException
public InputStream getConvertedStream(Blob blob, String mimeType, DocumentModel doc) throws IOException
BlobManager
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 BlobManager
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 Map<String,BlobProvider> getBlobProviders()
BlobManager
getBlobProviders
in interface BlobManager
public void freezeVersion(Document doc)
BlobManager
freezeVersion
in interface BlobManager
doc
- the new document versionpublic void notifyChanges(Document doc, Set<String> xpaths)
BlobManager
notifyChanges
in interface BlobManager
doc
- the documentxpaths
- the set of changed xpathsprotected List<BinaryGarbageCollector> getGarbageCollectors()
public BinaryManagerStatus garbageCollectBinaries(boolean delete)
BlobManager
garbageCollectBinaries
in interface BlobManager
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)
BlobManager
BlobManager.garbageCollectBinaries(boolean)
.markReferencedBinary
in interface BlobManager
key
- the binary keyrepositoryName
- the repository namepublic boolean isBinariesGarbageCollectionInProgress()
BlobManager
isBinariesGarbageCollectionInProgress
in interface BlobManager
true
if a garbage collection of the binaries is in progressCopyright © 2015 Nuxeo SA. All rights reserved.