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); }
/** * Create a new resolver for the given path. * * @param basePath * the base path all repositories are rooted under. * @param exportAll * if true, exports all repositories, ignoring the check for the * {@code git-daemon-export-ok} files. */ public FileResolver(File basePath, boolean exportAll) { this(); exportDirectory(basePath); setExportAll(exportAll); }
/** * Add a single repository to the set that is exported by this daemon. * <p> * The existence (or lack-thereof) of <code>git-daemon-export-ok</code> is * ignored by this method. The repository is always published. * * @param name * name the repository will be published under. * @param db * the repository instance. */ public void exportRepository(String name, Repository db) { exports.put(nameWithDotGit(name), db); }
public Repository open(C req, String name) throws RepositoryNotFoundException, ServiceNotEnabledException { if (isUnreasonableName(name)) throw new RepositoryNotFoundException(name); Repository db = exports.get(nameWithDotGit(name)); if (db != null) { db.incrementOpen(); if (isExportOk(req, name, db)) {
packConfig.setExecutor(Executors.newFixedThreadPool(threads)); final FileResolver<DaemonClient> resolver = new FileResolver<DaemonClient>(); for (final File f : directory) { outw.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath())); resolver.exportDirectory(f); resolver.setExportAll(exportAll);
@Autowired public SpeakeasyRepositoryResolver(GitRepositoryManager gitRepositoryManager, BundleContext bundleContext, PluginAccessor pluginAccessor) { this.gitRepositoryManager = gitRepositoryManager; this.bundleContext = bundleContext; this.pluginAccessor = pluginAccessor; this.resolver = new FileResolver<HttpServletRequest>(this.gitRepositoryManager.getRepositoriesDir(), true); }
/** * Check if this repository can be served. * <p> * The default implementation of this method returns true only if either * {@link #isExportAll()} is true, or the {@code git-daemon-export-ok} file * is present in the repository's directory. * * @param req * the current HTTP request. * @param repositoryName * name of the repository, as present in the URL. * @param db * the opened repository instance. * @return true if the repository is accessible; false if not. * @throws java.io.IOException * the repository could not be accessed, the caller will claim * the repository does not exist. */ protected boolean isExportOk(C req, String repositoryName, Repository db) throws IOException { if (isExportAll()) return true; else if (db.getDirectory() != null) return new File(db.getDirectory(), "git-daemon-export-ok").exists(); //$NON-NLS-1$ else return false; }
public Repository open(final C req, final String name) throws RepositoryNotFoundException, ServiceNotEnabledException { if (isUnreasonableName(name)) throw new RepositoryNotFoundException(name); Repository db = exports.get(nameWithDotGit(name)); if (db != null) { db.incrementOpen(); if (isExportOk(req, name, db)) {
File root = getFile(filterConfig, "base-path"); boolean exportAll = getBoolean(filterConfig, "export-all"); setRepositoryResolver(new FileResolver<HttpServletRequest>(root, exportAll));
/** * Check if this repository can be served. * <p> * The default implementation of this method returns true only if either * {@link #isExportAll()} is true, or the {@code git-daemon-export-ok} file * is present in the repository's directory. * * @param req * the current HTTP request. * @param repositoryName * name of the repository, as present in the URL. * @param db * the opened repository instance. * @return true if the repository is accessible; false if not. * @throws IOException * the repository could not be accessed, the caller will claim * the repository does not exist. */ protected boolean isExportOk(C req, String repositoryName, Repository db) throws IOException { if (isExportAll()) return true; else if (db.getDirectory() != null) return new File(db.getDirectory(), "git-daemon-export-ok").exists(); //$NON-NLS-1$ else return false; }
public Repository open(C req, String name) throws RepositoryNotFoundException, ServiceNotEnabledException { if (isUnreasonableName(name)) throw new RepositoryNotFoundException(name); Repository db = exports.get(nameWithDotGit(name)); if (db != null) { db.incrementOpen(); if (isExportOk(req, name, db)) {
/** * Create a new resolver for the given path. * * @param basePath * the base path all repositories are rooted under. * @param exportAll * if true, exports all repositories, ignoring the check for the * {@code git-daemon-export-ok} files. */ public FileResolver(File basePath, boolean exportAll) { this(); exportDirectory(basePath); setExportAll(exportAll); }
File root = getFile(filterConfig, "base-path"); boolean exportAll = getBoolean(filterConfig, "export-all"); setRepositoryResolver(new FileResolver<HttpServletRequest>(root, exportAll));
/** * Add a single repository to the set that is exported by this daemon. * <p> * The existence (or lack-thereof) of <code>git-daemon-export-ok</code> is * ignored by this method. The repository is always published. * * @param name * name the repository will be published under. * @param db * the repository instance. */ public void exportRepository(String name, Repository db) { exports.put(nameWithDotGit(name), db); }
/** * Check if this repository can be served. * <p> * The default implementation of this method returns true only if either * {@link #isExportAll()} is true, or the {@code git-daemon-export-ok} file * is present in the repository's directory. * * @param req * the current HTTP request. * @param repositoryName * name of the repository, as present in the URL. * @param db * the opened repository instance. * @return true if the repository is accessible; false if not. * @throws java.io.IOException * the repository could not be accessed, the caller will claim * the repository does not exist. */ protected boolean isExportOk(C req, String repositoryName, Repository db) throws IOException { if (isExportAll()) return true; else if (db.getDirectory() != null) return new File(db.getDirectory(), "git-daemon-export-ok").exists(); //$NON-NLS-1$ else return false; }
/** * Create a new resolver for the given path. * * @param basePath * the base path all repositories are rooted under. * @param exportAll * if true, exports all repositories, ignoring the check for the * {@code git-daemon-export-ok} files. */ public FileResolver(final File basePath, final boolean exportAll) { this(); exportDirectory(basePath); setExportAll(exportAll); }
/** * Add a single repository to the set that is exported by this daemon. * <p> * The existence (or lack-thereof) of <code>git-daemon-export-ok</code> is * ignored by this method. The repository is always published. * * @param name * name the repository will be published under. * @param db * the repository instance. */ public void exportRepository(String name, Repository db) { exports.put(nameWithDotGit(name), db); }