summaryrefslogtreecommitdiffstats
path: root/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AdminSetParent.java
diff options
context:
space:
mode:
Diffstat (limited to 'gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AdminSetParent.java')
-rw-r--r--gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AdminSetParent.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AdminSetParent.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AdminSetParent.java
index b7d85079d6..22eafd6927 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AdminSetParent.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AdminSetParent.java
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
+import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ListChildProjects;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectControl;
@@ -120,14 +121,18 @@ final class AdminSetParent extends SshCommand {
}
final List<Project.NameKey> childProjects = new ArrayList<>();
- for (final ProjectControl pc : children) {
+ for (ProjectControl pc : children) {
childProjects.add(pc.getProject().getNameKey());
}
if (oldParent != null) {
- childProjects.addAll(getChildrenForReparenting(oldParent));
+ try {
+ childProjects.addAll(getChildrenForReparenting(oldParent));
+ } catch (PermissionBackendException e) {
+ throw new Failure(1, "permissions unavailable", e);
+ }
}
- for (final Project.NameKey nameKey : childProjects) {
+ for (Project.NameKey nameKey : childProjects) {
final String name = nameKey.get();
if (allProjectsName.equals(nameKey)) {
@@ -180,17 +185,18 @@ final class AdminSetParent extends SshCommand {
* list of child projects does not contain projects that were specified to be excluded from
* reparenting.
*/
- private List<Project.NameKey> getChildrenForReparenting(final ProjectControl parent) {
+ private List<Project.NameKey> getChildrenForReparenting(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) {
+ for (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))) {
+ for (ProjectInfo child : listChildProjects.apply(new ProjectResource(parent))) {
final Project.NameKey childName = new Project.NameKey(child.name);
if (!excluded.contains(childName)) {
if (!automaticallyExcluded.contains(childName)) {
@@ -215,6 +221,6 @@ final class AdminSetParent extends SshCommand {
if (ps == null) {
return Collections.emptySet();
}
- return ps.parents().transform(s -> s.getProject().getNameKey()).toSet();
+ return ps.parents().transform(s -> s.getNameKey()).toSet();
}
}