Search in sources :

Example 1 with FileResolver

use of org.eclipse.jgit.transport.resolver.FileResolver in project gocd by gocd.

the class ConfigGitRepoFilter method init.

public void init(FilterConfig config) throws ServletException {
    ConfigRepository configRepository = ContextLoader.getCurrentWebApplicationContext().getBean(ConfigRepository.class);
    FileResolver<HttpServletRequest> resolver = new FileResolver<>();
    resolver.exportRepository("config-repository", configRepository.getGitRepo());
    setRepositoryResolver(resolver);
    setReceivePackFactory(null);
    super.init(config);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) FileResolver(org.eclipse.jgit.transport.resolver.FileResolver)

Example 2 with FileResolver

use of org.eclipse.jgit.transport.resolver.FileResolver in project gitiles by GerritCodeReview.

the class GitilesFilter method setDefaultAccess.

private void setDefaultAccess() throws ServletException {
    if (accessFactory == null || resolver == null) {
        String basePath = config.getString("gitiles", null, "basePath");
        if (basePath == null) {
            throw new ServletException("gitiles.basePath not set");
        }
        boolean exportAll = config.getBoolean("gitiles", null, "exportAll", false);
        FileResolver<HttpServletRequest> fileResolver;
        if (resolver == null) {
            fileResolver = new FileResolver<>(new File(basePath), exportAll);
            resolver = fileResolver;
        } else if (resolver instanceof FileResolver) {
            fileResolver = (FileResolver<HttpServletRequest>) resolver;
        } else {
            fileResolver = null;
        }
        if (accessFactory == null) {
            checkState(fileResolver != null, "need a FileResolver when GitilesAccess.Factory not set");
            try {
                accessFactory = new DefaultAccess.Factory(new File(basePath), getBaseGitUrl(config), config, fileResolver);
            } catch (IOException e) {
                throw new ServletException(e);
            }
        }
    }
}
Also used : ServletException(javax.servlet.ServletException) HttpServletRequest(javax.servlet.http.HttpServletRequest) IOException(java.io.IOException) FileResolver(org.eclipse.jgit.transport.resolver.FileResolver) File(java.io.File)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)2 FileResolver (org.eclipse.jgit.transport.resolver.FileResolver)2 ConfigRepository (com.thoughtworks.go.service.ConfigRepository)1 File (java.io.File)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1