Class FileResolver<C>
java.lang.Object
org.eclipse.jgit.transport.resolver.FileResolver<C>
- Type Parameters:
C- type of connection
- All Implemented Interfaces:
RepositoryResolver<C>
Default resolver serving from the local filesystem.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final Collection<File>private final Map<String,Repository> Fields inherited from interface org.eclipse.jgit.transport.resolver.RepositoryResolver
NONE -
Constructor Summary
ConstructorsConstructorDescriptionInitialize an empty file based resolver.FileResolver(File basePath, boolean exportAll) Create a new resolver for the given path. -
Method Summary
Modifier and TypeMethodDescriptionvoidexportDirectory(File dir) Recursively export all Git repositories within a directory.voidexportRepository(String name, Repository db) Add a single repository to the set that is exported by this daemon.booleanWhethergit-daemon-export-okis required to export a repositoryprotected booleanisExportOk(C req, String repositoryName, Repository db) Check if this repository can be served.private static booleanisUnreasonableName(String name) Locate and open a reference to aRepository.voidsetExportAll(boolean export) Set whether or not to export all repositories.
-
Field Details
-
exportAll
private volatile boolean exportAll -
exports
-
exportBase
-
-
Constructor Details
-
FileResolver
public FileResolver()Initialize an empty file based resolver. -
FileResolver
Create a new resolver for the given path.- Parameters:
basePath- the base path all repositories are rooted under.exportAll- if true, exports all repositories, ignoring the check for thegit-daemon-export-okfiles.
-
-
Method Details
-
open
public Repository open(C req, String name) throws RepositoryNotFoundException, ServiceNotEnabledException Locate and open a reference to aRepository.The caller is responsible for closing the returned Repository.
- Specified by:
openin interfaceRepositoryResolver<C>- Parameters:
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.- Returns:
- the opened repository instance, never null.
- Throws:
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.
-
isExportAll
public boolean isExportAll()Whethergit-daemon-export-okis required to export a repository- Returns:
- false if
git-daemon-export-okis required to export a repository; true ifgit-daemon-export-okis ignored. - See Also:
-
setExportAll
public void setExportAll(boolean export) Set whether or not to export all repositories.If false (the default), repositories must have a
git-daemon-export-okfile to be accessed through this daemon.If true, all repositories are available through the daemon, whether or not
git-daemon-export-okexists.- Parameters:
export- a boolean.
-
exportRepository
Add a single repository to the set that is exported by this daemon.The existence (or lack-thereof) of
git-daemon-export-okis ignored by this method. The repository is always published.- Parameters:
name- name the repository will be published under.db- the repository instance.
-
exportDirectory
Recursively export all Git repositories within a directory.- Parameters:
dir- the directory to export. This directory must not itself be a git repository, but any directory below it which has a file namedgit-daemon-export-okwill be published.
-
isExportOk
Check if this repository can be served.The default implementation of this method returns true only if either
isExportAll()is true, or thegit-daemon-export-okfile is present in the repository's directory.- Parameters:
req- the current HTTP request.repositoryName- name of the repository, as present in the URL.db- the opened repository instance.- Returns:
- true if the repository is accessible; false if not.
- Throws:
IOException- the repository could not be accessed, the caller will claim the repository does not exist.
-
isUnreasonableName
-