Search in sources :

Example 1 with ServiceMayNotContinueException

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

the class RepositoryFilter method doFilter.

@Override
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException {
    try {
        String repo = ViewFilter.trimLeadingSlash(getRegexGroup(req, 1));
        try (Repository git = resolver.open(req, repo)) {
            req.setAttribute(ATTRIBUTE_REPOSITORY, git);
            chain.doFilter(req, res);
        } catch (RepositoryNotFoundException e) {
            // Drop through the rest of the chain. ViewFilter will pass this
            // to HostIndexServlet which will attempt to list repositories
            // or send SC_NOT_FOUND there.
            chain.doFilter(req, res);
        } catch (ServiceMayNotContinueException e) {
            sendError(req, res, e.getStatusCode(), e.getMessage());
        } finally {
            req.removeAttribute(ATTRIBUTE_REPOSITORY);
        }
    } catch (ServiceNotEnabledException e) {
        sendError(req, res, SC_FORBIDDEN);
    } catch (ServiceNotAuthorizedException e) {
        res.sendError(SC_UNAUTHORIZED);
    }
}
Also used : Repository(org.eclipse.jgit.lib.Repository) ServiceNotEnabledException(org.eclipse.jgit.transport.resolver.ServiceNotEnabledException) RepositoryNotFoundException(org.eclipse.jgit.errors.RepositoryNotFoundException) ServiceMayNotContinueException(org.eclipse.jgit.transport.ServiceMayNotContinueException) ServiceNotAuthorizedException(org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException)

Example 2 with ServiceMayNotContinueException

use of org.eclipse.jgit.transport.ServiceMayNotContinueException in project gerrit by GerritCodeReview.

the class ReceiveCommitsAdvertiseRefsHook method advertiseRefs.

@Override
public void advertiseRefs(BaseReceivePack rp) throws ServiceMayNotContinueException {
    Map<String, Ref> oldRefs = rp.getAdvertisedRefs();
    if (oldRefs == null) {
        try {
            oldRefs = rp.getRepository().getRefDatabase().getRefs(ALL);
        } catch (ServiceMayNotContinueException e) {
            throw e;
        } catch (IOException e) {
            ServiceMayNotContinueException ex = new ServiceMayNotContinueException();
            ex.initCause(e);
            throw ex;
        }
    }
    Result r = advertiseRefs(oldRefs);
    rp.setAdvertisedRefs(r.allRefs(), r.additionalHaves());
}
Also used : Ref(org.eclipse.jgit.lib.Ref) ServiceMayNotContinueException(org.eclipse.jgit.transport.ServiceMayNotContinueException) IOException(java.io.IOException)

Example 3 with ServiceMayNotContinueException

use of org.eclipse.jgit.transport.ServiceMayNotContinueException in project gitblit by gitblit.

the class GitDaemonService method execute.

void execute(final GitDaemonClient client, final String commandLine) throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException {
    final String name = commandLine.substring(command.length() + 1);
    Repository db;
    try {
        db = client.getDaemon().openRepository(client, name);
    } catch (ServiceMayNotContinueException e) {
        // An error when opening the repo means the client is expecting a ref
        // advertisement, so use that style of error.
        PacketLineOut pktOut = new PacketLineOut(client.getOutputStream());
        //$NON-NLS-1$ //$NON-NLS-2$
        pktOut.writeString("ERR " + e.getMessage() + "\n");
        db = null;
    }
    if (db == null)
        return;
    try {
        if (isEnabledFor(db))
            execute(client, db);
    } finally {
        db.close();
    }
}
Also used : Repository(org.eclipse.jgit.lib.Repository) PacketLineOut(org.eclipse.jgit.transport.PacketLineOut) ServiceMayNotContinueException(org.eclipse.jgit.transport.ServiceMayNotContinueException)

Example 4 with ServiceMayNotContinueException

use of org.eclipse.jgit.transport.ServiceMayNotContinueException in project gerrit by GerritCodeReview.

the class HackPushNegotiateHook method advertiseRefs.

@Override
public void advertiseRefs(BaseReceivePack rp) throws ServiceMayNotContinueException {
    Map<String, Ref> r = rp.getAdvertisedRefs();
    if (r == null) {
        try {
            r = rp.getRepository().getRefDatabase().getRefs(ALL);
        } catch (ServiceMayNotContinueException e) {
            throw e;
        } catch (IOException e) {
            ServiceMayNotContinueException ex = new ServiceMayNotContinueException();
            ex.initCause(e);
            throw ex;
        }
    }
    rp.setAdvertisedRefs(r, history(r.values(), rp));
}
Also used : Ref(org.eclipse.jgit.lib.Ref) ServiceMayNotContinueException(org.eclipse.jgit.transport.ServiceMayNotContinueException) IOException(java.io.IOException)

Aggregations

ServiceMayNotContinueException (org.eclipse.jgit.transport.ServiceMayNotContinueException)4 IOException (java.io.IOException)2 Ref (org.eclipse.jgit.lib.Ref)2 Repository (org.eclipse.jgit.lib.Repository)2 RepositoryNotFoundException (org.eclipse.jgit.errors.RepositoryNotFoundException)1 PacketLineOut (org.eclipse.jgit.transport.PacketLineOut)1 ServiceNotAuthorizedException (org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException)1 ServiceNotEnabledException (org.eclipse.jgit.transport.resolver.ServiceNotEnabledException)1