Refactor array usage to list for RepositoryConfig and GroupSetProvider

Have getOwnerGroups return a list of strings rather than an array in
RepositoryConfig.

Replace string array usage with a list for the GroupSetProvider
constructor, to simplify the life of its caller(s) now using the
aforementioned list-returning getOwnerGroups.

Update the impacted RepositoryConfigTest tests accordingly. That
includes a minor refactoring in testAllBasePath, for consistency
purposes.

Change-Id: I540dae480a37c3bbb144fef48a95ba4ff29a019f
This commit is contained in:
Marco Miller
2016-04-06 17:42:29 -04:00
parent c2353a6a97
commit 823a4c25d4
5 changed files with 37 additions and 34 deletions

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.config;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.util.ServerRequestContext;
@@ -30,8 +31,8 @@ public class GitReceivePackGroupsProvider extends GroupSetProvider {
@GerritServerConfig Config config,
ThreadLocalRequestContext threadContext,
ServerRequestContext serverCtx) {
super(gb, threadContext, serverCtx, config.getStringList("receive", null,
"allowGroup"));
super(gb, threadContext, serverCtx, ImmutableList.copyOf(
config.getStringList("receive", null, "allowGroup")));
// If no group was set, default to "registered users"
//

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.config;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.group.SystemGroupBackend;
@@ -29,8 +30,8 @@ public class GitUploadPackGroupsProvider extends GroupSetProvider {
@GerritServerConfig Config config,
ThreadLocalRequestContext threadContext,
ServerRequestContext serverCtx) {
super(gb, threadContext, serverCtx, config.getStringList("upload", null,
"allowGroup"));
super(gb, threadContext, serverCtx, ImmutableList.copyOf(
config.getStringList("upload", null, "allowGroup")));
// If no group was set, default to "registered users" and "anonymous"
//

View File

@@ -28,6 +28,7 @@ import com.google.inject.Provider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Set;
public abstract class GroupSetProvider implements
@@ -40,7 +41,7 @@ public abstract class GroupSetProvider implements
@Inject
protected GroupSetProvider(GroupBackend groupBackend,
ThreadLocalRequestContext threadContext,
ServerRequestContext serverCtx, String[] groupNames) {
ServerRequestContext serverCtx, List<String> groupNames) {
RequestContext ctx = threadContext.setContext(serverCtx);
try {
ImmutableSet.Builder<AccountGroup.UUID> builder = ImmutableSet.builder();

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.config;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.reviewdb.client.Project;
import com.google.inject.Inject;
@@ -46,9 +47,9 @@ public class RepositoryConfig {
DEFAULT_SUBMIT_TYPE_NAME, SubmitType.MERGE_IF_NECESSARY);
}
public String[] getOwnerGroups(Project.NameKey project) {
return cfg.getStringList(SECTION_NAME, findSubSection(project.get()),
OWNER_GROUP_NAME);
public List<String> getOwnerGroups(Project.NameKey project) {
return ImmutableList.copyOf(cfg.getStringList(SECTION_NAME,
findSubSection(project.get()), OWNER_GROUP_NAME));
}
public Path getBasePath(Project.NameKey project) {