@@ -44,10 +44,10 @@ public class PluginManager {
44
44
/**
45
45
* Map of plugins.
46
46
*/
47
- private static Map <String , IMappingPlugin > plugins ;
47
+ private Map <String , IMappingPlugin > plugins ;
48
48
49
49
static {
50
- reloadPlugins (); // loads plugins on startup
50
+ soleInstance . reloadPlugins (); // loads plugins on startup
51
51
}
52
52
53
53
/**
@@ -69,7 +69,7 @@ public static PluginManager soleInstance() {
69
69
/**
70
70
* Reloads the plugins from the 'plugins' directory.
71
71
*/
72
- public static void reloadPlugins () {
72
+ public void reloadPlugins () {
73
73
Map <String , IMappingPlugin > plugins1 ;
74
74
try {
75
75
plugins1 = PluginLoader .loadPlugins (new File ("./plugins" ));
@@ -116,11 +116,17 @@ public List<String> getListOfAvailableValidators() {
116
116
* @throws MappingPluginException If there is an error with the plugin or the input.
117
117
*/
118
118
public MappingPluginState mapFile (String pluginId , Path mappingFile , Path inputFile , Path outputFile ) throws MappingPluginException {
119
- for (var entry : plugins .entrySet ()) {
120
- if (entry .getKey ().equals (pluginId )) {
121
- return entry .getValue ().mapFile (mappingFile , inputFile , outputFile );
122
- }
123
- }
124
- throw new MappingPluginException (MappingPluginState .NOT_FOUND , "Plugin " + pluginId + " not found!" );
119
+ // for (var entry : plugins.entrySet()) {
120
+ // if (entry.getKey().equals(pluginId)) {
121
+ // return entry.getValue().mapFile(mappingFile, inputFile, outputFile);
122
+ // }
123
+ // }
124
+ if (pluginId == null ) throw new MappingPluginException (MappingPluginState .INVALID_INPUT , "Plugin ID is null." );
125
+ if (mappingFile == null ) throw new MappingPluginException (MappingPluginState .INVALID_INPUT , "Path to mapping schema is null." );
126
+ if (inputFile == null ) throw new MappingPluginException (MappingPluginState .INVALID_INPUT , "Path to input file is null." );
127
+ if (outputFile == null ) throw new MappingPluginException (MappingPluginState .INVALID_INPUT , "Path to output file is null." );
128
+
129
+ if (plugins .containsKey (pluginId )) return plugins .get (pluginId ).mapFile (mappingFile , inputFile , outputFile );
130
+ throw new MappingPluginException (MappingPluginState .NOT_FOUND , "Plugin '" + pluginId + "' not found!" );
125
131
}
126
132
}
0 commit comments