Merge "Fix project creation with plugin config if user is not project owner" into stable-2.10

This commit is contained in:
Edwin Kempin 2015-04-30 07:10:29 +00:00 committed by Gerrit Code Review
commit fa7880a804
2 changed files with 9 additions and 4 deletions

View File

@ -147,7 +147,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
projectControlFactory.controlFor(p.getNameKey(), currentUser.get());
PutConfig.Input in = new PutConfig.Input();
in.pluginConfigValues = input.pluginConfigValues;
putConfig.get().apply(new ProjectResource(projectControl), in);
putConfig.get().apply(projectControl, in);
} catch (NoSuchProjectException e) {
throw new ResourceNotFoundException(p.getName());
}

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);
}