use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class DatasourceResourceProvider method delete.
public void delete(ConnectionData data, int fullPathHash, String path, String name) throws IOException {
Attr attr = getAttr(data, fullPathHash, path, name);
if (attr == null)
throw new IOException("can't delete resource " + path + name + ", resource does not exist");
DatasourceConnection dc = null;
try {
dc = getDatasourceConnection(data);
getCore(data).delete(dc, data.getPrefix(), attr);
} catch (SQLException e) {
throw new IOException(e.getMessage());
} catch (PageException e) {
throw new PageRuntimeException(e);
} finally {
removeFromCache(data, path, name);
release(dc);
// manager.releaseConnection(CONNECTION_ID,dc);
}
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class ArraySupport method toArray.
@Override
public final Object[] toArray(Object[] a) {
if (a == null)
return toArray();
Class trgClass = a.getClass().getComponentType();
short type = TYPE_OBJECT;
if (trgClass == Boolean.class)
type = TYPE_BOOLEAN;
else if (trgClass == Byte.class)
type = TYPE_BYTE;
else if (trgClass == Short.class)
type = TYPE_SHORT;
else if (trgClass == Integer.class)
type = TYPE_INT;
else if (trgClass == Long.class)
type = TYPE_LONG;
else if (trgClass == Float.class)
type = TYPE_FLOAT;
else if (trgClass == Double.class)
type = TYPE_DOUBLE;
else if (trgClass == Character.class)
type = TYPE_CHARACTER;
else if (trgClass == String.class)
type = TYPE_STRING;
Iterator it = iterator();
int i = 0;
Object o;
try {
while (it.hasNext()) {
o = it.next();
switch(type) {
case TYPE_BOOLEAN:
o = Caster.toBoolean(o);
break;
case TYPE_BYTE:
o = Caster.toByte(o);
break;
case TYPE_CHARACTER:
o = Caster.toCharacter(o);
break;
case TYPE_DOUBLE:
o = Caster.toDouble(o);
break;
case TYPE_FLOAT:
o = Caster.toFloat(o);
break;
case TYPE_INT:
o = Caster.toInteger(o);
break;
case TYPE_LONG:
o = Caster.toLong(o);
break;
case TYPE_SHORT:
o = Caster.toShort(o);
break;
case TYPE_STRING:
o = Caster.toString(o);
break;
}
a[i++] = o;
}
} catch (PageException pe) {
throw new PageRuntimeException(pe);
}
return a;
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class ForEachQueryIterator method next.
@Override
public Object next() {
try {
if (qry.go(++current, pid)) {
Struct sct = new StructImpl();
Object empty = NullSupportHelper.full() ? null : "";
for (int i = 0; i < names.length; i++) {
sct.setEL(names[i], qry.get(names[i], empty));
}
return sct;
}
} catch (PageException pe) {
throw new PageRuntimeException(pe);
}
return null;
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class UDFComparator method compare.
@Override
public int compare(Object oLeft, Object oRight) {
try {
args[0] = oLeft;
args[1] = oRight;
Object res = udf.call(pc, args, false);
Integer i = Caster.toInteger(res, null);
if (i == null)
throw new FunctionException(pc, "ArraySort", 2, "function", "return value of the " + (udf instanceof Closure ? "closure" : "function [" + udf.getFunctionName() + "]") + " cannot be casted to a integer.", CasterException.createMessage(res, "integer"));
return i.intValue();
} catch (PageException pe) {
throw new PageRuntimeException(pe);
}
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class DatasourceManagerImpl method commit.
@Override
public void commit() throws DatabaseException {
if (autoCommit || transConns.size() == 0)
return;
Iterator<DatasourceConnection> it = this.transConns.values().iterator();
DatasourceConnection dc = null;
Pair<DatasourceConnection, Exception> pair = null;
while (it.hasNext()) {
dc = it.next();
try {
dc.getConnection().commit();
} catch (Exception e) {
// we only keep the first exception
if (pair == null) {
pair = new Pair<DatasourceConnection, Exception>(dc, e);
}
}
}
if (pair != null) {
if (pair.getValue() instanceof SQLException) {
throw new DatabaseException((SQLException) pair.getValue(), pair.getName());
}
throw new PageRuntimeException(pair.getValue());
}
}
Aggregations