public class BlobManagerComponent extends DefaultComponent implements BlobManager
Blob
s, through internally-registered
BlobProvider
s.BlobManager.BlobInfo, BlobManager.UsageHint
Constructor and Description |
---|
BlobManagerComponent() |
Modifier and Type | Method and 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.
|
Map<String,URI> |
getAvailableConversions(Blob blob,
BlobManager.UsageHint hint)
Gets a map of available MIME type conversions and corresponding
URI for a blob. |
BlobProvider |
getBlobProvider(String providerId)
Gets the blob provider with the given id.
|
Map<String,BlobProvider> |
getBlobProviders()
Get the map of blob providers
|
InputStream |
getConvertedStream(Blob blob,
String mimeType)
Gets an
InputStream for a conversion to the given MIME type. |
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)
Gets an
URI for the content of a blob. |
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. |
void |
registerBlobProvider(BlobProviderDescriptor descr) |
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
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, unregisterExtension
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
public void registerBlobProvider(BlobProviderDescriptor descr)
public void unregisterBlobProvider(BlobProviderDescriptor descr)
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
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 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) throws IOException
BlobManager
URI
for the content of a blob.getURI
in interface BlobManager
blob
- the blobhint
- BlobManager.UsageHint
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) 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 tonull
if no conversion is available for the given MIME typeIOException
public Map<String,BlobProvider> getBlobProviders()
BlobManager
getBlobProviders
in interface BlobManager
public void freezeVersion(Document doc) throws DocumentException
BlobManager
freezeVersion
in interface BlobManager
doc
- the new document versionDocumentException
public void notifyChanges(Document doc, Set<String> xpaths)
BlobManager
notifyChanges
in interface BlobManager
doc
- the documentxpaths
- the set of changed xpathsCopyright © 2015 Nuxeo SA. All rights reserved.