use of lucee.runtime.PageContext in project Lucee by lucee.
the class ComponentUtil method registerTypeMapping.
/**
* search in methods of a class for complex types
* @param clazz
* @return
*/
private static Class registerTypeMapping(Class clazz) throws AxisFault {
PageContext pc = ThreadLocalPageContext.get();
RPCServer server = RPCServer.getInstance(pc.getId(), pc, pc.getServletContext());
return registerTypeMapping(server, clazz);
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class Ansi92 method select.
@Override
public Query select(Config config, String cfid, String applicationName, DatasourceConnection dc, int type, Log log, boolean createTableIfNotExist) throws PageException {
String strType = VariableInterpreter.scopeInt2String(type);
Query query = null;
SQL sqlSelect = new SQLImpl("select data from " + PREFIX + "_" + strType + "_data where cfid=? and name=? and expires > ?", new SQLItem[] { new SQLItemImpl(cfid, Types.VARCHAR), new SQLItemImpl(applicationName, Types.VARCHAR), new SQLItemImpl(now(config), Types.VARCHAR) });
PageContext pc = ThreadLocalPageContext.get();
try {
query = new QueryImpl(pc, dc, sqlSelect, -1, -1, null, "query");
} catch (DatabaseException de) {
if (dc == null || !createTableIfNotExist)
throw de;
// table does not exist???
try {
SQL sql = createSQL(dc, DataSourceUtil.isMySQL(dc) ? "longtext" : "ntext", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException _de) {
// don't like "ntext", try text
try {
SQL sql = createSQL(dc, "text", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException __de) {
// don't like text, try "memo"
try {
SQL sql = createSQL(dc, "memo", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException ___de) {
// don't like "memo", try clob
try {
SQL sql = createSQL(dc, "clob", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException ____de) {
___de.initCause(__de);
__de.initCause(_de);
_de.initCause(de);
// we could not create the table, so there seem to be an other ecception we cannot solve
DatabaseException exp = new DatabaseException("Unable to select from your client storage database, and was also unable to create the tables. Here's the exceptions we encountered.", null, null, dc);
exp.initCause(de);
throw exp;
}
}
}
}
query = new QueryImpl(pc, dc, sqlSelect, -1, -1, null, "query");
}
ScopeContext.info(log, sqlSelect.toString());
return query;
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class _GetElement method toResourceExisting.
public static Resource toResourceExisting(Config config, ApplicationContext ac, Object obj, boolean onlyDir) {
// Resource root = config.getRootDirectory();
String path = Caster.toString(obj, null);
if (StringUtil.isEmpty(path, true))
return null;
path = path.trim();
Resource res;
PageContext pc = ThreadLocalPageContext.get();
// first check relative to application . cfc
if (pc != null) {
if (ac == null)
ac = pc.getApplicationContext();
// abs path
if (path.startsWith("/")) {
ConfigWebImpl cwi = (ConfigWebImpl) config;
PageSource ps = cwi.getPageSourceExisting(pc, ac == null ? null : ac.getMappings(), path, false, false, true, false);
if (ps != null) {
res = ps.getResource();
if (res != null && (!onlyDir || res.isDirectory()))
return res;
}
} else // real path
{
Resource src = ac != null ? ac.getSource() : null;
if (src != null) {
res = src.getParentResource().getRealResource(path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
} else // happens when this is called from within the application . cfc (init)
{
res = ResourceUtil.toResourceNotExisting(pc, path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
}
}
}
// then in the webroot
res = config.getRootDirectory().getRealResource(path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
// then absolute
res = ResourceUtil.toResourceNotExisting(config, path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
return null;
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class SimpleQueryColumn method getChildElement.
private Object getChildElement(Key key, Object defaultValue) {
PageContext pc = ThreadLocalPageContext.get();
// column and query has same name
if (key.equals(this.key)) {
return get(qry.getCurrentrow(pc.getId()), defaultValue);
}
// get it from undefined scope
if (pc != null) {
Undefined undefined = pc.undefinedScope();
boolean old = undefined.setAllowImplicidQueryCall(false);
Object sister = undefined.get(this.key, null);
undefined.setAllowImplicidQueryCall(old);
if (sister != null) {
try {
return pc.get(sister, key);
} catch (PageException e) {
return defaultValue;
}
}
}
return defaultValue;
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class DataSourceServiceImpl method verifyDatasource.
@Override
public boolean verifyDatasource(String name) throws SQLException, SecurityException {
checkReadAccess();
lucee.runtime.db.DataSource d = _getDatasource(name);
PageContext pc = pc();
DataSourceManager manager = pc.getDataSourceManager();
try {
manager.releaseConnection(pc, manager.getConnection(pc, name, d.getUsername(), d.getPassword()));
return true;
} catch (PageException e) {
return false;
}
}
Aggregations