com.caucho.env.repository
Class FileRepository

java.lang.Object
  extended by com.caucho.env.repository.AbstractRepository
      extended by com.caucho.env.repository.FileRepository
All Implemented Interfaces:
Repository, RepositorySpi

public class FileRepository
extends AbstractRepository


Constructor Summary
FileRepository()
           
FileRepository(GitSystem git)
           
 
Method Summary
 java.lang.String addBlob(java.io.InputStream is)
          Adds a path to the repository.
 java.lang.String addBlob(java.io.InputStream is, long length)
          Adds a path to the repository.
 java.lang.String addCommit(GitCommit commit)
          Adds a git commit to the repository
 java.lang.String addTree(GitTree tree)
          Adds a git tree to the repository
 void checkForUpdate(boolean isExact)
          Updates the repository
 boolean exists(java.lang.String hash)
          Returns true if the file exists.
 void expandToPath(java.lang.String contentHash, Path path)
          Expands the repository to the filesystem.
 java.lang.String getRepositoryRootHash()
          Returns the hash stored in the git tag
 GitType getType(java.lang.String sha1)
          Returns true if the file is a blob.
 java.io.InputStream openBlob(java.lang.String sha1)
          Opens a stream to a blob
 java.io.InputStream openRawGitFile(java.lang.String sha1)
          Opens a stream to the raw git file.
 boolean putTag(java.lang.String tagName, java.lang.String contentHash, java.util.Map<java.lang.String,java.lang.String> commitMetaData)
          Adds a tag
 GitCommit readCommit(java.lang.String sha1)
          Reads a git commit from the repository
 GitTree readTree(java.lang.String sha1)
          Reads a git tree from the repository
 boolean removeTag(java.lang.String tagName, java.util.Map<java.lang.String,java.lang.String> commitMetaData)
          Removes a tag
 void setRepositoryRootHash(java.lang.String sha1)
          Sets the hash stored in the git tag
 void validateRawGitFile(java.lang.String sha1)
          Writes the git file from the StreamInput
 void writeBlobToStream(java.lang.String blobHash, java.io.OutputStream os)
          Writes the contents to a stream.
 void writeRawGitFile(java.lang.String sha1, java.io.InputStream is)
          Writes the git file from the StreamInput
 
Methods inherited from class com.caucho.env.repository.AbstractRepository
addArchive, addArchive, addArchive, addListener, addPath, addTagData, checkForUpdate, commitArchive, commitArchive, commitPath, getCommitHash, getRepositoryTag, getTagContentHash, getTagHash, getTagMap, getTagSequence, init, isBlob, isCommit, isTree, loadLocalRoot, removeListener, removeTag, removeTagData, setTagMap, start, stop, toString, update, updateLoad, updateRepositoryRoot, updateTagMap, validateHash, validateRawHash
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileRepository

public FileRepository()

FileRepository

public FileRepository(GitSystem git)
Method Detail

checkForUpdate

public void checkForUpdate(boolean isExact)
Updates the repository

Specified by:
checkForUpdate in interface RepositorySpi
Overrides:
checkForUpdate in class AbstractRepository

putTag

public boolean putTag(java.lang.String tagName,
                      java.lang.String contentHash,
                      java.util.Map<java.lang.String,java.lang.String> commitMetaData)
Adds a tag

Specified by:
putTag in interface RepositorySpi
Specified by:
putTag in class AbstractRepository
Parameters:
tagName - the symbolic tag for the repository
contentHash - the sha1 hash of the tag's content
commitMessage - user's message for the commit
commitMetaData - additional commit metadata

removeTag

public boolean removeTag(java.lang.String tagName,
                         java.util.Map<java.lang.String,java.lang.String> commitMetaData)
Removes a tag

Specified by:
removeTag in interface RepositorySpi
Specified by:
removeTag in class AbstractRepository
Parameters:
tagName - the symbolic tag for the repository
commitMessage - user's message for the commit
commitMetaData - additional metadata

getRepositoryRootHash

public java.lang.String getRepositoryRootHash()
Returns the hash stored in the git tag

