Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.jcr.value.binary
Class MongodbBinaryStore

    java.lang.Object
      org.modeshape.jcr.value.binary.AbstractBinaryStore
          org.modeshape.jcr.value.binary.MongodbBinaryStore

All Implemented Interfaces:
  BinaryStore

    public class MongodbBinaryStore

extends AbstractBinaryStore

A `BinaryStore` implementation that uses a MongoDB for persisting binary values.

Field Summary
`protected int` | `chunkSize`
`protected static BasicDBObject` | `DATA_CHUNK`
`protected static BasicDBObject` | `HEADER`

Fields inherited from class org.modeshape.jcr.value.binary.AbstractBinaryStore
`logger, MEDIUM_BUFFER_SIZE`

Fields inherited from interface org.modeshape.jcr.value.binary.BinaryStore
`DEFAULT_MINIMUM_BINARY_SIZE_IN_BYTES`

Constructor Summary
`MongodbBinaryStore(String database, Set<String> replicaSet)` Creates new store.
`MongodbBinaryStore(String database, String username, String password, Set<String> replicaSet)` Creates new store.

Method Summary
`Iterable<BinaryKey>` | `getAllBinaryKeys()` Obtain an iterable implementation containing all of the store's binary keys.
`int` | `getChunkSize()` Gets the size of the chunk used to store content.
`String` | `getExtractedText(BinaryValue source)` Returns the extracted text of a binary value, or `null` if such text hasn't been stored previously or if the binary value cannot be found in this store.
`InputStream` | `getInputStream(BinaryKey key)` Get an `InputStream` to the binary content with the supplied key.
`protected String` | `getStoredMimeType(BinaryValue source)` Returns the stored mime-type of a binary value.
`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` | `removeValuesUnusedLongerThan(long minimumAge, TimeUnit unit)` Remove binary values that have been `unused` for at least the specified amount of time.
`void` | `setChunkSize(int chunkSize)` Modifies chunk size used to store content.
`void` | `start()` Initialize the store and get ready for use.
`void` | `storeExtractedText(BinaryValue source, String extractedText)` Stores the extracted text of a binary value into this store.
`protected void` | `storeMimeType(BinaryValue source, String mimeType)` Stores the given mime-type for a binary value.
`BinaryValue` | `storeValue(InputStream stream)` Store the binary value and return the JCR representation.

Methods inherited from class org.modeshape.jcr.value.binary.AbstractBinaryStore
`bestBufferSize, detector, extractors, getMimeType, getMinimumBinarySizeInBytes, getText, setMimeTypeDetector, setMinimumBinarySizeInBytes, setTextExtractors, shutdown`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### HEADER

    protected static final BasicDBObject HEADER

### DATA_CHUNK

    protected static final BasicDBObject DATA_CHUNK

### chunkSize

    protected int chunkSize

Constructor Detail

### MongodbBinaryStore

    public MongodbBinaryStore(String database,
                              Set<String> replicaSet)

  Creates new store.

  Parameters:
    `database` - database name
    `replicaSet` - list of server addresses in the form 'host:port' or null for localhost

### MongodbBinaryStore

    public MongodbBinaryStore(String database,
                              String username,
                              String password,
                              Set<String> replicaSet)

  Creates new store.

  Parameters:
    `database` - database name
    `username` - database user
    `password` - user's password
    `replicaSet` - list of server addresses in the form 'host:port' or null for localhost

Method Detail

### getChunkSize

    public int getChunkSize()

  Gets the size of the chunk used to store content.

  Returns:
    chunk size in bytes.

### setChunkSize

    public void setChunkSize(int chunkSize)

  Modifies chunk size used to store content.

  Parameters:
    `chunkSize` - chunk size in bytes.

