Format Java files with google-java-format
Change-Id: Id0cce149584fa4887eaaf4ecfc22da29a9daecfd
This commit is contained in:
@@ -22,8 +22,8 @@ import com.google.gerrit.common.Nullable;
|
|||||||
import com.google.template.soy.SoyFileSet;
|
import com.google.template.soy.SoyFileSet;
|
||||||
import com.google.template.soy.data.SanitizedContent;
|
import com.google.template.soy.data.SanitizedContent;
|
||||||
import com.google.template.soy.data.SoyMapData;
|
import com.google.template.soy.data.SoyMapData;
|
||||||
import com.google.template.soy.tofu.SoyTofu;
|
|
||||||
import com.google.template.soy.data.UnsafeSanitizedContentOrdainer;
|
import com.google.template.soy.data.UnsafeSanitizedContentOrdainer;
|
||||||
|
import com.google.template.soy.tofu.SoyTofu;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -39,10 +39,13 @@ public class IndexServlet extends HttpServlet {
|
|||||||
String resourcePath = "com/google/gerrit/httpd/raw/index.html.soy";
|
String resourcePath = "com/google/gerrit/httpd/raw/index.html.soy";
|
||||||
SoyFileSet.Builder builder = SoyFileSet.builder();
|
SoyFileSet.Builder builder = SoyFileSet.builder();
|
||||||
builder.add(Resources.getResource(resourcePath));
|
builder.add(Resources.getResource(resourcePath));
|
||||||
SoyTofu.Renderer renderer = builder.build().compileToTofu()
|
SoyTofu.Renderer renderer =
|
||||||
.newRenderer("com.google.gerrit.httpd.raw.Index")
|
builder
|
||||||
.setContentKind(SanitizedContent.ContentKind.HTML)
|
.build()
|
||||||
.setData(getTemplateData(canonicalURL, cdnPath));
|
.compileToTofu()
|
||||||
|
.newRenderer("com.google.gerrit.httpd.raw.Index")
|
||||||
|
.setContentKind(SanitizedContent.ContentKind.HTML)
|
||||||
|
.setData(getTemplateData(canonicalURL, cdnPath));
|
||||||
indexSource = renderer.render().getBytes();
|
indexSource = renderer.render().getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +78,9 @@ public class IndexServlet extends HttpServlet {
|
|||||||
|
|
||||||
// The resource path must be typed as safe for use in a script src.
|
// The resource path must be typed as safe for use in a script src.
|
||||||
// TODO(wyatta): Upgrade this to use an appropriate safe URL type.
|
// TODO(wyatta): Upgrade this to use an appropriate safe URL type.
|
||||||
SanitizedContent sanitizedStaticPath = UnsafeSanitizedContentOrdainer.ordainAsSafe(staticPath,
|
SanitizedContent sanitizedStaticPath =
|
||||||
SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
|
UnsafeSanitizedContentOrdainer.ordainAsSafe(
|
||||||
|
staticPath, SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
|
||||||
|
|
||||||
return new SoyMapData(
|
return new SoyMapData(
|
||||||
"canonicalPath", canonicalPath,
|
"canonicalPath", canonicalPath,
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import com.google.gerrit.server.config.GerritServerConfig;
|
|||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.ProvisionException;
|
import com.google.inject.ProvisionException;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
@@ -252,8 +251,9 @@ public class StaticModule extends ServletModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named(POLYGERRIT_INDEX_SERVLET)
|
@Named(POLYGERRIT_INDEX_SERVLET)
|
||||||
HttpServlet getPolyGerritUiIndexServlet(@CanonicalWebUrl @Nullable String canonicalUrl,
|
HttpServlet getPolyGerritUiIndexServlet(
|
||||||
@GerritServerConfig Config cfg) throws URISyntaxException {
|
@CanonicalWebUrl @Nullable String canonicalUrl, @GerritServerConfig Config cfg)
|
||||||
|
throws URISyntaxException {
|
||||||
String cdnPath = cfg.getString("gerrit", null, "cdnPath");
|
String cdnPath = cfg.getString("gerrit", null, "cdnPath");
|
||||||
return new IndexServlet(canonicalUrl, cdnPath);
|
return new IndexServlet(canonicalUrl, cdnPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,12 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.raw;
|
package com.google.gerrit.httpd.raw;
|
||||||
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import com.google.template.soy.data.SoyMapData;
|
import com.google.template.soy.data.SoyMapData;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
public class IndexServletTest {
|
public class IndexServletTest {
|
||||||
@Test
|
@Test
|
||||||
public void noPathAndNoCDN() throws URISyntaxException {
|
public void noPathAndNoCDN() throws URISyntaxException {
|
||||||
@@ -38,8 +37,8 @@ public class IndexServletTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noPathAndCDN() throws URISyntaxException {
|
public void noPathAndCDN() throws URISyntaxException {
|
||||||
SoyMapData data = IndexServlet.getTemplateData("http://example.com/",
|
SoyMapData data =
|
||||||
"http://my-cdn.com/foo/bar/");
|
IndexServlet.getTemplateData("http://example.com/", "http://my-cdn.com/foo/bar/");
|
||||||
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("");
|
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("");
|
||||||
assertThat(data.getSingle("staticResourcePath").stringValue())
|
assertThat(data.getSingle("staticResourcePath").stringValue())
|
||||||
.isEqualTo("http://my-cdn.com/foo/bar/");
|
.isEqualTo("http://my-cdn.com/foo/bar/");
|
||||||
@@ -47,8 +46,8 @@ public class IndexServletTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pathAndCDN() throws URISyntaxException {
|
public void pathAndCDN() throws URISyntaxException {
|
||||||
SoyMapData data = IndexServlet.getTemplateData("http://example.com/gerrit",
|
SoyMapData data =
|
||||||
"http://my-cdn.com/foo/bar/");
|
IndexServlet.getTemplateData("http://example.com/gerrit", "http://my-cdn.com/foo/bar/");
|
||||||
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("/gerrit");
|
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("/gerrit");
|
||||||
assertThat(data.getSingle("staticResourcePath").stringValue())
|
assertThat(data.getSingle("staticResourcePath").stringValue())
|
||||||
.isEqualTo("http://my-cdn.com/foo/bar/");
|
.isEqualTo("http://my-cdn.com/foo/bar/");
|
||||||
|
|||||||
Reference in New Issue
Block a user