Reuse ProjectInfo from ProjectJson in ListProjects
It doesn't make sense to have two ProjectInfo classes that are virtually the same. Change-Id: I7473b4227ec7ca0981722c4d6e88a7206b6e7aff Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -26,7 +26,6 @@ import com.google.gerrit.extensions.restapi.BinaryResult;
|
|||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||||
import com.google.gerrit.extensions.restapi.Url;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
@@ -35,6 +34,7 @@ import com.google.gerrit.server.StringUtil;
|
|||||||
import com.google.gerrit.server.account.GroupCache;
|
import com.google.gerrit.server.account.GroupCache;
|
||||||
import com.google.gerrit.server.account.GroupControl;
|
import com.google.gerrit.server.account.GroupControl;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
|
import com.google.gerrit.server.project.ProjectJson.ProjectInfo;
|
||||||
import com.google.gerrit.server.util.TreeFormatter;
|
import com.google.gerrit.server.util.TreeFormatter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@@ -245,7 +245,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
&& !rejected.contains(parentState.getProject().getName())) {
|
&& !rejected.contains(parentState.getProject().getName())) {
|
||||||
ProjectControl parentCtrl = parentState.controlFor(currentUser);
|
ProjectControl parentCtrl = parentState.controlFor(currentUser);
|
||||||
if (parentCtrl.isVisible() || parentCtrl.isOwner()) {
|
if (parentCtrl.isVisible() || parentCtrl.isOwner()) {
|
||||||
info.setName(parentState.getProject().getName());
|
info.name = parentState.getProject().getName();
|
||||||
info.description = Strings.emptyToNull(
|
info.description = Strings.emptyToNull(
|
||||||
parentState.getProject().getDescription());
|
parentState.getProject().getDescription());
|
||||||
} else {
|
} else {
|
||||||
@@ -270,7 +270,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.setName(projectName.get());
|
info.name = projectName.get();
|
||||||
if (showTree && format.isJson()) {
|
if (showTree && format.isJson()) {
|
||||||
ProjectState parent = Iterables.getFirst(e.parents(), null);
|
ProjectState parent = Iterables.getFirst(e.parents(), null);
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@@ -364,6 +364,10 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
stdout.print('\n');
|
stdout.print('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ProjectInfo info : output.values()) {
|
||||||
|
info.finish();
|
||||||
|
info.name = null;
|
||||||
|
}
|
||||||
if (stdout == null) {
|
if (stdout == null) {
|
||||||
return OutputFormat.JSON.newGson().toJsonTree(
|
return OutputFormat.JSON.newGson().toJsonTree(
|
||||||
output,
|
output,
|
||||||
@@ -456,19 +460,4 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ProjectInfo {
|
|
||||||
final String kind = "gerritcodereview#project";
|
|
||||||
|
|
||||||
transient String name;
|
|
||||||
String id;
|
|
||||||
String parent;
|
|
||||||
String description;
|
|
||||||
Map<String, String> branches;
|
|
||||||
|
|
||||||
void setName(String n) {
|
|
||||||
name = n;
|
|
||||||
id = Url.encode(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,8 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gerrit.server.config.AllProjectsName;
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ProjectJson {
|
public class ProjectJson {
|
||||||
|
|
||||||
private final AllProjectsName allProjects;
|
private final AllProjectsName allProjects;
|
||||||
@@ -49,6 +51,7 @@ public class ProjectJson {
|
|||||||
String name;
|
String name;
|
||||||
String parent;
|
String parent;
|
||||||
String description;
|
String description;
|
||||||
|
Map<String, String> branches;
|
||||||
|
|
||||||
void finish() {
|
void finish() {
|
||||||
id = Url.encode(name);
|
id = Url.encode(name);
|
||||||
|
Reference in New Issue
Block a user