Package org.nuxeo.ecm.core.blob
Class AbstractBlobStore
java.lang.Object
org.nuxeo.ecm.core.blob.AbstractBlobStore
- All Implemented Interfaces:
BlobStore
- Direct Known Subclasses:
AzureBlobStore
,CachingBlobStore
,EmptyBlobStore
,GoogleStorageBlobStore
,GridFSBlobStore
,InMemoryBlobStore
,LocalBlobStore
,S3BlobStore
,TransactionalBlobStore
Basic helper implementations for a
BlobStore
.- Since:
- 11.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.blob.BlobStore
BlobStore.OptionalOrUnknown<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected final String
static final char
Separator between key and byte range (start/end, specified at end of key).protected final KeyStrategy
protected final String
-
Constructor Summary
ConstructorDescriptionAbstractBlobStore
(String blobProviderId, String name, KeyStrategy keyStrategy) AbstractBlobStore
(String name, KeyStrategy keyStrategy) -
Method Summary
Modifier and TypeMethodDescriptionboolean
copyBlobIsOptimized
(BlobStore sourceStore) Checks if blob copy/move from another blob store to this one can be done efficiently.void
deleteBlob
(BlobContext blobContext) Deletes a blob.protected String
A key may have been replaced by an async digest computation, use the new one.static ByteRange
getByteRangeFromKey
(org.apache.commons.lang3.mutable.MutableObject<String> keyHolder) Gets the key strategy used by the store.getName()
Name used for debugging / tracing.boolean
Whether this blob store has versioning.protected void
protected void
protected void
protected void
notifyAsyncDigest
(String key) protected long
Returns a random positive long.protected String
Returns a random string suitable as a key.static String
setByteRangeInKey
(String key, ByteRange byteRange) protected String
stripBlobKeyPrefix
(String key) protected String
void
transfer
(InputStream in, OutputStream out, KeyStrategy.WriteObserver writeObserver) Copies bytes from an input stream to an output stream, notifying an observer while doing this.void
transfer
(BlobWriteContext blobWriteContext, OutputStream out) Transfers a blob to an output stream, notifying an observer while doing this.void
transfer
(BlobWriteContext blobWriteContext, Path dest) Transfers a blob to a file, notifying an observer while doing this.unwrap()
If this blob store wraps another one, returns it, otherwise returns this.boolean
Whether this blob store is configured for async digest computation.writeBlob
(BlobContext blobContext) Writes a blob.writeBlob
(BlobWriteContext blobWriteContext) Writes a blob.protected String
writeBlobGeneric
(BlobWriteContext blobWriteContext) Writes the blob without using any store-to-store optimization.void
writeBlobProperties
(BlobUpdateContext blobUpdateContext) Sets properties on a blob.protected String
writeBlobUsingOptimizedCopy
(BlobWriteContext blobWriteContext) Tries to do an optimize copy to write this blob.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.BlobStore
clear, copyBlob, copyOrMoveBlob, deleteBlob, exists, getBinaryGarbageCollector, getFile, getStream, hasDefaultStorageClass, readBlob
-
Field Details
-
BYTE_RANGE_SEP
public static final char BYTE_RANGE_SEPSeparator between key and byte range (start/end, specified at end of key).Used when the blob provider is configured to allow byte ranges.
- See Also:
-
blobProviderId
-
name
-
keyStrategy
-
-
Constructor Details
-
AbstractBlobStore
-
AbstractBlobStore
- Since:
- 11.5
-
-
Method Details
-
getName
Description copied from interface:BlobStore
Name used for debugging / tracing. -
logTrace
-
logTrace
-
logTrace
-
hasVersioning
public boolean hasVersioning()Description copied from interface:BlobStore
Whether this blob store has versioning.With versioning, two writes may use the same key. The returned keys will include a different version number to distinguish the writes.
- Specified by:
hasVersioning
in interfaceBlobStore
-
getKeyStrategy
Description copied from interface:BlobStore
Gets the key strategy used by the store.- Specified by:
getKeyStrategy
in interfaceBlobStore
-
unwrap
Description copied from interface:BlobStore
If this blob store wraps another one, returns it, otherwise returns this. -
writeBlob
Description copied from interface:BlobStore
Writes a blob.- Specified by:
writeBlob
in interfaceBlobStore
- Parameters:
blobContext
- the blob context- Returns:
- the blob key
- Throws:
IOException
-
writeBlob
Description copied from interface:BlobStore
Writes a blob.Note that the returned key may be different than the one requested by the
BlobWriteContext
, if the blob store needs additional version info to retrieve it.- Specified by:
writeBlob
in interfaceBlobStore
- Parameters:
blobWriteContext
- the context of the blob write, including the blob- Returns:
- the key to use to read this blob in the future
- Throws:
IOException
-
writeBlobGeneric
Writes the blob without using any store-to-store optimization.- Throws:
IOException
- Since:
- 11.5
-
writeBlobUsingOptimizedCopy
Tries to do an optimize copy to write this blob. Returnsnull
if that's not possible.- Throws:
IOException
- Since:
- 11.5
-
useAsyncDigest
public boolean useAsyncDigest()Whether this blob store is configured for async digest computation.- Since:
- 11.5
-
writeBlobProperties
Description copied from interface:BlobStore
Sets properties on a blob.- Specified by:
writeBlobProperties
in interfaceBlobStore
- Parameters:
blobUpdateContext
- the blob update context- Throws:
IOException
-
deleteBlob
Description copied from interface:BlobStore
Deletes a blob.- Specified by:
deleteBlob
in interfaceBlobStore
- Parameters:
blobContext
- the blob context
-
copyBlobIsOptimized
Description copied from interface:BlobStore
Checks if blob copy/move from another blob store to this one can be done efficiently.- Specified by:
copyBlobIsOptimized
in interfaceBlobStore
- Parameters:
sourceStore
- the source store- Returns:
true
if the copy/move can be done efficiently
-
stripBlobKeyPrefix
-
stripBlobKeyVersionSuffix
-
setByteRangeInKey
-
getByteRangeFromKey
-
randomString
Returns a random string suitable as a key. -
randomLong
protected long randomLong()Returns a random positive long. -
transfer
Transfers a blob to a file, notifying an observer while doing this.- Parameters:
blobWriteContext
- the blob write context, to get the blob stream and write observerdest
- the destination file- Throws:
IOException
-
transfer
Transfers a blob to an output stream, notifying an observer while doing this.- Parameters:
blobWriteContext
- the blob write context, to get the blob stream and write observerout
- the output stream- Throws:
IOException
-
transfer
public void transfer(InputStream in, OutputStream out, KeyStrategy.WriteObserver writeObserver) throws IOException Copies bytes from an input stream to an output stream, notifying an observer while doing this.- Parameters:
in
- the input streamout
- the output streamwriteObserver
- the write observer- Throws:
IOException
-
notifyAsyncDigest
-
getBlobKeyReplacement
A key may have been replaced by an async digest computation, use the new one.
-