use of com.google.gerrit.server.project.ProjectControl in project gerrit by GerritCodeReview.
the class AdminSetParent method getChildrenForReparenting.
/**
* Returns the children of the specified parent project that should be reparented. The returned
* list of child projects does not contain projects that were specified to be excluded from
* reparenting.
*/
private List<Project.NameKey> getChildrenForReparenting(final ProjectControl parent) throws PermissionBackendException {
final List<Project.NameKey> childProjects = new ArrayList<>();
final List<Project.NameKey> excluded = new ArrayList<>(excludedChildren.size());
for (final ProjectControl excludedChild : excludedChildren) {
excluded.add(excludedChild.getProject().getNameKey());
}
final List<Project.NameKey> automaticallyExcluded = new ArrayList<>(excludedChildren.size());
if (newParentKey != null) {
automaticallyExcluded.addAll(getAllParents(newParentKey));
}
for (final ProjectInfo child : listChildProjects.apply(new ProjectResource(parent))) {
final Project.NameKey childName = new Project.NameKey(child.name);
if (!excluded.contains(childName)) {
if (!automaticallyExcluded.contains(childName)) {
childProjects.add(childName);
} else {
stdout.println("Automatically excluded '" + childName + "' " + "from reparenting because it is in the parent " + "line of the new parent '" + newParentKey + "'.");
}
}
}
return childProjects;
}
Aggregations