### storeValue

    public BinaryValue storeValue(InputStream stream)
                           throws BinaryStoreException

  Description copied from interface: `BinaryStore`
  Store the binary value and return the JCR representation. Note that if the binary content in the supplied stream is already persisted in the store, the store may simply return the binary value referencing the existing content.

  Parameters:
    `stream` - the stream containing the binary content to be stored; may not be null
  Returns:
    the binary value representing the stored binary value; never null
  Throws:
    `BinaryStoreException`

### getInputStream

    public InputStream getInputStream(BinaryKey key)
                               throws BinaryStoreException

  Description copied from interface: `BinaryStore`
  Get an `InputStream` to the binary content with the supplied key.

  Parameters:
    `key` - the key to the binary content; never null
  Returns:
    the input stream through which the content can be read, `never null`
  Throws:
    `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.

### markAsUnused

    public void markAsUnused(Iterable<BinaryKey> keys)

  Description copied from interface: `BinaryStore`
  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. This method ignores any keys for values not stored within this store.

  Parameters:
    `keys` - the keys for the binary values that are no longer needed

### removeValuesUnusedLongerThan

    public void removeValuesUnusedLongerThan(long minimumAge,
                                             TimeUnit unit)

  Description copied from interface: `BinaryStore`
  Remove binary values that have been `unused` for at least the specified amount of time.

  Parameters:
    `minimumAge` - the minimum time that a binary value has been `unused` before it can be removed; must be non-negative
    `unit` - the time unit for the minimum age; may not be null

### storeMimeType

    protected void storeMimeType(BinaryValue source,
                                 String mimeType)
                          throws BinaryStoreException

  Description copied from class: `AbstractBinaryStore`
  Stores the given mime-type for a binary value.

  Overrides:
    `storeMimeType` in class `AbstractBinaryStore`
  Parameters:
    `source` - a `non-null` `BinaryValue`
    `mimeType` - a non-empty `String`
  Throws:
    `BinaryStoreException` - if there's a problem accessing the binary store

### getStoredMimeType

    protected String getStoredMimeType(BinaryValue source)
                                throws BinaryStoreException

  Description copied from class: `AbstractBinaryStore`
  Returns the stored mime-type of a binary value.

  Overrides:
    `getStoredMimeType` in class `AbstractBinaryStore`
  Parameters:
    `source` - a `non-null` `BinaryValue`
  Returns:
    either a non-empty `String` if a stored mimetype exists, or `null` if such a value doesn't exist yet.
  Throws:
    `BinaryStoreException` - if there's a problem accessing the binary store

### storeExtractedText

    public void storeExtractedText(BinaryValue source,
                                   String extractedText)
                            throws BinaryStoreException

  Description copied from interface: `BinaryStore`
  Stores the extracted text of a binary value into this store.

  Parameters:
    `source` - a `non-null` `BinaryValue` instance from which the text was extracted
    `extractedText` - a `non-null` and `non-blank` string representing the extracted text
  Throws:
    `BinaryStoreException` - if the operation fails or if the extracted text cannot be stored for the given binary value (regardless of the reason)

### getExtractedText

    public String getExtractedText(BinaryValue source)
                            throws BinaryStoreException

  Description copied from interface: `BinaryStore`
  Returns the extracted text of a binary value, or `null` if such text hasn't been stored previously or if the binary value cannot be found in this store.

  Parameters:
    `source` - a `non-null` `BinaryValue` instance from which the text was extracted
  Returns:
    a `String` representing the extracted text, or `null` if such text hasn't been stored in this store previously.
  Throws:
    `BinaryStoreException` - if anything unexpected happens.

### getAllBinaryKeys

    public Iterable<BinaryKey> getAllBinaryKeys()

  Description copied from interface: `BinaryStore`
  Obtain an iterable implementation containing all of the store's binary keys. The resulting iterator may be lazy, in the sense that it may determine additional `BinaryKey`s only as the iterator is used.

  Returns:
    the iterable set of binary keys; never null

### start

    public void start()

  Description copied from class: `AbstractBinaryStore`
  Initialize the store and get ready for use.

  Overrides:
    `start` in class `AbstractBinaryStore`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.