C - type of connectionpublic class FileResolver<C> extends Object implements RepositoryResolver<C>
NONE| Constructor and Description |
|---|
FileResolver()
Initialize an empty file based resolver.
|
FileResolver(File basePath,
boolean exportAll)
Create a new resolver for the given path.
|
| Modifier and Type | Method and Description |
|---|---|
void |
exportDirectory(File dir)
Recursively export all Git repositories within a directory.
|
void |
exportRepository(String name,
Repository db)
Add a single repository to the set that is exported by this daemon.
|
boolean |
isExportAll() |
protected boolean |
isExportOk(C req,
String repositoryName,
Repository db)
Check if this repository can be served.
|
Repository |
open(C req,
String name)
Locate and open a reference to a
Repository. |
void |
setExportAll(boolean export)
Set whether or not to export all repositories.
|
public FileResolver()
public FileResolver(File basePath, boolean exportAll)
basePath - the base path all repositories are rooted under.exportAll - if true, exports all repositories, ignoring the check for the
git-daemon-export-ok files.public Repository open(C req, String name) throws RepositoryNotFoundException, ServiceNotEnabledException
RepositoryResolverRepository.
The caller is responsible for closing the returned Repository.
open in interface RepositoryResolver<C>req - the current request, may be used to inspect session state
including cookies or user authentication.name - name of the repository, as parsed out of the URL.RepositoryNotFoundException - the repository does not exist or the name is incorrectly
formatted as a repository name.ServiceNotEnabledException - the repository may exist, but HTTP access is not allowed on the
target repository, for the current user.public boolean isExportAll()
git-daemon-export-ok is required to export
a repository; true if git-daemon-export-ok is
ignored.setExportAll(boolean)public void setExportAll(boolean export)
If false (the default), repositories must have a
git-daemon-export-ok file to be accessed through this
daemon.
If true, all repositories are available through the daemon, whether or
not git-daemon-export-ok exists.
export - public void exportRepository(String name, Repository db)
The existence (or lack-thereof) of git-daemon-export-ok is
ignored by this method. The repository is always published.
name - name the repository will be published under.db - the repository instance.public void exportDirectory(File dir)
dir - the directory to export. This directory must not itself be a
git repository, but any directory below it which has a file
named git-daemon-export-ok will be published.protected boolean isExportOk(C req, String repositoryName, Repository db) throws IOException
The default implementation of this method returns true only if either
isExportAll() is true, or the git-daemon-export-ok file
is present in the repository's directory.
req - the current HTTP request.repositoryName - name of the repository, as present in the URL.db - the opened repository instance.IOException - the repository could not be accessed, the caller will claim
the repository does not exist.Copyright © 2014. All rights reserved.