List of usage examples for org.eclipse.jgit.errors RepositoryNotFoundException RepositoryNotFoundException
public RepositoryNotFoundException(String location)
From source file:co.bledo.gitmin.servlet.Git.java
License:Apache License
@Override public void init(final ServletConfig config) throws ServletException { log.entry(config);// w ww .j av a2s.c o m setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() { protected RepositoryBuilder builder = new RepositoryBuilder(); @Override public Repository open(HttpServletRequest arg0, String arg1) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException { log.debug("RESOLVING REPO: {}", arg1); File path = new File(GitminConfig.getGitRepositoriesPath() + "/" + arg1); Repository repo; try { repo = builder.setGitDir(path).readEnvironment().findGitDir().build(); } catch (IOException e) { log.catching(e); throw log.throwing(new RepositoryNotFoundException(path)); } return log.exit(repo); } }); super.init(new ServletConfig() { @Override public String getServletName() { return config.getServletName(); } @Override public ServletContext getServletContext() { return config.getServletContext(); } @Override public Enumeration<String> getInitParameterNames() { return config.getInitParameterNames(); } @Override public String getInitParameter(String arg0) { if ("base-path".equals(arg0)) { return GitminConfig.getGitRepositoriesPath(); } else if ("eport-all".equals(arg0)) { return GitminConfig.getGitExportAll(); } return config.getInitParameter(arg0); } }); log.exit(); }
From source file:com.cloudata.git.jgit.CloudGitRepositoryStore.java
License:Apache License
Repository openUncached(GitRepository repo, boolean mustExist) throws IOException { String objectPath = repo.getObjectPath(); // ByteString suffix = ZERO.concat(ByteString.copyFromUtf8(absolutePath)).concat(ZERO); // KeyValuePath refsPath = refsBase.child(suffix); DfsRepositoryDescription description = new DfsRepositoryDescription(objectPath); ObjectStorePath repoPath = new ObjectStorePath(objectStore, objectPath); CloudDfsRepository dfs = new CloudDfsRepository(repo.getData(), description, repoPath, dataStore, tempDir); try {/* ww w . j a v a 2 s.com*/ if (!dfs.exists()) { if (mustExist) { throw new RepositoryNotFoundException(repo.getData().getName()); } dfs.create(true); dfs.updateRef(Constants.HEAD).link("refs/heads/master"); } } catch (IOException e) { throw new IllegalStateException("Error creating repository", e); } dfs.getConfig().setBoolean("http", null, "receivepack", true); return dfs; }
From source file:com.google.gerrit.server.git.LocalDiskRepositoryManager.java
License:Apache License
private Repository openRepository(Path path, Project.NameKey name) throws RepositoryNotFoundException { if (isUnreasonableName(name)) { throw new RepositoryNotFoundException("Invalid name: " + name); }// w w w .j av a2 s . co m File gitDir = path.resolve(name.get()).toFile(); if (!names.contains(name)) { // The this.names list does not hold the project-name but it can still exist // on disk; for instance when the project has been created directly on the // file-system through replication. // if (!name.get().endsWith(Constants.DOT_GIT_EXT)) { if (FileKey.resolve(gitDir, FS.DETECTED) != null) { onCreateProject(name); } else { throw new RepositoryNotFoundException(gitDir); } } else { final File directory = gitDir; if (FileKey.isGitRepository(new File(directory, Constants.DOT_GIT), FS.DETECTED)) { onCreateProject(name); } else if (FileKey.isGitRepository( new File(directory.getParentFile(), directory.getName() + Constants.DOT_GIT_EXT), FS.DETECTED)) { onCreateProject(name); } else { throw new RepositoryNotFoundException(gitDir); } } } final FileKey loc = FileKey.lenient(gitDir, FS.DETECTED); try { return RepositoryCache.open(loc); } catch (IOException e1) { final RepositoryNotFoundException e2; e2 = new RepositoryNotFoundException("Cannot open repository " + name); e2.initCause(e1); throw e2; } }
From source file:com.google.gerrit.server.git.LocalDiskRepositoryManager.java
License:Apache License
private Repository createRepository(Path path, Project.NameKey name) throws RepositoryNotFoundException, RepositoryCaseMismatchException { if (isUnreasonableName(name)) { throw new RepositoryNotFoundException("Invalid name: " + name); }//from w w w. ja va 2s.c om File dir = FileKey.resolve(path.resolve(name.get()).toFile(), FS.DETECTED); FileKey loc; if (dir != null) { // Already exists on disk, use the repository we found. // loc = FileKey.exact(dir, FS.DETECTED); if (!names.contains(name)) { throw new RepositoryCaseMismatchException(name); } } else { // It doesn't exist under any of the standard permutations // of the repository name, so prefer the standard bare name. // String n = name.get() + Constants.DOT_GIT_EXT; loc = FileKey.exact(path.resolve(n).toFile(), FS.DETECTED); } try { Repository db = RepositoryCache.open(loc, false); db.create(true /* bare */); StoredConfig config = db.getConfig(); config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, true); config.save(); // JGit only writes to the reflog for refs/meta/config if the log file // already exists. // File metaConfigLog = new File(db.getDirectory(), "logs/" + RefNames.REFS_CONFIG); if (!metaConfigLog.getParentFile().mkdirs() || !metaConfigLog.createNewFile()) { log.error(String.format("Failed to create ref log for %s in repository %s", RefNames.REFS_CONFIG, name)); } onCreateProject(name); return db; } catch (IOException e1) { final RepositoryNotFoundException e2; e2 = new RepositoryNotFoundException("Cannot create repository " + name); e2.initCause(e1); throw e2; } }
From source file:com.google.gerrit.testutil.InMemoryRepositoryManager.java
License:Apache License
private synchronized Repo get(Project.NameKey name) throws RepositoryNotFoundException { Repo repo = repos.get(name.get().toLowerCase()); if (repo != null) { return repo; } else {// w w w . j a va 2 s. com throw new RepositoryNotFoundException(name.get()); } }
From source file:com.google.gitiles.TestGitilesServlet.java
License:Open Source License
/** * Create a servlet backed by a single test repository. * <p>//from w ww . j a va2 s. c om * The servlet uses the same filter lists as a real servlet, but only knows * about a single repo, having the name returned by * {@link org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription#getRepositoryName()}. * Pass a {@link FakeHttpServletRequest} and {@link FakeHttpServletResponse} * to the servlet's {@code service} method to test. * * @param repo the test repo backing the servlet. * @param gitwebRedirect optional redirect filter for gitweb URLs. * @return a servlet. */ public static GitilesServlet create(final TestRepository<DfsRepository> repo, GitwebRedirectFilter gitwebRedirect) throws ServletException { final String repoName = repo.getRepository().getDescription().getRepositoryName(); GitilesServlet servlet = new GitilesServlet(new Config(), new DefaultRenderer(GitilesServlet.STATIC_PREFIX, ImmutableList.<URL>of(), repoName + " test site"), TestGitilesUrls.URLS, new TestGitilesAccess(repo.getRepository()), new RepositoryResolver<HttpServletRequest>() { @Override public Repository open(HttpServletRequest req, String name) throws RepositoryNotFoundException { if (!repoName.equals(name)) { throw new RepositoryNotFoundException(name); } return repo.getRepository(); } }, null, null, null, gitwebRedirect); servlet.init(new ServletConfig() { @Override public String getInitParameter(String name) { return null; } @Override public Enumeration<String> getInitParameterNames() { return Collections.enumeration(ImmutableList.<String>of()); } @Override public ServletContext getServletContext() { return null; } @Override public String getServletName() { return TestGitilesServlet.class.getName(); } }); return servlet; }
From source file:com.googlesource.gerrit.plugins.gitiles.GerritGitilesAccess.java
License:Apache License
@Override public RepositoryDescription getRepositoryDescription() throws IOException { Project.NameKey nameKey = Resolver.getNameKey(req); ProjectState state = projectCache.get(nameKey); if (state == null) { throw new RepositoryNotFoundException(nameKey.get()); }/*from ww w .j a v a2 s . c om*/ return toDescription(nameKey.get(), projectJson.format(state.getProject())); }
From source file:org.gitorious.http.GitoriousResolver.java
License:Open Source License
public Repository open(HttpServletRequest req, String name) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException { String realName = lookupName(name); if (realName == null) { throw new RepositoryNotFoundException(name); }// w w w . j a v a 2 s . co m try { File gitDir = new File(repositoryRoot, realName); Repository db = RepositoryCache.open(FileKey.lenient(gitDir, FS.DETECTED), true); return db; } catch (IOException io) { logger.error("ERROR: " + io.getMessage()); throw new RepositoryNotFoundException(name); } }