ModeShape Distribution 3.2.0.Final

org.modeshape.connector.git
Class GitConnector

java.lang.Object
  extended by org.modeshape.jcr.federation.spi.Connector
      extended by org.modeshape.jcr.federation.spi.ReadOnlyConnector
          extended by 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:

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.federation.spi.Connector
Connector.ExtraProperties
 
Constructor Summary
GitConnector()
           
 
Method Summary
 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 a page of children.
 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 path.
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()
           
 void shutdown()
          Shutdown the connector by releasing all resources.
 
Methods inherited from class org.modeshape.jcr.federation.spi.ReadOnlyConnector
isReadonly, newDocumentId, removeDocument, storeDocument, updateDocument
 
Methods inherited from class org.modeshape.jcr.federation.spi.Connector
checkFieldNotNull, extraPropertiesFor, extraPropertiesStore, factories, getCacheTtlSeconds, getContext, getLogger, getMimeTypeDetector, getRepositoryName, getSourceName, getTransactionManager, isQueryable, nameFrom, nameFrom, nameFrom, newChildReference, newDocument, newPageDocument, propertyFactory, readDocument, setExtraPropertiesStore, translator
 
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 a page of children. 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:
either a non-null page document or null indicating that such a page doesn't exist

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 path.

Specified by:
getDocumentId in class Connector
Parameters:
path - a non-null string representing an exeternal path.
Returns:
either the id of the document or 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()

getQueryableBranches

protected List<String> getQueryableBranches()

ModeShape Distribution 3.2.0.Final

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