org.modeshape.connector.git

## Class GitConnector

- java.lang.Object
- - org.modeshape.jcr.spi.federation.Connector
  - - org.modeshape.jcr.spi.federation.ReadOnlyConnector
    - - org.modeshape.connector.git.GitConnector

- All Implemented Interfaces:
    Pageable

      public class GitConnector
      extends ReadOnlyConnector
      implements Pageable

  A read-only `Connector` that accesses the content in a local Git repository that is a clone of a remote repository.

  This connector has several properties that must be configured via the `RepositoryConfiguration`:

  - `directoryPath` - The path to the folder that is or contains the `.git` data structure is to be accessed by this connector.
  - `remoteName` - The alias used by the local Git repository for the remote repository. The default is the "`origin`". If the value contains commas, the value contains an ordered list of remote aliases that should be searched; the first one to match an existing remote will be used.
  - `queryableBranches` - An array with the names of the branches that should be queryable by the repository. By default, only the master branch is queryable.

  The connector results in the following structure:

  Path | Description
  --- | ---
  `/branches/{branchName}` | The list of branches.
  `/tags/{tagName}` | The list of tags.
  `/commits/{branchOrTagNameOrCommit}/{objectId}` | The history of commits on the branch, tag or object ID name "`{branchOrTagNameOrCommit}`", where " `{objectId}`" is the object ID of the commit.
  `/commit/{branchOrTagNameOrCommit}` | The information about a particular branch, tag or commit "`{branchOrTagNameOrCommit}`".
  `/tree/{branchOrTagOrObjectId}/{filesAndFolders}/...` | The structure of the directories and files in the specified branch, tag or commit "`{branchOrTagNameOrCommit}`".

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.modeshape.jcr.spi.federation.Connector

      `Connector.ExtraProperties`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GitConnector()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ExternalBinaryValue` | `getBinaryValue(String id)` Returns a binary value which is connector specific and which is never stored by ModeShape.
    `Document` | `getChildReference(String parentKey, String childKey)` Returns a document representing a single child reference from the supplied parent to the supplied child.
    `Document` | `getChildren(PageKey pageKey)` Returns a document which represents the document of a parent node to which an optiona page of children has been added.
    `Document` | `getDocumentById(String id)` Returns a `Document` instance representing the document with a given id.
    `String` | `getDocumentId(String path)` Returns the id of an external node located at the given external path within the connector's exposed tree of content.
    `Collection<String>` | `getDocumentPathsById(String id)` Return the path(s) of the external node with the given identifier.
    `protected List<String>` | `getQueryableBranches()`
    `boolean` | `hasDocument(String id)` Checks if a document with the given id exists in the end-source.
    `protected boolean` | `includeMimeType()`
    `void` | `initialize(NamespaceRegistry registry, NodeTypeManager nodeTypeManager)` Initialize the connector.
    `protected DocumentWriter` | `newDocumentWriter(String id)`
    `protected String` | `remoteName()`
    `protected List<String>` | `remoteNames()`
    `void` | `shutdown()` Shutdown the connector by releasing all resources.

    - ### Methods inherited from class org.modeshape.jcr.spi.federation.ReadOnlyConnector

      `isReadonly, newDocumentId, removeDocument, storeDocument, updateDocument`

    - ### Methods inherited from class org.modeshape.jcr.spi.federation.Connector

      `checkFieldNotNull, extraPropertiesFor, extraPropertiesStore, factories, getCacheTtlSeconds, getContext, getEnvironment, getLogger, getMimeTypeDetector, getRepositoryName, getSourceName, getTransactionManager, isQueryable, log, nameFrom, nameFrom, nameFrom, newChildReference, newConnectorChangedSet, newDocument, newPageDocument, pathFactory, pathFrom, pathFrom, propertyFactory, readDocument, setExtraPropertiesStore, translator, writeDocument`

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

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

- - ### Constructor Detail

    - #### GitConnector

          public GitConnector()

  - ### Method Detail

    - #### initialize

          public void initialize(NamespaceRegistry registry,
                        NodeTypeManager nodeTypeManager)
                          throws RepositoryException,
                                 IOException

      Description copied from class: `Connector`
      Initialize the connector. This is called automatically by ModeShape once for each Connector instance, and should not be called by the connector. By the time this method is called, ModeShape will hav already set the `Connector.context`, `Connector.logger`, `Connector.name`, and `Connector.repositoryName` plus any fields that match configuration properties for the connector.

      By default this method does nothing, so it should be overridden by implementations to do a one-time initialization of any internal components. For example, connectors can use the supplied `registry` and `nodeTypeManager` objects to register custom namesapces and node types required by the external content.

      This is an excellent place for connector to validate the connector-specific fields set by ModeShape via reflection during instantiation.

      Overrides:
        `initialize` in class `Connector`
      Parameters:
        `registry` - the namespace registry that can be used to register custom namespaces; never null
        `nodeTypeManager` - the node type manager that can be used to register custom node types; never null
      Throws:
        `RepositoryException` - if operations on the `NamespaceRegistry` or `NodeTypeManager` fail
        `IOException` - if any stream based operations fail (like importing cnd files)

    - #### newDocumentWriter

          protected DocumentWriter newDocumentWriter(String id)

    - #### includeMimeType

          protected boolean includeMimeType()

    - #### shutdown

          public void shutdown()

      Description copied from class: `Connector`
      Shutdown the connector by releasing all resources. This is called automatically by ModeShape when this Connector instance is no longer needed, and should never be called by the connector.
      Overrides:
        `shutdown` in class `Connector`

    - #### getDocumentById

          public Document getDocumentById(String id)

      Description copied from class: `Connector`
      Returns a `Document` instance representing the document with a given id. The document should have a "proper" structure for it to be usable by ModeShape.
      Specified by:
        `getDocumentById` in class `Connector`
      Parameters:
        `id` - a `non-null` string
      Returns:
        either an `Document` instance or `null`

    - #### getChildren

          public Document getChildren(PageKey pageKey)

      Description copied from interface: `Pageable`
      Returns a document which represents the document of a parent node to which an optiona page of children has been added. In order to add a next page, `PageWriter.addPage(String, String, long, long)` should be used to add a new page of children.
      Specified by:
        `getChildren` in interface `Pageable`
      Parameters:
        `pageKey` - a `non-null` `PageKey` instance, which offers information about the page that should be retrieved.
      Returns:
        a `non-null` document representing the parent document.

    - #### getChildReference

          public Document getChildReference(String parentKey,
                                   String childKey)

      Description copied from class: `Connector`
      Returns a document representing a single child reference from the supplied parent to the supplied child. This method is called when there are an unknown number of children on a node.

      This method should be implemented and will be called if and only if a `connector uses paging` and specifies an `unknown number of children` in the `PageWriter.addPage(String, int, long, long)` or `PageWriter.addPage(String, String, long, long)` methods.

      Overrides:
        `getChildReference` in class `Connector`
      Parameters:
        `parentKey` - the key for the parent
        `childKey` - the key for the child
      Returns:
        the document representation of a child reference, of null if the parent does not contain a child with the given key

    - #### getDocumentId

          public String getDocumentId(String path)

      Description copied from class: `Connector`
      Returns the id of an external node located at the given external path within the connector's exposed tree of content.
      Specified by:
        `getDocumentId` in class `Connector`
      Parameters:
        `path` - a `non-null` string representing an external path, or "/" for the top-level node exposed by the connector
      Returns:
        either the id of the document or `null`

    - #### getDocumentPathsById

          public Collection<String> getDocumentPathsById(String id)

      Description copied from class: `Connector`
      Return the path(s) of the external node with the given identifier. The resulting paths are from the point of view of the connector. For example, the "root" node exposed by the connector wil have a path of "/".
      Specified by:
        `getDocumentPathsById` in class `Connector`
      Parameters:
        `id` - a `non-null` string
      Returns:
        the connector-specific path(s) of the node, or an empty document if there is no such document; never null

    - #### hasDocument

          public boolean hasDocument(String id)

      Description copied from class: `Connector`
      Checks if a document with the given id exists in the end-source.
      Specified by:
        `hasDocument` in class `Connector`
      Parameters:
        `id` - a `non-null` string.
      Returns:
        `true` if such a document exists, `false` otherwise.

    - #### getBinaryValue

          public ExternalBinaryValue getBinaryValue(String id)

      Description copied from class: `Connector`
      Returns a binary value which is connector specific and which is never stored by ModeShape. Connectors who need this feature must return an object that is an instance of a subclasses of `ExternalBinaryValue`, either `UrlBinaryValue` or a custom subclass with connector-specific information.

      Normally, the `Connector.getDocumentById(String)` method implementation will set binary values on properties of nodes, which should create the same ExternalBinaryValue subclass that is returned by this method. The `ExternalBinaryValue.getId()` value from that instance will be passed into this method.

      Overrides:
        `getBinaryValue` in class `Connector`
      Parameters:
        `id` - a `String` representing the identifier of the external binary which should have connector-specific meaning. This identifier need not be the SHA-1 hash of the content.
      Returns:
        either a binary value implementation or `null` if there is no such value with the given id.

    - #### remoteName

          protected final String remoteName()

    - #### remoteNames

          protected final List<String> remoteNames()

    - #### getQueryableBranches

          protected List<String> getQueryableBranches()

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