Search in sources :

Example 21 with PageContext

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);
}
Also used : PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) RPCServer(lucee.runtime.net.rpc.server.RPCServer)

Example 22 with PageContext

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;
}
Also used : SQLImpl(lucee.runtime.db.SQLImpl) QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) SQLItemImpl(lucee.runtime.db.SQLItemImpl) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) PageContext(lucee.runtime.PageContext) DatabaseException(lucee.runtime.exp.DatabaseException) SQL(lucee.runtime.db.SQL)

Example 23 with PageContext

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;
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) Resource(lucee.commons.io.res.Resource) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) PageContext(lucee.runtime.PageContext) PageSource(lucee.runtime.PageSource)

Example 24 with PageContext

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;
}
Also used : Undefined(lucee.runtime.type.scope.Undefined) PageException(lucee.runtime.exp.PageException) PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext)

Example 25 with PageContext

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;
    }
}
Also used : PageException(lucee.runtime.exp.PageException) PageContext(lucee.runtime.PageContext) DataSourceManager(lucee.runtime.db.DataSourceManager)

Aggregations

PageContext (lucee.runtime.PageContext)44 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)32 PageException (lucee.runtime.exp.PageException)11 Component (lucee.runtime.Component)7 PageContextImpl (lucee.runtime.PageContextImpl)6 IOException (java.io.IOException)5 Key (lucee.runtime.type.Collection.Key)5 Pair (lucee.commons.lang.Pair)4 ConfigWeb (lucee.runtime.config.ConfigWeb)4 Entry (java.util.Map.Entry)3 CFMLEngine (lucee.loader.engine.CFMLEngine)3 CFMLFactory (lucee.runtime.CFMLFactory)3 CFMLFactoryImpl (lucee.runtime.CFMLFactoryImpl)3 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)3 ArrayList (java.util.ArrayList)2 Cookie (javax.servlet.http.Cookie)2 TypeMapping (javax.xml.rpc.encoding.TypeMapping)2 DevNullOutputStream (lucee.commons.io.DevNullOutputStream)2 ComponentScope (lucee.runtime.ComponentScope)2 Config (lucee.runtime.config.Config)2