Format all Java files with google-java-format 1.6
Change-Id: Ia9400a576e5c6e60d3d40f449dc0b3ef5a4b25d9
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritGitBlitContext.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritGitBlitContext.java
index d32e5e9..b7d00b9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritGitBlitContext.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritGitBlitContext.java
@@ -14,8 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit;
-import javax.servlet.ServletContext;
-
import com.gitblit.manager.IAuthenticationManager;
import com.gitblit.manager.IGitblit;
import com.gitblit.manager.INotificationManager;
@@ -27,6 +25,7 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import javax.servlet.ServletContext;
@Singleton
class GerritGitBlitContext extends GitblitContext {
@@ -40,12 +39,13 @@
private final IGitblit gitblit;
@Inject
- GerritGitBlitContext(SitePaths sitePaths,
+ GerritGitBlitContext(
+ SitePaths sitePaths,
IRuntimeManager runtime,
- INotificationManager notificationManager,
+ INotificationManager notificationManager,
IUserManager userManager,
IAuthenticationManager authenticationManager,
- IRepositoryManager repositoryManager,
+ IRepositoryManager repositoryManager,
IProjectManager projectManager,
IGitblit gitblit) {
this.sitePaths = sitePaths;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritWicketFilter.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritWicketFilter.java
index 9cdce94..90fd65d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritWicketFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GerritWicketFilter.java
@@ -14,24 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.gitblit.Constants;
import com.gitblit.IStoredSettings;
import com.gitblit.manager.IProjectManager;
@@ -45,14 +27,29 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.gitblit.auth.GerritAuthFilter;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
public class GerritWicketFilter extends GitblitWicketFilter {
- private static final Logger log = LoggerFactory
- .getLogger(GerritWicketFilter.class);
+ private static final Logger log = LoggerFactory.getLogger(GerritWicketFilter.class);
private static final Set<String> RESOURCES_SUFFIXES =
- new ImmutableSet.Builder<String>().add("css", "js", "png", "gif", "ttf",
- "swf", "afm", "eot", "otf", "scss", "svg", "woff").build();
+ new ImmutableSet.Builder<String>()
+ .add("css", "js", "png", "gif", "ttf", "swf", "afm", "eot", "otf", "scss", "svg", "woff")
+ .build();
private final DynamicItem<WebSession> webSession;
@@ -115,26 +112,23 @@
}
@Override
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
String requestPathInfo = httpServletRequest.getPathInfo();
if (isStaticResourceRequest(requestPathInfo)) {
- if (!requestPathInfo.startsWith("/static")
- && !requestPathInfo.startsWith("/resources")) {
+ if (!requestPathInfo.startsWith("/static") && !requestPathInfo.startsWith("/resources")) {
httpServletRequest = new StaticHttpServletRequest(httpServletRequest);
}
super.doFilter(httpServletRequest, response, chain);
- } else if (gerritAuthFilter.doFilter(webSession, httpServletRequest,
- response)) {
+ } else if (gerritAuthFilter.doFilter(webSession, httpServletRequest, response)) {
super.doFilter(httpServletRequest, response, chain);
}
}
private boolean isStaticResourceRequest(String requestPathInfo) {
- return RESOURCES_SUFFIXES.contains(getResourceSuffix(requestPathInfo)
- .toLowerCase());
+ return RESOURCES_SUFFIXES.contains(getResourceSuffix(requestPathInfo).toLowerCase());
}
private String getResourceSuffix(String requestPathInfo) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitInitStep.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitInitStep.java
index 2580731..b623c97 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitInitStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitInitStep.java
@@ -13,8 +13,6 @@
// limitations under the License.
package com.googlesource.gerrit.plugins.gitblit;
-import org.eclipse.jgit.lib.Config;
-
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitFlags;
@@ -22,6 +20,7 @@
import com.google.gerrit.pgm.init.api.Section;
import com.google.gerrit.pgm.init.api.Section.Factory;
import com.google.inject.Inject;
+import org.eclipse.jgit.lib.Config;
public class GitBlitInitStep implements InitStep {
private final ConsoleUI ui;
@@ -30,10 +29,8 @@
private final Config cfg;
@Inject
- public GitBlitInitStep(ConsoleUI ui,
- Section.Factory sections,
- @PluginName String pluginName,
- InitFlags flags) {
+ public GitBlitInitStep(
+ ConsoleUI ui, Section.Factory sections, @PluginName String pluginName, InitFlags flags) {
this.ui = ui;
this.pluginName = pluginName;
this.sections = sections;
@@ -76,18 +73,16 @@
private void initGitBlitPluginConfig() {
Section pluginCfg = sections.get("plugin", pluginName);
// These values are displayed in the UI.
- pluginCfg.string("\"Repositories\" submenu title", "repositories",
- "Repositories", true);
- pluginCfg
- .string("\"Activity\" submenu title", "activity", "Activity", true);
- pluginCfg.string("\"Documentation\" submenu title", "documentation",
- "Documentation", true);
+ pluginCfg.string("\"Repositories\" submenu title", "repositories", "Repositories", true);
+ pluginCfg.string("\"Activity\" submenu title", "activity", "Activity", true);
+ pluginCfg.string("\"Documentation\" submenu title", "documentation", "Documentation", true);
String originalValue = pluginCfg.get("search");
if (originalValue == null) {
- pluginCfg
- .string(
- "\"Search\" submenu title (makes only sense to set if some projects are indexed in GitBlit)",
- "search", "", true);
+ pluginCfg.string(
+ "\"Search\" submenu title (makes only sense to set if some projects are indexed in GitBlit)",
+ "search",
+ "",
+ true);
} else {
String newValue =
ui.readString(
@@ -101,8 +96,7 @@
}
}
pluginCfg.string(
- "\"Browse\" submenu title for the \"Projects\" top-level menu",
- "browse", "Browse", true);
+ "\"Browse\" submenu title for the \"Projects\" top-level menu", "browse", "Browse", true);
// If everything is at the default, then make sure we don't have the section
// at all.
if (cfg.getNames("plugin", pluginName).isEmpty()) {
@@ -111,6 +105,5 @@
}
@Override
- public void postRun() throws Exception {
- }
+ public void postRun() throws Exception {}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitModule.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitModule.java
index 3f4f9cf..89877d2 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitModule.java
@@ -23,5 +23,4 @@
protected void configure() {
DynamicSet.bind(binder(), TopMenu.class).to(GitBlitTopMenu.class);
}
-
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitServletModule.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitServletModule.java
index f2f878d..b1f00bf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitServletModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitServletModule.java
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.gitblit.AvatarGenerator;
import com.gitblit.GravatarGenerator;
import com.gitblit.IStoredSettings;
@@ -57,10 +54,11 @@
import com.googlesource.gerrit.plugins.gitblit.app.GitBlitSettings;
import com.googlesource.gerrit.plugins.gitblit.app.ReallyNullTicketService;
import com.googlesource.gerrit.plugins.gitblit.auth.GerritToGitBlitUserService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class GitBlitServletModule extends ServletModule {
- private static final Logger log = LoggerFactory
- .getLogger(GitBlitServletModule.class);
+ private static final Logger log = LoggerFactory.getLogger(GitBlitServletModule.class);
@Inject
public GitBlitServletModule(@PluginName final String name) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitTopMenu.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitTopMenu.java
index ab15209..31b402d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitTopMenu.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitTopMenu.java
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit;
-import java.util.Arrays;
-import java.util.List;
-
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginCanonicalWebUrl;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -28,6 +25,8 @@
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
+import java.util.Arrays;
+import java.util.List;
public class GitBlitTopMenu implements TopMenu {
@@ -41,7 +40,8 @@
private final Provider<CurrentUser> userProvider;
@Inject
- public GitBlitTopMenu(@PluginName String pluginName,
+ public GitBlitTopMenu(
+ @PluginName String pluginName,
@PluginCanonicalWebUrl String pluginUrl,
Provider<CurrentUser> userProvider,
PluginConfigFactory cfgProvider) {
@@ -56,17 +56,22 @@
// he'll simply end up with a funny looking menu item, but he can't inject
// things here.
MenuItem repositories =
- new MenuItem(cfg.getString("repositories", "Repositories"),
- gitBlitBaseUrl + "repositories/", "");
- // GitBlit handles its own "/" url, so Gerrit won't produce any link, not even on the "plugins" page, that would display the documentation.
- // I've considered simply redirecting "/" to "/Documentation/" since GitBlit's "/" screen is very similar to its "/activity/" screen, but
+ new MenuItem(
+ cfg.getString("repositories", "Repositories"), gitBlitBaseUrl + "repositories/", "");
+ // GitBlit handles its own "/" url, so Gerrit won't produce any link, not even on the "plugins"
+ // page, that would display the documentation.
+ // I've considered simply redirecting "/" to "/Documentation/" since GitBlit's "/" screen is
+ // very similar to its "/activity/" screen, but
// decided finally to provide an explicit documentation submenu instead.
- MenuItem documentation = new MenuItem(cfg.getString("documentation", "Documentation"), gitBlitBaseUrl + "Documentation/", "");
- restrictedMenuEntries = new MenuEntry(GITBLIT_TOPMENU_NAME, Arrays.asList(repositories, documentation));
+ MenuItem documentation =
+ new MenuItem(
+ cfg.getString("documentation", "Documentation"), gitBlitBaseUrl + "Documentation/", "");
+ restrictedMenuEntries =
+ new MenuEntry(GITBLIT_TOPMENU_NAME, Arrays.asList(repositories, documentation));
List<MenuItem> fullMenuItems = Lists.newArrayList();
fullMenuItems.add(repositories);
- fullMenuItems.add(new MenuItem(cfg.getString("activity", "Activity"),
- gitBlitBaseUrl + "activity/", ""));
+ fullMenuItems.add(
+ new MenuItem(cfg.getString("activity", "Activity"), gitBlitBaseUrl + "activity/", ""));
String search = cfg.getString("search");
if (search != null && !search.isEmpty()) {
fullMenuItems.add(new MenuItem(search, gitBlitBaseUrl + "lucene/", ""));
@@ -74,14 +79,19 @@
fullMenuItems.add(documentation);
fullMenuEntries = new MenuEntry(GITBLIT_TOPMENU_NAME, fullMenuItems);
extraProjectEntries =
- new MenuEntry(GerritTopMenu.PROJECTS, Arrays.asList(new MenuItem(cfg
- .getString("browse", "Browse"), gitBlitBaseUrl
- + "summary?r=${projectName}", "")));
+ new MenuEntry(
+ GerritTopMenu.PROJECTS,
+ Arrays.asList(
+ new MenuItem(
+ cfg.getString("browse", "Browse"),
+ gitBlitBaseUrl + "summary?r=${projectName}",
+ "")));
}
@Override
public List<MenuEntry> getEntries() {
- return Arrays.asList(userProvider.get().isIdentifiedUser()
- ? fullMenuEntries : restrictedMenuEntries, extraProjectEntries);
+ return Arrays.asList(
+ userProvider.get().isIdentifiedUser() ? fullMenuEntries : restrictedMenuEntries,
+ extraProjectEntries);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitUrlsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitUrlsConfig.java
index 0fdad98..e865e03 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitUrlsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/GitBlitUrlsConfig.java
@@ -14,25 +14,22 @@
package com.googlesource.gerrit.plugins.gitblit;
+import com.google.common.base.MoreObjects;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
-
import org.eclipse.jgit.lib.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.MoreObjects;
-
public class GitBlitUrlsConfig {
private static final int SSH_DEF_PORT = 22;
private static final String GITBLIT_REPO = "{0}";
private static final String GITBLIT_USER = "{1}";
- private static final Logger log = LoggerFactory
- .getLogger(GitBlitUrlsConfig.class);
+ private static final Logger log = LoggerFactory.getLogger(GitBlitUrlsConfig.class);
private String canonicalWebUrlString;
private String sshdListenAddressString;
@@ -63,8 +60,14 @@
String hostname = getHost(urlParts[0]);
int port = getPort(urlParts[1]);
- return "ssh://" + GITBLIT_USER + "@" + hostname
- + (port == SSH_DEF_PORT ? "" : ":" + port) + "/" + GITBLIT_REPO + "";
+ return "ssh://"
+ + GITBLIT_USER
+ + "@"
+ + hostname
+ + (port == SSH_DEF_PORT ? "" : ":" + port)
+ + "/"
+ + GITBLIT_REPO
+ + "";
} catch (UnknownHostException e) {
log.error("Cannot detect localhostname");
return "";
@@ -82,8 +85,10 @@
return new URI(canonicalWebUrlString).getHost();
}
} catch (URISyntaxException e) {
- log.error("Cannot parse canonicalWebUrl and get external hostname,"
- + " fallback to auto-detected local hostname", e);
+ log.error(
+ "Cannot parse canonicalWebUrl and get external hostname,"
+ + " fallback to auto-detected local hostname",
+ e);
}
return InetAddress.getLocalHost().getCanonicalHostName();
}
@@ -95,9 +100,9 @@
if (httpListenUrl == null) {
return "";
}
- if (!downloadSchemes.isEmpty() && !downloadSchemes.contains("http")) {
- return "";
- }
+ if (!downloadSchemes.isEmpty() && !downloadSchemes.contains("http")) {
+ return "";
+ }
String httpUrl = MoreObjects.firstNonNull(canonicalWebUrlString, httpListenUrl);
httpUrl = httpUrl.replace("://", "://" + GITBLIT_USER + "@");
@@ -111,9 +116,7 @@
}
String url = httpdListenUrlString.replaceFirst("proxy-", "");
if (url.indexOf('*') > 0) {
- url =
- url.replaceFirst("\\*", InetAddress.getLocalHost()
- .getCanonicalHostName());
+ url = url.replaceFirst("\\*", InetAddress.getLocalHost().getCanonicalHostName());
}
return url;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/NullPluginManager.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/NullPluginManager.java
index fa89c87..818f4b6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/NullPluginManager.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/NullPluginManager.java
@@ -14,20 +14,18 @@
package com.googlesource.gerrit.plugins.gitblit;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import ro.fortsoft.pf4j.PluginState;
-import ro.fortsoft.pf4j.PluginWrapper;
-import ro.fortsoft.pf4j.Version;
-
import com.gitblit.manager.IManager;
import com.gitblit.manager.IPluginManager;
import com.gitblit.models.PluginRegistry.InstallState;
import com.gitblit.models.PluginRegistry.PluginRegistration;
import com.gitblit.models.PluginRegistry.PluginRelease;
import com.google.inject.Singleton;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import ro.fortsoft.pf4j.PluginState;
+import ro.fortsoft.pf4j.PluginWrapper;
+import ro.fortsoft.pf4j.Version;
@Singleton
public class NullPluginManager implements IPluginManager {
@@ -48,12 +46,10 @@
}
@Override
- public void startPlugins() {
- }
+ public void startPlugins() {}
@Override
- public void stopPlugins() {
- }
+ public void stopPlugins() {}
@Override
public PluginState startPlugin(String pluginId) {
@@ -111,14 +107,13 @@
}
@Override
- public boolean installPlugin(String url, boolean verifyChecksum)
- throws IOException {
+ public boolean installPlugin(String url, boolean verifyChecksum) throws IOException {
return false;
}
@Override
- public boolean upgradePlugin(String pluginId, String url,
- boolean verifyChecksum) throws IOException {
+ public boolean upgradePlugin(String pluginId, String url, boolean verifyChecksum)
+ throws IOException {
return false;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedPagesFilter.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedPagesFilter.java
index 8beeff0..d7bb00a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedPagesFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedPagesFilter.java
@@ -14,14 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit;
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
import com.gitblit.manager.IAuthenticationManager;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.manager.IRuntimeManager;
@@ -32,6 +24,12 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.gitblit.auth.GerritAuthFilter;
+import java.io.IOException;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
@Singleton
public class WrappedPagesFilter extends PagesFilter {
@@ -39,7 +37,8 @@
private final DynamicItem<WebSession> webSession;
@Inject
- public WrappedPagesFilter(DynamicItem<WebSession> webSession,
+ public WrappedPagesFilter(
+ DynamicItem<WebSession> webSession,
GerritAuthFilter gerritAuthFilter,
IRuntimeManager runtimeManager,
IAuthenticationManager authenticationManager,
@@ -51,8 +50,8 @@
}
@Override
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
if (gerritAuthFilter.doFilter(webSession, request, response)) {
super.doFilter(request, response, chain);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedSyndicationFilter.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedSyndicationFilter.java
index 8197aef..e3a70ca 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedSyndicationFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/WrappedSyndicationFilter.java
@@ -14,15 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit;
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
import com.gitblit.manager.IAuthenticationManager;
import com.gitblit.manager.IProjectManager;
import com.gitblit.manager.IRepositoryManager;
@@ -34,6 +25,13 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.gitblit.auth.GerritAuthFilter;
+import java.io.IOException;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
@Singleton
public class WrappedSyndicationFilter extends SyndicationFilter {
@@ -52,7 +50,8 @@
}
@Inject
- public WrappedSyndicationFilter(DynamicItem<WebSession> webSession,
+ public WrappedSyndicationFilter(
+ DynamicItem<WebSession> webSession,
GerritAuthFilter gerritAuthFilter,
IRuntimeManager runtimeManager,
IAuthenticationManager authenticationManager,
@@ -64,11 +63,11 @@
}
@Override
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
if (gerritAuthFilter.doFilter(webSession, request, response)) {
- super.doFilter(new SyndicationHttpServletRequest(
- (HttpServletRequest) request), response, chain);
+ super.doFilter(
+ new SyndicationHttpServletRequest((HttpServletRequest) request), response, chain);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/GitBlitSettings.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/GitBlitSettings.java
index 1d72fe1..3dcc3d5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/GitBlitSettings.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/GitBlitSettings.java
@@ -14,6 +14,13 @@
package com.googlesource.gerrit.plugins.gitblit.app;
+import com.gitblit.IStoredSettings;
+import com.google.gerrit.server.config.GerritServerConfig;
+import com.google.gerrit.server.config.SitePaths;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.googlesource.gerrit.plugins.gitblit.GitBlitUrlsConfig;
+import com.googlesource.gerrit.plugins.gitblit.auth.GerritToGitBlitUserService;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -23,19 +30,10 @@
import java.util.Date;
import java.util.Map;
import java.util.Properties;
-
import org.eclipse.jgit.lib.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.gitblit.IStoredSettings;
-import com.google.gerrit.server.config.GerritServerConfig;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.googlesource.gerrit.plugins.gitblit.GitBlitUrlsConfig;
-import com.googlesource.gerrit.plugins.gitblit.auth.GerritToGitBlitUserService;
-
@Singleton
public class GitBlitSettings extends IStoredSettings {
private static final Logger log = LoggerFactory.getLogger(GitBlitSettings.class);
@@ -49,15 +47,13 @@
private File gitblitPropertiesFile;
@Inject
- public GitBlitSettings(@GerritServerConfig Config config,
- SitePaths sitePaths)
+ public GitBlitSettings(@GerritServerConfig Config config, SitePaths sitePaths)
throws IOException {
super(GitBlitSettings.class);
this.properties = new Properties();
this.config = new GitBlitUrlsConfig(config);
this.etcDir = sitePaths.etc_dir.toFile();
- this.basePath =
- sitePaths.resolve(config.getString("gerrit", null, "basePath")).toFile();
+ this.basePath = sitePaths.resolve(config.getString("gerrit", null, "basePath")).toFile();
load();
}
@@ -76,17 +72,17 @@
try (InputStream resin = openPropertiesFile()) {
properties = new Properties();
properties.load(resin);
- properties.put("git.repositoriesFolder",
- getBasePath().getAbsolutePath());
- properties.put("realm.userService",
- GerritToGitBlitUserService.class.getName());
+ properties.put("git.repositoriesFolder", getBasePath().getAbsolutePath());
+ properties.put("realm.userService", GerritToGitBlitUserService.class.getName());
if (properties.get("web.otherUrls") != null) {
- properties.put("web.otherUrls",
- (config.getGitHttpUrl() + " " + config.getGitSshUrl()).trim() + " "
+ properties.put(
+ "web.otherUrls",
+ (config.getGitHttpUrl() + " " + config.getGitSshUrl()).trim()
+ + " "
+ properties.get("web.otherUrls"));
} else {
- properties.put("web.otherUrls",
- (config.getGitHttpUrl() + " " + config.getGitSshUrl()).trim());
+ properties.put(
+ "web.otherUrls", (config.getGitHttpUrl() + " " + config.getGitSshUrl()).trim());
}
}
}
@@ -112,13 +108,13 @@
public String toString() {
StringBuilder stringSettings = new StringBuilder();
if (!gitblitPropertiesFile.exists()) {
- stringSettings.append(GITBLIT_GERRIT_PROPERTIES
- + " from gitblit plugin jar");
+ stringSettings.append(GITBLIT_GERRIT_PROPERTIES + " from gitblit plugin jar");
} else {
- stringSettings.append(gitblitPropertiesFile.getAbsolutePath()
- + " (lastModified: "
- + new SimpleDateFormat().format(new Date(gitblitPropertiesFile
- .lastModified())) + ")");
+ stringSettings.append(
+ gitblitPropertiesFile.getAbsolutePath()
+ + " (lastModified: "
+ + new SimpleDateFormat().format(new Date(gitblitPropertiesFile.lastModified()))
+ + ")");
}
stringSettings.append(" with values ");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/ReallyNullTicketService.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/ReallyNullTicketService.java
index 14f3fe3..0e2d9bb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/ReallyNullTicketService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/app/ReallyNullTicketService.java
@@ -13,9 +13,6 @@
// limitations under the License.
package com.googlesource.gerrit.plugins.gitblit.app;
-import java.util.Collections;
-import java.util.List;
-
import com.gitblit.manager.INotificationManager;
import com.gitblit.manager.IPluginManager;
import com.gitblit.manager.IRepositoryManager;
@@ -27,24 +24,25 @@
import com.gitblit.tickets.TicketMilestone;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.Collections;
+import java.util.List;
/**
- * The {@link NullTicketService} of GitBlit is not really a null service. It
- * creates a TicketIndexer, and because it neglects to override some methods
- * from its base class, that even gets called sometimes, which then produces
- * exceptions.
+ * The {@link NullTicketService} of GitBlit is not really a null service. It creates a
+ * TicketIndexer, and because it neglects to override some methods from its base class, that even
+ * gets called sometimes, which then produces exceptions.
*/
@Singleton
public class ReallyNullTicketService extends NullTicketService {
@Inject
- public ReallyNullTicketService(IRuntimeManager runtimeManager,
+ public ReallyNullTicketService(
+ IRuntimeManager runtimeManager,
IPluginManager pluginManager,
INotificationManager notificationManager,
IUserManager userManager,
IRepositoryManager repositoryManager) {
- super(runtimeManager, pluginManager, notificationManager, userManager,
- repositoryManager);
+ super(runtimeManager, pluginManager, notificationManager, userManager, repositoryManager);
}
@Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritAuthFilter.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritAuthFilter.java
index a561bf8..d0019b5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritAuthFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritAuthFilter.java
@@ -16,16 +16,6 @@
import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.codec.binary.Base64;
-
import com.gitblit.manager.IGitblit;
import com.gitblit.models.UserModel;
import com.google.common.base.MoreObjects;
@@ -33,6 +23,13 @@
import com.google.gerrit.httpd.WebSession;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.codec.binary.Base64;
@Singleton
public class GerritAuthFilter {
@@ -47,6 +44,7 @@
/**
* Returns the user making the request, if the user has authenticated.
+ *
* @param httpRequest
* @return user
*/
@@ -60,8 +58,8 @@
}
user =
- gitBlit.authenticate(username,
- (GerritToGitBlitUserService.SESSIONAUTH + token).toCharArray(), null);
+ gitBlit.authenticate(
+ username, (GerritToGitBlitUserService.SESSIONAUTH + token).toCharArray(), null);
if (user != null) {
return user;
}
@@ -69,15 +67,14 @@
return null;
}
- public boolean doFilter(final DynamicItem<WebSession> webSession,
- ServletRequest request, ServletResponse response)
+ public boolean doFilter(
+ final DynamicItem<WebSession> webSession, ServletRequest request, ServletResponse response)
throws IOException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String hdr = httpRequest.getHeader("Authorization");
if (hdr != null) {
- return filterBasicAuth((HttpServletRequest) request,
- (HttpServletResponse) response, hdr);
+ return filterBasicAuth((HttpServletRequest) request, (HttpServletResponse) response, hdr);
} else if (webSession.get().isSignedIn()) {
return filterSessionAuth(webSession, (HttpServletRequest) request);
} else {
@@ -85,40 +82,34 @@
}
}
- public boolean filterSessionAuth(final DynamicItem<WebSession> webSession,
- HttpServletRequest request) {
- request.setAttribute("gerrit-username", webSession.get().getUser()
- .getUserName());
+ public boolean filterSessionAuth(
+ final DynamicItem<WebSession> webSession, HttpServletRequest request) {
+ request.setAttribute("gerrit-username", webSession.get().getUser().getUserName());
request.setAttribute("gerrit-token", webSession.get().getSessionId());
return true;
}
- public boolean filterBasicAuth(HttpServletRequest request,
- HttpServletResponse response, String hdr) throws IOException,
- UnsupportedEncodingException {
+ public boolean filterBasicAuth(
+ HttpServletRequest request, HttpServletResponse response, String hdr)
+ throws IOException, UnsupportedEncodingException {
if (!hdr.startsWith(LIT_BASIC)) {
response.setHeader("WWW-Authenticate", "Basic realm=\"Gerrit Code Review\"");
response.sendError(SC_UNAUTHORIZED);
return false;
}
- final byte[] decoded =
- new Base64().decode(hdr.substring(LIT_BASIC.length()).getBytes());
+ final byte[] decoded = new Base64().decode(hdr.substring(LIT_BASIC.length()).getBytes());
String usernamePassword =
- new String(decoded, MoreObjects.firstNonNull(
- request.getCharacterEncoding(), "UTF-8"));
+ new String(decoded, MoreObjects.firstNonNull(request.getCharacterEncoding(), "UTF-8"));
int splitPos = usernamePassword.indexOf(':');
if (splitPos < 1) {
response.setHeader("WWW-Authenticate", "Basic realm=\"Gerrit Code Review\"");
response.sendError(SC_UNAUTHORIZED);
return false;
}
- request.setAttribute("gerrit-username",
- usernamePassword.substring(0, splitPos));
- request.setAttribute("gerrit-password",
- usernamePassword.substring(splitPos + 1));
+ request.setAttribute("gerrit-username", usernamePassword.substring(0, splitPos));
+ request.setAttribute("gerrit-password", usernamePassword.substring(splitPos + 1));
return true;
}
-
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserModel.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserModel.java
index deb2a98..3802743 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserModel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserModel.java
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit.auth;
-import java.util.HashSet;
-import java.util.Set;
-
import com.gitblit.Constants.AccessPermission;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.models.RepositoryModel;
@@ -27,6 +24,8 @@
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gerrit.server.project.ProjectControl;
import com.google.gerrit.server.project.ProjectControl.Factory;
+import java.util.HashSet;
+import java.util.Set;
public class GerritToGitBlitUserModel extends UserModel {
public static final String ANONYMOUS_USER = "$anonymous";
@@ -45,7 +44,7 @@
public final Set<String> repositories = new HashSet<>();
public final Set<TeamModel> teams = new HashSet<>();
- private transient final ProjectControl.Factory projectControlFactory;
+ private final transient ProjectControl.Factory projectControlFactory;
// non-persisted fields
public boolean isAuthenticated;
@@ -54,8 +53,8 @@
this(username, null);
}
- public GerritToGitBlitUserModel(String username,
- final ProjectControl.Factory projectControlFactory) {
+ public GerritToGitBlitUserModel(
+ String username, final ProjectControl.Factory projectControlFactory) {
super(username);
this.username = username;
this.isAuthenticated = true;
@@ -72,8 +71,7 @@
boolean result = false;
try {
- ProjectControl control =
- projectControlFactory.controlFor(new NameKey(repositoryName));
+ ProjectControl control = projectControlFactory.controlFor(new NameKey(repositoryName));
result = control != null;
} catch (NoSuchProjectException e) {
result = false;
@@ -83,14 +81,15 @@
}
@Override
- protected boolean canAccess(RepositoryModel repository,
- AccessRestrictionType ifRestriction, AccessPermission requirePermission) {
+ protected boolean canAccess(
+ RepositoryModel repository,
+ AccessRestrictionType ifRestriction,
+ AccessPermission requirePermission) {
boolean result = false;
try {
ProjectControl control =
- projectControlFactory.controlFor(new NameKey(
- getRepositoryName(repository.name)));
+ projectControlFactory.controlFor(new NameKey(getRepositoryName(repository.name)));
if (control == null) {
return false;
@@ -127,8 +126,7 @@
try {
name = getRepositoryName(name);
- ProjectControl control =
- projectControlFactory.controlFor(new NameKey(name));
+ ProjectControl control = projectControlFactory.controlFor(new NameKey(name));
result = control != null && !control.isHidden();
} catch (NoSuchProjectException e) {
result = false;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserService.java b/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserService.java
index d240cda..b8dcbd5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitblit/auth/GerritToGitBlitUserService.java
@@ -14,16 +14,6 @@
package com.googlesource.gerrit.plugins.gitblit.auth;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.gitblit.Constants;
import com.gitblit.Constants.AuthenticationType;
import com.gitblit.Constants.Role;
@@ -43,12 +33,17 @@
import com.google.gerrit.server.project.ProjectControl;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
-public class GerritToGitBlitUserService implements IAuthenticationManager,
- IUserManager {
- private static final Logger log = LoggerFactory
- .getLogger(GerritToGitBlitUserService.class);
+public class GerritToGitBlitUserService implements IAuthenticationManager, IUserManager {
+ private static final Logger log = LoggerFactory.getLogger(GerritToGitBlitUserService.class);
private final ProjectControl.Factory projectControl;
private final AccountManager accountManager;
@@ -59,7 +54,8 @@
@Inject
public GerritToGitBlitUserService(
final ProjectControl.Factory projectControl,
- AccountManager accountManager, final DynamicItem<WebSession> webSession) {
+ AccountManager accountManager,
+ final DynamicItem<WebSession> webSession) {
this.projectControl = projectControl;
this.accountManager = accountManager;
this.webSession = webSession;
@@ -71,11 +67,9 @@
if (username.equals(GerritToGitBlitUserModel.ANONYMOUS_USER)) {
return GerritToGitBlitUserModel.getAnonymous(projectControl);
- } else if (passwordString
- .startsWith(GerritToGitBlitUserService.SESSIONAUTH)) {
- return authenticateSSO(username,
- passwordString.substring(GerritToGitBlitUserService.SESSIONAUTH
- .length()));
+ } else if (passwordString.startsWith(GerritToGitBlitUserService.SESSIONAUTH)) {
+ return authenticateSSO(
+ username, passwordString.substring(GerritToGitBlitUserService.SESSIONAUTH.length()));
} else {
return authenticateBasicAuth(username, passwordString);
}
@@ -84,8 +78,7 @@
public UserModel authenticateSSO(String username, String sessionToken) {
WebSession session = webSession.get();
- if (session.getSessionId() == null
- || !session.getSessionId().equals(sessionToken)) {
+ if (session.getSessionId() == null || !session.getSessionId().equals(sessionToken)) {
log.warn("Invalid Gerrit session token for user '" + username + "'");
return null;
}
@@ -96,8 +89,7 @@
}
if (!session.getUser().getUserName().equals(username)) {
- log.warn("Gerrit session " + session.getSessionId()
- + " is not assigned to user " + username);
+ log.warn("Gerrit session " + session.getSessionId() + " is not assigned to user " + username);
return null;
}
@@ -105,8 +97,7 @@
}
public UserModel authenticateBasicAuth(String username, String password) {
- if (Strings.isNullOrEmpty(username) || password == null
- || password.length() <= 0) {
+ if (Strings.isNullOrEmpty(username) || password == null || password.length() <= 0) {
log.warn("Authentication failed: no username or password specified");
return null;
}
@@ -125,7 +116,6 @@
return new GerritToGitBlitUserModel(username, projectControl);
}
-
@Override
public IManager start() {
return null;
@@ -138,14 +128,11 @@
@Override
public UserModel authenticate(HttpServletRequest httpRequest) {
- String gerritUsername =
- (String) httpRequest.getAttribute("gerrit-username");
+ String gerritUsername = (String) httpRequest.getAttribute("gerrit-username");
String gerritToken = (String) httpRequest.getAttribute("gerrit-token");
- httpRequest.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE,
- AuthenticationType.CONTAINER);
+ httpRequest.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE, AuthenticationType.CONTAINER);
- if (Strings.isNullOrEmpty(gerritUsername)
- || Strings.isNullOrEmpty(gerritToken)) {
+ if (Strings.isNullOrEmpty(gerritUsername) || Strings.isNullOrEmpty(gerritToken)) {
return GerritToGitBlitUserModel.getAnonymous(projectControl);
}
return authenticateSSO(gerritUsername, gerritToken);
@@ -162,8 +149,7 @@
}
@Override
- public UserModel authenticate(HttpServletRequest httpRequest,
- boolean requiresCertificate) {
+ public UserModel authenticate(HttpServletRequest httpRequest, boolean requiresCertificate) {
return null;
}
@@ -173,22 +159,16 @@
}
@Override
- public void setCookie(HttpServletResponse response, UserModel user) {
- }
+ public void setCookie(HttpServletResponse response, UserModel user) {}
@Override
- public void setCookie(HttpServletRequest request,
- HttpServletResponse response, UserModel user) {
- }
+ public void setCookie(HttpServletRequest request, HttpServletResponse response, UserModel user) {}
@Override
- public void logout(HttpServletResponse response, UserModel user) {
- }
+ public void logout(HttpServletResponse response, UserModel user) {}
@Override
- public void logout(HttpServletRequest request, HttpServletResponse response,
- UserModel user) {
- }
+ public void logout(HttpServletRequest request, HttpServletResponse response, UserModel user) {}
@Override
public boolean supportsCredentialChanges(UserModel user) {
@@ -216,8 +196,7 @@
}
@Override
- public void setup(IRuntimeManager runtimeManager) {
- }
+ public void setup(IRuntimeManager runtimeManager) {}
@Override
public String getCookie(UserModel model) {