Merge "Move handling of ListPluginsServlet to HttpPluginServlet"

This commit is contained in:
Shawn Pearce
2012-06-26 13:11:56 -07:00
committed by gerrit code review
2 changed files with 8 additions and 3 deletions

View File

@@ -26,7 +26,6 @@ import com.google.gerrit.httpd.raw.ToolServlet;
import com.google.gerrit.httpd.rpc.account.AccountCapabilitiesServlet; import com.google.gerrit.httpd.rpc.account.AccountCapabilitiesServlet;
import com.google.gerrit.httpd.rpc.change.DeprecatedChangeQueryServlet; import com.google.gerrit.httpd.rpc.change.DeprecatedChangeQueryServlet;
import com.google.gerrit.httpd.rpc.change.ListChangesServlet; import com.google.gerrit.httpd.rpc.change.ListChangesServlet;
import com.google.gerrit.httpd.rpc.plugin.ListPluginsServlet;
import com.google.gerrit.httpd.rpc.project.ListProjectsServlet; import com.google.gerrit.httpd.rpc.project.ListProjectsServlet;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
@@ -96,7 +95,6 @@ class UrlModule extends ServletModule {
filter("/a/*").through(RequireIdentifiedUserFilter.class); filter("/a/*").through(RequireIdentifiedUserFilter.class);
serveRegex("^/(?:a/)?accounts/self/capabilities$").with(AccountCapabilitiesServlet.class); serveRegex("^/(?:a/)?accounts/self/capabilities$").with(AccountCapabilitiesServlet.class);
serveRegex("^/(?:a/)?changes/$").with(ListChangesServlet.class); serveRegex("^/(?:a/)?changes/$").with(ListChangesServlet.class);
serveRegex("^/(?:a/)?plugins/$").with(ListPluginsServlet.class);
serveRegex("^/(?:a/)?projects/(.*)?$").with(ListProjectsServlet.class); serveRegex("^/(?:a/)?projects/(.*)?$").with(ListProjectsServlet.class);
if (cfg.deprecatedQuery) { if (cfg.deprecatedQuery) {

View File

@@ -19,6 +19,7 @@ import com.google.common.cache.Cache;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gerrit.extensions.registration.RegistrationHandle; import com.google.gerrit.extensions.registration.RegistrationHandle;
import com.google.gerrit.httpd.rpc.plugin.ListPluginsServlet;
import com.google.gerrit.server.MimeUtilFileTypeRegistry; import com.google.gerrit.server.MimeUtilFileTypeRegistry;
import com.google.gerrit.server.config.CanonicalWebUrl; import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
@@ -79,6 +80,7 @@ class HttpPluginServlet extends HttpServlet
private final Cache<ResourceKey, Resource> resourceCache; private final Cache<ResourceKey, Resource> resourceCache;
private final String sshHost; private final String sshHost;
private final int sshPort; private final int sshPort;
private final ListPluginsServlet listServlet;
private List<Plugin> pending = Lists.newArrayList(); private List<Plugin> pending = Lists.newArrayList();
private String base; private String base;
@@ -90,10 +92,11 @@ class HttpPluginServlet extends HttpServlet
@CanonicalWebUrl Provider<String> webUrl, @CanonicalWebUrl Provider<String> webUrl,
@Named(HttpPluginModule.PLUGIN_RESOURCES) Cache<ResourceKey, Resource> cache, @Named(HttpPluginModule.PLUGIN_RESOURCES) Cache<ResourceKey, Resource> cache,
@GerritServerConfig Config cfg, @GerritServerConfig Config cfg,
SshInfo sshInfo) { SshInfo sshInfo, ListPluginsServlet listServlet) {
this.mimeUtil = mimeUtil; this.mimeUtil = mimeUtil;
this.webUrl = webUrl; this.webUrl = webUrl;
this.resourceCache = cache; this.resourceCache = cache;
this.listServlet = listServlet;
String sshHost = "review.example.com"; String sshHost = "review.example.com";
int sshPort = 29418; int sshPort = 29418;
@@ -185,6 +188,10 @@ class HttpPluginServlet extends HttpServlet
public void service(HttpServletRequest req, HttpServletResponse res) public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException { throws IOException, ServletException {
String name = extractName(req); String name = extractName(req);
if (name.equals("")) {
listServlet.service(req, res);
return;
}
final PluginHolder holder = plugins.get(name); final PluginHolder holder = plugins.get(name);
if (holder == null) { if (holder == null) {
noCache(res); noCache(res);