diff --git a/Documentation/rest-api-projects.txt b/Documentation/rest-api-projects.txt index 6e460d6efa..eee31519f1 100644 --- a/Documentation/rest-api-projects.txt +++ b/Documentation/rest-api-projects.txt @@ -2805,7 +2805,7 @@ limit] of a project. |=============================== |Field Name ||Description |`value` |optional| -The effective value of the max object size limit as a formatted string. + +The effective value in bytes of the max object size limit. + Not set if there is no limit for the object size. |`configured_value`|optional| The max object size limit that is configured on the project as a diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java index cc88a6d121..7c62302192 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java @@ -151,7 +151,7 @@ public class ProjectIT extends AbstractDaemonTest { public void maxObjectSizeCanBeSetAndCleared() throws Exception { // Set a value ConfigInfo info = setMaxObjectSize("100k"); - assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k"); + assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400"); assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k"); assertThat(info.maxObjectSizeLimit.inheritedValue).isNull(); @@ -167,6 +167,7 @@ public class ProjectIT extends AbstractDaemonTest { Project.NameKey child = createProject(name("child"), project); ConfigInfo info = setMaxObjectSize("100k"); + assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400"); assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k"); assertThat(info.maxObjectSizeLimit.inheritedValue).isNull(); @@ -180,7 +181,7 @@ public class ProjectIT extends AbstractDaemonTest { @GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k") public void maxObjectSizeIsInheritedFromGlobalConfig() throws Exception { ConfigInfo info = getConfig(); - assertThat(info.maxObjectSizeLimit.value).isEqualTo("200k"); + assertThat(info.maxObjectSizeLimit.value).isEqualTo("204800"); assertThat(info.maxObjectSizeLimit.configuredValue).isNull(); assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k"); } @@ -189,7 +190,7 @@ public class ProjectIT extends AbstractDaemonTest { @GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k") public void maxObjectSizeOverridesGlobalConfigWhenLower() throws Exception { ConfigInfo info = setMaxObjectSize("100k"); - assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k"); + assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400"); assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k"); assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k"); } @@ -198,7 +199,7 @@ public class ProjectIT extends AbstractDaemonTest { @GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k") public void maxObjectSizeDoesNotOverrideGlobalConfigWhenHigher() throws Exception { ConfigInfo info = setMaxObjectSize("300k"); - assertThat(info.maxObjectSizeLimit.value).isEqualTo("200k"); + assertThat(info.maxObjectSizeLimit.value).isEqualTo("204800"); assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("300k"); assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k"); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.java index 0c2f6fa80c..fe27e9c7cf 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.java @@ -38,6 +38,8 @@ public interface AdminMessages extends Messages { String globalMaxObjectSizeLimit(String globalMaxObjectSizeLimit); + String noMaxObjectSizeLimit(); + String pluginProjectOptionsTitle(String pluginName); String pluginProjectInheritedValue(String value); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.properties index 6338920c6e..f746365f18 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminMessages.properties @@ -5,8 +5,9 @@ project = Project {0} deletedGroup = Deleted Group {0} deletedReference = Reference {0} was deleted deletedSection = Section {0} was deleted -effectiveMaxObjectSizeLimit = effective: {0} +effectiveMaxObjectSizeLimit = effective: {0} bytes globalMaxObjectSizeLimit = The global max object size limit is set to {0}. The limit cannot be increased on project level. +noMaxObjectSizeLimit = No max object size limit is set. pluginProjectOptionsTitle = {0} Plugin Options pluginProjectOptionsTitle = {0} Plugin pluginProjectInheritedValue = inherited: {0} diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java index 144a152373..0e185eb130 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java @@ -401,14 +401,15 @@ public class ProjectInfoScreen extends ProjectScreen { setSubmitType(result.submitType()); setState(result.state()); maxObjectSizeLimit.setText(result.maxObjectSizeLimit().configuredValue()); - if (result.maxObjectSizeLimit().inheritedValue() != null) { - effectiveMaxObjectSizeLimit.setVisible(true); + if (result.maxObjectSizeLimit().value() != null) { effectiveMaxObjectSizeLimit.setText( AdminMessages.I.effectiveMaxObjectSizeLimit(result.maxObjectSizeLimit().value())); - effectiveMaxObjectSizeLimit.setTitle( - AdminMessages.I.globalMaxObjectSizeLimit(result.maxObjectSizeLimit().inheritedValue())); + if (result.maxObjectSizeLimit().inheritedValue() != null) { + effectiveMaxObjectSizeLimit.setTitle( + AdminMessages.I.globalMaxObjectSizeLimit(result.maxObjectSizeLimit().inheritedValue())); + } } else { - effectiveMaxObjectSizeLimit.setVisible(false); + effectiveMaxObjectSizeLimit.setText(AdminMessages.I.noMaxObjectSizeLimit()); } saveProject.setEnabled(false); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java index 0ddb8475ec..24760b7b10 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java @@ -125,10 +125,8 @@ public class ConfigInfoImpl extends ConfigInfo { private MaxObjectSizeLimitInfo getMaxObjectSizeLimit( ProjectState projectState, TransferConfig transferConfig, Project p) { MaxObjectSizeLimitInfo info = new MaxObjectSizeLimitInfo(); - info.value = - projectState.getEffectiveMaxObjectSizeLimit() == transferConfig.getMaxObjectSizeLimit() - ? transferConfig.getFormattedMaxObjectSizeLimit() - : p.getMaxObjectSizeLimit(); + long value = projectState.getEffectiveMaxObjectSizeLimit(); + info.value = value == 0 ? null : String.valueOf(value); info.configuredValue = p.getMaxObjectSizeLimit(); info.inheritedValue = transferConfig.getFormattedMaxObjectSizeLimit(); return info;