public void init(FilterConfig config) throws ServletException { ConfigRepository configRepository = ContextLoader.getCurrentWebApplicationContext().getBean(ConfigRepository.class); FileResolver<HttpServletRequest> resolver = new FileResolver<>(); resolver.exportRepository("api/config-repository.git", configRepository.getGitRepo()); setRepositoryResolver(resolver); setReceivePackFactory(null); super.init(config); }
File root = getFile(filterConfig, "base-path"); boolean exportAll = getBoolean(filterConfig, "export-all"); setRepositoryResolver(new FileResolver<HttpServletRequest>(root, exportAll)); ServletBinder b = serve("*/" + GitSmartHttpTools.UPLOAD_PACK); b = b.through(new UploadPackServlet.Factory(uploadPackFactory)); for (Filter f : uploadPackFilters) ServletBinder b = serve("*/" + GitSmartHttpTools.RECEIVE_PACK); b = b.through(new ReceivePackServlet.Factory(receivePackFactory)); for (Filter f : receivePackFilters) ServletBinder refs = serve("*/" + Constants.INFO_REFS); if (uploadPackFactory != UploadPackFactory.DISABLED) { refs = refs.through(new UploadPackServlet.InfoRefs( serve("*/" + Constants.HEAD)// serve("*/" + info_alternates)// serve("*/" + http_alternates)// serve("*/objects/info/packs")// serveRegex("^/(.*)/objects/([0-9a-f]{2}/[0-9a-f]{38})$")// serveRegex("^/(.*)/objects/(pack/pack-[0-9a-f]{40}\\.pack)$")// serveRegex("^/(.*)/objects/(pack/pack-[0-9a-f]{40}\\.idx)$")//
/** * @param f * the filter to validate direct access to repository files * through a dumb client. If {@code null} then dumb client * support is completely disabled. */ public void setAsIsFileService(AsIsFileService f) { assertNotInitialized(); this.asIs = f != null ? f : AsIsFileService.DISABLED; }
/** * @param filter * filter to apply before any of the UploadPack operations. The * UploadPack instance is available in the request attribute * {@link ServletUtils#ATTRIBUTE_HANDLER}. */ public void addUploadPackFilter(Filter filter) { gitFilter.addUploadPackFilter(filter); }
/** * @param f * the filter to validate direct access to repository files * through a dumb client. If {@code null} then dumb client * support is completely disabled. */ public void setAsIsFileService(AsIsFileService f) { gitFilter.setAsIsFileService(f); }
/** * New servlet that will load its base directory from {@code web.xml}. * <p> * The required parameter {@code base-path} must be configured to point to * the local filesystem directory where all served Git repositories reside. */ public GitServlet() { super(new GitFilter()); gitFilter = (GitFilter) getDelegateFilter(); }
/** * @param filter * filter to apply before any of the ReceivePack operations. The * ReceivePack instance is available in the request attribute * {@link ServletUtils#ATTRIBUTE_HANDLER}. */ public void addReceivePackFilter(Filter filter) { gitFilter.addReceivePackFilter(filter); }
File root = getFile(filterConfig, "base-path"); boolean exportAll = getBoolean(filterConfig, "export-all"); setRepositoryResolver(new FileResolver<HttpServletRequest>(root, exportAll)); ServletBinder b = serve("*/" + GitSmartHttpTools.UPLOAD_PACK); b = b.through(new UploadPackServlet.Factory(uploadPackFactory)); for (Filter f : uploadPackFilters) ServletBinder b = serve("*/" + GitSmartHttpTools.RECEIVE_PACK); b = b.through(new ReceivePackServlet.Factory(receivePackFactory)); for (Filter f : receivePackFilters) ServletBinder refs = serve("*/" + Constants.INFO_REFS); if (uploadPackFactory != UploadPackFactory.DISABLED) { refs = refs.through(new UploadPackServlet.InfoRefs( serve("*/" + Constants.HEAD)// serve("*/" + info_alternates)// serve("*/" + http_alternates)// serve("*/objects/info/packs")// serveRegex("^/(.*)/objects/([0-9a-f]{2}/[0-9a-f]{38})$")// serveRegex("^/(.*)/objects/(pack/pack-[0-9a-f]{40}\\.pack)$")// serveRegex("^/(.*)/objects/(pack/pack-[0-9a-f]{40}\\.idx)$")//
/** * New servlet configured with a specific resolver. * * @param resolver * the resolver to use when matching URL to Git repository. If * null the {@code base-path} parameter will be looked for in the * parameter table during init, which usually comes from the * {@code web.xml} file of the web application. */ public void setRepositoryResolver(RepositoryResolver<HttpServletRequest> resolver) { assertNotInitialized(); this.resolver = resolver; }
/** * @param filter * filter to apply before any of the UploadPack operations. The * UploadPack instance is available in the request attribute * {@link ServletUtils#ATTRIBUTE_HANDLER}. */ public void addUploadPackFilter(Filter filter) { gitFilter.addUploadPackFilter(filter); }
/** * @param f * the filter to validate direct access to repository files * through a dumb client. If {@code null} then dumb client * support is completely disabled. */ public void setAsIsFileService(AsIsFileService f) { gitFilter.setAsIsFileService(f); }
/** * New servlet that will load its base directory from {@code web.xml}. * <p> * The required parameter {@code base-path} must be configured to point to * the local filesystem directory where all served Git repositories reside. */ public GitServlet() { super(new GitFilter()); gitFilter = (GitFilter) getDelegateFilter(); }
/** * @param filter * filter to apply before any of the ReceivePack operations. The * ReceivePack instance is available in the request attribute * {@link ServletUtils#ATTRIBUTE_HANDLER}. */ public void addReceivePackFilter(Filter filter) { gitFilter.addReceivePackFilter(filter); }
/** * @param f * the filter to validate direct access to repository files * through a dumb client. If {@code null} then dumb client * support is completely disabled. */ public void setAsIsFileService(AsIsFileService f) { assertNotInitialized(); this.asIs = f != null ? f : AsIsFileService.DISABLED; }
@Override public void init(final ServletConfig config) throws ServletException { gitFilter.init(new FilterConfig() { public String getFilterName() { return gitFilter.getClass().getName(); } public String getInitParameter(String name) { return config.getInitParameter(name); } public Enumeration<String> getInitParameterNames() { return config.getInitParameterNames(); } public ServletContext getServletContext() { return config.getServletContext(); } }); } }
/** * @param f * the factory to construct and configure a {@link ReceivePack} * session when a push is requested by a client. */ @SuppressWarnings("unchecked") public void setReceivePackFactory(ReceivePackFactory<HttpServletRequest> f) { assertNotInitialized(); this.receivePackFactory = f != null ? f : (ReceivePackFactory<HttpServletRequest>)ReceivePackFactory.DISABLED; }
@Override public void init(final ServletConfig config) throws ServletException { gitFilter.init(new FilterConfig() { public String getFilterName() { return gitFilter.getClass().getName(); } public String getInitParameter(String name) { return config.getInitParameter(name); } public Enumeration<String> getInitParameterNames() { return config.getInitParameterNames(); } public ServletContext getServletContext() { return config.getServletContext(); } }); } }
/** * @param f * the factory to construct and configure an {@link UploadPack} * session when a fetch or clone is requested by a client. */ @SuppressWarnings("unchecked") public void setUploadPackFactory(UploadPackFactory<HttpServletRequest> f) { assertNotInitialized(); this.uploadPackFactory = f != null ? f : (UploadPackFactory<HttpServletRequest>)UploadPackFactory.DISABLED; }
/** * @param f * the factory to construct and configure an {@link UploadPack} * session when a fetch or clone is requested by a client. */ @SuppressWarnings("unchecked") public void setUploadPackFactory(UploadPackFactory<HttpServletRequest> f) { assertNotInitialized(); this.uploadPackFactory = f != null ? f : (UploadPackFactory<HttpServletRequest>)UploadPackFactory.DISABLED; }
/** * @param f * the factory to construct and configure a {@link ReceivePack} * session when a push is requested by a client. */ @SuppressWarnings("unchecked") public void setReceivePackFactory(ReceivePackFactory<HttpServletRequest> f) { assertNotInitialized(); this.receivePackFactory = f != null ? f : (ReceivePackFactory<HttpServletRequest>)ReceivePackFactory.DISABLED; }