summaryrefslogtreecommitdiffstats
path: root/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java
diff options
context:
space:
mode:
Diffstat (limited to 'gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java')
-rw-r--r--gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java51
1 files changed, 39 insertions, 12 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java
index a55c5a7534..f90c20dd8d 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java
@@ -23,6 +23,8 @@ import com.google.gerrit.httpd.raw.LegacyGerritServlet;
import com.google.gerrit.httpd.raw.SshInfoServlet;
import com.google.gerrit.httpd.raw.StaticServlet;
import com.google.gerrit.httpd.raw.ToolServlet;
+import com.google.gerrit.reviewdb.client.Change;
+import com.google.gerrit.reviewdb.client.Project;
import com.google.gwtexpui.server.CacheControlFilter;
import com.google.inject.Key;
import com.google.inject.Provider;
@@ -52,10 +54,6 @@ class UrlModule extends ServletModule {
serve("/static/*").with(StaticServlet.class);
serve("/tools/*").with(ToolServlet.class);
- filter("/p/*").through(ProjectAccessPathFilter.class);
- filter("/p/*").through(ProjectDigestFilter.class);
- serve("/p/*").with(ProjectServlet.class);
-
serve("/Main.class").with(notFound());
serve("/com/google/gerrit/launcher/*").with(notFound());
serve("/servlet/*").with(notFound());
@@ -63,14 +61,14 @@ class UrlModule extends ServletModule {
serve("/all").with(query("status:merged"));
serve("/mine").with(screen(PageLinks.MINE));
serve("/open").with(query("status:open"));
- serve("/settings").with(screen(PageLinks.SETTINGS));
serve("/watched").with(query("is:watched status:open"));
serve("/starred").with(query("is:starred"));
- serveRegex( //
- "^/([1-9][0-9]*)/?$", //
- "^/r/(.+)/?$" //
- ).with(changeQuery());
+ serveRegex("^/settings/?$").with(screen(PageLinks.SETTINGS));
+ serveRegex("^/register/?$").with(screen(PageLinks.REGISTER + "/"));
+ serveRegex("^/([1-9][0-9]*)/?$").with(directChangeById());
+ serveRegex("^/p/(.*)$").with(queryProjectNew());
+ serveRegex("^/r/(.+)/?$").with(DirectChangeByCommit.class);
}
private Key<HttpServlet> notFound() {
@@ -110,14 +108,43 @@ class UrlModule extends ServletModule {
});
}
- private Key<HttpServlet> changeQuery() {
+ private Key<HttpServlet> directChangeById() {
return key(new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(final HttpServletRequest req,
final HttpServletResponse rsp) throws IOException {
- toGerrit(PageLinks.toChangeQuery(req.getPathInfo()), req, rsp);
+ try {
+ Change.Id id = Change.Id.parse(req.getPathInfo());
+ toGerrit(PageLinks.toChange(id), req, rsp);
+ } catch (IllegalArgumentException err) {
+ rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+ });
+ }
+
+ private Key<HttpServlet> queryProjectNew() {
+ return key(new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse rsp)
+ throws IOException {
+ String name = req.getPathInfo();
+ while (name.endsWith("/")) {
+ name = name.substring(0, name.length() - 1);
+ }
+ if (name.endsWith(".git")) {
+ name = name.substring(0, name.length() - 4);
+ }
+ while (name.endsWith("/")) {
+ name = name.substring(0, name.length() - 1);
+ }
+ Project.NameKey project = new Project.NameKey(name);
+ toGerrit(PageLinks.toChangeQuery(PageLinks.projectQuery(project,
+ Change.Status.NEW)), req, rsp);
}
});
}
@@ -146,7 +173,7 @@ class UrlModule extends ServletModule {
return srv;
}
- private void toGerrit(final String target, final HttpServletRequest req,
+ static void toGerrit(final String target, final HttpServletRequest req,
final HttpServletResponse rsp) throws IOException {
final StringBuilder url = new StringBuilder();
url.append(req.getContextPath());