Search in sources :

Example 1 with RepositoryResolver

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

the class DevServer method createRootedDocServlet.

private Servlet createRootedDocServlet(DebugRenderer renderer, String docRoot) {
    File docRepo = new File(docRoot);
    FileKey repoKey = FileKey.exact(docRepo, FS.DETECTED);
    RepositoryResolver<HttpServletRequest> resolver = (req, name) -> {
        try {
            return RepositoryCache.open(repoKey, true);
        } catch (IOException e) {
            throw new RepositoryNotFoundException(repoKey.getFile(), e);
        }
    };
    return new RootedDocServlet(resolver, new RootedDocAccess(docRepo), renderer);
}
Also used : ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) Handler(org.eclipse.jetty.server.Handler) NoSuchFileException(java.nio.file.NoSuchFileException) Arrays(java.util.Arrays) ResourceHandler(org.eclipse.jetty.server.handler.ResourceHandler) PathResource(org.eclipse.jetty.util.resource.PathResource) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) RepositoryNotFoundException(org.eclipse.jgit.errors.RepositoryNotFoundException) URISyntaxException(java.net.URISyntaxException) GitilesAccess(com.google.gitiles.GitilesAccess) LoggerFactory(org.slf4j.LoggerFactory) InetAddress(java.net.InetAddress) Strings(com.google.common.base.Strings) Config(org.eclipse.jgit.lib.Config) HttpServletRequest(javax.servlet.http.HttpServletRequest) Map(java.util.Map) RepositoryDescription(com.google.gitiles.RepositoryDescription) Path(java.nio.file.Path) Server(org.eclipse.jetty.server.Server) GitilesServlet(com.google.gitiles.GitilesServlet) RepositoryCache(org.eclipse.jgit.lib.RepositoryCache) Logger(org.slf4j.Logger) Servlet(javax.servlet.Servlet) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) PathServlet(com.google.gitiles.PathServlet) Set(java.util.Set) IOException(java.io.IOException) Constants(org.eclipse.jgit.lib.Constants) RepositoryResolver(org.eclipse.jgit.transport.resolver.RepositoryResolver) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) STATIC_PREFIX(com.google.gitiles.GitilesServlet.STATIC_PREFIX) UnknownHostException(java.net.UnknownHostException) FileKey(org.eclipse.jgit.lib.RepositoryCache.FileKey) File(java.io.File) RootedDocServlet(com.google.gitiles.RootedDocServlet) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) Paths(java.nio.file.Paths) MoreObjects.firstNonNull(com.google.common.base.MoreObjects.firstNonNull) FS(org.eclipse.jgit.util.FS) DebugRenderer(com.google.gitiles.DebugRenderer) Collections(java.util.Collections) HttpServletRequest(javax.servlet.http.HttpServletRequest) FileKey(org.eclipse.jgit.lib.RepositoryCache.FileKey) IOException(java.io.IOException) RepositoryNotFoundException(org.eclipse.jgit.errors.RepositoryNotFoundException) File(java.io.File) RootedDocServlet(com.google.gitiles.RootedDocServlet)

Aggregations

MoreObjects.firstNonNull (com.google.common.base.MoreObjects.firstNonNull)1 Strings (com.google.common.base.Strings)1 DebugRenderer (com.google.gitiles.DebugRenderer)1 GitilesAccess (com.google.gitiles.GitilesAccess)1 GitilesServlet (com.google.gitiles.GitilesServlet)1 STATIC_PREFIX (com.google.gitiles.GitilesServlet.STATIC_PREFIX)1 PathServlet (com.google.gitiles.PathServlet)1 RepositoryDescription (com.google.gitiles.RepositoryDescription)1 RootedDocServlet (com.google.gitiles.RootedDocServlet)1 File (java.io.File)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Map (java.util.Map)1