Top Description Fields Constructors Methods
org.eclipse.jgit.http.server

public Class GitFilter

extends MetaFilter
Class Inheritance
Imports
java.io.File, java.text.MessageFormat, java.util.ArrayList, .List, jakarta.servlet.Filter, .FilterConfig, .ServletException, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.eclipse.jgit.http.server.glue.ErrorServlet, .MetaFilter, .RegexGroupFilter, .ServletBinder, org.eclipse.jgit.http.server.resolver.AsIsFileService, .DefaultReceivePackFactory, .DefaultUploadPackFactory, org.eclipse.jgit.lib.Constants, org.eclipse.jgit.transport.resolver.FileResolver, .ReceivePackFactory, .RepositoryResolver, .UploadPackFactory, org.eclipse.jgit.util.StringUtils

Handles Git repository access over HTTP.

Applications embedding this filter should map a directory path within the application to this filter. For a servlet version, see org.eclipse.jgit.http.server.GitServlet.

Applications may wish to add additional repository action URLs to this servlet by taking advantage of its extension from org.eclipse.jgit.http.server.glue.MetaFilter. Callers may register their own URL suffix translations through serve(String), or their regex translations through serveRegex(String). Each translation should contain a complete filter pipeline which ends with the HttpServlet that should handle the requested action.

Field Summary

Modifier and TypeField and Description
private AsIsFileService
private volatile boolean
private ReceivePackErrorHandler
private ReceivePackFactory<HttpServletRequest>
private final List<Filter>
private RepositoryResolver<HttpServletRequest>
private UploadPackErrorHandler
private UploadPackFactory<HttpServletRequest>
private final List<Filter>

Constructor Summary

AccessConstructor and Description
public
GitFilter()

New servlet that will load its base directory from web.xml.

Method Summary

Modifier and TypeMethod and Description
public void
addReceivePackFilter(Filter
filter to apply before any of the ReceivePack operations. The ReceivePack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.
filter
)

Add receive-pack filter

public void
addUploadPackFilter(Filter
filter to apply before any of the UploadPack operations. The UploadPack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.
filter
)

Add upload-pack filter

private void
private static boolean
private static File
public void
init(FilterConfig
a FilterConfig object containing the filter's configuration and initialization parameters
filterConfig
)

Overrides org.eclipse.jgit.http.server.glue.MetaFilter.init.

Overrides default jakarta.servlet.Filter.init.

Called by the web container to indicate to a filter that it is being placed into service.

protected ServletBinder
register(ServletBinder
the newly created binder.
binder
)

Overrides org.eclipse.jgit.http.server.glue.MetaFilter.register.

Configure a newly created binder.

public void
setAsIsFileService(AsIsFileService
the filter to validate direct access to repository files through a dumb client. If null then dumb client support is completely disabled.
f
)

Set AsIsFileService

public void
setReceivePackErrorHandler(ReceivePackErrorHandler
A custom error handler for git-receive-pack.
h
)

Set a custom error handler for git-receive-pack.

public void
setReceivePackFactory(ReceivePackFactory<HttpServletRequest>
the factory to construct and configure a org.eclipse.jgit.transport.ReceivePack session when a push is requested by a client.
f
)

Set the receive-pack factory

public void
setRepositoryResolver(RepositoryResolver<HttpServletRequest>
the resolver to use when matching URL to Git repository. If null the base-path parameter will be looked for in the parameter table during init, which usually comes from the web.xml file of the web application.
resolver
)

New servlet configured with a specific resolver.

public void
setUploadPackErrorHandler(UploadPackErrorHandler
A custom error handler for git-upload-pack.
h
)

Set a custom error handler for git-upload-pack.

public void
setUploadPackFactory(UploadPackFactory<HttpServletRequest>
the factory to construct and configure an org.eclipse.jgit.transport.UploadPack session when a fetch or clone is requested by a client.
f
)

Set upload-pack factory

Inherited from org.eclipse.jgit.http.server.glue.MetaFilter:
destroydoFilterserveserveRegexserveRegex

Field Detail

asIsback to summary
private AsIsFileService asIs
initializedback to summary
private volatile boolean initialized
receivePackErrorHandlerback to summary
private ReceivePackErrorHandler receivePackErrorHandler
receivePackFactoryback to summary
private ReceivePackFactory<HttpServletRequest> receivePackFactory
receivePackFiltersback to summary
private final List<Filter> receivePackFilters
resolverback to summary
private RepositoryResolver<HttpServletRequest> resolver
uploadPackErrorHandlerback to summary
private UploadPackErrorHandler uploadPackErrorHandler
uploadPackFactoryback to summary
private UploadPackFactory<HttpServletRequest> uploadPackFactory
uploadPackFiltersback to summary
private final List<Filter> uploadPackFilters

