|
ModeShape Distribution 3.3.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.modeshape.jcr.value.binary.CompositeBinaryStore
public class CompositeBinaryStore
A BinaryStore implementation that stores files in other BinaryStores.
This store is initialized with a map of number of BinaryStores. On retrieval,
the CompositeBinaryStore will look in all the other BinaryStores for the value.
When storing a value, the CompositeBinaryStore may receive a StorageHint that
MAY be used when determining which named BinaryStore to write to. If a storage
hint is not provided (or doesn't match a store), the value will be stored in
the default store.
| Field Summary | |
|---|---|
protected Logger |
logger
|
| Constructor Summary | |
|---|---|
CompositeBinaryStore(Map<String,BinaryStore> namedStores)
Initialize a new CompositeBinaryStore using a Map of other BinaryKeys that are keyed by an implementer-provided key. |
|
| Method Summary | |
|---|---|
BinaryStore |
findBinaryStoreContainingKey(BinaryKey key)
Get the named binary store that contains the key |
Iterable<BinaryKey> |
getAllBinaryKeys()
Obtain an iterable implementation containing all of the store's binary keys. |
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. |
Iterator<Map.Entry<String,BinaryStore>> |
getNamedStoreIterator()
Get an iterator over all the named stores |
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 key them in quarantine until needed again (at which point they're removed from quarantine) or until BinaryStore.removeValuesUnusedLongerThan(long, TimeUnit) is called. |
void |
moveValue(BinaryKey key,
String destination)
Move a BinaryKey to a named store |
BinaryKey |
moveValue(BinaryKey key,
String source,
String destination)
Move a value from one named store to another store |
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()
Shut down all the named stores |
void |
start()
Initialize the store, and initialize all the named stores. |
BinaryValue |
storeValue(InputStream stream)
Store the binary value and return the JCR representation. |
BinaryValue |
storeValue(InputStream stream,
String hint)
Store the binary value and return the JCR representation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Logger logger
| Constructor Detail |
|---|
public CompositeBinaryStore(Map<String,BinaryStore> namedStores)
namedStores - a Map of inner stores, grouped by the hint.| Method Detail |
|---|
public void start()
start in interface BinaryStorepublic void shutdown()
shutdown in interface BinaryStorepublic long getMinimumBinarySizeInBytes()
BinaryStore
getMinimumBinarySizeInBytes in interface BinaryStorepublic void setMinimumBinarySizeInBytes(long minSizeInBytes)
BinaryStore
setMinimumBinarySizeInBytes in interface BinaryStoreminSizeInBytes - the minimum number of bytes for a stored binary value; may not be negativepublic void setTextExtractors(TextExtractors textExtractors)
BinaryStore
setTextExtractors in interface BinaryStoretextExtractors - a non-null TextExtractors instancepublic void setMimeTypeDetector(MimeTypeDetector mimeTypeDetector)
BinaryStore
setMimeTypeDetector in interface BinaryStoremimeTypeDetector - the detector
public BinaryValue storeValue(InputStream stream)
throws BinaryStoreException
BinaryStore
storeValue in interface BinaryStorestream - the stream containing the binary content to be stored; may not be null
BinaryStoreException - if there any unexpected problem
public BinaryValue storeValue(InputStream stream,
String hint)
throws BinaryStoreException
BinaryStore
storeValue in interface BinaryStorestream - 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 stream
BinaryStoreException - if there any unexpected problem
public BinaryKey moveValue(BinaryKey key,
String source,
String destination)
throws BinaryStoreException
key - Binary key to transfer from the source store to the destination storesource - a hint for discovering the source repository; may be nulldestination - a hint for discovering the destination repository
BinaryKey value of the moved binary, never null
BinaryStoreException - if a source store cannot be found or the source store does not contain the binary key
public void moveValue(BinaryKey key,
String destination)
throws BinaryStoreException
key - Binary key to transfer from the source store to the destination storedestination - a hint for discovering the destination repository
BinaryStoreException - if anything unexpected fails
public InputStream getInputStream(BinaryKey key)
throws BinaryStoreException
BinaryStoreInputStream to the binary content with the supplied key.
getInputStream in interface BinaryStorekey - the key to the binary content; never null
never 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.public boolean hasBinary(BinaryKey key)
BinaryStore
hasBinary in interface BinaryStorekey - a non-null BinaryKey instance
true if a binary with this key exists in this store, false otherwise.
public void markAsUnused(Iterable<BinaryKey> keys)
throws BinaryStoreException
BinaryStoreBinaryStore.removeValuesUnusedLongerThan(long, TimeUnit) is called. This method ignores any keys for
values not stored within this store.
markAsUnused in interface BinaryStorekeys - the keys for the binary values that are no longer needed
BinaryStoreException - if there is a problem marking any of the supplied binary values as unused
public void removeValuesUnusedLongerThan(long minimumAge,
TimeUnit unit)
throws BinaryStoreException
BinaryStoreunused for at least the specified amount of time.
removeValuesUnusedLongerThan in interface BinaryStoreminimumAge - 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 null
BinaryStoreException - if there is a problem removing the unused values
public String getText(BinaryValue binary)
throws BinaryStoreException
BinaryStorenull
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.
getText in interface BinaryStorebinary - the binary content; may not be null
BinaryStoreException - if the binary content could not be accessed or if the given binary value cannot be found
within the store.
public String getMimeType(BinaryValue binary,
String name)
throws IOException,
RepositoryException
BinaryStorenull.
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.
getMimeType in interface BinaryStorebinary - the binary content; may not be nullname - the name of the content, useful for determining the MIME type; may be null if not known
null if none of the detectors can
determine it.
IOException - if there is a problem reading the binary content
BinaryStoreException - if the binary value cannot be found in the store
RepositoryException - if any other error occurs.
public Iterable<BinaryKey> getAllBinaryKeys()
throws BinaryStoreException
BinaryStoreBinaryKeys only as the iterator is used.
getAllBinaryKeys in interface BinaryStoreBinaryStoreException - if anything unexpected happens.public Iterator<Map.Entry<String,BinaryStore>> getNamedStoreIterator()
public BinaryStore findBinaryStoreContainingKey(BinaryKey key)
key - the key to the binary content; never null
|
ModeShape Distribution 3.3.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||