List<HierarchicalConfiguration> allAccounts = configuration.configurationsAt("accounts");
if (allAccounts.size() < 1)
throw new ConfigurationException("Missing <accounts> section.");
if (allAccounts.size() > 1)
throw new ConfigurationException("Too many <accounts> sections, there must be exactly one");
HierarchicalConfiguration accounts = allAccounts.get(0);
if (accounts.getKeys().hasNext() == false)
throw new ConfigurationException("Missing <account> section.");
List<Node> accountsChildren = accounts.getRoot().getChildren();
int i = 0;
// Create an Account for every configured account
for (Node accountsChild: accountsChildren) {
String accountsChildName = accountsChild.getName();
HierarchicalConfiguration accountsChildConfig = accounts.configurationAt(accountsChildName);
if ("alllocal".equals(accountsChildName))
{
// <allLocal> is dynamic, save the parameters for accounts to
// be created when the task is triggered
getParsedDynamicAccountParameters().add(
new ParsedDynamicAccountParameters(i, accountsChildConfig));
continue;
}
if ("account".equals(accountsChildName))
{
// Create an Account for the named user and
// add it to the list of static accounts
getStaticAccounts().add(
new Account(
i,
parsedConfiguration,
accountsChildConfig.getString("[@user]"),
accountsChildConfig.getString("[@password]"),
accountsChildConfig.getString("[@recipient]"),
accountsChildConfig.getBoolean(
"[@ignorercpt-header]"),
accountsChildConfig.getString("[@customrcpt-header]",""),
getSession()));
continue;
}
throw new ConfigurationException(