com.caucho.env.repository
Interface RepositorySpi

All Known Implementing Classes:
AbstractRepository, ClusterRepository, FileRepository

public interface RepositorySpi

The Repository is a collection of archives organized by a tag map. Each archive is equivalent to a .jar file or a directory, consisting of the binary data Blobs, the directory name Tree, and a .git Commit item to track versions. The tag map is a map of strings to tag entries, where the entry is the sha1 of the .git Commit root of the archive, and metadata.


Method Summary
 java.lang.String addArchive(Path path)
          Adds a path as a jar/zip archive to the repository.
 java.lang.String addBlob(java.io.InputStream is)
          Adds a stream to the repository where the length is not known.
 java.lang.String addBlob(java.io.InputStream is, long length)
          Adds a stream to the repository where the length is known.
 java.lang.String addCommit(GitCommit commit)
          Adds a git commit entry to the repository
 void addListener(java.lang.String tagName, RepositoryTagListener listener)
          Adds a tag change listener
 java.lang.String addPath(Path path)
          Adds a path to the repository.
 java.lang.String addTree(GitTree tree)
          Adds a git tree to the repository
 void checkForUpdate(boolean isExact)
          Updates the repository, checking for any changes across the cluster.
 boolean exists(java.lang.String contentHash)
          Returns true if the file exists.
 void expandToPath(java.lang.String contentHash, Path path)
          Expands the repository to the filesystem.
 java.lang.String getRepositoryRootHash()
          The Commit .git hash for the repository itself.
 java.lang.String getTagContentHash(java.lang.String tag)
          Convenience method returning the tag's contentHash.
 java.util.Map<java.lang.String,RepositoryTagEntry> getTagMap()
          Returns the current read-only tag map.
 GitType getType(java.lang.String contentHash)
          Returns the GitType of the file.
 boolean isBlob(java.lang.String contentHash)
          Returns true if the file is a blob.
 boolean isCommit(java.lang.String contentHash)
          Returns true if the file is a commit
 boolean isTree(java.lang.String contentHash)
          Returns true if the file is a tree
 java.io.InputStream openBlob(java.lang.String blobHash)
          Opens an InputStream to a git blob
 java.io.InputStream openRawGitFile(java.lang.String contentHash)
          Opens a stream to the raw git file.
 boolean putTag(java.lang.String tag, java.lang.String contentHash, java.util.Map<java.lang.String,java.lang.String> attributes)
          Atomic operations.
 GitCommit readCommit(java.lang.String commitHash)
          Reads a git commit entry from the repository
 GitTree readTree(java.lang.String treeHash)
          Reads a git tree from the repository
 void removeListener(java.lang.String tagName, RepositoryTagListener listener)
          Adds a tag change listener
 boolean removeTag(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> attributes)
          Atomic operations.
 void setRepositoryRootHash(java.lang.String rootCommitHash)
          The root .git hash for the repository itself.
 boolean validateHash(java.lang.String contentHash)
          Validates a hash, checking that it and its dependencies exist.
 void validateRawGitFile(java.lang.String contentHash)
          Remove a raw git file
 void writeBlobToStream(java.lang.String blobHash, java.io.OutputStream os)
          Writes the contents of a blob to an OutputStream.
 void writeRawGitFile(java.lang.String contentHash, java.io.InputStream is)
          Writes a raw git file
 

Method Detail

exists

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


getType

GitType getType(java.lang.String contentHash)
Returns the GitType of the file.


isBlob

boolean isBlob(java.lang.String contentHash)
Returns true if the file is a blob.


isTree

boolean isTree(java.lang.String contentHash)
Returns true if the file is a tree


isCommit

boolean isCommit(java.lang.String contentHash)
Returns true if the file is a commit


addBlob

java.lang.String addBlob(java.io.InputStream is)
                         throws java.io.IOException
Adds a stream to the repository where the length is not known. When possible the alternate method with a length should be used because this method requires a copy of the entire stream to calculate the length.

Parameters:
is - the blob's input stream
Throws:
java.io.IOException

addBlob

java.lang.String addBlob(java.io.InputStream is,
                         long length)
                         throws java.io.IOException
Adds a stream to the repository where the length is known.

Parameters:
is - the blob's input stream
length - the blob's length
Throws:
java.io.IOException

openBlob

java.io.InputStream openBlob(java.lang.String blobHash)
                             throws java.io.IOException
Opens an InputStream to a git blob

Throws:
java.io.IOException

writeBlobToStream

void writeBlobToStream(java.lang.String blobHash,
                       java.io.OutputStream os)
Writes the contents of a blob to an OutputStream.

Parameters:
blobHash - the hash of the source blob
os - the OutputStream to write to

addTree

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

Throws:
java.io.IOException

readTree

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

Throws:
java.io.IOException

addCommit

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

Throws:
java.io.IOException

readCommit

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

Throws:
java.io.IOException

validateHash

boolean validateHash(java.lang.String contentHash)
                     throws java.io.IOException
Validates a hash, checking that it and its dependencies exist.

Throws:
java.io.IOException

addPath

java.lang.String addPath(Path path)
Adds a path to the repository. If the path is a directory or a adds the contents recursively.


addArchive

java.lang.String addArchive(Path path)
Adds a path as a jar/zip archive to the repository.


expandToPath

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


openRawGitFile

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

Throws:
java.io.IOException

writeRawGitFile

void writeRawGitFile(java.lang.String contentHash,
                     java.io.InputStream is)
                     throws java.io.IOException
Writes a raw git file

Throws:
java.io.IOException

validateRawGitFile

void validateRawGitFile(java.lang.String contentHash)
Remove a raw git file


checkForUpdate

void checkForUpdate(boolean isExact)
Updates the repository, checking for any changes across the cluster.


getTagMap

java.util.Map<java.lang.String,RepositoryTagEntry> getTagMap()
Returns the current read-only tag map.


getTagContentHash

java.lang.String getTagContentHash(java.lang.String tag)
Convenience method returning the tag's contentHash.


putTag

boolean putTag(java.lang.String tag,
               java.lang.String contentHash,
               java.util.Map<java.lang.String,java.lang.String> attributes)
Atomic operations.


removeTag

boolean removeTag(java.lang.String tag,
                  java.util.Map<java.lang.String,java.lang.String> attributes)
Atomic operations.


addListener

void addListener(java.lang.String tagName,
                 RepositoryTagListener listener)
Adds a tag change listener


removeListener

void removeListener(java.lang.String tagName,
                    RepositoryTagListener listener)
Adds a tag change listener


getRepositoryRootHash

java.lang.String getRepositoryRootHash()
The Commit .git hash for the repository itself. The hash points to a .git Commit entry for the current repository version.

Returns:
the hash of the .git Commit for the current repository root.

setRepositoryRootHash

void setRepositoryRootHash(java.lang.String rootCommitHash)
The root .git hash for the repository itself. The hash points to a .git Commit entry for the current repository version.

Parameters:
rootCommitHash - the hash of the new .git Commit for the repository.