Reformat all files with GJF
Change-Id: If8c985901c1ecbc76d668cc085c850c5cd504c29
diff --git a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/Module.java b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/Module.java
index 4675c4e..fc07578 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/Module.java
@@ -21,8 +21,7 @@
@Override
protected void configure() {
- DynamicSet.bind(binder(), ServerPluginProvider.class).to(
- ScalaPluginProvider.class);
+ DynamicSet.bind(binder(), ServerPluginProvider.class).to(ScalaPluginProvider.class);
bind(ScalaSettings.class);
bind(ScalaReporter.class);
bind(ScalaPluginScriptEngine.class);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginProvider.java b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginProvider.java
index eb4fa13..511b406 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginProvider.java
@@ -21,30 +21,23 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
-
-import org.eclipse.jgit.internal.storage.file.FileSnapshot;
-
import java.nio.file.Path;
+import org.eclipse.jgit.internal.storage.file.FileSnapshot;
/**
* Scala scripting plugins.
*
- * Allows to define a Groovy class to implement any type of Gerrit plugin.
+ * <p>Allows to define a Groovy class to implement any type of Gerrit plugin.
*
- * Example of Scala SSH Plugin (hello-1.0.scala):
+ * <p>Example of Scala SSH Plugin (hello-1.0.scala):
* ------------------------------------------------ TBD
*
- * The above example add a "hello scala" command to Gerrit SSH interface that
- * displays "Hello Gerrit from Scala !"
+ * <p>The above example add a "hello scala" command to Gerrit SSH interface that displays "Hello
+ * Gerrit from Scala !"
*
- * import com.google.gerrit.sshd._
- * import com.google.gerrit.extensions.annotations._
- *
- * @Export("scala")
- * class MyClass extends SshCommand {
- * override def run = stdout println "Hello Gerrit from Scala!"
- * }
- *
+ * <p>import com.google.gerrit.sshd._ import
+ * com.google.gerrit.extensions.annotations._ @Export("scala") class MyClass extends SshCommand {
+ * override def run = stdout println "Hello Gerrit from Scala!" }
*/
@Singleton
class ScalaPluginProvider implements ServerPluginProvider {
@@ -62,14 +55,19 @@
}
@Override
- public ServerPlugin get(Path srcFile,
- FileSnapshot snapshot, PluginDescription description)
+ public ServerPlugin get(Path srcFile, FileSnapshot snapshot, PluginDescription description)
throws InvalidPluginException {
ScalaPluginScriptEngine scriptEngine = scriptEngineProvider.get();
String name = getPluginName(srcFile);
- return new ServerPlugin(name, description.canonicalUrl, description.user, srcFile,
- snapshot, new ScalaPluginScanner(name, srcFile, scriptEngine),
- description.dataDir, scriptEngine.getClassLoader());
+ return new ServerPlugin(
+ name,
+ description.canonicalUrl,
+ description.user,
+ srcFile,
+ snapshot,
+ new ScalaPluginScanner(name, srcFile, scriptEngine),
+ description.dataDir,
+ scriptEngine.getClassLoader());
}
@Override
@@ -92,4 +90,3 @@
return providerPluginName;
}
}
-
diff --git a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScanner.java b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScanner.java
index ab170ae..439c171 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScanner.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScanner.java
@@ -13,27 +13,28 @@
// limitations under the License.
package com.googlesource.gerrit.plugins.scripting.scala;
-import java.util.Optional;
import com.google.gerrit.server.plugins.AbstractPreloadedPluginScanner;
import com.google.gerrit.server.plugins.InvalidPluginException;
import com.google.gerrit.server.plugins.Plugin;
import com.google.gerrit.server.plugins.PluginEntry;
-
import com.googlesource.gerrit.plugins.web.WebPluginScanner;
-
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Enumeration;
+import java.util.Optional;
import java.util.Set;
public class ScalaPluginScanner extends AbstractPreloadedPluginScanner {
private final WebPluginScanner webScanner;
- public ScalaPluginScanner(String pluginName, Path srcFile,
- ScalaPluginScriptEngine scriptEngine) throws InvalidPluginException {
- super(pluginName, getPluginVersion(srcFile), loadScriptClasses(srcFile,
- scriptEngine), Plugin.ApiType.PLUGIN);
+ public ScalaPluginScanner(String pluginName, Path srcFile, ScalaPluginScriptEngine scriptEngine)
+ throws InvalidPluginException {
+ super(
+ pluginName,
+ getPluginVersion(srcFile),
+ loadScriptClasses(srcFile, scriptEngine),
+ Plugin.ApiType.PLUGIN);
this.webScanner = new WebPluginScanner(srcFile);
}
@@ -48,13 +49,12 @@
return srcFileName.substring(startPos + 1, endPos);
}
- private static Set<Class<?>> loadScriptClasses(Path srcFile,
- ScalaPluginScriptEngine scriptEngine) throws InvalidPluginException {
+ private static Set<Class<?>> loadScriptClasses(Path srcFile, ScalaPluginScriptEngine scriptEngine)
+ throws InvalidPluginException {
try {
return scriptEngine.eval(srcFile);
} catch (ClassNotFoundException | IOException e) {
- throw new InvalidPluginException(
- "Cannot evaluate script file " + srcFile, e);
+ throw new InvalidPluginException("Cannot evaluate script file " + srcFile, e);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScriptEngine.java b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScriptEngine.java
index ccabb82..43704ce 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScriptEngine.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaPluginScriptEngine.java
@@ -20,23 +20,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import scala.Char;
-import scala.Option;
-import scala.Tuple2;
-import scala.collection.Iterator;
-import scala.collection.immutable.Seq;
-import scala.collection.mutable.Map;
-import scala.reflect.internal.util.BatchSourceFile;
-import scala.reflect.internal.util.SourceFile;
-import scala.reflect.io.AbstractFile;
-import scala.reflect.io.VirtualDirectory;
-import scala.tools.nsc.Global;
-import scala.tools.nsc.Global.Run;
-
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.FileVisitOption;
@@ -50,10 +33,23 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import scala.Char;
+import scala.Option;
+import scala.Tuple2;
+import scala.collection.Iterator;
+import scala.collection.immutable.Seq;
+import scala.collection.mutable.Map;
+import scala.reflect.internal.util.BatchSourceFile;
+import scala.reflect.internal.util.SourceFile;
+import scala.reflect.io.AbstractFile;
+import scala.reflect.io.VirtualDirectory;
+import scala.tools.nsc.Global;
+import scala.tools.nsc.Global.Run;
public class ScalaPluginScriptEngine {
- private static final Logger LOG = LoggerFactory
- .getLogger(ScalaPluginScriptEngine.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ScalaPluginScriptEngine.class);
// private final IMain scalaEngine;
private final ScalaClassLoader classLoader;
@@ -66,9 +62,7 @@
public ScalaClassLoader(ScalaSettings settings) {
super(ScalaClassLoader.class.getClassLoader());
- scalaClasses =
- settings.getVirtualDirectory()
- .scala$reflect$io$VirtualDirectory$$files();
+ scalaClasses = settings.getVirtualDirectory().scala$reflect$io$VirtualDirectory$$files();
}
@Override
@@ -79,31 +73,31 @@
ba = classFile.toByteArray();
return defineClass(name, ba, 0, ba.length);
} catch (IOException e) {
- throw new ClassNotFoundException("Cannot open Scala class file "
- + classFile, e);
+ throw new ClassNotFoundException("Cannot open Scala class file " + classFile, e);
}
}
- private AbstractFile getClassFile(String fullClassName,
- Map<String, AbstractFile> tree) throws ClassNotFoundException {
+ private AbstractFile getClassFile(String fullClassName, Map<String, AbstractFile> tree)
+ throws ClassNotFoundException {
String[] nameComponents = fullClassName.split("\\.");
- nameComponents[nameComponents.length-1] =
- nameComponents[nameComponents.length-1] + CLASS_EXTENSION;
+ nameComponents[nameComponents.length - 1] =
+ nameComponents[nameComponents.length - 1] + CLASS_EXTENSION;
for (String component : nameComponents) {
Option<AbstractFile> node = tree.get(component);
if (node.isEmpty()) {
throw new ClassNotFoundException(
- "Cannot find compiled Scala code for class " + fullClassName
- + ": " + component + " is unknown");
+ "Cannot find compiled Scala code for class "
+ + fullClassName
+ + ": "
+ + component
+ + " is unknown");
}
AbstractFile abstractFile = node.get();
if (component.endsWith(CLASS_EXTENSION)) {
return abstractFile;
} else {
- tree =
- ((VirtualDirectory) abstractFile)
- .scala$reflect$io$VirtualDirectory$$files();
+ tree = ((VirtualDirectory) abstractFile).scala$reflect$io$VirtualDirectory$$files();
}
}
throw new ClassNotFoundException(
@@ -114,26 +108,26 @@
return scanTree("", scalaClasses);
}
- private Set<String> scanTree(String packageName,
- Map<String, AbstractFile> tree) {
+ private Set<String> scanTree(String packageName, Map<String, AbstractFile> tree) {
Set<String> classNames = Sets.newHashSet();
- for (Iterator<Tuple2<String, AbstractFile>> keysIter = tree.toIterator(); keysIter
- .hasNext();) {
+ for (Iterator<Tuple2<String, AbstractFile>> keysIter = tree.toIterator();
+ keysIter.hasNext(); ) {
Tuple2<String, AbstractFile> node = keysIter.next();
String fileName = node._1;
AbstractFile fileContent = node._2;
if (fileName.endsWith(CLASS_EXTENSION)) {
- classNames.add(nameWithPackage(
- packageName,
- fileName.substring(0,
- fileName.length() - CLASS_EXTENSION.length())));
+ classNames.add(
+ nameWithPackage(
+ packageName,
+ fileName.substring(0, fileName.length() - CLASS_EXTENSION.length())));
- } else if (VirtualDirectory.class.isAssignableFrom(fileContent
- .getClass())) {
+ } else if (VirtualDirectory.class.isAssignableFrom(fileContent.getClass())) {
VirtualDirectory subNode = (VirtualDirectory) node._2;
- classNames.addAll(scanTree(nameWithPackage(packageName, fileName),
- subNode.scala$reflect$io$VirtualDirectory$$files()));
+ classNames.addAll(
+ scanTree(
+ nameWithPackage(packageName, fileName),
+ subNode.scala$reflect$io$VirtualDirectory$$files()));
}
}
return classNames;
@@ -149,38 +143,36 @@
}
@Inject
- public ScalaPluginScriptEngine(ScalaSettings settings,
- ScalaReporter reporter) {
+ public ScalaPluginScriptEngine(ScalaSettings settings, ScalaReporter reporter) {
this.classLoader = new ScalaClassLoader(settings);
- globalEngine =
- new Global(settings.getSettings(), reporter.getConsoleReporter());
+ globalEngine = new Global(settings.getSettings(), reporter.getConsoleReporter());
this.reporter = reporter;
}
- public Set<Class<?>> eval(Path scalaFile) throws IOException,
- ClassNotFoundException {
+ public Set<Class<?>> eval(Path scalaFile) throws IOException, ClassNotFoundException {
if (Files.isRegularFile(scalaFile)) {
return evalFiles(Arrays.asList(scalaFile));
} else if (Files.isDirectory(scalaFile)) {
return evalDirectory(scalaFile);
} else {
- throw new IOException("File " + scalaFile
- + " is not a supported for loading Scala scripts");
+ throw new IOException("File " + scalaFile + " is not a supported for loading Scala scripts");
}
}
- private Set<Class<?>> evalDirectory(Path scalaFile) throws IOException,
- ClassNotFoundException {
+ private Set<Class<?>> evalDirectory(Path scalaFile) throws IOException, ClassNotFoundException {
final List<Path> scalaFiles = Lists.newArrayList();
- Files.walkFileTree(scalaFile,
- EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
+ Files.walkFileTree(
+ scalaFile,
+ EnumSet.of(FileVisitOption.FOLLOW_LINKS),
+ Integer.MAX_VALUE,
new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path path, BasicFileAttributes attrs)
throws IOException {
String fileName = path.getFileName().toString();
- if (Files.isRegularFile(path) && fileName.endsWith(ScalaPluginProvider.SCALA_EXTENSION)) {
+ if (Files.isRegularFile(path)
+ && fileName.endsWith(ScalaPluginProvider.SCALA_EXTENSION)) {
scalaFiles.add(path);
}
return FileVisitResult.CONTINUE;
@@ -189,20 +181,23 @@
return evalFiles(scalaFiles);
}
- private Set<Class<?>> evalFiles(List<Path> scalaFiles) throws IOException,
- ClassNotFoundException {
+ private Set<Class<?>> evalFiles(List<Path> scalaFiles)
+ throws IOException, ClassNotFoundException {
Set<Class<?>> classes = Sets.newHashSet();
- List<SourceFile> scalaSourceFiles = Lists.transform(scalaFiles, new Function<Path,SourceFile>() {
- @Override
- public SourceFile apply(Path scalaFile) {
- try {
- return new BatchSourceFile(scalaFile.toString(), readScalaFile(scalaFile));
- } catch (IOException e) {
- throw new IllegalArgumentException("Cannot load scala file " + scalaFile, e);
- }
- }
- });
+ List<SourceFile> scalaSourceFiles =
+ Lists.transform(
+ scalaFiles,
+ new Function<Path, SourceFile>() {
+ @Override
+ public SourceFile apply(Path scalaFile) {
+ try {
+ return new BatchSourceFile(scalaFile.toString(), readScalaFile(scalaFile));
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Cannot load scala file " + scalaFile, e);
+ }
+ }
+ });
Run run = globalEngine.new Run();
reporter.reset();
run.compileSources(asScalaBuffer(scalaSourceFiles).toList());
@@ -212,7 +207,7 @@
throw new IOException("Invalid Scala files " + scalaFiles);
} else {
String output = reporter.getOutput();
- if(output.length() > 0) {
+ if (output.length() > 0) {
LOG.info("Scala files " + scalaFiles + " loaded successfully");
LOG.info(output);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaReporter.java b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaReporter.java
index f5514e6..0b9c672 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaReporter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaReporter.java
@@ -14,14 +14,12 @@
package com.googlesource.gerrit.plugins.scripting.scala;
import com.google.inject.Inject;
-
-import scala.tools.nsc.reporters.ConsoleReporter;
-import scala.tools.nsc.reporters.Reporter;
-
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import scala.tools.nsc.reporters.ConsoleReporter;
+import scala.tools.nsc.reporters.Reporter;
public class ScalaReporter {
@@ -33,8 +31,10 @@
public ScalaReporter(ScalaSettings settings) {
buffer = new ByteArrayOutputStream();
consoleReporter =
- new ConsoleReporter(settings.getSettings(), new BufferedReader(
- new InputStreamReader(System.in)), new PrintWriter(buffer, true));
+ new ConsoleReporter(
+ settings.getSettings(),
+ new BufferedReader(new InputStreamReader(System.in)),
+ new PrintWriter(buffer, true));
}
public String getOutput() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaSettings.java b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaSettings.java
index 3827397..633afc3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaSettings.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/scripting/scala/ScalaSettings.java
@@ -15,14 +15,12 @@
import com.google.gerrit.server.plugins.PluginLoader;
import com.google.inject.Inject;
-
+import java.net.URL;
+import java.net.URLClassLoader;
import scala.Option;
import scala.reflect.io.VirtualDirectory;
import scala.tools.nsc.Settings;
-import java.net.URL;
-import java.net.URLClassLoader;
-
public class ScalaSettings {
private static final String CLASSPATH_DEBUG = "false";
private static final String VERBOSE_COMPILE_OUTPUT = "false";
@@ -40,13 +38,14 @@
settings.feature().tryToSetFromPropertyValue("true");
settings.outputDirs().setSingleOutput(initVirtualDirectory());
- settings.classpath().tryToSetFromPropertyValue(
- classPathOf(PluginLoader.class) + ":" + classPathOf(this.getClass()));
+ settings
+ .classpath()
+ .tryToSetFromPropertyValue(
+ classPathOf(PluginLoader.class) + ":" + classPathOf(this.getClass()));
}
private VirtualDirectory initVirtualDirectory() {
- virtualDirectory =
- new VirtualDirectory("(memory)", Option.apply((VirtualDirectory) null));
+ virtualDirectory = new VirtualDirectory("(memory)", Option.apply((VirtualDirectory) null));
return virtualDirectory;
}
@@ -71,5 +70,4 @@
public VirtualDirectory getVirtualDirectory() {
return virtualDirectory;
}
-
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/web/LookAheadFileInputStream.java b/src/main/java/com/googlesource/gerrit/plugins/web/LookAheadFileInputStream.java
index d1a672e..22de6a4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/web/LookAheadFileInputStream.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/web/LookAheadFileInputStream.java
@@ -41,8 +41,15 @@
@Override
public String toString() {
- return "pos=" + pos + " count=" + count + " lineNr=" + lineNr
- + " buffer=\'" + new String(buf, pos, count - pos) + "'";
+ return "pos="
+ + pos
+ + " count="
+ + count
+ + " lineNr="
+ + lineNr
+ + " buffer=\'"
+ + new String(buf, pos, count - pos)
+ + "'";
}
@Override
@@ -68,8 +75,7 @@
return numBytes;
}
- public synchronized boolean startsWith(String includeVirtualPrefix)
- throws IOException {
+ public synchronized boolean startsWith(String includeVirtualPrefix) throws IOException {
mark(includeVirtualPrefix.length());
try {
byte[] cmp = new byte[includeVirtualPrefix.length()];
@@ -103,5 +109,4 @@
public Path getCurrentDir() {
return currentDir;
}
-
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/web/SSIPageInputStream.java b/src/main/java/com/googlesource/gerrit/plugins/web/SSIPageInputStream.java
index 965b97a..4d91787 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/web/SSIPageInputStream.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/web/SSIPageInputStream.java
@@ -20,16 +20,14 @@
import java.util.Stack;
public class SSIPageInputStream extends FilterInputStream {
- private static final String INCLUDE_VIRTUAL_PREFIX =
- "<!--#include virtual=\"";
+ private static final String INCLUDE_VIRTUAL_PREFIX = "<!--#include virtual=\"";
private static final String INCLUDE_VIRTUAL_SUFFIX = " -->";
private LookAheadFileInputStream currentIs;
private Stack<LookAheadFileInputStream> fileInputStreamStack;
private final Path basePath;
- public SSIPageInputStream(Path basePath, String filePath)
- throws IOException {
+ public SSIPageInputStream(Path basePath, String filePath) throws IOException {
super(new LookAheadFileInputStream(basePath.resolve(filePath)));
this.basePath = basePath;
@@ -63,9 +61,13 @@
fileInputStreamStack.push(currentIs);
Path inputFile = getFile(includeFileName);
if (!Files.exists(inputFile)) {
- throw new IOException("Cannot find file '" + includeFileName
- + "' included in " + currentIs.getFileName() + ":"
- + currentIs.getLineNr());
+ throw new IOException(
+ "Cannot find file '"
+ + includeFileName
+ + "' included in "
+ + currentIs.getFileName()
+ + ":"
+ + currentIs.getLineNr());
}
currentIs = new LookAheadFileInputStream(inputFile);
in = currentIs;
@@ -95,8 +97,7 @@
last = (char) currentIs.read();
}
if (!currentIs.startsWith(INCLUDE_VIRTUAL_SUFFIX)) {
- throw new IOException("Invalid SHTML include directive at line "
- + currentIs.getLineNr());
+ throw new IOException("Invalid SHTML include directive at line " + currentIs.getLineNr());
}
skipAll(INCLUDE_VIRTUAL_SUFFIX.length());
@@ -104,9 +105,7 @@
}
private void skipAll(int length) throws IOException {
- for (long skipped = skip(length);
- length > 0 && skipped > 0;
- skipped = skip(length)) {
+ for (long skipped = skip(length); length > 0 && skipped > 0; skipped = skip(length)) {
length -= skipped;
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/web/WebPluginScanner.java b/src/main/java/com/googlesource/gerrit/plugins/web/WebPluginScanner.java
index 130750a..6b31ed0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/web/WebPluginScanner.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/web/WebPluginScanner.java
@@ -13,13 +13,11 @@
// limitations under the License.
package com.googlesource.gerrit.plugins.web;
-import java.util.Optional;
import com.google.common.collect.Lists;
import com.google.gerrit.server.plugins.InvalidPluginException;
import com.google.gerrit.server.plugins.PluginContentScanner;
import com.google.gerrit.server.plugins.PluginEntry;
import com.google.inject.Inject;
-
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
@@ -34,6 +32,7 @@
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.jar.Manifest;
public class WebPluginScanner implements PluginContentScanner {
@@ -74,8 +73,8 @@
if (resourcePath.endsWith("html")) {
return Optional.of(new PluginEntry(resourcePath, fileLastModifiedTimeMillis));
} else {
- return Optional.of(new PluginEntry(resourcePath, fileLastModifiedTimeMillis,
- Optional.of(fileSize)));
+ return Optional.of(
+ new PluginEntry(resourcePath, fileLastModifiedTimeMillis, Optional.of(fileSize)));
}
} else {
return Optional.empty();
@@ -87,13 +86,12 @@
}
@Override
- public InputStream getInputStream(PluginEntry entry)
- throws IOException {
+ public InputStream getInputStream(PluginEntry entry) throws IOException {
String name = entry.getName();
- if(name.endsWith("html")) {
+ if (name.endsWith("html")) {
return new SSIPageInputStream(staticResourcesPath, name);
} else {
- return Files.newInputStream(getResourceFile(name));
+ return Files.newInputStream(getResourceFile(name));
}
}
@@ -101,15 +99,16 @@
public Enumeration<PluginEntry> entries() {
final List<PluginEntry> resourcesList = Lists.newArrayList();
try {
- Files.walkFileTree(staticResourcesPath,
- EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
+ Files.walkFileTree(
+ staticResourcesPath,
+ EnumSet.of(FileVisitOption.FOLLOW_LINKS),
+ Integer.MAX_VALUE,
new SimpleFileVisitor<Path>() {
- private int basicPathLength = staticResourcesPath.toAbsolutePath().toString()
- .length();
+ private int basicPathLength = staticResourcesPath.toAbsolutePath().toString().length();
@Override
- public FileVisitResult visitFile(Path path,
- BasicFileAttributes attrs) throws IOException {
+ public FileVisitResult visitFile(Path path, BasicFileAttributes attrs)
+ throws IOException {
Optional<PluginEntry> resource = resourceOf(relativePathOf(path));
if (resource.isPresent()) {
resourcesList.add(resource.get());
@@ -126,5 +125,4 @@
}
return Collections.enumeration(resourcesList);
}
-
}