Example usage for org.eclipse.jgit.errors RepositoryNotFoundException RepositoryNotFoundException

List of usage examples for org.eclipse.jgit.errors RepositoryNotFoundException RepositoryNotFoundException

Introduction

In this page you can find the example usage for org.eclipse.jgit.errors RepositoryNotFoundException RepositoryNotFoundException.

Prototype

public RepositoryNotFoundException(String location, Throwable why) 

Source Link

Document

Constructs an exception indicating a local repository does not exist.

Usage

From source file:com.googlesource.gerrit.plugins.gitiles.Resolver.java

License:Apache License

@Override
public Repository open(HttpServletRequest req, String name)
        throws RepositoryNotFoundException, ServiceMayNotContinueException {
    Project.NameKey oldName = getNameKey(req);
    checkState(oldName == null, "Resolved multiple repositories on %s: %s, %s", req.getRequestURL(), oldName,
            name);//  w  w  w . j  a va 2 s . co m
    Project.NameKey nameKey = new Project.NameKey(name);
    req.setAttribute(NAME_KEY_ATTRIBUTE, nameKey);
    try {
        return repoFactory.create(nameKey);
    } catch (NoSuchProjectException e) {
        throw new RepositoryNotFoundException(name, e);
    } catch (IOException e) {
        ServiceMayNotContinueException err = new ServiceMayNotContinueException(
                "error opening repository " + name);
        err.initCause(e);
        throw err;
    }
}

From source file:com.sap.poc.jgit.storage.jdbc.pgm.JdbcDaemon.java

License:Eclipse Distribution License

@Override
protected void run() throws Exception {
    final PackConfig packConfig = new PackConfig();

    if (configFile != null) {
        if (!configFile.exists())
            throw die(MessageFormat.format(CLIText.get().configFileNotFound, configFile.getAbsolutePath()));

        final FileBasedConfig cfg = new FileBasedConfig(configFile, FS.DETECTED);
        cfg.load();/* w  w  w  .  j  ava2  s.co  m*/
        packConfig.fromConfig(cfg);
    }

    int threads = packConfig.getThreads();
    if (threads <= 0)
        threads = Runtime.getRuntime().availableProcessors();
    if (1 < threads)
        packConfig.setExecutor(Executors.newFixedThreadPool(threads));

    final org.eclipse.jgit.transport.Daemon d;

    d = new org.eclipse.jgit.transport.Daemon(
            host != null ? new InetSocketAddress(host, port) : new InetSocketAddress(port));

    final JdbcDatabase db = new JdbcDatabaseBuilder().setURI(uri).build();

    final RepositoryResolver<DaemonClient> resolver = new RepositoryResolver<DaemonClient>() {
        @Override
        public Repository open(DaemonClient req, String name) throws RepositoryNotFoundException {
            try {
                return new JdbcRepositoryBuilder().setDatabase(db).setRepositoryName(name).build();
            } catch (DhtException e) {
                throw new RepositoryNotFoundException(name, e);
            }
        }
    };

    d.setPackConfig(packConfig);
    d.setRepositoryResolver(resolver);
    if (0 <= timeout)
        d.setTimeout(timeout);

    for (final String n : enable)
        service(d, n).setEnabled(true);
    for (final String n : disable)
        service(d, n).setEnabled(false);

    for (final String n : canOverride)
        service(d, n).setOverridable(true);
    for (final String n : forbidOverride)
        service(d, n).setOverridable(false);

    d.start();
    out.println(MessageFormat.format(CLIText.get().listeningOn, d.getAddress()));
}