Check if project state is readable in ProjectsCollection

This commit adds a dedicated check for project state to
ProjectsCollection that is only triggered when the user is not a project
owner. This is intended as safety net for the case where child views
forget to check for the project state explicity.

We can't do a general check in ProjectsCollection that is not gated on
being a project owner since the API has to allow setting back a project
state from HIDDEN to READ_ONLY or ACTIVE. Therfore child views should
continue with explicit checks on the project state.

Change-Id: I4bf6d50569ac41678e8a75711ed604ab22154894
This commit is contained in:
Patrick Hiesel
2018-01-16 17:04:31 +01:00
parent 0a9994fab9
commit a0cce23a7f
5 changed files with 32 additions and 17 deletions

View File

@@ -18,7 +18,6 @@ import com.google.gerrit.extensions.client.ProjectWatchInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountsUpdate;
@@ -83,8 +82,7 @@ public class PostWatchedProjects
}
private Map<ProjectWatchKey, Set<NotifyType>> asMap(List<ProjectWatchInfo> input)
throws BadRequestException, UnprocessableEntityException, IOException,
PermissionBackendException {
throws RestApiException, IOException, PermissionBackendException {
Map<ProjectWatchKey, Set<NotifyType>> m = new HashMap<>();
for (ProjectWatchInfo info : input) {
if (info.project == null) {