private static EnumMap<ExecutionPhase, List<ExecutionScript>> consumeScripts(
NavigableMap<String, String> flowMap, String flowId) {
EnumMap<ExecutionPhase, List<ExecutionScript>> results = new EnumMap<>(ExecutionPhase.class);
for (ExecutionPhase phase : ExecutionPhase.values()) {
results.put(phase, Collections.emptyList());
}
int count = 0;
Map<String, NavigableMap<String, String>> phaseMap = partitioning(flowMap);
for (Map.Entry<String, NavigableMap<String, String>> entry : phaseMap.entrySet()) {
String phaseSymbol = entry.getKey();
NavigableMap<String, String> phaseContents = entry.getValue();
ExecutionPhase phase = ExecutionPhase.findFromSymbol(phaseSymbol);
if (phase == null) {
throw new IllegalArgumentException(MessageFormat.format(
"Unknown phase in \"{0}\": {1}",
flowId,
phaseSymbol));
}
List<ExecutionScript> scriptsInPhase = loadScripts(flowId, phase, phaseContents);
results.put(phase, scriptsInPhase);
count += scriptsInPhase.size();
}
LOG.debug("Loaded {} execution scripts: {}*", count, getPrefix(flowId));
return results;
}