Search in sources :

Example 16 with PageContextImpl

use of lucee.runtime.PageContextImpl in project Lucee by lucee.

the class SecurityManagerImpl method isValid.

private boolean isValid(Config config, Password spw) {
    if (spw == null) {
        try {
            PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
            spw = pc.getServerPassword();
        } catch (Throwable t) {
            ExceptionUtil.rethrowIfNecessary(t);
        }
    }
    config = ThreadLocalPageContext.getConfig(config);
    if (config == null || spw == null)
        return false;
    try {
        ConfigImpl.getConfigServer(config, spw);
        return true;
    } catch (PageException e) {
        return false;
    }
}
Also used : PageException(lucee.runtime.exp.PageException) PageContextImpl(lucee.runtime.PageContextImpl)

Example 17 with PageContextImpl

use of lucee.runtime.PageContextImpl in project Lucee by lucee.

the class Admin method doGetCharset.

private void doGetCharset() throws PageException {
    Struct sct = new StructImpl();
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
    sct.set("resourceCharset", config.getResourceCharset().name());
    sct.set("templateCharset", config.getTemplateCharset().name());
    sct.set("webCharset", ((PageContextImpl) pageContext).getWebCharset().name());
    sct.set("jreCharset", SystemUtil.getCharset().name());
}
Also used : StructImpl(lucee.runtime.type.StructImpl) PageContextImpl(lucee.runtime.PageContextImpl) Struct(lucee.runtime.type.Struct)

Example 18 with PageContextImpl

use of lucee.runtime.PageContextImpl in project Lucee by lucee.

the class UDFGSProperty method call.

@Override
public Object call(PageContext pc, Key calledName, Object[] args, boolean doIncludePath) throws PageException {
    PageContextImpl pci = ((PageContextImpl) pc);
    Key old = pci.getActiveUDFCalledName();
    pci.setActiveUDFCalledName(calledName);
    try {
        return call(pci, args, doIncludePath);
    } finally {
        pci.setActiveUDFCalledName(old);
    }
}
Also used : PageContextImpl(lucee.runtime.PageContextImpl) Key(lucee.runtime.type.Collection.Key)

Example 19 with PageContextImpl

use of lucee.runtime.PageContextImpl in project Lucee by lucee.

the class UDFGSProperty method callWithNamedValues.

@Override
public Object callWithNamedValues(PageContext pc, Key calledName, Struct values, boolean doIncludePath) throws PageException {
    PageContextImpl pci = ((PageContextImpl) pc);
    Key old = pci.getActiveUDFCalledName();
    pci.setActiveUDFCalledName(calledName);
    try {
        return callWithNamedValues(pci, values, doIncludePath);
    } finally {
        pci.setActiveUDFCalledName(old);
    }
}
Also used : PageContextImpl(lucee.runtime.PageContextImpl) Key(lucee.runtime.type.Collection.Key)

Example 20 with PageContextImpl

use of lucee.runtime.PageContextImpl in project Lucee by lucee.

the class UDFImpl method _call.

