From 2712c9c38827ec97da8fcd240109578c7782225a Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Wed, 29 Apr 2015 13:49:15 +0200 Subject: Fix project creation with plugin config if user is not project owner On project creation it is possible to specify plugin configuration values that should be stored in the project.config file. This failed if the calling user was not becoming owner of the created project, because only project owners can edit the project.config file. With this change now it is sufficient to have the 'Create Project' capability to create a project with an initial plugin configuration, even if the creating user is not becoming project owner of the created project. Change-Id: Ifecfeadd425afeff83197b11c97c1c2bbbef8eef --- .../java/com/google/gerrit/server/project/CreateProject.java | 2 +- .../main/java/com/google/gerrit/server/project/PutConfig.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java index 37ab506a91..e69b62cf9d 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java @@ -147,7 +147,7 @@ public class CreateProject implements RestModifyView { public ConfigInfo apply(ProjectResource rsrc, Input input) throws ResourceNotFoundException, BadRequestException, ResourceConflictException { - Project.NameKey projectName = rsrc.getNameKey(); if (!rsrc.getControl().isOwner()) { - throw new ResourceNotFoundException(projectName.get()); + throw new ResourceNotFoundException(rsrc.getName()); } + return apply(rsrc.getControl(), input); + } + public ConfigInfo apply(ProjectControl ctrl, Input input) + throws ResourceNotFoundException, BadRequestException, + ResourceConflictException { + Project.NameKey projectName = ctrl.getProject().getNameKey(); if (input == null) { throw new BadRequestException("config is required"); } @@ -163,7 +168,7 @@ public class PutConfig implements RestModifyView { } if (input.pluginConfigValues != null) { - setPluginConfigValues(rsrc.getControl().getProjectState(), + setPluginConfigValues(ctrl.getProjectState(), projectConfig, input.pluginConfigValues); } -- cgit v1.2.3