org.modeshape.jcr.cache.document

## Interface DocumentStore

- All Known Implementing Classes:
    FederatedDocumentStore, LocalDocumentStore

      public interface DocumentStore

  A store which persists/retrieves documents.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsKey(String key)` Determine whether the database contains an entry with the supplied key.
    `String` | `createExternalProjection(String projectedNodeKey, String sourceName, String externalPath, String alias)` Creates an external projection from the federated node with the given key, towards the external node from the given path, from a source.
    `SchematicEntry` | `get(String key)` Get the entry with the supplied key.
    `Document` | `getChildReference(String parentKey, String childKey)` Returns a document representing a single child reference from the supplied parent to the supplied child.
    `Document` | `getChildrenBlock(String key)` Returns a document representing a block of children, that has the given key.
    `ExternalBinaryValue` | `getExternalBinary(String sourceName, String id)` Retrieves a binary value which has the given id and which is not stored by ModeShape.
    `String` | `getLocalSourceKey()` Returns the value of the local repository source key.
    `LocalDocumentStore` | `localStore()` Returns a local store instance which will use the local Infinispan cache to store/retrieve information.
    `String` | `newDocumentKey(String parentKey, Name documentName, Name documentPrimaryType)` Generates a new key which will be assigned to a new child document when it is being added to its parent.
    `boolean` | `prepareDocumentsForUpdate(Collection<String> keys)` Prepare to update all of the documents with the given keys.
    `boolean` | `remove(String key)` Remove the existing document at the given key.
    `void` | `setLocalSourceKey(String sourceKey)` Sets the value of the local repository source key.
    `SchematicEntry` | `storeDocument(String key, Document document)` Store the supplied document at the given key.
    `TransactionManager` | `transactionManager()` Returns a transaction manager instance which can be used to manage transactions for this document store.
    `void` | `updateDocument(String key, Document document, SessionNode sessionNode)` Updates the content of the document at the given key with the given document.
    `boolean` | `updatesRequirePreparing()` Return whether `prepareDocumentsForUpdate(Collection)` should be called before updating the documents.
    `XAResource` | `xaResource()` Returns a resource used in distributed transactions

- - ### Method Detail

    - #### get

          SchematicEntry get(String key)

      Get the entry with the supplied key.
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        the entry, or null if there was no document with the supplied key
      Throws:
        `DocumentStoreException` - if there is a problem retrieving the document

    - #### storeDocument

          SchematicEntry storeDocument(String key,
                                     Document document)

      Store the supplied document at the given key.
      Parameters:
        `key` - the key or identifier for the document
        `document` - the document that is to be stored
      Returns:
        the existing entry for the supplied key, or null if there was no entry and the put was successful
      Throws:
        `DocumentStoreException` - if there is a problem storing the document

    - #### updateDocument

          void updateDocument(String key,
                            Document document,
                            SessionNode sessionNode)

      Updates the content of the document at the given key with the given document.
      Parameters:
        `key` - the key or identifier for the document
        `document` - the content with which the existing document should be updated
        `sessionNode` - the `SessionNode` instance which contains the changes that caused the update
      Throws:
        `DocumentStoreException` - if there is a problem updating the document

    - #### newDocumentKey

          String newDocumentKey(String parentKey,
                              Name documentName,
                              Name documentPrimaryType)

      Generates a new key which will be assigned to a new child document when it is being added to its parent.
      Parameters:
        `parentKey` - a `non-null` `String`, the key of the existing parent
        `documentName` - `non-null` `Name`, the name of the new child document.
        `documentPrimaryType` - `non-null` `Name`, the name of the primary type of the new child document
      Returns:
        a `String` which will be assigned as key to the new child, or `null` indicating that no preferred key is to be used. If this is the case, the repository will assign a random key.

    - #### updatesRequirePreparing

          boolean updatesRequirePreparing()

      Return whether `prepareDocumentsForUpdate(Collection)` should be called before updating the documents.
      Returns:
        true if `prepareDocumentsForUpdate(Collection)` should be called, or false otherwise

    - #### prepareDocumentsForUpdate

          boolean prepareDocumentsForUpdate(Collection<String> keys)

      Prepare to update all of the documents with the given keys.
      Parameters:
        `keys` - the set of keys identifying the documents that are to be updated via `updateDocument(String, Document, SessionNode)` or via `get(String)` followed by `SchematicEntry.editDocumentContent()`.
      Returns:
        true if the documents were locked, or false if not all of the documents could be locked
      Throws:
        `DocumentStoreException` - if there is an error or problem while obtaining the locks

    - #### remove

          boolean remove(String key)

      Remove the existing document at the given key.
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        true if a document was removed, or false if there was no document with that key
      Throws:
        `DocumentStoreException` - if there is a problem removing the document

    - #### containsKey

          boolean containsKey(String key)

      Determine whether the database contains an entry with the supplied key.
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        true if the database contains an entry with this key, or false otherwise

    - #### setLocalSourceKey

          void setLocalSourceKey(String sourceKey)

      Sets the value of the local repository source key.
      Parameters:
        `sourceKey` - a `non-null` string

    - #### getLocalSourceKey

          String getLocalSourceKey()

      Returns the value of the local repository source key.
      Returns:
        a `non-null` string

    - #### transactionManager

          TransactionManager transactionManager()

      Returns a transaction manager instance which can be used to manage transactions for this document store.
      Returns:
        a `TransactionManager` instance, never null.

    - #### xaResource

          XAResource xaResource()

      Returns a resource used in distributed transactions
      Returns:
        an `instance` or `null`

    - #### localStore

          LocalDocumentStore localStore()

      Returns a local store instance which will use the local Infinispan cache to store/retrieve information.
      Returns:
        a non-null `LocalDocumentStore` instance.

    - #### createExternalProjection

          String createExternalProjection(String projectedNodeKey,
                                        String sourceName,
                                        String externalPath,
                                        String alias)

      Creates an external projection from the federated node with the given key, towards the external node from the given path, from a source.
      Parameters:
        `projectedNodeKey` - a `non-null` string, the key of the federated node which will contain the projection
        `sourceName` - a `non-null` string, the name of an external source.
        `externalPath` - a `non-null` string, representing a path towards a node from the source
        `alias` - a `non-null` string, representing the alias given to the projection.
      Returns:
        a `non-null` string representing the node key of the external node located at `externalPath`.

    - #### getChildrenBlock

          Document getChildrenBlock(String key)

      Returns a document representing a block of children, that has the given key.
      Parameters:
        `key` - a `non-null` String the key of the block
      Returns:
        either a `Document` with children and possibly a pointer to the next block, or `null` if there isn't a block with such a key.

    - #### getChildReference

          Document getChildReference(String parentKey,
                                   String childKey)

      Returns a document representing a single child reference from the supplied parent to the supplied child. This method is called when it is too expensive to find the child reference within the child references.
      Parameters:
        `parentKey` - the key for the parent
        `childKey` - the key for the child
      Returns:
        the document representation of a child reference, or null if the implementation doesn't support this method or the parent does not contain a child with the given key

    - #### getExternalBinary

          ExternalBinaryValue getExternalBinary(String sourceName,
                                              String id)

      Retrieves a binary value which has the given id and which is not stored by ModeShape.
      Parameters:
        `sourceName` - a `non-null` String; the name of an external source
        `id` - a `non-null` String; the id of an external binary value
      Returns:
        either an `ExternalBinaryValue` implementation or `null`

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