private Object _call(PageContext pc, Collection.Key calledName, Object[] args, Struct values, boolean doIncludePath) throws PageException {
    // print.out(count++);
    PageContextImpl pci = (PageContextImpl) pc;
    Argument newArgs = pci.getScopeFactory().getArgumentInstance();
    newArgs.setFunctionArgumentNames(properties.getArgumentsSet());
    LocalImpl newLocal = pci.getScopeFactory().getLocalInstance();
    Undefined undefined = pc.undefinedScope();
    Argument oldArgs = pc.argumentsScope();
    Local oldLocal = pc.localScope();
    Collection.Key oldCalledName = pci.getActiveUDFCalledName();
    pc.setFunctionScopes(newLocal, newArgs);
    pci.setActiveUDFCalledName(calledName);
    int oldCheckArgs = undefined.setMode(pc.getCurrentTemplateDialect() == CFMLEngine.DIALECT_CFML ? (properties.getLocalMode() == null ? pc.getApplicationContext().getLocalMode() : properties.getLocalMode().intValue()) : Undefined.MODE_LOCAL_OR_ARGUMENTS_ALWAYS);
    PageSource ps = null;
    PageSource psInc = null;
    try {
        ps = properties.getPageSource();
        if (doIncludePath)
            psInc = ps;
        if (doIncludePath && getOwnerComponent() != null) {
            psInc = ComponentUtil.getPageSource(getOwnerComponent());
            if (psInc == pci.getCurrentTemplatePageSource()) {
                psInc = null;
            }
        }
        if (ps != null)
            pci.addPageSource(ps, psInc);
        pci.addUDF(this);
        // ////////////////////////////////////////
        BodyContent bc = null;
        Boolean wasSilent = null;
        boolean bufferOutput = getBufferOutput(pci);
        if (!getOutput()) {
            if (bufferOutput)
                bc = pci.pushBody();
            else
                wasSilent = pc.setSilent() ? Boolean.TRUE : Boolean.FALSE;
        }
        UDF parent = null;
        if (ownerComponent != null) {
            parent = pci.getActiveUDF();
            pci.setActiveUDF(this);
        }
        Object returnValue = null;
        try {
            if (args != null)
                defineArguments(pc, getFunctionArguments(), args, newArgs);
            else
                defineArguments(pc, getFunctionArguments(), values, newArgs);
            returnValue = implementation(pci);
            if (ownerComponent != null)
                pci.setActiveUDF(parent);
        } catch (Throwable t) {
            ExceptionUtil.rethrowIfNecessary(t);
            if (ownerComponent != null)
                pci.setActiveUDF(parent);
            if (!getOutput()) {
                if (bufferOutput)
                    BodyContentUtil.flushAndPop(pc, bc);
                else if (!wasSilent)
                    pc.unsetSilent();
            }
            // BodyContentUtil.flushAndPop(pc,bc);
            throw Caster.toPageException(t);
        }
        if (!getOutput()) {
            if (bufferOutput)
                BodyContentUtil.clearAndPop(pc, bc);
            else if (!wasSilent)
                pc.unsetSilent();
        }
        if (returnValue == null && pc.getConfig().getFullNullSupport())
            return returnValue;
        if (properties.getReturnType() == CFTypes.TYPE_ANY || !((PageContextImpl) pc).getTypeChecking())
            return returnValue;
        if (Decision.isCastableTo(properties.getReturnTypeAsString(), returnValue, false, false, -1))
            return returnValue;
        throw new UDFCasterException(this, properties.getReturnTypeAsString(), returnValue);
    // REALCAST return Caster.castTo(pageContext,returnType,returnValue,false);
    // ////////////////////////////////////////
    } finally {
        if (ps != null)
            pc.removeLastPageSource(psInc != null);
        pci.removeUDF();
        pci.setFunctionScopes(oldLocal, oldArgs);
        pci.setActiveUDFCalledName(oldCalledName);
        undefined.setMode(oldCheckArgs);
        pci.getScopeFactory().recycle(pci, newArgs);
        pci.getScopeFactory().recycle(pci, newLocal);
    }
}
Also used : Undefined(lucee.runtime.type.scope.Undefined) Argument(lucee.runtime.type.scope.Argument) Local(lucee.runtime.type.scope.Local) PageContextImpl(lucee.runtime.PageContextImpl) PageSource(lucee.runtime.PageSource) BodyContent(javax.servlet.jsp.tagext.BodyContent) Key(lucee.runtime.type.Collection.Key) LocalImpl(lucee.runtime.type.scope.LocalImpl) UDFCasterException(lucee.runtime.exp.UDFCasterException)

Aggregations

PageContextImpl (lucee.runtime.PageContextImpl)84 PageSource (lucee.runtime.PageSource)19 Resource (lucee.commons.io.res.Resource)17 Key (lucee.runtime.type.Collection.Key)15 Struct (lucee.runtime.type.Struct)15 StructImpl (lucee.runtime.type.StructImpl)14 IOException (java.io.IOException)12 ApplicationException (lucee.runtime.exp.ApplicationException)10 PageException (lucee.runtime.exp.PageException)10 Component (lucee.runtime.Component)9 ConfigWeb (lucee.runtime.config.ConfigWeb)9 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)9 CFMLFactoryImpl (lucee.runtime.CFMLFactoryImpl)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ArrayList (java.util.ArrayList)6 Mapping (lucee.runtime.Mapping)6 PageContext (lucee.runtime.PageContext)6 ConfigImpl (lucee.runtime.config.ConfigImpl)6 ExpressionException (lucee.runtime.exp.ExpressionException)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)5