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
This commit is contained in:
Edwin Kempin
2015-04-29 13:49:15 +02:00
parent e6782847f8
commit 2712c9c388
2 changed files with 9 additions and 4 deletions

View File

@@ -114,11 +114,16 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
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<ProjectResource, Input> {
}
if (input.pluginConfigValues != null) {
setPluginConfigValues(rsrc.getControl().getProjectState(),
setPluginConfigValues(ctrl.getProjectState(),
projectConfig, input.pluginConfigValues);
}