@ThreadSafe public interface BinaryStore
minimum threshold size
are stored in the store; smaller binary values are kept in-memory
and are stored within the nodes.Modifier and Type | Method and Description |
---|---|
Iterable<BinaryKey> |
getAllBinaryKeys()
Obtain an iterable implementation containing all of the store's binary keys of those binaries that are in use.
|
InputStream |
getInputStream(BinaryKey key)
Get an
InputStream to the binary content with the supplied key. |
String |
getMimeType(BinaryValue binary,
String name)
Get the MIME type for this binary value, never
null . |
long |
getMinimumBinarySizeInBytes()
Get the minimum number of bytes that a binary value must contain before it can be stored in the binary store.
|
String |
getText(BinaryValue binary)
Get the text that can be extracted from this binary content.
|
boolean |
hasBinary(BinaryKey key)
Searches for a binary which has the given key in this store.
|
void |
markAsUnused(Iterable<BinaryKey> keys)
Mark the supplied binary keys as unused, but keep them in quarantine until needed again (at which point they're removed from
quarantine) or until
removeValuesUnusedLongerThan(long, TimeUnit) is called. |
void |
markAsUsed(Iterable<BinaryKey> keys)
Marks the binary with supplied keys as used.
|
void |
removeValuesUnusedLongerThan(long minimumAge,
TimeUnit unit)
Remove binary values that have been
unused for at least the specified amount of time. |
void |
setMimeTypeDetector(MimeTypeDetector mimeTypeDetector)
Set the MIME type detector that can be used for determining the MIME type for binary content.
|
void |
setMinimumBinarySizeInBytes(long minSizeInBytes)
Set the minimum number of bytes that a binary value must contain before it can be stored in the binary store.
|
void |
setTextExtractors(TextExtractors textExtractors)
Set the text extractor that can be used for extracting text from binary content.
|
void |
shutdown()
Shuts down the store.
|
void |
start()
Initialize the store and get ready for use.
|
BinaryValue |
storeValue(InputStream stream,
boolean markAsUnused)
Store the binary value and return the JCR representation.
|
BinaryValue |
storeValue(InputStream stream,
String hint,
boolean markAsUnused)
Store the binary value and return the JCR representation.
|
void start()
void shutdown()
long getMinimumBinarySizeInBytes()
void setMinimumBinarySizeInBytes(long minSizeInBytes)
minSizeInBytes
- the minimum number of bytes for a stored binary value; may not be negativevoid setTextExtractors(TextExtractors textExtractors)
textExtractors
- a non-null TextExtractors
instancevoid setMimeTypeDetector(MimeTypeDetector mimeTypeDetector)
mimeTypeDetector
- the detector; may not be null
BinaryValue storeValue(InputStream stream, boolean markAsUnused) throws BinaryStoreException
stream
- the stream containing the binary content to be stored; may not be nullmarkAsUnused
- a boolean
which indicates if the binary will be stored as unused or not. Binaries used from
normal sessions (via properties) will normally be stored as unused and they will be marked as used only on tx commit.BinaryStoreException
- if there any unexpected problemBinaryValue storeValue(InputStream stream, String hint, boolean markAsUnused) throws BinaryStoreException
stream
- the stream containing the binary content to be stored; may not be nullhint
- a hint that the BinaryStore may use to make storage decisions about this input streammarkAsUnused
- a boolean
which indicates if the binary will be stored as unused or not. Binaries used from
normal sessions (via properties) will normally be stored as unused and they will be marked as used only on tx commit.BinaryStoreException
- if there any unexpected problemInputStream getInputStream(BinaryKey key) throws BinaryStoreException
InputStream
to the binary content with the supplied key. The input stream will be returned as long as
the binary value has not been removed, so expired binary values should be included here as well.key
- the key to the binary content; never nullnever null
BinaryStoreException
- if there is a problem reading the content from the store or if a valid, non-null
InputStream
cannot be returned for the given key.boolean hasBinary(BinaryKey key)
true
as long the binary
is still present physically, regardless of any "trash" semantics.key
- a non-null BinaryKey
instancetrue
if a binary with this key exists in this store, false
otherwise.void markAsUsed(Iterable<BinaryKey> keys) throws BinaryStoreException
keys
- a BinaryKey
Iterable
, may not be nullBinaryStoreException
- if anything unexpected fails.void markAsUnused(Iterable<BinaryKey> keys) throws BinaryStoreException
removeValuesUnusedLongerThan(long, TimeUnit)
is called. This method ignores any keys for
values not stored within this store.keys
- the keys for the binary values that are no longer neededBinaryStoreException
- if there is a problem marking any of the supplied binary values as unusedvoid removeValuesUnusedLongerThan(long minimumAge, TimeUnit unit) throws BinaryStoreException
unused
for at least the specified amount of time.minimumAge
- the minimum time that a binary value has been unused
before it can be
removed; must be non-negativeunit
- the time unit for the minimum age; may not be nullBinaryStoreException
- if there is a problem removing the unused valuesString getText(BinaryValue binary) throws BinaryStoreException
null
If extraction is enabled, this method may block until a text extractor has finished extracting the text.
If there are any problems either with the binary value or during the extraction process, the exception will be logged and
null
is returned
AbstractBinaryStore
should be enough and any custom BinaryStore
implementations aren't expected to implement this.binary
- the binary content; may not be nullBinaryStoreException
- if the binary content could not be accessed or if the given binary value cannot be found
within the store.String getMimeType(BinaryValue binary, String name) throws IOException, RepositoryException
null
.
If the store has never determined the mime-type of the given binary and the binary can be located in the store, it will
attempt to determine it via the configured detectors
and store it.
binary
- the binary content; may not be nullname
- the name of the content, useful for determining the MIME type; may be null if not knownnull
if none of the detectors can
determine it.IOException
- if there is a problem reading the binary contentBinaryStoreException
- if the binary value cannot be found in the storeRepositoryException
- if any other error occurs.Iterable<BinaryKey> getAllBinaryKeys() throws BinaryStoreException
BinaryKey
s only as the iterator is used.BinaryStoreException
- if anything unexpected happens.Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.