Package org.nuxeo.ecm.core.blob
Class BlobManagerComponent
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.core.blob.BlobManagerComponent
-
- All Implemented Interfaces:
BlobManager
,Adaptable
,Component
,Extensible
,TimestampedService
public class BlobManagerComponent extends DefaultComponent implements BlobManager
Implementation of the service managing the storage and retrieval ofBlob
s, through internally-registeredBlobProvider
s.- Since:
- 7.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
BlobManagerComponent.BlobProviderDescriptorRegistry
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.blob.BlobManager
BlobManager.UsageHint
-
-
Field Summary
Fields Modifier and Type Field Description protected static Duration
BLOB_DELETION_DELAY_DEFAULT
protected static String
BLOB_DELETION_DELAY_PROP
protected static String
BLOB_DELETION_KV
static String
BLOB_KEY_REPLACEMENT_KV
protected static Duration
BLOB_KEY_REPLACEMENT_TTL
protected BlobManagerComponent.BlobProviderDescriptorRegistry
blobProviderDescriptorsRegistry
protected Map<String,BlobProvider>
blobProviders
static String
DEFAULT_ID
static String
TRANSIENT_ID_PREFIX
Blob providers whose id starts with this prefix are automatically marked transient.protected static String
XP
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description BlobManagerComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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
deleteBlob(String k)
Deletes a blob.void
deleteBlobsMarkedForDeletion()
Deletes the blobs marked for deletion, if enough time has elapsed.Map<String,URI>
getAvailableConversions(Blob blob, BlobManager.UsageHint hint)
Gets a map of available MIME type conversions and correspondingURI
for a blob.protected KeyValueStore
getBlobDeletionKeyValueStore()
String
getBlobKeyReplacement(String blobProviderId, String key)
Gets the replacement (if any) for a blob key.protected KeyValueStore
getBlobKeyReplacementKeyValuestore()
BlobProvider
getBlobProvider(String providerId)
Gets the blob provider with the given id.BlobProvider
getBlobProvider(Blob blob)
Gets the blob provider for the given blob.Map<String,BlobProvider>
getBlobProviders()
Get the map of blob providersBlobProvider
getBlobProviderWithNamespace(String providerId, String defaultId)
Gets the blob provider with the given id, or, if none has been registered, a namespaced version of the blob provider with the given default id.File
getFile(Blob blob)
Deprecated.InputStream
getStream(Blob blob)
Deprecated.InputStream
getThumbnail(Blob blob)
Gets anInputStream
for a thumbnail of a blob.URI
getURI(Blob blob, BlobManager.UsageHint hint, javax.servlet.http.HttpServletRequest servletRequest)
Gets anURI
for the content of a blob.void
markBlobForDeletion(String blobProviderId, String key)
Marks the given blob for deletion at a later time.void
registerBlobProvider(BlobProviderDescriptor descr)
void
registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
void
setBlobKeyReplacement(String blobProviderId, String key, String newKey)
Records the fact that a blob key has been replaced by another one.void
unregisterBlobProvider(BlobProviderDescriptor descr)
void
unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
-
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.ecm.core.blob.BlobManager
getBlobProviderWithNamespace
-
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_ID
public static final String DEFAULT_ID
- See Also:
- Constant Field Values
-
TRANSIENT_ID_PREFIX
public static final String TRANSIENT_ID_PREFIX
Blob providers whose id starts with this prefix are automatically marked transient.- Since:
- 10.10
- See Also:
BlobProvider.isTransient()
, Constant Field Values
-
BLOB_KEY_REPLACEMENT_KV
public static final String BLOB_KEY_REPLACEMENT_KV
- Since:
- 11.5
- See Also:
- Constant Field Values
-
BLOB_KEY_REPLACEMENT_TTL
protected static final Duration BLOB_KEY_REPLACEMENT_TTL
-
BLOB_DELETION_KV
protected static final String BLOB_DELETION_KV
- See Also:
- Constant Field Values
-
BLOB_DELETION_DELAY_PROP
protected static final String BLOB_DELETION_DELAY_PROP
- See Also:
- Constant Field Values
-
BLOB_DELETION_DELAY_DEFAULT
protected static final Duration BLOB_DELETION_DELAY_DEFAULT
-
blobProviderDescriptorsRegistry
protected BlobManagerComponent.BlobProviderDescriptorRegistry blobProviderDescriptorsRegistry
-
blobProviders
protected Map<String,BlobProvider> blobProviders
-
-
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
-
registerBlobProvider
public void registerBlobProvider(BlobProviderDescriptor descr)
-
unregisterBlobProvider
public void unregisterBlobProvider(BlobProviderDescriptor descr)
-
closeOldBlobProvider
protected void closeOldBlobProvider(String id)
We're about to change something about a contributed blob provider. Close the old one.
-
getBlobProvider
public BlobProvider getBlobProvider(String providerId)
Description copied from interface:BlobManager
Gets the blob provider with the given id.- Specified by:
getBlobProvider
in interfaceBlobManager
- Parameters:
providerId
- the blob provider id- Returns:
- the blob provider
-
getBlobProviderWithNamespace
public BlobProvider getBlobProviderWithNamespace(String providerId, String defaultId)
Description copied from interface:BlobManager
Gets the blob provider with the given id, or, if none has been registered, a namespaced version of the blob provider with the given default id.- Specified by:
getBlobProviderWithNamespace
in interfaceBlobManager
- Parameters:
providerId
- the blob provider id or namespacedefaultId
- the blob provider to use as a fallback to create a namespaced version- Returns:
- the blob provider
-
getBlobProvider
public BlobProvider getBlobProvider(Blob blob)
Description copied from interface:BlobManager
Gets the blob provider for the given blob.- Specified by:
getBlobProvider
in interfaceBlobManager
- Returns:
- the blob provider
-
getStream
@Deprecated public InputStream getStream(Blob blob) throws IOException
Deprecated.Description copied from interface:BlobManager
Gets anInputStream
for the data of a managed blob.If the blob is managed this is equivalent to
ManagedBlob.getStream()
, otherwise returnsnull
.- Specified by:
getStream
in interfaceBlobManager
- Parameters:
blob
- the blob- Returns:
- the stream, or
null
if the blob is not managed - Throws:
IOException
-
getFile
@Deprecated public File getFile(Blob blob)
Deprecated.Description copied from interface:BlobManager
Gets aFile
(if one exists) for the data of a managed blob.If the blob is managed this is equivalent to
ManagedBlob.getFile()
, otherwise returnsnull
.- Specified by:
getFile
in interfaceBlobManager
- Parameters:
blob
- the blob- Returns:
- the file, or
null
if no underlying file is available or the blob is not managed
-
getThumbnail
public InputStream getThumbnail(Blob blob) throws IOException
Description copied from interface:BlobManager
Gets anInputStream
for a thumbnail of a blob.Like all
InputStream
, the result must be closed when done with it to avoid resource leaks.- Specified by:
getThumbnail
in interfaceBlobManager
- Parameters:
blob
- the blob- Returns:
- the thumbnail stream
- Throws:
IOException
-
getURI
public URI getURI(Blob blob, BlobManager.UsageHint hint, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
Description copied from interface:BlobManager
Gets anURI
for the content of a blob.- Specified by:
getURI
in interfaceBlobManager
- Parameters:
blob
- the blobhint
-BlobManager.UsageHint
servletRequest
- the servlet request, ornull
- Returns:
- the
URI
, ornull
if none available - Throws:
IOException
-
getAvailableConversions
public Map<String,URI> getAvailableConversions(Blob blob, BlobManager.UsageHint hint) throws IOException
Description copied from interface:BlobManager
Gets a map of available MIME type conversions and correspondingURI
for a blob.- Specified by:
getAvailableConversions
in interfaceBlobManager
- Returns:
- a map of MIME types and
URI
, which may be empty - Throws:
IOException
-
getBlobProviders
public Map<String,BlobProvider> getBlobProviders()
Description copied from interface:BlobManager
Get the map of blob providers- Specified by:
getBlobProviders
in interfaceBlobManager
- Returns:
- the list of blob providers
-
getBlobKeyReplacementKeyValuestore
protected KeyValueStore getBlobKeyReplacementKeyValuestore()
-
setBlobKeyReplacement
public void setBlobKeyReplacement(String blobProviderId, String key, String newKey)
Description copied from interface:BlobManager
Records the fact that a blob key has been replaced by another one.- Specified by:
setBlobKeyReplacement
in interfaceBlobManager
- Parameters:
blobProviderId
- the blob provider idkey
- the old blob keynewKey
- the new blob key- See Also:
BlobManager.getBlobKeyReplacement(String, String)
-
getBlobKeyReplacement
public String getBlobKeyReplacement(String blobProviderId, String key)
Description copied from interface:BlobManager
Gets the replacement (if any) for a blob key.- Specified by:
getBlobKeyReplacement
in interfaceBlobManager
- Parameters:
blobProviderId
- the blob provider idkey
- the old blob key- Returns:
- the new blob key, or the old one if there was no replacement
- See Also:
BlobManager.setBlobKeyReplacement(String, String, String)
-
getBlobDeletionKeyValueStore
protected KeyValueStore getBlobDeletionKeyValueStore()
-
markBlobForDeletion
public void markBlobForDeletion(String blobProviderId, String key)
Description copied from interface:BlobManager
Marks the given blob for deletion at a later time.- Specified by:
markBlobForDeletion
in interfaceBlobManager
- Parameters:
blobProviderId
- the blob provider idkey
- the blob key
-
deleteBlobsMarkedForDeletion
public void deleteBlobsMarkedForDeletion()
Description copied from interface:BlobManager
Deletes the blobs marked for deletion, if enough time has elapsed.- Specified by:
deleteBlobsMarkedForDeletion
in interfaceBlobManager
-
deleteBlob
protected void deleteBlob(String k)
Deletes a blob.- Parameters:
k
- the blob provider id + ":" + the blob key
-
-