Make project state check in DELETE explicit

The majority of code in {Project,Ref,Change}Control is now about
permissions, but not all. Exceptions include checks for a project's
state. This is confusing, because users are presented with an exception
telling them that they lack some kind of permission while the real
reason for the failed operation is that the project's current state
doesn't permit the operation.

This is part of a series of commits to remove all project state checks
from *Control classes and make explicit checks instead.

Change-Id: I261a535527bdfb2ae5449781115537cd7a71082c
This commit is contained in:
Patrick Hiesel
2018-01-12 11:47:57 +01:00
parent 3ea2679096
commit 9e1fb490c1
9 changed files with 27 additions and 14 deletions

View File

@@ -1120,7 +1120,7 @@ class ReceiveCommits {
private boolean canDelete(ReceiveCommand cmd) throws PermissionBackendException {
try {
permissions.ref(cmd.getRefName()).check(RefPermission.DELETE);
return true;
return projectState.statePermitsWrite();
} catch (AuthException e) {
return false;
}