com.caucho.env.git
Class GitSystem

java.lang.Object
  extended by com.caucho.env.service.AbstractResinSubSystem
      extended by com.caucho.env.git.GitSystem
All Implemented Interfaces:
ResinSubSystem

public class GitSystem
extends AbstractResinSubSystem

Top-level class for a repository


Field Summary
static int START_PRIORITY
           
 
Fields inherited from interface com.caucho.env.service.ResinSubSystem
START_PRIORITY_CACHE_SERVICE, START_PRIORITY_CLASSLOADER, START_PRIORITY_CLUSTER_SERVICE, START_PRIORITY_DEFAULT, START_PRIORITY_ENV_SYSTEM, START_PRIORITY_NETWORK_CLUSTER
 
Constructor Summary
GitSystem(Path root)
           
 
Method Summary
 boolean contains(java.lang.String hash)
           
 void copyToFile(Path path, java.lang.String sha1)
           
static GitSystem createAndAddService()
           
static GitSystem createAndAddService(Path root)
           
 void expandToPath(Path path, java.lang.String sha1)
           
 void expandToPath(Path path, java.lang.String sha1, long now)
           
 java.lang.String getBlobSha1(Path path)
          Writes a file to the repository
static GitSystem getCurrent()
           
 java.lang.String getMaster()
           
 int getStartPriority()
          Returns the start priority of the service, used to determine which services to start first.
 java.lang.String getTag(java.lang.String tag)
           
 java.lang.String[] listRefs(java.lang.String dir)
           
 GitType objectType(java.lang.String sha1)
          Returns the object type of the specified file.
 GitObjectStream open(java.lang.String sha1)
          Opens an object file specified by a sha1 hash.
 java.io.InputStream openBlob(java.lang.String sha1)
          Returns an input stream to a blob
 java.io.InputStream openRawGitFile(java.lang.String sha1)
          Opens a stream to the raw git file.
 GitCommit parseCommit(java.lang.String sha1)
          Parses and returns the commit file specified by the sha1 hash.
 GitTree parseTree(java.lang.String sha1)
          Parses and returns the tree (directory) specified by the sha1 hash.
 void start()
          Starts the service.
 java.lang.String toString()
           
static GitType validate(java.lang.String hash, java.io.InputStream is)
           
 void validateRawGitFile(java.lang.String sha1)
          Validate and remove.
 java.lang.String writeCommit(GitCommit commit)
          Writes a file to the repository
static java.lang.String writeData(java.io.OutputStream os, java.lang.String type, java.io.InputStream is, long length)
           
 java.lang.String writeFile(Path path)
          Writes a file to the repository
 java.lang.String writeFile(TempOutputStream os, java.lang.String hex)
           
 java.lang.String writeInputStream(java.io.InputStream is)
          Writes a file to the repository
 java.lang.String writeInputStream(java.io.InputStream is, long length)
          Writes a file to the repository
 java.lang.String writeRawGitFile(java.lang.String sha1, java.io.InputStream is)
          Writes a raw git file directly to the repository with an expected sha1.
 void writeTag(java.lang.String tag, java.lang.String hex)
           
 java.lang.String writeTree(GitTree tree)
          Writes a file to the repository
 
Methods inherited from class com.caucho.env.service.AbstractResinSubSystem
destroy, getStopPriority, preCreate, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

START_PRIORITY

public static final int START_PRIORITY
See Also:
Constant Field Values
Constructor Detail

GitSystem

public GitSystem(Path root)
Method Detail

createAndAddService

public static GitSystem createAndAddService()

createAndAddService

public static GitSystem createAndAddService(Path root)

getCurrent

public static GitSystem getCurrent()

getStartPriority

public int getStartPriority()
Description copied from interface: ResinSubSystem
Returns the start priority of the service, used to determine which services to start first.

Specified by:
getStartPriority in interface ResinSubSystem
Overrides:
getStartPriority in class AbstractResinSubSystem

start

public void start()
           throws java.io.IOException
Description copied from interface: ResinSubSystem
Starts the service.

Specified by:
start in interface ResinSubSystem
Overrides:
start in class AbstractResinSubSystem
Throws:
java.io.IOException

getMaster

public java.lang.String getMaster()