Constructor Detail

GitFilterback to summary
public GitFilter()

New servlet that will load its base directory from web.xml.

The required parameter base-path must be configured to point to the local filesystem directory where all served Git repositories reside.

Method Detail

addReceivePackFilterback to summary
public void addReceivePackFilter(Filter filter)

Add receive-pack filter

Parameters
filter:Filter

filter to apply before any of the ReceivePack operations. The ReceivePack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.

Since
7.0
addUploadPackFilterback to summary
public void addUploadPackFilter(Filter filter)

Add upload-pack filter

Parameters
filter:Filter

filter to apply before any of the UploadPack operations. The UploadPack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.

Since
7.0
assertNotInitializedback to summary
private void assertNotInitialized()
getBooleanback to summary
private static boolean getBoolean(FilterConfig cfg, String param) throws ServletException
getFileback to summary
private static File getFile(FilterConfig cfg, String param) throws ServletException
initback to summary
public void init(FilterConfig filterConfig) throws ServletException

Overrides org.eclipse.jgit.http.server.glue.MetaFilter.init.

Overrides default jakarta.servlet.Filter.init.

Doc from jakarta.servlet.Filter.init.

Called by the web container to indicate to a filter that it is being placed into service.

The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work. The container will ensure that actions performed in the init method will be visible to any threads that subsequently call the doFilter method according to the rules in JSR-133 (i.e. there is a 'happens before' relationship between init and doFilter).

The web container cannot place the filter into service if the init method either

  1. Throws a ServletException
  2. Does not return within a time period defined by the web container
Parameters
filterConfig:FilterConfig

a FilterConfig object containing the filter's configuration and initialization parameters

Annotations
@Override
Exceptions
ServletException:
if an exception has occurred that interferes with the filter's normal operation
registerback to summary
protected ServletBinder register(ServletBinder binder)

Overrides org.eclipse.jgit.http.server.glue.MetaFilter.register.

Doc from org.eclipse.jgit.http.server.glue.MetaFilter.register.

Configure a newly created binder.

Parameters
binder:ServletBinder

the newly created binder.

Returns:ServletBinder

binder for the caller, potentially after adding one or more filters into the pipeline.

Annotations
@Override
setAsIsFileServiceback to summary
public void setAsIsFileService(AsIsFileService f)

Set AsIsFileService

Parameters
f:AsIsFileService

the filter to validate direct access to repository files through a dumb client. If null then dumb client support is completely disabled.

setReceivePackErrorHandlerback to summary
public void setReceivePackErrorHandler(ReceivePackErrorHandler h)

Set a custom error handler for git-receive-pack.

Parameters
h:ReceivePackErrorHandler

A custom error handler for git-receive-pack.

Since
5.7
setReceivePackFactoryback to summary
public void setReceivePackFactory(ReceivePackFactory<HttpServletRequest> f)

Set the receive-pack factory

Parameters
f:ReceivePackFactory<HttpServletRequest>

the factory to construct and configure a org.eclipse.jgit.transport.ReceivePack session when a push is requested by a client.

Annotations
@SuppressWarnings:unchecked
setRepositoryResolverback to summary
public void setRepositoryResolver(RepositoryResolver<HttpServletRequest> resolver)

New servlet configured with a specific resolver.

Parameters
resolver:RepositoryResolver<HttpServletRequest>

the resolver to use when matching URL to Git repository. If null the base-path parameter will be looked for in the parameter table during init, which usually comes from the web.xml file of the web application.

setUploadPackErrorHandlerback to summary
public void setUploadPackErrorHandler(UploadPackErrorHandler h)

Set a custom error handler for git-upload-pack.

Parameters
h:UploadPackErrorHandler

A custom error handler for git-upload-pack.

Since
5.6
setUploadPackFactoryback to summary
public void setUploadPackFactory(UploadPackFactory<HttpServletRequest> f)

Set upload-pack factory

Parameters
f:UploadPackFactory<HttpServletRequest>

the factory to construct and configure an org.eclipse.jgit.transport.UploadPack session when a fetch or clone is requested by a client.

Annotations
@SuppressWarnings:unchecked