Google-formatting reindenting on all files
Change-Id: I713d780e41546a3d9e4f3d506795c1aea30a4b96
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/AvailablePluginsCollection.java b/src/main/java/com/googlesource/gerrit/plugins/manager/AvailablePluginsCollection.java
index 6c0629c..880384f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/AvailablePluginsCollection.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/AvailablePluginsCollection.java
@@ -29,16 +29,15 @@
import com.google.inject.Singleton;
@Singleton
-public class AvailablePluginsCollection implements
- RestCollection<TopLevelResource, PluginResource>,
- AcceptsCreate<TopLevelResource> {
+public class AvailablePluginsCollection
+ implements RestCollection<TopLevelResource, PluginResource>, AcceptsCreate<TopLevelResource> {
private final DynamicMap<RestView<PluginResource>> views;
private final Provider<ListAvailablePlugins> list;
@Inject
- AvailablePluginsCollection(DynamicMap<RestView<PluginResource>> views,
- Provider<ListAvailablePlugins> list) {
+ AvailablePluginsCollection(
+ DynamicMap<RestView<PluginResource>> views, Provider<ListAvailablePlugins> list) {
this.views = views;
this.list = list;
}
@@ -51,7 +50,7 @@
@Override
public PluginResource parse(TopLevelResource parent, IdString id)
throws ResourceNotFoundException {
- throw new ResourceNotFoundException(id);
+ throw new ResourceNotFoundException(id);
}
@Override
@@ -60,8 +59,8 @@
}
@Override
- public <I> RestModifyView<TopLevelResource, I> create(
- TopLevelResource parent, IdString id) throws RestApiException {
+ public <I> RestModifyView<TopLevelResource, I> create(TopLevelResource parent, IdString id)
+ throws RestApiException {
throw new IllegalArgumentException("Operation not supported");
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/FirstWebLoginListener.java b/src/main/java/com/googlesource/gerrit/plugins/manager/FirstWebLoginListener.java
index 0d18bd6..feea5d4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/FirstWebLoginListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/FirstWebLoginListener.java
@@ -20,13 +20,11 @@
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.plugins.PluginLoader;
import com.google.inject.Inject;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Date;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -36,7 +34,8 @@
private final String pluginUrl;
@Inject
- public FirstWebLoginListener(PluginLoader pluginLoader,
+ public FirstWebLoginListener(
+ PluginLoader pluginLoader,
@PluginData Path pluginData,
@PluginCanonicalWebUrl String pluginUrl) {
this.pluginData = pluginData;
@@ -45,23 +44,19 @@
}
@Override
- public void onLogin(IdentifiedUser user, HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- if (pluginLoader.isRemoteAdminEnabled()
- && user.getCapabilities().canAdministrateServer()) {
- Path firstLoginFile =
- pluginData.resolve("firstLogin." + user.getAccountId().get());
+ public void onLogin(IdentifiedUser user, HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
+ if (pluginLoader.isRemoteAdminEnabled() && user.getCapabilities().canAdministrateServer()) {
+ Path firstLoginFile = pluginData.resolve("firstLogin." + user.getAccountId().get());
if (!firstLoginFile.toFile().exists()) {
response.sendRedirect(pluginUrl + "static/index.html");
- Files.write(firstLoginFile, new Date().toString().getBytes(),
- StandardOpenOption.CREATE);
+ Files.write(firstLoginFile, new Date().toString().getBytes(), StandardOpenOption.CREATE);
}
}
}
@Override
- public void onLogout(IdentifiedUser user, HttpServletRequest request,
- HttpServletResponse response) {
- }
+ public void onLogout(
+ IdentifiedUser user, HttpServletRequest request, HttpServletResponse response) {}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/GerritVersionBranch.java b/src/main/java/com/googlesource/gerrit/plugins/manager/GerritVersionBranch.java
index faca388..02aeea3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/GerritVersionBranch.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/GerritVersionBranch.java
@@ -18,7 +18,8 @@
private static final String GERRIT_NEXT_VERSION = "2.13";
public static String getBranch(String gerritVersion) {
- if (gerritVersion == null || gerritVersion.trim().isEmpty()
+ if (gerritVersion == null
+ || gerritVersion.trim().isEmpty()
|| !Character.isDigit(gerritVersion.trim().charAt(0))
|| gerritVersion.startsWith(GERRIT_NEXT_VERSION)) {
return "master";
@@ -29,8 +30,7 @@
String fixVersionNumber = versionNumbers[2];
if (fixVersionNumber.contains("-")) {
String nextVersion =
- String.format("%s.%d", versionNumbers[0],
- Integer.parseInt(versionNumbers[1]) + 1);
+ String.format("%s.%d", versionNumbers[0], Integer.parseInt(versionNumbers[1]) + 1);
if (nextVersion.equals(GERRIT_NEXT_VERSION)) {
return "master";
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/ListAvailablePlugins.java b/src/main/java/com/googlesource/gerrit/plugins/manager/ListAvailablePlugins.java
index 9d2bb66..76e7669 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/ListAvailablePlugins.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/ListAvailablePlugins.java
@@ -24,9 +24,7 @@
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.manager.repository.PluginInfo;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -55,21 +53,23 @@
try {
plugins = new ArrayList<>(pluginsCache.availablePlugins());
} catch (ExecutionException e) {
- throw new RestApiException(
- "Unable to load the list of available plugins", e);
+ throw new RestApiException("Unable to load the list of available plugins", e);
}
- Collections.sort(plugins, new Comparator<PluginInfo>() {
- @Override
- public int compare(PluginInfo a, PluginInfo b) {
- return a.name.compareTo(b.name);
- }
- });
+ Collections.sort(
+ plugins,
+ new Comparator<PluginInfo>() {
+ @Override
+ public int compare(PluginInfo a, PluginInfo b) {
+ return a.name.compareTo(b.name);
+ }
+ });
for (PluginInfo p : plugins) {
output.put(p.name, p);
}
- return OutputFormat.JSON.newGson().toJsonTree(output,
- new TypeToken<Map<String, Object>>() {}.getType());
+ return OutputFormat.JSON
+ .newGson()
+ .toJsonTree(output, new TypeToken<Map<String, Object>>() {}.getType());
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/Module.java b/src/main/java/com/googlesource/gerrit/plugins/manager/Module.java
index fa27964..2f231be 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/Module.java
@@ -19,7 +19,6 @@
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.inject.AbstractModule;
import com.google.inject.internal.UniqueAnnotations;
-
import com.googlesource.gerrit.plugins.manager.repository.CorePluginsRepository;
import com.googlesource.gerrit.plugins.manager.repository.JenkinsCiPluginsRepository;
import com.googlesource.gerrit.plugins.manager.repository.PluginsRepository;
@@ -36,8 +35,6 @@
install(PluginsCentralCache.module());
- bind(LifecycleListener.class).annotatedWith(UniqueAnnotations.create()).to(
- OnStartStop.class);
-
+ bind(LifecycleListener.class).annotatedWith(UniqueAnnotations.create()).to(OnStartStop.class);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/OnStartStop.java b/src/main/java/com/googlesource/gerrit/plugins/manager/OnStartStop.java
index 1032613..9db6d87 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/OnStartStop.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/OnStartStop.java
@@ -17,14 +17,11 @@
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.manager.repository.PluginInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.Collection;
import java.util.concurrent.ExecutionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class OnStartStop implements LifecycleListener {
private static final Logger log = LoggerFactory.getLogger(OnStartStop.class);
@@ -36,8 +33,8 @@
private final PluginManagerConfig config;
@Inject
- public OnStartStop(PluginsCentralCache pluginsCache,
- @PluginName String pluginName, PluginManagerConfig config) {
+ public OnStartStop(
+ PluginsCentralCache pluginsCache, @PluginName String pluginName, PluginManagerConfig config) {
this.pluginsCache = pluginsCache;
this.pluginName = pluginName;
this.config = config;
@@ -46,25 +43,26 @@
@Override
public void start() {
if (config.isCachePreloadEnabled()) {
- Thread preloader = new Thread(new Runnable() {
+ Thread preloader =
+ new Thread(
+ new Runnable() {
- @Override
- public void run() {
- log.info("Start-up: pre-loading list of plugins from registry");
- try {
- Collection<PluginInfo> plugins = pluginsCache.availablePlugins();
- log.info("{} plugins successfully pre-loaded", plugins.size());
- } catch (ExecutionException e) {
- log.error("Cannot access plugins list at this time", e);
- }
- }
- });
+ @Override
+ public void run() {
+ log.info("Start-up: pre-loading list of plugins from registry");
+ try {
+ Collection<PluginInfo> plugins = pluginsCache.availablePlugins();
+ log.info("{} plugins successfully pre-loaded", plugins.size());
+ } catch (ExecutionException e) {
+ log.error("Cannot access plugins list at this time", e);
+ }
+ }
+ });
preloader.setName(pluginName + "-preloader");
preloader.start();
}
}
@Override
- public void stop() {
- }
+ public void stop() {}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerConfig.java b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerConfig.java
index b7dfb63..37c9b1f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerConfig.java
@@ -20,14 +20,12 @@
import com.google.inject.Inject;
public class PluginManagerConfig {
- private static final String DEFAULT_GERRIT_CI_URL =
- "https://gerrit-ci.gerritforge.com";
+ private static final String DEFAULT_GERRIT_CI_URL = "https://gerrit-ci.gerritforge.com";
private final PluginConfig config;
@Inject
- public PluginManagerConfig(PluginConfigFactory configFactory,
- @PluginName String pluginName) {
+ public PluginManagerConfig(PluginConfigFactory configFactory, @PluginName String pluginName) {
this.config = configFactory.getFromGerritConfig(pluginName);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerRestApiServlet.java b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerRestApiServlet.java
index bb94616..81cd2c7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerRestApiServlet.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerRestApiServlet.java
@@ -24,9 +24,7 @@
private static final long serialVersionUID = 1L;
@Inject
- PluginManagerRestApiServlet(
- Globals globals,
- AvailablePluginsCollection members) {
+ PluginManagerRestApiServlet(Globals globals, AvailablePluginsCollection members) {
super(globals, Providers.of(members));
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerTopMenu.java b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerTopMenu.java
index ec25d8f..9cddbd3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerTopMenu.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginManagerTopMenu.java
@@ -22,7 +22,6 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -35,13 +34,17 @@
private Provider<CurrentUser> userProvider;
@Inject
- public PluginManagerTopMenu(@PluginCanonicalWebUrl String myUrl,
- PluginLoader loader, Provider<CurrentUser> userProvider) {
+ public PluginManagerTopMenu(
+ @PluginCanonicalWebUrl String myUrl,
+ PluginLoader loader,
+ Provider<CurrentUser> userProvider) {
this.loader = loader;
this.userProvider = userProvider;
this.menuEntries =
- Arrays.asList(new MenuEntry("Plugins", Arrays.asList(new MenuItem(
- "Manage", myUrl + "static/index.html", "_blank"))));
+ Arrays.asList(
+ new MenuEntry(
+ "Plugins",
+ Arrays.asList(new MenuItem("Manage", myUrl + "static/index.html", "_blank"))));
}
@Override
@@ -50,7 +53,6 @@
&& userProvider.get().getCapabilities().canAdministrateServer()) {
return menuEntries;
}
-
return Collections.emptyList();
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralCache.java b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralCache.java
index c4ffbab..1c490e0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralCache.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralCache.java
@@ -19,10 +19,8 @@
import com.google.inject.Inject;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
-
import com.googlesource.gerrit.plugins.manager.PluginsCentralLoader.ListKey;
import com.googlesource.gerrit.plugins.manager.repository.PluginInfo;
-
import java.util.Collection;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -47,9 +45,12 @@
return new CacheModule() {
@Override
protected void configure() {
- cache(PluginsCentralCache.PLUGINS_LIST_CACHE_NAME, ListKey.class,
- new TypeLiteral<Collection<PluginInfo>>() {}).expireAfterWrite(1,
- TimeUnit.DAYS).loader(PluginsCentralLoader.class);
+ cache(
+ PluginsCentralCache.PLUGINS_LIST_CACHE_NAME,
+ ListKey.class,
+ new TypeLiteral<Collection<PluginInfo>>() {})
+ .expireAfterWrite(1, TimeUnit.DAYS)
+ .loader(PluginsCentralLoader.class);
bind(PluginsCentralCache.class);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralLoader.java b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralLoader.java
index ccc8a70..c9381dc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralLoader.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/PluginsCentralLoader.java
@@ -19,18 +19,15 @@
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-
import com.googlesource.gerrit.plugins.manager.PluginsCentralLoader.ListKey;
import com.googlesource.gerrit.plugins.manager.repository.PluginInfo;
import com.googlesource.gerrit.plugins.manager.repository.PluginsRepository;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@Singleton
-public class PluginsCentralLoader extends
- CacheLoader<ListKey, Collection<PluginInfo>> {
+public class PluginsCentralLoader extends CacheLoader<ListKey, Collection<PluginInfo>> {
public static class ListKey {
static final ListKey ALL = new ListKey();
@@ -58,12 +55,10 @@
return pluginsMap.values();
}
- private void addAll(Map<String, PluginInfo> pluginsMap,
- Collection<PluginInfo> plugins) {
+ private void addAll(Map<String, PluginInfo> pluginsMap, Collection<PluginInfo> plugins) {
for (PluginInfo pluginInfo : plugins) {
PluginInfo currPlugin = pluginsMap.get(pluginInfo.name);
- if (currPlugin == null
- || isLaterVersion(pluginInfo.version, currPlugin.version)) {
+ if (currPlugin == null || isLaterVersion(pluginInfo.version, currPlugin.version)) {
pluginsMap.put(pluginInfo.name, pluginInfo);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/TokenReplaceOutputStream.java b/src/main/java/com/googlesource/gerrit/plugins/manager/TokenReplaceOutputStream.java
index 4eb643b..01dd35c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/TokenReplaceOutputStream.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/TokenReplaceOutputStream.java
@@ -17,7 +17,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
-
import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletResponse;
@@ -34,8 +33,8 @@
private final int outLen;
- public TokenReplaceOutputStream(HttpServletResponse resp, int contentLength,
- byte[] token, byte[] replace) {
+ public TokenReplaceOutputStream(
+ HttpServletResponse resp, int contentLength, byte[] token, byte[] replace) {
this.resp = resp;
this.outLen = contentLength;
this.token = token;
@@ -56,8 +55,7 @@
byte[] outData = outBuff.toByteArray();
byte[] cmp = new byte[token.length];
- ByteArrayOutputStream convertedData =
- new ByteArrayOutputStream(outData.length);
+ ByteArrayOutputStream convertedData = new ByteArrayOutputStream(outData.length);
for (int i = 0; i < outData.length; i++) {
byte b = outData[i];
@@ -98,8 +96,7 @@
}
@Override
- public void setWriteListener(WriteListener writeListener) {
- }
+ public void setWriteListener(WriteListener writeListener) {}
@Override
public boolean isReady() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/WebModule.java b/src/main/java/com/googlesource/gerrit/plugins/manager/WebModule.java
index 0cbc9c8..86405c6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/WebModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/WebModule.java
@@ -22,8 +22,7 @@
@Override
protected void configureServlets() {
bind(AvailablePluginsCollection.class);
- DynamicSet.bind(binder(), WebLoginListener.class)
- .to(FirstWebLoginListener.class);
+ DynamicSet.bind(binder(), WebLoginListener.class).to(FirstWebLoginListener.class);
serve("/available*").with(PluginManagerRestApiServlet.class);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/XAuthFilter.java b/src/main/java/com/googlesource/gerrit/plugins/manager/XAuthFilter.java
index 57fc2c9..de1eb10 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/XAuthFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/XAuthFilter.java
@@ -19,13 +19,8 @@
import com.google.gerrit.server.AccessPath;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.io.PrintWriter;
-
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -36,6 +31,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
public class XAuthFilter implements Filter {
@@ -49,12 +46,11 @@
}
@Override
- public void destroy() {
- }
+ public void destroy() {}
@Override
- public void doFilter(ServletRequest req, ServletResponse resp,
- FilterChain chain) throws IOException, ServletException {
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
+ throws IOException, ServletException {
HttpServletRequest httpReq = (HttpServletRequest) req;
HttpServletResponse httpResp = (HttpServletResponse) resp;
@@ -64,34 +60,38 @@
session.setAccessPathOk(AccessPath.REST_API, true);
log.debug("Injecting X-Gerrit-Auth for {}", httpReq.getRequestURI());
- httpResp = new HttpServletResponseWrapper(httpResp) {
+ httpResp =
+ new HttpServletResponseWrapper(httpResp) {
- private int origContentLength;
+ private int origContentLength;
- @Override
- public void setHeader(String name, String value) {
- log.debug("{}: {}", name, value);
- if (name.equalsIgnoreCase("Content-Length")) {
- origContentLength = Integer.parseInt(value);
- } else {
- super.setHeader(name, value);
- }
- }
+ @Override
+ public void setHeader(String name, String value) {
+ log.debug("{}: {}", name, value);
+ if (name.equalsIgnoreCase("Content-Length")) {
+ origContentLength = Integer.parseInt(value);
+ } else {
+ super.setHeader(name, value);
+ }
+ }
- @Override
- public PrintWriter getWriter() throws IOException {
- return super.getWriter();
- }
+ @Override
+ public PrintWriter getWriter() throws IOException {
+ return super.getWriter();
+ }
- @Override
- public ServletOutputStream getOutputStream() throws IOException {
- return new TokenReplaceOutputStream(
- (HttpServletResponse) getResponse(), origContentLength,
- "@X-Gerrit-Auth".getBytes(), gerritAuth.getBytes());
- }
- };
+ @Override
+ public ServletOutputStream getOutputStream() throws IOException {
+ return new TokenReplaceOutputStream(
+ (HttpServletResponse) getResponse(),
+ origContentLength,
+ "@X-Gerrit-Auth".getBytes(),
+ gerritAuth.getBytes());
+ }
+ };
- httpResp.setHeader("Cache-Control", "private, no-cache, no-store, must-revalidate, max-age=0");
+ httpResp.setHeader(
+ "Cache-Control", "private, no-cache, no-store, must-revalidate, max-age=0");
httpResp.setHeader("Pragma", "no-cache");
httpResp.setHeader("Expires", "0");
@@ -103,6 +103,5 @@
}
@Override
- public void init(FilterConfig conf) throws ServletException {
- }
+ public void init(FilterConfig conf) throws ServletException {}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartGson.java b/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartGson.java
index 400505d..b091ca6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartGson.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartGson.java
@@ -17,7 +17,6 @@
import com.google.gerrit.server.OutputFormat;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
-
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
@@ -47,8 +46,7 @@
try {
ciUrl = new URL(url);
} catch (MalformedURLException e) {
- throw new IllegalArgumentException(
- "Internal error: Gerrit CI URL seems to be malformed", e);
+ throw new IllegalArgumentException("Internal error: Gerrit CI URL seems to be malformed", e);
}
return new InputStreamReader(ciUrl.openStream());
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartJson.java b/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartJson.java
index bc2ff06..abfc879 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartJson.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/gson/SmartJson.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.manager.gson;
import com.google.gson.JsonElement;
-
import java.util.Optional;
import java.util.function.Function;
@@ -32,16 +31,18 @@
}
public Optional<String> getOptionalString(String fieldName) {
- return getOptional(fieldName).map(new Function<SmartJson, String>() {
- @Override
- public String apply(SmartJson elem) {
- if (!elem.jsonElem.isJsonPrimitive()) {
- throw new IllegalArgumentException("cannot convert " + elem.jsonElem
- + " into a String");
- }
- return elem.jsonElem.getAsString();
- }
- });
+ return getOptional(fieldName)
+ .map(
+ new Function<SmartJson, String>() {
+ @Override
+ public String apply(SmartJson elem) {
+ if (!elem.jsonElem.isJsonPrimitive()) {
+ throw new IllegalArgumentException(
+ "cannot convert " + elem.jsonElem + " into a String");
+ }
+ return elem.jsonElem.getAsString();
+ }
+ });
}
public String getString(String fieldName) {
@@ -50,8 +51,7 @@
public Optional<SmartJson> getOptional(String fieldName) {
if (jsonElem != null && jsonElem.getAsJsonObject().get(fieldName) != null) {
- return Optional.of(SmartJson
- .of(jsonElem.getAsJsonObject().get(fieldName)));
+ return Optional.of(SmartJson.of(jsonElem.getAsJsonObject().get(fieldName)));
}
return Optional.empty();
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/repository/CorePluginsRepository.java b/src/main/java/com/googlesource/gerrit/plugins/manager/repository/CorePluginsRepository.java
index 7ba1518..1f5b055 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/repository/CorePluginsRepository.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/repository/CorePluginsRepository.java
@@ -20,10 +20,6 @@
import com.google.gerrit.common.Version;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -37,10 +33,11 @@
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CorePluginsRepository implements PluginsRepository {
- private static final Logger log = LoggerFactory
- .getLogger(CorePluginsRepository.class);
+ private static final Logger log = LoggerFactory.getLogger(CorePluginsRepository.class);
private static final String GERRIT_VERSION = Version.getVersion();
private final SitePaths site;
@@ -53,13 +50,11 @@
@Override
public boolean apply(JarEntry entry) {
String entryName = entry.getName();
- return (entryName.startsWith("WEB-INF/plugins") &&
- entryName.endsWith(".jar"));
+ return (entryName.startsWith("WEB-INF/plugins") && entryName.endsWith(".jar"));
}
}
- static class ExtractPluginInfoFromJarEntry implements
- Function<JarEntry, PluginInfo> {
+ static class ExtractPluginInfoFromJarEntry implements Function<JarEntry, PluginInfo> {
private String gerritWarFilename;
public ExtractPluginInfoFromJarEntry(String gerritWarFilename) {
@@ -70,20 +65,18 @@
public PluginInfo apply(JarEntry entry) {
try {
Path entryName = Paths.get(entry.getName());
- URI pluginUrl =
- new URI("jar:file:" + gerritWarFilename + "!/" + entry.getName());
- try (JarInputStream pluginJar =
- new JarInputStream(pluginUrl.toURL().openStream())) {
+ URI pluginUrl = new URI("jar:file:" + gerritWarFilename + "!/" + entry.getName());
+ try (JarInputStream pluginJar = new JarInputStream(pluginUrl.toURL().openStream())) {
Manifest manifestJarEntry = getManifestEntry(pluginJar);
if (manifestJarEntry != null) {
Attributes pluginAttributes = manifestJarEntry.getMainAttributes();
return new PluginInfo(
pluginAttributes.getValue("Gerrit-PluginName"),
- pluginAttributes.getValue("Implementation-Version"), "",
+ pluginAttributes.getValue("Implementation-Version"),
+ "",
pluginUrl.toString());
}
- return new PluginInfo(entryName.getFileName().toString(), "", "",
- pluginUrl.toString());
+ return new PluginInfo(entryName.getFileName().toString(), "", "", pluginUrl.toString());
} catch (IOException e) {
log.error("Unable to open plugin " + pluginUrl, e);
return null;
@@ -94,10 +87,10 @@
}
}
- private Manifest getManifestEntry(JarInputStream pluginJar)
- throws IOException {
- for (JarEntry entry = pluginJar.getNextJarEntry(); entry != null; entry =
- pluginJar.getNextJarEntry()) {
+ private Manifest getManifestEntry(JarInputStream pluginJar) throws IOException {
+ for (JarEntry entry = pluginJar.getNextJarEntry();
+ entry != null;
+ entry = pluginJar.getNextJarEntry()) {
if (entry.getName().equals("META-INF/MANIFEST.MF")) {
return new Manifest(pluginJar);
}
@@ -110,8 +103,9 @@
public Collection<PluginInfo> list(String gerritVersion) throws IOException {
if (!gerritVersion.equals(GERRIT_VERSION)) {
log.warn(
- "No core plugins available for version {} which is different than " +
- "the current running Gerrit", gerritVersion);
+ "No core plugins available for version {} which is different than "
+ + "the current running Gerrit",
+ gerritVersion);
return Collections.emptyList();
}
@@ -123,22 +117,23 @@
try (JarFile gerritWar = new JarFile(gerritWarPath.toFile())) {
- return FluentIterable
- .from(Collections.list(gerritWar.entries()))
+ return FluentIterable.from(Collections.list(gerritWar.entries()))
.filter(new SelectPluginsFromJar())
- .transform(
- new ExtractPluginInfoFromJarEntry(gerritWarPath.toString()))
- .filter(new Predicate<PluginInfo>() {
- @Override
- public boolean apply(PluginInfo pluginInfo) {
- return pluginInfo != null;
- }
- }).toSortedList(new Comparator<PluginInfo>() {
- @Override
- public int compare(PluginInfo a, PluginInfo b) {
- return a.name.compareTo(b.name);
- }
- });
+ .transform(new ExtractPluginInfoFromJarEntry(gerritWarPath.toString()))
+ .filter(
+ new Predicate<PluginInfo>() {
+ @Override
+ public boolean apply(PluginInfo pluginInfo) {
+ return pluginInfo != null;
+ }
+ })
+ .toSortedList(
+ new Comparator<PluginInfo>() {
+ @Override
+ public int compare(PluginInfo a, PluginInfo b) {
+ return a.name.compareTo(b.name);
+ }
+ });
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/repository/JenkinsCiPluginsRepository.java b/src/main/java/com/googlesource/gerrit/plugins/manager/repository/JenkinsCiPluginsRepository.java
index 0b609ad..a01555a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/repository/JenkinsCiPluginsRepository.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/repository/JenkinsCiPluginsRepository.java
@@ -19,16 +19,10 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
-
import com.googlesource.gerrit.plugins.manager.GerritVersionBranch;
import com.googlesource.gerrit.plugins.manager.PluginManagerConfig;
import com.googlesource.gerrit.plugins.manager.gson.SmartGson;
import com.googlesource.gerrit.plugins.manager.gson.SmartJson;
-
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -39,12 +33,14 @@
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
public class JenkinsCiPluginsRepository implements PluginsRepository {
- private static final Logger log = LoggerFactory
- .getLogger(JenkinsCiPluginsRepository.class);
+ private static final Logger log = LoggerFactory.getLogger(JenkinsCiPluginsRepository.class);
private static final Optional<PluginInfo> noPluginInfo = Optional.empty();
@@ -66,8 +62,7 @@
private final Provider<SmartGson> gsonProvider;
@Inject
- public JenkinsCiPluginsRepository(Provider<SmartGson> gsonProvider,
- PluginManagerConfig config) {
+ public JenkinsCiPluginsRepository(Provider<SmartGson> gsonProvider, PluginManagerConfig config) {
this.gsonProvider = gsonProvider;
this.config = config;
}
@@ -75,7 +70,7 @@
@Override
public List<PluginInfo> list(String gerritVersion) throws IOException {
List<PluginInfo> list = cache.get(gerritVersion);
- if(list == null) {
+ if (list == null) {
list = getList(gerritVersion);
cache.put(gerritVersion, list);
}
@@ -89,8 +84,7 @@
try {
Job[] jobs =
- gson.get(config.getJenkinsUrl() + "/view/" + viewName + "/api/json",
- View.class).jobs;
+ gson.get(config.getJenkinsUrl() + "/view/" + viewName + "/api/json", View.class).jobs;
for (Job job : jobs) {
if (job.color.equals("blue")) {
@@ -107,32 +101,31 @@
return plugins;
}
- private Optional<PluginInfo> getPluginInfo(final SmartGson gson, String url)
- throws IOException {
+ private Optional<PluginInfo> getPluginInfo(final SmartGson gson, String url) throws IOException {
SmartJson jobDetails = gson.get(url + "/api/json");
- Optional<SmartJson> lastSuccessfulBuild =
- jobDetails.getOptional("lastSuccessfulBuild");
+ Optional<SmartJson> lastSuccessfulBuild = jobDetails.getOptional("lastSuccessfulBuild");
- return lastSuccessfulBuild.map(
- new Function<SmartJson, Optional<PluginInfo>>() {
- @Override
- public Optional<PluginInfo> apply(SmartJson build) {
- String buildUrl = build.getString("url");
- try {
- return getPluginArtifactInfo(gson, buildUrl);
- } catch (IOException e) {
- log.warn("Cannot retrieve plugin artifact info from {}", buildUrl);
- return noPluginInfo;
- }
- }
- }).orElse(noPluginInfo);
+ return lastSuccessfulBuild
+ .map(
+ new Function<SmartJson, Optional<PluginInfo>>() {
+ @Override
+ public Optional<PluginInfo> apply(SmartJson build) {
+ String buildUrl = build.getString("url");
+ try {
+ return getPluginArtifactInfo(gson, buildUrl);
+ } catch (IOException e) {
+ log.warn("Cannot retrieve plugin artifact info from {}", buildUrl);
+ return noPluginInfo;
+ }
+ }
+ })
+ .orElse(noPluginInfo);
}
private Optional<PluginInfo> getPluginArtifactInfo(SmartGson gson, String url)
throws IOException {
SmartJson buildExecution = gson.get(url + "/api/json");
- JsonArray artifacts =
- buildExecution.get("artifacts").get().getAsJsonArray();
+ JsonArray artifacts = buildExecution.get("artifacts").get().getAsJsonArray();
if (artifacts.size() == 0) {
return Optional.empty();
}
@@ -150,47 +143,39 @@
? fixPluginNameForMavenBuilds(pluginPathParts)
: pluginPathParts[pluginPathParts.length - 2];
- String pluginUrl =
- String.format("%s/artifact/%s", buildExecution.getString("url"),
- pluginPath);
+ String pluginUrl = String.format("%s/artifact/%s", buildExecution.getString("url"), pluginPath);
String pluginVersion = "";
- Optional<SmartJson> verArtifactJson =
- findArtifact(artifacts, ".jar-version");
+ Optional<SmartJson> verArtifactJson = findArtifact(artifacts, ".jar-version");
if (verArtifactJson.isPresent()) {
String versionUrl =
- String.format("%s/artifact/%s", buildExecution.getString("url"),
- verArtifactJson.get().getString("relativePath"));
+ String.format(
+ "%s/artifact/%s",
+ buildExecution.getString("url"), verArtifactJson.get().getString("relativePath"));
try (BufferedReader reader =
- new BufferedReader(new InputStreamReader(
- new URL(versionUrl).openStream()), 4096)) {
+ new BufferedReader(new InputStreamReader(new URL(versionUrl).openStream()), 4096)) {
pluginVersion = reader.readLine();
}
}
String sha1 = "";
- for (JsonElement elem : buildExecution.get("actions").get()
- .getAsJsonArray()) {
+ for (JsonElement elem : buildExecution.get("actions").get().getAsJsonArray()) {
SmartJson elemJson = SmartJson.of(elem);
- Optional<SmartJson> lastBuildRevision =
- elemJson.getOptional("lastBuiltRevision");
+ Optional<SmartJson> lastBuildRevision = elemJson.getOptional("lastBuiltRevision");
if (lastBuildRevision.isPresent()) {
sha1 = lastBuildRevision.get().getString("SHA1").substring(0, 8);
}
}
- return Optional.of(new PluginInfo(pluginName, pluginVersion, sha1,
- pluginUrl));
+ return Optional.of(new PluginInfo(pluginName, pluginVersion, sha1, pluginUrl));
}
private String fixPluginNameForMavenBuilds(String[] pluginPathParts) {
String mavenPluginFilename =
- StringUtils.substringBeforeLast(
- pluginPathParts[pluginPathParts.length - 1], ".");
+ StringUtils.substringBeforeLast(pluginPathParts[pluginPathParts.length - 1], ".");
int versionDelim = mavenPluginFilename.indexOf('-');
- return versionDelim > 0 ? mavenPluginFilename
- .substring(0, versionDelim) : mavenPluginFilename;
+ return versionDelim > 0 ? mavenPluginFilename.substring(0, versionDelim) : mavenPluginFilename;
}
private boolean isMavenBuild(String[] pluginPathParts) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/manager/repository/PluginInfo.java b/src/main/java/com/googlesource/gerrit/plugins/manager/repository/PluginInfo.java
index 32bb47f..c6af444 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/manager/repository/PluginInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/manager/repository/PluginInfo.java
@@ -30,4 +30,4 @@
this.sha1 = sha1;
this.url = url;
}
-}
\ No newline at end of file
+}