use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method updateMailServer.
/**
* insert or update a mailserver on system
* @param hostName
* @param username
* @param password
* @param port
* @param ssl
* @param tls
* @throws PageException
*/
public void updateMailServer(int id, String hostName, String username, String password, int port, boolean tls, boolean ssl, long lifeTimeSpan, long idleTimeSpan, boolean reuseConnections) throws PageException {
checkWriteAccess();
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_MAIL);
if (!hasAccess)
throw new SecurityException("no access to update mail server settings");
Element mail = _getRootElement("mail");
if (port < 1)
port = 21;
if (hostName == null || hostName.trim().length() == 0)
throw new ExpressionException("Host (SMTP) can be a empty value");
hostName = hostName.trim();
Element[] children = XMLConfigWebFactory.getChildren(mail, "server");
boolean checkId = id > 0;
// Update
Element server = null;
String _hostName, _username;
for (int i = 0; i < children.length; i++) {
Element el = children[i];
if (checkId) {
if (i + 1 == id) {
server = el;
break;
}
} else {
_hostName = StringUtil.emptyIfNull(el.getAttribute("smtp"));
_username = StringUtil.emptyIfNull(el.getAttribute("username"));
if (_hostName.equalsIgnoreCase(hostName) && _username.equals(StringUtil.emptyIfNull(username))) {
server = el;
break;
}
}
}
// Insert
if (server == null) {
server = doc.createElement("server");
mail.appendChild(XMLCaster.toRawNode(server));
}
server.setAttribute("smtp", hostName);
server.setAttribute("username", username);
server.setAttribute("password", ConfigWebUtil.encrypt(password));
server.setAttribute("port", Caster.toString(port));
server.setAttribute("tls", Caster.toString(tls));
server.setAttribute("ssl", Caster.toString(ssl));
server.setAttribute("life", Caster.toString(lifeTimeSpan));
server.setAttribute("idle", Caster.toString(idleTimeSpan));
server.setAttribute("reuse-connection", Caster.toString(reuseConnections));
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method _updateResourceProvider.
public void _updateResourceProvider(String scheme, ClassDefinition cd, String arguments) throws PageException {
// check parameters
if (StringUtil.isEmpty(scheme))
throw new ExpressionException("scheme can't be a empty value");
Element parent = _getRootElement("resources");
// Update
Element[] children = XMLConfigWebFactory.getChildren(parent, "resource-provider");
for (int i = 0; i < children.length; i++) {
// String cn=children[i].getAttribute("class");
String elScheme = children[i].getAttribute("scheme");
if (elScheme.equalsIgnoreCase(scheme)) {
Element el = children[i];
setClass(el, null, "", cd);
el.setAttribute("scheme", scheme);
el.setAttribute("arguments", arguments);
return;
}
}
// Insert
Element el = doc.createElement("resource-provider");
parent.appendChild(el);
el.setAttribute("scheme", scheme);
el.setAttribute("arguments", arguments);
setClass(el, null, "", cd);
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method _updateGatewayEntry.
void _updateGatewayEntry(String id, ClassDefinition cd, String componentPath, String listenerCfcPath, int startupMode, Struct custom, boolean readOnly) throws PageException {
// check parameters
id = id.trim();
if (StringUtil.isEmpty(id))
throw new ExpressionException("id can't be a empty value");
if ((cd == null || StringUtil.isEmpty(cd.getClassName())) && StringUtil.isEmpty(componentPath))
throw new ExpressionException("you must define className or componentPath");
Element parent = _getRootElement("gateways");
// Update
Element[] children = XMLConfigWebFactory.getChildren(parent, "gateway");
for (int i = 0; i < children.length; i++) {
String n = children[i].getAttribute("id");
Element el = children[i];
if (n.equalsIgnoreCase(id)) {
setClass(el, null, "", cd);
el.setAttribute("cfc-path", componentPath);
el.setAttribute("listener-cfc-path", listenerCfcPath);
el.setAttribute("startup-mode", GatewayEntryImpl.toStartup(startupMode, "automatic"));
el.setAttribute("custom", toStringURLStyle(custom));
el.setAttribute("read-only", Caster.toString(readOnly));
return;
}
}
// Insert
Element el = doc.createElement("gateway");
parent.appendChild(el);
el.setAttribute("id", id);
el.setAttribute("cfc-path", componentPath);
el.setAttribute("listener-cfc-path", listenerCfcPath);
el.setAttribute("startup-mode", GatewayEntryImpl.toStartup(startupMode, "automatic"));
setClass(el, null, "", cd);
el.setAttribute("custom", toStringURLStyle(custom));
el.setAttribute("read-only", Caster.toString(readOnly));
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method removeCFX.
/**
* remove a CFX Tag
* @param name
* @throws ExpressionException
* @throws SecurityException
*/
public void removeCFX(String name) throws ExpressionException, SecurityException {
checkWriteAccess();
// check parameters
if (name == null || name.length() == 0)
throw new ExpressionException("name for CFX Tag can be a empty value");
renameOldstyleCFX();
Element mappings = _getRootElement("ext-tags");
Element[] children = XMLConfigWebFactory.getChildren(mappings, "ext-tag");
for (int i = 0; i < children.length; i++) {
String n = children[i].getAttribute("name");
if (n != null && n.equalsIgnoreCase(name)) {
mappings.removeChild(children[i]);
}
}
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method _updateCustomTag.
private void _updateCustomTag(String virtual, String physical, String archive, String primary, short inspect) throws ExpressionException, SecurityException {
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_CUSTOM_TAG);
if (!hasAccess)
throw new SecurityException("no access to change custom tag settings");
if (physical == null)
physical = "";
if (archive == null)
archive = "";
// virtual="/custom-tag";
if (StringUtil.isEmpty(virtual))
virtual = createVirtual(physical, archive);
boolean isArchive = primary.equalsIgnoreCase("archive");
if (isArchive && archive.length() == 0) {
throw new ExpressionException("archive must have a value when primary has value archive");
}
if (!isArchive && physical.length() == 0) {
throw new ExpressionException("physical must have a value when primary has value physical");
}
Element mappings = _getRootElement("custom-tag");
// Update
String v;
Element[] children = XMLConfigWebFactory.getChildren(mappings, "mapping");
for (int i = 0; i < children.length; i++) {
Element el = children[i];
v = createVirtual(el);
if (v.equals(virtual)) {
el.setAttribute("virtual", v);
el.setAttribute("physical", physical);
el.setAttribute("archive", archive);
el.setAttribute("primary", primary.equalsIgnoreCase("archive") ? "archive" : "physical");
el.setAttribute("inspect-template", ConfigWebUtil.inspectTemplate(inspect, ""));
el.removeAttribute("trusted");
return;
}
}
// Insert
Element el = doc.createElement("mapping");
mappings.appendChild(el);
if (physical.length() > 0)
el.setAttribute("physical", physical);
if (archive.length() > 0)
el.setAttribute("archive", archive);
el.setAttribute("primary", primary.equalsIgnoreCase("archive") ? "archive" : "physical");
el.setAttribute("inspect-template", ConfigWebUtil.inspectTemplate(inspect, ""));
el.setAttribute("virtual", virtual);
}
Aggregations