use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class UDFSetterProperty method call.
@Override
public Object call(PageContext pageContext, Object[] args, boolean doIncludePath) throws PageException {
if (args.length < 1)
throw new ExpressionException("The parameter " + prop.getName() + " to function " + getFunctionName() + " is required but was not passed in.");
validate(validate, validateParams, args[0]);
component.getComponentScope().set(propName, cast(pageContext, this.arguments[0], args[0], 1));
// make sure it is reconized that set is called by hibernate
// if(component.isPersistent())ORMUtil.getSession(pageContext);
ApplicationContext appContext = pageContext.getApplicationContext();
if (appContext.isORMEnabled() && component.isPersistent())
ORMUtil.getSession(pageContext);
return component;
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method _updateComponentMapping.
private void _updateComponentMapping(String virtual, String physical, String archive, String primary, short inspect) throws ExpressionException {
primary = primary.equalsIgnoreCase("archive") ? "archive" : "physical";
if (physical == null)
physical = "";
else
physical = physical.trim();
if (archive == null)
archive = "";
else
archive = archive.trim();
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("component");
Element[] children = XMLConfigWebFactory.getChildren(mappings, "mapping");
Element el;
/* ignore when exists
for(int i=0;i<children.length;i++) {
el=children[i];
if(el.getAttribute("physical").equals(physical) &&
el.getAttribute("archive").equals(archive) &&
el.getAttribute("primary").equals(primary) &&
el.getAttribute("trusted").equals(Caster.toString(trusted))){
return;
}
}*/
// Update
String v;
for (int i = 0; i < children.length; i++) {
el = children[i];
// if there is no virtual defintion (old records), we use the position
v = createVirtual(el);
if (v.equals(virtual)) {
// set to make sure it exists for the future
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
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);
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method removeJDBCDriver.
public void removeJDBCDriver(String className) throws ExpressionException, SecurityException {
checkWriteAccess();
// check parameters
if (StringUtil.isEmpty(className))
throw new ExpressionException("class name for jdbc driver cannot be empty");
Element parent = _getRootElement("jdbc");
Element[] children = XMLConfigWebFactory.getChildren(parent, "driver");
for (int i = 0; i < children.length; i++) {
String n = children[i].getAttribute("class");
if (n != null && n.equalsIgnoreCase(className)) {
parent.removeChild(children[i]);
}
}
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method updateCPPCFX.
public void updateCPPCFX(String name, String procedure, String strServerLibrary, boolean keepAlive) throws PageException {
checkWriteAccess();
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_CFX_SETTING);
if (!hasAccess)
throw new SecurityException("no access to change cfx settings");
// name
if (StringUtil.isEmpty(name))
throw new ExpressionException("name cannot be a empty value");
// serverLibrary
if (StringUtil.isEmpty(strServerLibrary))
throw new ExpressionException("serverLibrary cannot be a empty value");
Resource serverLibrary = ResourceUtil.toResourceExisting(config, strServerLibrary);
// procedure
if (StringUtil.isEmpty(procedure))
throw new ExpressionException("procedure cannot be a empty value");
renameOldstyleCFX();
Element tags = _getRootElement("ext-tags");
// Update
Element[] children = XMLConfigWebFactory.getChildren(tags, "ext-tag");
for (int i = 0; i < children.length; i++) {
String n = children[i].getAttribute("name");
if (n != null && n.equalsIgnoreCase(name)) {
Element el = children[i];
if (!"cpp".equalsIgnoreCase(el.getAttribute("type")))
throw new ExpressionException("there is already a java cfx tag with this name");
el.setAttribute("server-library", serverLibrary.getAbsolutePath());
el.setAttribute("procedure", procedure);
el.setAttribute("keep-alive", Caster.toString(keepAlive));
el.setAttribute("type", "cpp");
return;
}
}
// Insert
Element el = doc.createElement("ext-tag");
tags.appendChild(el);
el.setAttribute("server-library", serverLibrary.getAbsolutePath());
el.setAttribute("procedure", procedure);
el.setAttribute("keep-alive", Caster.toString(keepAlive));
el.setAttribute("name", name);
el.setAttribute("type", "cpp");
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class XMLConfigAdmin method removeDataSource.
/**
* remove a DataSource Connection
* @param name
* @throws ExpressionException
* @throws SecurityException
*/
public void removeDataSource(String name) throws ExpressionException, SecurityException {
checkWriteAccess();
// check parameters
if (name == null || name.length() == 0)
throw new ExpressionException("name for Datasource Connection can be a empty value");
Element datasources = _getRootElement("data-sources");
Element[] children = XMLConfigWebFactory.getChildren(datasources, "data-source");
for (int i = 0; i < children.length; i++) {
String n = children[i].getAttribute("name");
if (n != null && n.equalsIgnoreCase(name)) {
datasources.removeChild(children[i]);
}
}
}
Aggregations