Top Description Fields Constructors Methods
org.eclipse.jgit.transport.resolver

public Class FileResolver<C>

extends Object
implements RepositoryResolver<C>
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.transport.resolver.RepositoryResolver
Type Parameters
<C>
type of connection
Imports
java.io.File, .IOException, java.util.Collection, .Map, java.util.concurrent.ConcurrentHashMap, .CopyOnWriteArrayList, org.eclipse.jgit.errors.RepositoryNotFoundException, org.eclipse.jgit.lib.Repository, .RepositoryCache, .RepositoryCache.FileKey, org.eclipse.jgit.util.FS, .StringUtils

Default resolver serving from the local filesystem.

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final Collection<File>
private final Map<String, Repository>

Constructor Summary

AccessConstructor and Description
public
FileResolver()

Initialize an empty file based resolver.

public
FileResolver(File
the base path all repositories are rooted under.
basePath
,
boolean
if true, exports all repositories, ignoring the check for the git-daemon-export-ok files.
exportAll
)

Create a new resolver for the given path.

Method Summary

Modifier and TypeMethod and Description
public void
exportDirectory(File
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.
dir
)

Recursively export all Git repositories within a directory.

public void
exportRepository(String
name the repository will be published under.
name
,
Repository
the repository instance.
db
)

Add a single repository to the set that is exported by this daemon.

public boolean

Returns:

false if git-daemon-export-ok is required to export a repository; true if git-daemon-export-ok is ignored.
isExportAll
()

Whether git-daemon-export-ok is required to export a repository

protected boolean

Returns:

true if the repository is accessible; false if not.
isExportOk
(C
the current HTTP request.
req
,
String
name of the repository, as present in the URL.
repositoryName
,
Repository
the opened repository instance.
db
)

Check if this repository can be served.

private static boolean
public Repository
open(C
the current request, may be used to inspect session state including cookies or user authentication.
req
,
String
name of the repository, as parsed out of the URL.
name
)

Implements org.eclipse.jgit.transport.resolver.RepositoryResolver.open.

Locate and open a reference to a Repository.

public void
setExportAll(boolean
a boolean.
export
)

Set whether or not to export all repositories.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exportAllback to summary
private volatile boolean exportAll
exportBaseback to summary
private final Collection<File> exportBase
exportsback to summary
private final Map<String, Repository> exports

Constructor Detail

FileResolverback to summary
public FileResolver()

Initialize an empty file based resolver.

FileResolverback to summary
public FileResolver(File basePath, boolean exportAll)

Create a new resolver for the given path.

Parameters
basePath:File

the base path all repositories are rooted under.

exportAll:boolean

if true, exports all repositories, ignoring the check for the git-daemon-export-ok files.

Method Detail

exportDirectoryback to summary
public void exportDirectory(File dir)

Recursively export all Git repositories within a directory.

Parameters
dir:File

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.

exportRepositoryback to summary
public void exportRepository(String name, Repository db)

Add a single repository to the set that is exported by this daemon.

The existence (or lack-thereof) of git-daemon-export-ok is ignored by this method. The repository is always published.

Parameters
name:String

name the repository will be published under.

db:Repository

the repository instance.

isExportAllback to summary
public boolean isExportAll()

Whether git-daemon-export-ok is required to export a repository

Returns:boolean

false if git-daemon-export-ok is required to export a repository; true if git-daemon-export-ok is ignored.

See Also
setExportAll(boolean)
isExportOkback to summary
protected boolean isExportOk(C req, String repositoryName, Repository db) throws IOException

Check if this repository can be served.

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.

Parameters
req:C

the current HTTP request.

repositoryName:String

name of the repository, as present in the URL.

db:Repository

the opened repository instance.

Returns:boolean

true if the repository is accessible; false if not.

Exceptions
IOException:
the repository could not be accessed, the caller will claim the repository does not exist.
isUnreasonableNameback to summary
private static boolean isUnreasonableName(String name)
openback to summary
public Repository open(C req, String name) throws RepositoryNotFoundException, ServiceNotEnabledException

Implements org.eclipse.jgit.transport.resolver.RepositoryResolver.open.

Doc from org.eclipse.jgit.transport.resolver.RepositoryResolver.open.

Locate and open a reference to a Repository.

The caller is responsible for closing the returned Repository.

Parameters
req:C

the current request, may be used to inspect session state including cookies or user authentication.

name:String

name of the repository, as parsed out of the URL.

Returns:Repository

the opened repository instance, never null.

Annotations
@Override
Exceptions
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.
setExportAllback to summary
public void setExportAll(boolean export)

Set whether or not to export all repositories.

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.

Parameters
export:boolean

a boolean.