From f7479fda63b43a6beaa108ed98de9675ee3f90a0 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Tue, 22 Jan 2019 09:08:50 +0100 Subject: [PATCH] ListProjects: Remove parent candidates option After removal of GWT UI this feature is not used and this can be removed. Create project SSH command is offering a similar --suggest-parents but this is implemented using a dedicated: SuggestParentCandidates class. PolyGerrit UI doesn't offer the list of parent candidates to select from in create repository dialog. Change-Id: Iaaa687f4df373bc945632367be49941c939f8b9b --- .../extensions/api/projects/Projects.java | 1 - .../server/api/projects/ProjectsImpl.java | 3 -- .../server/restapi/project/ListProjects.java | 47 +------------------ 3 files changed, 2 insertions(+), 49 deletions(-) diff --git a/java/com/google/gerrit/extensions/api/projects/Projects.java b/java/com/google/gerrit/extensions/api/projects/Projects.java index 85ec26fd0c..34ca7d493f 100644 --- a/java/com/google/gerrit/extensions/api/projects/Projects.java +++ b/java/com/google/gerrit/extensions/api/projects/Projects.java @@ -80,7 +80,6 @@ public interface Projects { abstract class ListRequest { public enum FilterType { CODE, - PARENT_CANDIDATES, PERMISSIONS, ALL } diff --git a/java/com/google/gerrit/server/api/projects/ProjectsImpl.java b/java/com/google/gerrit/server/api/projects/ProjectsImpl.java index 4552e7a6f7..580ec54d4a 100644 --- a/java/com/google/gerrit/server/api/projects/ProjectsImpl.java +++ b/java/com/google/gerrit/server/api/projects/ProjectsImpl.java @@ -118,9 +118,6 @@ class ProjectsImpl implements Projects { case CODE: type = FilterType.CODE; break; - case PARENT_CANDIDATES: - type = FilterType.PARENT_CANDIDATES; - break; case PERMISSIONS: type = FilterType.PERMISSIONS; break; diff --git a/java/com/google/gerrit/server/restapi/project/ListProjects.java b/java/com/google/gerrit/server/restapi/project/ListProjects.java index ef5abcb8b4..075febec85 100644 --- a/java/com/google/gerrit/server/restapi/project/ListProjects.java +++ b/java/com/google/gerrit/server/restapi/project/ListProjects.java @@ -69,7 +69,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; @@ -97,17 +96,6 @@ public class ListProjects implements RestReadView { return true; } }, - PARENT_CANDIDATES { - @Override - boolean matches(Repository git) { - return true; - } - - @Override - boolean useMatch() { - return false; - } - }, PERMISSIONS { @Override boolean matches(Repository git) throws IOException { @@ -339,11 +327,6 @@ public class ListProjects implements RestReadView { new PrintWriter(new BufferedWriter(new OutputStreamWriter(displayOutputStream, UTF_8))); } - if (type == FilterType.PARENT_CANDIDATES) { - // Historically, PARENT_CANDIDATES implied showDescription. - showDescription = true; - } - int foundIndex = 0; int found = 0; TreeMap output = new TreeMap<>(); @@ -447,10 +430,8 @@ public class ListProjects implements RestReadView { continue; } - if (type != FilterType.PARENT_CANDIDATES) { - List links = webLinks.getProjectLinks(projectName.get()); - info.webLinks = links.isEmpty() ? null : links; - } + List links = webLinks.getProjectLinks(projectName.get()); + info.webLinks = links.isEmpty() ? null : links; if (foundIndex++ < start) { continue; @@ -509,9 +490,6 @@ public class ListProjects implements RestReadView { private Collection filter(PermissionBackend.WithUser perm) throws BadRequestException, PermissionBackendException { Stream matches = scan(); - if (type == FilterType.PARENT_CANDIDATES) { - matches = parentsOf(matches); - } List results = new ArrayList<>(); List projectNameKeys = matches.sorted().collect(toList()); @@ -536,27 +514,6 @@ public class ListProjects implements RestReadView { return results; } - private Stream parentsOf(Stream matches) { - return matches - .map( - p -> { - ProjectState ps = projectCache.get(p); - if (ps != null) { - Project.NameKey parent = ps.getProject().getParent(); - if (parent != null) { - if (projectCache.get(parent) != null) { - return parent; - } - logger.atWarning().log( - "parent project %s of project %s not found", parent.get(), ps.getName()); - } - } - return null; - }) - .filter(Objects::nonNull) - .distinct(); - } - private boolean isParentAccessible( Map checked, PermissionBackend.WithUser perm, ProjectState state) throws PermissionBackendException {