Moved loading to separate object. Added a unit test for loading the properties
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
package org.owasp.webgoat.plugins;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
public final class GlobalProperties {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
public GlobalProperties(Path pluginDirectory) {
|
||||
this.plugin = new Plugin(pluginDirectory);
|
||||
}
|
||||
|
||||
public void loadProperties(Path globalPropertiesPath) {
|
||||
try {
|
||||
List<Path> filesInDirectory = PluginFileUtils.getFilesInDirectory(globalPropertiesPath);
|
||||
this.plugin.loadFiles(filesInDirectory, true);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Unable to load global properties, check your installation for the directory i18n: " + globalPropertiesPath.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ public class PluginFileUtils {
|
||||
}
|
||||
|
||||
public static boolean hasParentDirectoryWithName(Path p, String s) {
|
||||
if (p == null || p.getParent() == null || p.getRoot().equals(p.getParent())) {
|
||||
if (p == null || p.getParent() == null || p.getParent().equals(p.getRoot())) {
|
||||
return false;
|
||||
}
|
||||
if (p.getParent().getFileName().toString().equals(s)) {
|
||||
@ -31,8 +31,7 @@ public class PluginFileUtils {
|
||||
return p;
|
||||
}
|
||||
|
||||
public static List<Path> getFilesInDirectory( Path directory) throws IOException
|
||||
{
|
||||
public static List<Path> getFilesInDirectory( Path directory) throws IOException {
|
||||
List<Path> files = new ArrayList<>();
|
||||
DirectoryStream<Path> dirStream;
|
||||
dirStream = Files.newDirectoryStream(directory);
|
||||
|
Reference in New Issue
Block a user