use of lucee.runtime.net.mail.Server in project Lucee by lucee.
the class XMLConfigWebFactory method loadMail.
/**
* @param configServer
* @param config
* @param doc
* @throws IOException
*/
private static void loadMail(ConfigServerImpl configServer, ConfigImpl config, Document doc) throws IOException {
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_MAIL);
boolean hasCS = configServer != null;
Element mail = getChildByName(doc.getDocumentElement(), "mail");
// Send partial
String strSendPartial = mail.getAttribute("send-partial");
if (!StringUtil.isEmpty(strSendPartial) && hasAccess) {
config.setMailSendPartial(toBoolean(strSendPartial, false));
} else if (hasCS)
config.setMailSendPartial(configServer.isMailSendPartial());
// Spool Interval
String strSpoolInterval = getAttr(mail, "spool-interval");
if (!StringUtil.isEmpty(strSpoolInterval) && hasAccess) {
config.setMailSpoolInterval(Caster.toIntValue(strSpoolInterval, 30));
} else if (hasCS)
config.setMailSpoolInterval(configServer.getMailSpoolInterval());
String strEncoding = getAttr(mail, "default-encoding");
if (!StringUtil.isEmpty(strEncoding) && hasAccess)
config.setMailDefaultEncoding(strEncoding);
else if (hasCS)
config.setMailDefaultEncoding(configServer.getMailDefaultCharset());
// Spool Enable
String strSpoolEnable = getAttr(mail, "spool-enable");
if (!StringUtil.isEmpty(strSpoolEnable) && hasAccess) {
config.setMailSpoolEnable(toBoolean(strSpoolEnable, false));
} else if (hasCS)
config.setMailSpoolEnable(configServer.isMailSpoolEnable());
// Timeout
String strTimeout = getAttr(mail, "timeout");
if (!StringUtil.isEmpty(strTimeout) && hasAccess) {
config.setMailTimeout(Caster.toIntValue(strTimeout, 60));
} else if (hasCS)
config.setMailTimeout(configServer.getMailTimeout());
// Servers
int index = 0;
// Server[] servers = null;
Element[] elServers = getChildren(mail, "server");
List<Server> servers = new ArrayList<Server>();
if (hasCS) {
Server[] readOnlyServers = configServer.getMailServers();
for (int i = 0; i < readOnlyServers.length; i++) {
servers.add(readOnlyServers[index++].cloneReadOnly());
}
}
/*else {
servers = new Server[elServers.length];
}*/
if (hasAccess) {
for (int i = 0; i < elServers.length; i++) {
Element el = elServers[i];
if (el.getNodeName().equals("server"))
servers.add(i, new ServerImpl(Caster.toIntValue(getAttr(el, "id"), i + 1), getAttr(el, "smtp"), Caster.toIntValue(getAttr(el, "port"), 25), getAttr(el, "username"), ConfigWebUtil.decrypt(getAttr(el, "password")), toLong(el.getAttribute("life"), 1000 * 60 * 5), toLong(el.getAttribute("idle"), 1000 * 60 * 1), toBoolean(getAttr(el, "tls"), false), toBoolean(getAttr(el, "ssl"), false), toBoolean(getAttr(el, "reuse-connection"), true), hasCS ? ServerImpl.TYPE_LOCAL : ServerImpl.TYPE_GLOBAL));
}
}
config.setMailServers(servers.toArray(new Server[servers.size()]));
}
Aggregations