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);
}
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);
}
}
}
}
Aggregations