Set maxObjectSizeLimit when project is created via REST

Change-Id: I28f7239bc2095909eaa011b01c38be1eecd856df
This commit is contained in:
Sasa Zivkov
2013-07-01 15:28:22 +02:00
parent a1ec941227
commit 6b40cb447f
3 changed files with 13 additions and 1 deletions

View File

@@ -1210,6 +1210,9 @@ Whether content merge should be enabled for the project (`TRUE`,
|`require_change_id` |`INHERIT` if not set|
Whether the usage of Change-Ids is required for the project (`TRUE`,
`FALSE`, `INHERIT`).
|`max_object_size_limit` |optional|
Max allowed Git object size for this project.
Common unit suffixes of 'k', 'm', or 'g' are supported.
|=========================================
[[project-parent-input]]

View File

@@ -746,7 +746,7 @@ public class ProjectConfig extends VersionedMetaData {
saveGroupList();
}
private static final String validMaxObjectSizeLimit(String value)
public static final String validMaxObjectSizeLimit(String value)
throws ConfigInvalidException {
if (value == null) {
return null;

View File

@@ -29,12 +29,15 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.group.GroupsCollection;
import com.google.gerrit.server.project.CreateProject.Input;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted;
import org.eclipse.jgit.errors.ConfigInvalidException;
import java.io.IOException;
import java.util.List;
@@ -53,6 +56,7 @@ class CreateProject implements RestModifyView<TopLevelResource, Input> {
InheritableBoolean useSignedOffBy;
InheritableBoolean useContentMerge;
InheritableBoolean requireChangeId;
String maxObjectSizeLimit;
}
static interface Factory {
@@ -118,6 +122,11 @@ class CreateProject implements RestModifyView<TopLevelResource, Input> {
input.useContentMerge, InheritableBoolean.INHERIT);
args.changeIdRequired =
Objects.firstNonNull(input.requireChangeId, InheritableBoolean.INHERIT);
try {
args.maxObjectSizeLimit = ProjectConfig.validLong(input.maxObjectSizeLimit);
} catch (ConfigInvalidException e) {
throw new BadRequestException(e.getMessage());
}
Project p = createProjectFactory.create(args).createProject();
return Response.created(json.format(p));