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);
}
}
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());
}
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();
}
}
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));
}
Aggregations