org.modeshape.jcr.federation

## Class FederatedDocumentStore

- java.lang.Object
- - org.modeshape.jcr.federation.FederatedDocumentStore

- All Implemented Interfaces:
    DocumentStore

      public class FederatedDocumentStore
      extends Object
      implements DocumentStore

  An implementation of `DocumentStore` which is used when federation is enabled

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FederatedDocumentStore(Connectors connectors, SchematicDb localDb)` Creates a new instance with the given connectors and local db.

  - ### 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 localSourceKey)` 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.
    `protected DocumentTranslator` | `translator()`
    `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 `DocumentStore.prepareDocumentsForUpdate(Collection)` should be called before updating the documents.
    `XAResource` | `xaResource()` Returns a resource used in distributed transactions

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FederatedDocumentStore

          public FederatedDocumentStore(Connectors connectors,
                                SchematicDb localDb)

      Creates a new instance with the given connectors and local db.
      Parameters:
        `connectors` - a `non-null` `Connectors` instance
        `localDb` - a `non-null` `SchematicDb` instance

  - ### Method Detail

    - #### translator

          protected final DocumentTranslator translator()

    - #### localStore

          public LocalDocumentStore localStore()

      Description copied from interface: `DocumentStore`
      Returns a local store instance which will use the local Infinispan cache to store/retrieve information.
      Specified by:
        `localStore` in interface `DocumentStore`
      Returns:
        a non-null `LocalDocumentStore` instance.

    - #### newDocumentKey

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

      Description copied from interface: `DocumentStore`
      Generates a new key which will be assigned to a new child document when it is being added to its parent.
      Specified by:
        `newDocumentKey` in interface `DocumentStore`
      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.

    - #### storeDocument

          public SchematicEntry storeDocument(String key,
                                     Document document)

      Description copied from interface: `DocumentStore`
      Store the supplied document at the given key.
      Specified by:
        `storeDocument` in interface `DocumentStore`
      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

    - #### updateDocument

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

      Description copied from interface: `DocumentStore`
      Updates the content of the document at the given key with the given document.
      Specified by:
        `updateDocument` in interface `DocumentStore`
      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

    - #### get

          public SchematicEntry get(String key)

      Description copied from interface: `DocumentStore`
      Get the entry with the supplied key.
      Specified by:
        `get` in interface `DocumentStore`
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        the entry, or null if there was no document with the supplied key

    - #### containsKey

          public boolean containsKey(String key)

      Description copied from interface: `DocumentStore`
      Determine whether the database contains an entry with the supplied key.
      Specified by:
        `containsKey` in interface `DocumentStore`
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        true if the database contains an entry with this key, or false otherwise

    - #### remove

          public boolean remove(String key)

      Description copied from interface: `DocumentStore`
      Remove the existing document at the given key.
      Specified by:
        `remove` in interface `DocumentStore`
      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

    - #### updatesRequirePreparing

          public boolean updatesRequirePreparing()

      Description copied from interface: `DocumentStore`
      Return whether `DocumentStore.prepareDocumentsForUpdate(Collection)` should be called before updating the documents.
      Specified by:
        `updatesRequirePreparing` in interface `DocumentStore`
      Returns:
        true if `DocumentStore.prepareDocumentsForUpdate(Collection)` should be called, or false otherwise

    - #### prepareDocumentsForUpdate

          public boolean prepareDocumentsForUpdate(Collection<String> keys)

      Description copied from interface: `DocumentStore`
      Prepare to update all of the documents with the given keys.
      Specified by:
        `prepareDocumentsForUpdate` in interface `DocumentStore`
      Parameters:
        `keys` - the set of keys identifying the documents that are to be updated via `DocumentStore.updateDocument(String, Document, SessionNode)` or via `DocumentStore.get(String)` followed by `SchematicEntry.editDocumentContent()`.
      Returns:
        true if the documents were locked, or false if not all of the documents could be locked

    - #### transactionManager

          public TransactionManager transactionManager()

      Description copied from interface: `DocumentStore`
      Returns a transaction manager instance which can be used to manage transactions for this document store.
      Specified by:
        `transactionManager` in interface `DocumentStore`
      Returns:
        a `TransactionManager` instance, never null.

    - #### xaResource

          public XAResource xaResource()

      Description copied from interface: `DocumentStore`
      Returns a resource used in distributed transactions
      Specified by:
        `xaResource` in interface `DocumentStore`
      Returns:
        an `instance` or `null`

    - #### setLocalSourceKey

          public void setLocalSourceKey(String localSourceKey)

      Description copied from interface: `DocumentStore`
      Sets the value of the local repository source key.
      Specified by:
        `setLocalSourceKey` in interface `DocumentStore`
      Parameters:
        `localSourceKey` - a `non-null` string

    - #### getLocalSourceKey

          public String getLocalSourceKey()

      Description copied from interface: `DocumentStore`
      Returns the value of the local repository source key.
      Specified by:
        `getLocalSourceKey` in interface `DocumentStore`
      Returns:
        a `non-null` string

    - #### createExternalProjection

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

      Description copied from interface: `DocumentStore`
      Creates an external projection from the federated node with the given key, towards the external node from the given path, from a source.
      Specified by:
        `createExternalProjection` in interface `DocumentStore`
      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

          public Document getChildrenBlock(String key)

      Description copied from interface: `DocumentStore`
      Returns a document representing a block of children, that has the given key.
      Specified by:
        `getChildrenBlock` in interface `DocumentStore`
      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

          public Document getChildReference(String parentKey,
                                   String childKey)

      Description copied from interface: `DocumentStore`
      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.
      Specified by:
        `getChildReference` in interface `DocumentStore`
      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

          public ExternalBinaryValue getExternalBinary(String sourceName,
                                              String id)

      Description copied from interface: `DocumentStore`
      Retrieves a binary value which has the given id and which is not stored by ModeShape.
      Specified by:
        `getExternalBinary` in interface `DocumentStore`
      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.