filechampion4j 0.9.8.3
File validation library for Java
Loading...
Searching...
No Matches
dev.filechampion.filechampion4j.PluginsHelper Class Reference
Collaboration diagram for dev.filechampion.filechampion4j.PluginsHelper:
Collaboration graph

Classes

class  PluginConfig
 
class  StepConfig
 

Public Member Functions

 PluginsHelper (JSONObject plugins)
 
Map< String, PluginConfiggetPluginConfigs ()
 

Private Attributes

JSONObject plugins
 

Detailed Description

This class is used to fetch and load the Json configuration data for all plugins. Allowing the Json configuration data to be loaded once and then used by all plugins. Returns a list of PluginConfig objects.

Definition at line 12 of file PluginsHelper.java.

Constructor & Destructor Documentation

◆ PluginsHelper()

dev.filechampion.filechampion4j.PluginsHelper.PluginsHelper ( JSONObject  plugins)

Constructor

Parameters
plugins(JSONObject) a JSONObject containing plugin configuration data

Definition at line 19 of file PluginsHelper.java.

19 {
20 this.plugins = plugins;
21 }

References dev.filechampion.filechampion4j.PluginsHelper.plugins.

Member Function Documentation

◆ getPluginConfigs()

Map< String, PluginConfig > dev.filechampion.filechampion4j.PluginsHelper.getPluginConfigs ( )

Returns a list of PluginConfig objects.

Returns
(HashMap<String, PluginConfig>) a map of PluginConfig objects

Definition at line 27 of file PluginsHelper.java.

27 {
28 HashMap<String, PluginConfig> pluginConfigs = new HashMap<>();
29 Map<String, StepConfig> stepConfigs = new HashMap<>();
30
31
32 for (String pluginName : plugins.keySet()) {
33 JSONObject plugin = plugins.getJSONObject(pluginName);
34 PluginConfig pluginConfig = new PluginConfig();
35 pluginConfig.setName(pluginName);
36
37 for (String stepName : plugin.keySet()) {
38 JSONObject step = plugin.getJSONObject(stepName);
39 StepConfig stepConfig = new StepConfig();
40 String pluginStepName = pluginName + "." + stepName.substring(0, stepName.lastIndexOf('.'));
41 stepConfig.setName(pluginStepName);
42
43 stepConfig.setType(step.getString("type"));
44 stepConfig.setRunBefore(step.optBoolean("run_before"));
45 stepConfig.setRunAfter(step.optBoolean("run_after"));
46 stepConfig.setCredsPath(step.optString("creds_path"));
47 stepConfig.setTimeout(step.getInt("timeout"));
48 stepConfig.setOnFail(step.getString("on_timeout_or_fail"));
49 stepConfig.setEndpoint(step.getString("endpoint"));
50 stepConfig.setResponse(step.getString("response"));
51
52 switch (stepConfig.getType()) {
53 case "cli":
54 CliPluginHelper cliPluginStep = new CliPluginHelper(stepConfig);
55 stepConfig.setCliPluginHelper(cliPluginStep);
56 stepConfigs.put(pluginStepName, stepConfig);
57
58 continue;
59 case "http":
60 stepConfig.setMethod(step.optString("method"));
61 stepConfig.setHeaders(step.optJSONObject("headers"));
62 stepConfig.setBody(step.optJSONObject("body"));
63 stepConfig.setHttpPassCode(step.optInt("http_pass_code"));
64 stepConfig.setHttpFailCode(step.optInt("http_fail_code"));
65 stepConfigs.put(pluginStepName, stepConfig);
66 continue;
67 default:
68 continue;
69 }
70 }
71 pluginConfig.setStepConfigs(stepConfigs);
72 pluginConfigs.put(pluginName, pluginConfig);
73 }
74 return pluginConfigs;
75 }

References dev.filechampion.filechampion4j.PluginsHelper.StepConfig.getType(), dev.filechampion.filechampion4j.PluginsHelper.plugins, dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setBody(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setCliPluginHelper(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setCredsPath(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setEndpoint(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setHeaders(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setHttpFailCode(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setHttpPassCode(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setMethod(), dev.filechampion.filechampion4j.PluginsHelper.PluginConfig.setName(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setName(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setOnFail(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setResponse(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setRunAfter(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setRunBefore(), dev.filechampion.filechampion4j.PluginsHelper.PluginConfig.setStepConfigs(), dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setTimeout(), and dev.filechampion.filechampion4j.PluginsHelper.StepConfig.setType().

Referenced by dev.filechampion.filechampion4j.FileValidator.loadPlugins().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ plugins

JSONObject dev.filechampion.filechampion4j.PluginsHelper.plugins
private

The documentation for this class was generated from the following file: