WebLinks: Use WebLinkInfo directly
Intermediate class WebLinks.Link is used in REST web links related endpoints. This is unnecessary complication. Use WebLinkInfo class directly. Change-Id: I279f65bb8a2b9442f3035ad3e8a02fe34761b54f
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.extensions.common.WebLinkInfo;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.extensions.webui.PatchSetWebLink;
|
||||
import com.google.gerrit.extensions.webui.ProjectWebLink;
|
||||
@@ -32,31 +33,21 @@ public class WebLinks {
|
||||
this.projectLinks = projectLinks;
|
||||
}
|
||||
|
||||
public Iterable<Link> getPatchSetLinks(String project, String commit) {
|
||||
List<Link> links = Lists.newArrayList();
|
||||
public Iterable<WebLinkInfo> getPatchSetLinks(String project, String commit) {
|
||||
List<WebLinkInfo> links = Lists.newArrayList();
|
||||
for (PatchSetWebLink webLink : patchSetLinks) {
|
||||
links.add(new Link(webLink.getLinkName(),
|
||||
links.add(new WebLinkInfo(webLink.getLinkName(),
|
||||
webLink.getPatchSetUrl(project, commit)));
|
||||
}
|
||||
return links;
|
||||
}
|
||||
|
||||
public Iterable<Link> getProjectLinks(String project) {
|
||||
List<Link> links = Lists.newArrayList();
|
||||
public Iterable<WebLinkInfo> getProjectLinks(String project) {
|
||||
List<WebLinkInfo> links = Lists.newArrayList();
|
||||
for (ProjectWebLink webLink : projectLinks) {
|
||||
links.add(new Link(webLink.getLinkName(),
|
||||
links.add(new WebLinkInfo(webLink.getLinkName(),
|
||||
webLink.getProjectUrl(project)));
|
||||
}
|
||||
return links;
|
||||
}
|
||||
|
||||
public class Link {
|
||||
public String name;
|
||||
public String url;
|
||||
|
||||
public Link(String name, String url) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -830,9 +830,9 @@ public class ChangeJson {
|
||||
|
||||
if (has(WEB_LINKS)) {
|
||||
out.webLinks = Lists.newArrayList();
|
||||
for (WebLinks.Link link : webLinks.get().getPatchSetLinks(
|
||||
for (WebLinkInfo link : webLinks.get().getPatchSetLinks(
|
||||
project, in.getRevision().get())) {
|
||||
out.webLinks.add(new WebLinkInfo(link.name, link.url));
|
||||
out.webLinks.add(link);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
|
@@ -386,9 +386,9 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
}
|
||||
|
||||
info.webLinks = Lists.newArrayList();
|
||||
for (WebLinks.Link link : webLinks.get().getProjectLinks(projectName.get())) {
|
||||
for (WebLinkInfo link : webLinks.get().getProjectLinks(projectName.get())) {
|
||||
if (!Strings.isNullOrEmpty(link.name) && !Strings.isNullOrEmpty(link.url)) {
|
||||
info.webLinks.add(new WebLinkInfo(link.name, link.url));
|
||||
info.webLinks.add(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -54,9 +54,9 @@ public class ProjectJson {
|
||||
info.id = Url.encode(info.name);
|
||||
|
||||
info.webLinks = Lists.newArrayList();
|
||||
for (WebLinks.Link link : webLinks.get().getProjectLinks(p.getName())) {
|
||||
for (WebLinkInfo link : webLinks.get().getProjectLinks(p.getName())) {
|
||||
if (!Strings.isNullOrEmpty(link.name) && !Strings.isNullOrEmpty(link.url)) {
|
||||
info.webLinks.add(new WebLinkInfo(link.name, link.url));
|
||||
info.webLinks.add(link);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user