Removing redundant class WeblinksProvider
Change-Id: I06f2117ad16718a7329dd589ca9d95235783363c
This commit is contained in:
@@ -21,9 +21,12 @@ import com.google.gerrit.extensions.webui.BranchWebLink;
|
||||
import com.google.gerrit.extensions.webui.FileWebLink;
|
||||
import com.google.gerrit.extensions.webui.PatchSetWebLink;
|
||||
import com.google.gerrit.extensions.webui.ProjectWebLink;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class WebLinks {
|
||||
|
||||
private final DynamicSet<PatchSetWebLink> patchSetLinks;
|
||||
@@ -31,6 +34,7 @@ public class WebLinks {
|
||||
private final DynamicSet<ProjectWebLink> projectLinks;
|
||||
private final DynamicSet<BranchWebLink> branchLinks;
|
||||
|
||||
@Inject
|
||||
public WebLinks(DynamicSet<PatchSetWebLink> patchSetLinks,
|
||||
DynamicSet<FileWebLink> fileLinks,
|
||||
DynamicSet<ProjectWebLink> projectLinks,
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.extensions.webui.BranchWebLink;
|
||||
import com.google.gerrit.extensions.webui.FileWebLink;
|
||||
import com.google.gerrit.extensions.webui.PatchSetWebLink;
|
||||
import com.google.gerrit.extensions.webui.ProjectWebLink;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class WebLinksProvider implements Provider<WebLinks> {
|
||||
|
||||
private final DynamicSet<PatchSetWebLink> patchSetLinks;
|
||||
private final DynamicSet<FileWebLink> fileLinks;
|
||||
private final DynamicSet<ProjectWebLink> projectLinks;
|
||||
private final DynamicSet<BranchWebLink> branchLinks;
|
||||
|
||||
@Inject
|
||||
public WebLinksProvider(DynamicSet<PatchSetWebLink> patchSetLinks,
|
||||
DynamicSet<FileWebLink> fileLinks,
|
||||
DynamicSet<ProjectWebLink> projectLinks,
|
||||
DynamicSet<BranchWebLink> branchLinks) {
|
||||
this.patchSetLinks = patchSetLinks;
|
||||
this.fileLinks = fileLinks;
|
||||
this.projectLinks = projectLinks;
|
||||
this.branchLinks = branchLinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebLinks get() {
|
||||
return new WebLinks(patchSetLinks, fileLinks, projectLinks, branchLinks);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class ChangeJson {
|
||||
private final DynamicMap<DownloadCommand> downloadCommands;
|
||||
private final DynamicMap<RestView<ChangeResource>> changeViews;
|
||||
private final Revisions revisions;
|
||||
private final Provider<WebLinks> webLinks;
|
||||
private final WebLinks webLinks;
|
||||
private final EnumSet<ListChangesOption> options;
|
||||
private final ChangeMessagesUtil cmUtil;
|
||||
private final PatchLineCommentsUtil plcUtil;
|
||||
@@ -149,7 +149,7 @@ public class ChangeJson {
|
||||
DynamicMap<DownloadCommand> downloadCommands,
|
||||
DynamicMap<RestView<ChangeResource>> changeViews,
|
||||
Revisions revisions,
|
||||
Provider<WebLinks> webLinks,
|
||||
WebLinks webLinks,
|
||||
ChangeMessagesUtil cmUtil,
|
||||
PatchLineCommentsUtil plcUtil) {
|
||||
this.db = db;
|
||||
@@ -844,7 +844,7 @@ public class ChangeJson {
|
||||
|
||||
if (has(WEB_LINKS)) {
|
||||
out.webLinks = Lists.newArrayList();
|
||||
for (WebLinkInfo link : webLinks.get().getPatchSetLinks(
|
||||
for (WebLinkInfo link : webLinks.getPatchSetLinks(
|
||||
project, in.getRevision().get())) {
|
||||
out.webLinks.add(link);
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jgit.diff.Edit;
|
||||
import org.eclipse.jgit.diff.ReplaceEdit;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
@@ -69,7 +67,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
||||
private final ProjectCache projectCache;
|
||||
private final PatchScriptFactory.Factory patchScriptFactoryFactory;
|
||||
private final Revisions revisions;
|
||||
private final Provider<WebLinks> webLinks;
|
||||
private final WebLinks webLinks;
|
||||
|
||||
@Option(name = "--base", metaVar = "REVISION")
|
||||
String base;
|
||||
@@ -87,7 +85,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
||||
GetDiff(ProjectCache projectCache,
|
||||
PatchScriptFactory.Factory patchScriptFactoryFactory,
|
||||
Revisions revisions,
|
||||
Provider<WebLinks> webLinks) {
|
||||
WebLinks webLinks) {
|
||||
this.projectCache = projectCache;
|
||||
this.patchScriptFactoryFactory = patchScriptFactoryFactory;
|
||||
this.revisions = revisions;
|
||||
@@ -206,7 +204,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
||||
private List<WebLinkInfo> getFileWebLinks(Project project, String rev,
|
||||
String file) {
|
||||
List<WebLinkInfo> fileWebLinks = new ArrayList<>();
|
||||
for (WebLinkInfo link : webLinks.get().getFileLinks(project.getName(),
|
||||
for (WebLinkInfo link : webLinks.getFileLinks(project.getName(),
|
||||
rev, file)) {
|
||||
if (!Strings.isNullOrEmpty(link.name) && !Strings.isNullOrEmpty(link.url)) {
|
||||
fileWebLinks.add(link);
|
||||
|
||||
@@ -47,8 +47,6 @@ import com.google.gerrit.server.FileTypeRegistry;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.MimeUtilFileTypeRegistry;
|
||||
import com.google.gerrit.server.PluginUser;
|
||||
import com.google.gerrit.server.WebLinks;
|
||||
import com.google.gerrit.server.WebLinksProvider;
|
||||
import com.google.gerrit.server.account.AccountByEmailCacheImpl;
|
||||
import com.google.gerrit.server.account.AccountCacheImpl;
|
||||
import com.google.gerrit.server.account.AccountControl;
|
||||
@@ -235,7 +233,6 @@ public class GerritGlobalModule extends FactoryModule {
|
||||
.in(SINGLETON);
|
||||
bind(FromAddressGenerator.class).toProvider(
|
||||
FromAddressGeneratorProvider.class).in(SINGLETON);
|
||||
bind(WebLinks.class).toProvider(WebLinksProvider.class).in(SINGLETON);
|
||||
bind(Boolean.class).annotatedWith(DisableReverseDnsLookup.class)
|
||||
.toProvider(DisableReverseDnsLookupProvider.class).in(SINGLETON);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.google.gerrit.server.WebLinks;
|
||||
import com.google.gerrit.server.extensions.webui.UiActions;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
@@ -51,12 +50,12 @@ import java.util.TreeMap;
|
||||
public class ListBranches implements RestReadView<ProjectResource> {
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final DynamicMap<RestView<BranchResource>> branchViews;
|
||||
private final Provider<WebLinks> webLinks;
|
||||
private final WebLinks webLinks;
|
||||
|
||||
@Inject
|
||||
public ListBranches(GitRepositoryManager repoManager,
|
||||
DynamicMap<RestView<BranchResource>> branchViews,
|
||||
Provider<WebLinks> webLinks) {
|
||||
WebLinks webLinks) {
|
||||
this.repoManager = repoManager;
|
||||
this.branchViews = branchViews;
|
||||
this.webLinks = webLinks;
|
||||
@@ -169,7 +168,7 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
info.actions.put(d.getId(), new ActionInfo(d));
|
||||
}
|
||||
info.webLinks = Lists.newArrayList();
|
||||
for (WebLinkInfo link : webLinks.get().getBranchLinks(
|
||||
for (WebLinkInfo link : webLinks.getBranchLinks(
|
||||
refControl.getProjectControl().getProject().getName(), ref.getName())) {
|
||||
if (!Strings.isNullOrEmpty(link.name) && !Strings.isNullOrEmpty(link.url)) {
|
||||
info.webLinks.add(link);
|
||||
|
||||
@@ -43,8 +43,6 @@ import com.google.gerrit.server.util.RegexListSearcher;
|
||||
import com.google.gerrit.server.util.TreeFormatter;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
@@ -112,7 +110,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
private final GroupControl.Factory groupControlFactory;
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final ProjectNode.Factory projectNodeFactory;
|
||||
private final Provider<WebLinks> webLinks;
|
||||
private final WebLinks webLinks;
|
||||
|
||||
@Deprecated
|
||||
@Option(name = "--format", usage = "(deprecated) output format")
|
||||
@@ -193,7 +191,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
protected ListProjects(CurrentUser currentUser, ProjectCache projectCache,
|
||||
GroupCache groupCache, GroupControl.Factory groupControlFactory,
|
||||
GitRepositoryManager repoManager, ProjectNode.Factory projectNodeFactory,
|
||||
Provider<WebLinks> webLinks) {
|
||||
WebLinks webLinks) {
|
||||
this.currentUser = currentUser;
|
||||
this.projectCache = projectCache;
|
||||
this.groupCache = groupCache;
|
||||
@@ -385,7 +383,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
}
|
||||
|
||||
info.webLinks = Lists.newArrayList();
|
||||
for (WebLinkInfo link : webLinks.get().getProjectLinks(projectName.get())) {
|
||||
for (WebLinkInfo link : webLinks.getProjectLinks(projectName.get())) {
|
||||
if (!Strings.isNullOrEmpty(link.name) && !Strings.isNullOrEmpty(link.url)) {
|
||||
info.webLinks.add(link);
|
||||
}
|
||||
|
||||
@@ -24,18 +24,17 @@ import com.google.gerrit.server.WebLinks;
|
||||
import com.google.gerrit.server.config.AllProjectsName;
|
||||
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class ProjectJson {
|
||||
|
||||
private final AllProjectsName allProjects;
|
||||
private final Provider<WebLinks> webLinks;
|
||||
private final WebLinks webLinks;
|
||||
|
||||
@Inject
|
||||
ProjectJson(AllProjectsNameProvider allProjectsNameProvider,
|
||||
Provider<WebLinks> webLinks) {
|
||||
WebLinks webLinks) {
|
||||
this.allProjects = allProjectsNameProvider.get();
|
||||
this.webLinks = webLinks;
|
||||
}
|
||||
@@ -54,7 +53,7 @@ public class ProjectJson {
|
||||
info.id = Url.encode(info.name);
|
||||
|
||||
info.webLinks = Lists.newArrayList();
|
||||
for (WebLinkInfo link : webLinks.get().getProjectLinks(p.getName())) {
|
||||
for (WebLinkInfo link : webLinks.getProjectLinks(p.getName())) {
|
||||
if (!Strings.isNullOrEmpty(link.name) && !Strings.isNullOrEmpty(link.url)) {
|
||||
info.webLinks.add(link);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user