Fix wrong AuthException in GetHead

The AuthException for the REST API should be used and not the
AuthException from the authentication backend.

Change-Id: I4fcbf10fac258d2798971ac1c9a78ca6f15a7969
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2014-01-26 10:02:14 +01:00
parent dd34a05fdf
commit 36b26bb4d6

View File

@@ -14,9 +14,9 @@
package com.google.gerrit.server.project;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.auth.AuthException;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.inject.Inject;
@@ -54,7 +54,7 @@ public class GetHead implements RestReadView<ProjectResource> {
if (rsrc.getControl().controlForRef(n).isVisible()) {
return n;
}
throw new AuthException();
throw new AuthException("not allowed to see HEAD");
} else if (head.getObjectId() != null) {
RevWalk rw = new RevWalk(repo);
try {
@@ -62,12 +62,12 @@ public class GetHead implements RestReadView<ProjectResource> {
if (rsrc.getControl().canReadCommit(rw, commit)) {
return head.getObjectId().name();
}
throw new AuthException();
throw new AuthException("not allowed to see HEAD");
} catch (MissingObjectException | IncorrectObjectTypeException e) {
if (rsrc.getControl().isOwner()) {
return head.getObjectId().name();
}
throw new AuthException();
throw new AuthException("not allowed to see HEAD");
} finally {
rw.release();
}