import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
} catch (ServiceNotAuthorizedException e) {
res.sendError(SC_UNAUTHORIZED);
return;
+ } catch (ServiceMayNotContinueException e) {
+ sendError(req, res, SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ return;
}
try {
request.setAttribute(ATTRIBUTE_REPOSITORY, db);
return null;
}
- Repository openRepository(DaemonClient client, String name) {
+ Repository openRepository(DaemonClient client, String name)
+ throws ServiceMayNotContinueException {
// Assume any attempt to use \ was by a Windows client
// and correct to the more typical / used in Git URIs.
//
throws IOException, ServiceNotEnabledException,
ServiceNotAuthorizedException {
final String name = commandLine.substring(command.length() + 1);
- Repository db = client.getDaemon().openRepository(client, name);
+ 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());
+ pktOut.writeString("ERR " + e.getMessage() + "\n");
+ db = null;
+ }
if (db == null)
return;
try {
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.transport.ServiceMayNotContinueException;
/**
* Locate a Git {@link Repository} by name from the URL.
* @throws ServiceNotEnabledException
* the repository may exist, but HTTP access is not allowed on the
* target repository, for the current user.
+ * @throws ServiceMayNotContinueException
+ * the repository may exist, but HTTP access is not allowed for
+ * the current request. The exception message contains a detailed
+ * message that should be shown to the user.
*/
Repository open(C req, String name) throws RepositoryNotFoundException,
- ServiceNotAuthorizedException, ServiceNotEnabledException;
+ ServiceNotAuthorizedException, ServiceNotEnabledException,
+ ServiceMayNotContinueException;
}