Search in sources :

Example 16 with ProjectControl

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;
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) ArrayList(java.util.ArrayList) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) ProjectResource(com.google.gerrit.server.project.ProjectResource) ProjectControl(com.google.gerrit.server.project.ProjectControl)

Aggregations

ProjectControl (com.google.gerrit.server.project.ProjectControl)16 AuthException (com.google.gerrit.extensions.restapi.AuthException)5 Project (com.google.gerrit.reviewdb.client.Project)5 Capable (com.google.gerrit.common.data.Capable)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)4 Change (com.google.gerrit.reviewdb.client.Change)4 RefControl (com.google.gerrit.server.project.RefControl)4 ArrayList (java.util.ArrayList)4 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)3 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)3 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)3 NoSuchProjectException (com.google.gerrit.server.project.NoSuchProjectException)3 ProjectState (com.google.gerrit.server.project.ProjectState)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 AccessSection (com.google.gerrit.common.data.AccessSection)2 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)2 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)2 IntegrationException (com.google.gerrit.server.git.IntegrationException)2 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)2 ChangeControl (com.google.gerrit.server.project.ChangeControl)2