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
This commit is contained in:
@@ -80,7 +80,6 @@ public interface Projects {
|
|||||||
abstract class ListRequest {
|
abstract class ListRequest {
|
||||||
public enum FilterType {
|
public enum FilterType {
|
||||||
CODE,
|
CODE,
|
||||||
PARENT_CANDIDATES,
|
|
||||||
PERMISSIONS,
|
PERMISSIONS,
|
||||||
ALL
|
ALL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,9 +118,6 @@ class ProjectsImpl implements Projects {
|
|||||||
case CODE:
|
case CODE:
|
||||||
type = FilterType.CODE;
|
type = FilterType.CODE;
|
||||||
break;
|
break;
|
||||||
case PARENT_CANDIDATES:
|
|
||||||
type = FilterType.PARENT_CANDIDATES;
|
|
||||||
break;
|
|
||||||
case PERMISSIONS:
|
case PERMISSIONS:
|
||||||
type = FilterType.PERMISSIONS;
|
type = FilterType.PERMISSIONS;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -97,17 +96,6 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PARENT_CANDIDATES {
|
|
||||||
@Override
|
|
||||||
boolean matches(Repository git) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean useMatch() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
PERMISSIONS {
|
PERMISSIONS {
|
||||||
@Override
|
@Override
|
||||||
boolean matches(Repository git) throws IOException {
|
boolean matches(Repository git) throws IOException {
|
||||||
@@ -339,11 +327,6 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
new PrintWriter(new BufferedWriter(new OutputStreamWriter(displayOutputStream, UTF_8)));
|
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 foundIndex = 0;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
TreeMap<String, ProjectInfo> output = new TreeMap<>();
|
TreeMap<String, ProjectInfo> output = new TreeMap<>();
|
||||||
@@ -447,10 +430,8 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != FilterType.PARENT_CANDIDATES) {
|
List<WebLinkInfo> links = webLinks.getProjectLinks(projectName.get());
|
||||||
List<WebLinkInfo> links = webLinks.getProjectLinks(projectName.get());
|
info.webLinks = links.isEmpty() ? null : links;
|
||||||
info.webLinks = links.isEmpty() ? null : links;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundIndex++ < start) {
|
if (foundIndex++ < start) {
|
||||||
continue;
|
continue;
|
||||||
@@ -509,9 +490,6 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
private Collection<Project.NameKey> filter(PermissionBackend.WithUser perm)
|
private Collection<Project.NameKey> filter(PermissionBackend.WithUser perm)
|
||||||
throws BadRequestException, PermissionBackendException {
|
throws BadRequestException, PermissionBackendException {
|
||||||
Stream<Project.NameKey> matches = scan();
|
Stream<Project.NameKey> matches = scan();
|
||||||
if (type == FilterType.PARENT_CANDIDATES) {
|
|
||||||
matches = parentsOf(matches);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Project.NameKey> results = new ArrayList<>();
|
List<Project.NameKey> results = new ArrayList<>();
|
||||||
List<Project.NameKey> projectNameKeys = matches.sorted().collect(toList());
|
List<Project.NameKey> projectNameKeys = matches.sorted().collect(toList());
|
||||||
@@ -536,27 +514,6 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream<Project.NameKey> parentsOf(Stream<Project.NameKey> 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(
|
private boolean isParentAccessible(
|
||||||
Map<Project.NameKey, Boolean> checked, PermissionBackend.WithUser perm, ProjectState state)
|
Map<Project.NameKey, Boolean> checked, PermissionBackend.WithUser perm, ProjectState state)
|
||||||
throws PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
|
|||||||
Reference in New Issue
Block a user