objectType

public GitType objectType(java.lang.String sha1)
                   throws java.io.IOException
Returns the object type of the specified file.

Parameters:
sha1 - the sha1 hash identifier of the file
Returns:
"blob", "commit" or "tree"
Throws:
java.io.IOException

getTag

public java.lang.String getTag(java.lang.String tag)

writeTag

public void writeTag(java.lang.String tag,
                     java.lang.String hex)

listRefs

public java.lang.String[] listRefs(java.lang.String dir)

parseCommit

public GitCommit parseCommit(java.lang.String sha1)
                      throws java.io.IOException
Parses and returns the commit file specified by the sha1 hash.

Parameters:
sha1 - the sha1 hash identifier of the commit file
Returns:
the parsed GitCommit structure
Throws:
java.io.IOException

parseTree

public GitTree parseTree(java.lang.String sha1)
                  throws java.io.IOException
Parses and returns the tree (directory) specified by the sha1 hash.

Parameters:
sha1 - the sha1 hash identifier of the tree file
Returns:
the parsed GitTree structure
Throws:
java.io.IOException

openBlob

public java.io.InputStream openBlob(java.lang.String sha1)
                             throws java.io.IOException
Returns an input stream to a blob

Throws:
java.io.IOException

expandToPath

public void expandToPath(Path path,
                         java.lang.String sha1)
                  throws java.io.IOException
Throws:
java.io.IOException

expandToPath

public void expandToPath(Path path,
                         java.lang.String sha1,
                         long now)
                  throws java.io.IOException
Throws:
java.io.IOException

copyToFile

public void copyToFile(Path path,
                       java.lang.String sha1)
                throws java.io.IOException
Throws:
java.io.IOException

contains

public boolean contains(java.lang.String hash)

open

public GitObjectStream open(java.lang.String sha1)
                     throws java.io.IOException
Opens an object file specified by a sha1 hash.

Parameters:
sha1 - the sha1 hash identifier for the file
Returns:
an opened GitObjectStream to the file
Throws:
java.io.IOException

writeFile

public java.lang.String writeFile(Path path)
                           throws java.io.IOException
Writes a file to the repository

Throws:
java.io.IOException

getBlobSha1

public java.lang.String getBlobSha1(Path path)
                             throws java.io.IOException
Writes a file to the repository

Throws:
java.io.IOException

writeInputStream

public java.lang.String writeInputStream(java.io.InputStream is)
                                  throws java.io.IOException
Writes a file to the repository

Throws:
java.io.IOException

writeInputStream

public java.lang.String writeInputStream(java.io.InputStream is,
                                         long length)
                                  throws java.io.IOException
Writes a file to the repository

Throws:
java.io.IOException

writeTree

public java.lang.String writeTree(GitTree tree)
                           throws java.io.IOException
Writes a file to the repository

Throws:
java.io.IOException

writeCommit

public java.lang.String writeCommit(GitCommit commit)
                             throws java.io.IOException
Writes a file to the repository

Throws:
java.io.IOException

writeFile

public java.lang.String writeFile(TempOutputStream os,
                                  java.lang.String hex)
                           throws java.io.IOException
Throws:
java.io.IOException

openRawGitFile

public java.io.InputStream openRawGitFile(java.lang.String sha1)
                                   throws java.io.IOException
Opens a stream to the raw git file.

Throws:
java.io.IOException

writeRawGitFile

public java.lang.String writeRawGitFile(java.lang.String sha1,
                                        java.io.InputStream is)
                                 throws java.io.IOException
Writes a raw git file directly to the repository with an expected sha1. The write will verify that the stream matches the expected content.

Throws:
java.io.IOException

validateRawGitFile

public void validateRawGitFile(java.lang.String sha1)
Validate and remove.


validate

public static GitType validate(java.lang.String hash,
                               java.io.InputStream is)
                        throws java.io.IOException,
                               java.security.NoSuchAlgorithmException
Throws:
java.io.IOException
java.security.NoSuchAlgorithmException

writeData

public static java.lang.String writeData(java.io.OutputStream os,
                                         java.lang.String type,
                                         java.io.InputStream is,
                                         long length)
                                  throws java.io.IOException
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class AbstractResinSubSystem