Skip to content

Commit

Permalink
ListChildProjects: Make settting recursive option chainable
Browse files Browse the repository at this point in the history
Change-Id: I4ffa174cd8ba2b062cd230a8e116f45c65f58693
  • Loading branch information
davido authored and dpursehouse committed Feb 4, 2019
1 parent d3039e7 commit 712f699
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Expand Up @@ -70,7 +70,6 @@
import com.google.gerrit.server.restapi.project.GetParent;
import com.google.gerrit.server.restapi.project.Index;
import com.google.gerrit.server.restapi.project.ListBranches;
import com.google.gerrit.server.restapi.project.ListChildProjects;
import com.google.gerrit.server.restapi.project.ListDashboards;
import com.google.gerrit.server.restapi.project.ListTags;
import com.google.gerrit.server.restapi.project.ProjectsCollection;
Expand Down Expand Up @@ -475,10 +474,8 @@ public List<ProjectInfo> children() throws RestApiException {

@Override
public List<ProjectInfo> children(boolean recursive) throws RestApiException {
ListChildProjects list = children.list();
list.setRecursive(recursive);
try {
return list.apply(checkExists());
return children.list().withRecursive(recursive).apply(checkExists());
} catch (Exception e) {
throw asRestApiException("Cannot list children", e);
}
Expand Down
4 changes: 1 addition & 3 deletions java/com/google/gerrit/server/restapi/project/Index.java
Expand Up @@ -63,9 +63,7 @@ public Response.Accepted apply(ProjectResource rsrc, IndexProjectInput input)

reindex(rsrc.getNameKey(), input.async);
if (Boolean.TRUE.equals(input.indexChildren)) {
ListChildProjects listChildProjects = listChildProjectsProvider.get();
listChildProjects.setRecursive(true);
for (ProjectInfo child : listChildProjects.apply(rsrc)) {
for (ProjectInfo child : listChildProjectsProvider.get().withRecursive(true).apply(rsrc)) {
reindex(new Project.NameKey(child.name), input.async);
}

Expand Down
Expand Up @@ -56,8 +56,9 @@ public class ListChildProjects implements RestReadView<ProjectResource> {
this.queryProvider = queryProvider;
}

public void setRecursive(boolean recursive) {
public ListChildProjects withRecursive(boolean recursive) {
this.recursive = recursive;
return this;
}

public ListChildProjects withLimit(int limit) {
Expand Down

0 comments on commit 712f699

Please sign in to comment.