Specified by:
getRepositoryRootHash in interface RepositorySpi
Specified by:
getRepositoryRootHash in class AbstractRepository
Returns:
the hash of the .git Commit for the current repository root.

setRepositoryRootHash

public void setRepositoryRootHash(java.lang.String sha1)
Sets the hash stored in the git tag

Specified by:
setRepositoryRootHash in interface RepositorySpi
Specified by:
setRepositoryRootHash in class AbstractRepository
Parameters:
sha1 - the hash of the new .git Commit for the repository.

exists

public boolean exists(java.lang.String hash)
Returns true if the file exists.

Specified by:
exists in interface RepositorySpi
Specified by:
exists in class AbstractRepository

getType

public GitType getType(java.lang.String sha1)
Returns true if the file is a blob.

Specified by:
getType in interface RepositorySpi
Specified by:
getType in class AbstractRepository

addBlob

public java.lang.String addBlob(java.io.InputStream is)
Adds a path to the repository. If the path is a directory or a jar scheme, adds the contents recursively.

Parameters:
is - the blob's input stream

addBlob

public java.lang.String addBlob(java.io.InputStream is,
                                long length)
Adds a path to the repository. If the path is a directory or a jar scheme, adds the contents recursively.

Specified by:
addBlob in interface RepositorySpi
Overrides:
addBlob in class AbstractRepository
Parameters:
is - the blob's input stream
length - the blob's length

openBlob

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

Specified by:
openBlob in interface RepositorySpi
Specified by:
openBlob in class AbstractRepository
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.

Specified by:
openRawGitFile in interface RepositorySpi
Specified by:
openRawGitFile in class AbstractRepository
Throws:
java.io.IOException

readTree

public GitTree readTree(java.lang.String sha1)
                 throws java.io.IOException
Reads a git tree from the repository

Specified by:
readTree in interface RepositorySpi
Specified by:
readTree in class AbstractRepository
Throws:
java.io.IOException

addTree

public java.lang.String addTree(GitTree tree)
                         throws java.io.IOException
Adds a git tree to the repository

Specified by:
addTree in interface RepositorySpi
Overrides:
addTree in class AbstractRepository
Throws:
java.io.IOException

readCommit

public GitCommit readCommit(java.lang.String sha1)
                     throws java.io.IOException
Reads a git commit from the repository

Specified by:
readCommit in interface RepositorySpi
Specified by:
readCommit in class AbstractRepository
Throws:
java.io.IOException

addCommit

public java.lang.String addCommit(GitCommit commit)
                           throws java.io.IOException
Adds a git commit to the repository

Specified by:
addCommit in interface RepositorySpi
Specified by:
addCommit in class AbstractRepository
Throws:
java.io.IOException

writeRawGitFile

public void writeRawGitFile(java.lang.String sha1,
                            java.io.InputStream is)
                     throws java.io.IOException
Writes the git file from the StreamInput

Specified by:
writeRawGitFile in interface RepositorySpi
Specified by:
writeRawGitFile in class AbstractRepository
Parameters:
sha1 - the file hash
is - the raw contents for the new file
Throws:
java.io.IOException

validateRawGitFile

public void validateRawGitFile(java.lang.String sha1)
Writes the git file from the StreamInput

Specified by:
validateRawGitFile in interface RepositorySpi
Overrides:
validateRawGitFile in class AbstractRepository
Parameters:
sha1 - the file hash
is - the raw contents for the new file

writeBlobToStream

public void writeBlobToStream(java.lang.String blobHash,
                              java.io.OutputStream os)
Writes the contents to a stream.

Specified by:
writeBlobToStream in interface RepositorySpi
Specified by:
writeBlobToStream in class AbstractRepository
Parameters:
blobHash - the hash of the source blob
os - the OutputStream to write to

expandToPath

public void expandToPath(java.lang.String contentHash,
                         Path path)
Expands the repository to the filesystem.

Specified by:
expandToPath in interface RepositorySpi
Specified by:
expandToPath in class AbstractRepository