Skip to content

Commit

Permalink
Throw error if no steps exist in an interact script. Make default ste…
Browse files Browse the repository at this point in the history
…p only step if only one step is present.
  • Loading branch information
aufdemrand committed Apr 8, 2013
1 parent acd5e68 commit 12d7e8a
Showing 1 changed file with 14 additions and 2 deletions.
Expand Up @@ -18,24 +18,36 @@ public InteractScriptContainer(ConfigurationSection configurationSection, String

try {
// Find steps/default step in the script
for (String step : getConfigurationSection("STEPS").getKeys(false)) {
Set<String> keys = new HashSet<String>();
keys = getConfigurationSection("STEPS").getKeys(false);

if (keys.isEmpty())
throw new ExceptionInInitializerError("Could not find any STEPS in " + getName() + "! Is the type on this script correct?");

for (String step : keys) {
if (step.contains("*")) {
ConfigurationSection defaultStepSection = getConfigurationSection("STEPS." + step);
step = step.replace("*", "");
set("STEPS." + step, defaultStepSection);
set("STEPS." + step + "*", null);
defaultStep = step;
}

if (step.equalsIgnoreCase("1")) defaultStep = step;
if (step.equalsIgnoreCase("DEFAULT")) defaultStep = step;
steps.add(step);
}

} catch (Exception e) {
dB.echoError("Could not find any STEPS in " + getName() + "! Is the type on this script correct?");
}

// Make default step the only step if there is only one step
if (defaultStep == null && steps.size() == 1)
defaultStep = steps.get(0);
}

private String defaultStep;
private String defaultStep = null;
private List<String> steps = new ArrayList<String>();

public List<String> getStepNames() {
Expand Down

0 comments on commit 12d7e8a

Please sign in to comment.