Search in sources :

Example 36 with ExpressionException

use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.

the class ComponentImpl method _set.

/**
 * sets a value to the current Component, dont to base Component
 * @param key
 * @param value
 * @return value set
 * @throws ExpressionException
 */
private Object _set(PageContext pc, Collection.Key key, Object value) throws ExpressionException {
    if (value instanceof Member) {
        if (value instanceof UDFPlus) {
            UDFPlus udf = (UDFPlus) ((UDFPlus) value).duplicate();
            // udf.isComponentMember(true);///+++
            udf.setOwnerComponent(this);
            if (udf.getAccess() > Component.ACCESS_PUBLIC)
                udf.setAccess(Component.ACCESS_PUBLIC);
            _data.put(key, udf);
            _udfs.put(key, udf);
            hasInjectedFunctions = true;
        } else
            _data.put(key, (Member) value);
    } else {
        Member existing = _data.get(key);
        if (loaded && !isAccessible(pc, existing != null ? existing.getAccess() : dataMemberDefaultAccess))
            throw new ExpressionException("Component [" + getCallName() + "] has no accessible Member with name [" + key + "]", "enable [trigger data member] in admininistrator to also invoke getters and setters");
        _data.put(key, new DataMember(existing != null ? existing.getAccess() : dataMemberDefaultAccess, existing != null ? existing.getModifier() : Member.MODIFIER_NONE, value));
    }
    return value;
}
Also used : DataMember(lucee.runtime.component.DataMember) UDFPlus(lucee.runtime.type.UDFPlus) Member(lucee.runtime.component.Member) DataMember(lucee.runtime.component.DataMember) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 37 with ExpressionException

use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.

the class ComponentImpl method get.

public Object get(int access, Collection.Key key) throws PageException {
    Member member = getMember(access, key, true, false);
    if (member != null)
        return member.getValue();
    // Trigger
    PageContext pc = ThreadLocalPageContext.get();
    if (triggerDataMember(pc) && !isPrivate(pc)) {
        return callGetter(pc, key);
    }
    throw new ExpressionException("Component [" + getCallName() + "] has no accessible Member with name [" + key + "]");
}
Also used : ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) Member(lucee.runtime.component.Member) DataMember(lucee.runtime.component.DataMember) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 38 with ExpressionException

use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.

the class PageContextImpl method _param.

private void _param(String type, String name, Object defaultValue, double min, double max, String strPattern, int maxLength) throws PageException {
    // check attributes name
    if (StringUtil.isEmpty(name))
        throw new ExpressionException("The attribute name is required");
    Object value = null;
    boolean isNew = false;
    // get value
    value = VariableInterpreter.getVariableEL(this, name, NullSupportHelper.NULL(this));
    if (NullSupportHelper.NULL(this) == value) {
        if (defaultValue == null)
            throw new ExpressionException("The required parameter [" + name + "] was not provided.");
        value = defaultValue;
        isNew = true;
    }
    subparam(type, name, value, min, max, strPattern, maxLength, isNew);
}
Also used : ExpressionException(lucee.runtime.exp.ExpressionException)

Example 39 with ExpressionException

use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.

the class CustomTagUtil method loadInitFile.

public static InitFile loadInitFile(PageContext pc, String name) throws PageException {
    InitFile initFile = loadInitFile(pc, name, null);
    if (initFile != null) {
        return initFile;
    }
    // EXCEPTION
    ConfigWeb config = pc.getConfig();
    // message
    StringBuilder msg = new StringBuilder("Custom tag \"").append(getDisplayName(config, name)).append("\" was not found.");
    List<String> dirs = new ArrayList();
    if (config.doLocalCustomTag()) {
        dirs.add(ResourceUtil.getResource(pc, pc.getCurrentPageSource()).getParent());
    }
    Mapping[] actms = pc.getApplicationContext().getCustomTagMappings();
    Mapping[] cctms = config.getCustomTagMappings();
    Resource r;
    if (actms != null) {
        for (Mapping m : actms) {
            r = m.getPhysical();
            if (r != null)
                dirs.add(r.toString());
        }
    }
    if (cctms != null) {
        for (Mapping m : cctms) {
            r = m.getPhysical();
            if (r != null)
                dirs.add(r.toString());
        }
    }
    if (!dirs.isEmpty()) {
        msg.append(" Directories searched: ");
        Iterator<String> it = dirs.iterator();
        while (it.hasNext()) {
            msg.append('"').append(it.next()).append('"');
            if (it.hasNext())
                msg.append(", ");
        }
    }
    throw new ExpressionException(msg.toString());
}
Also used : ArrayList(java.util.ArrayList) Resource(lucee.commons.io.res.Resource) Mapping(lucee.runtime.Mapping) ConfigWeb(lucee.runtime.config.ConfigWeb) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 40 with ExpressionException

use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.

the class ComponentLoader method _search.

private static Object _search(PageContext pc, PageSource loadingLocation, String rawPath, Boolean searchLocal, Boolean searchRoot, boolean executeConstr, short returnType, final boolean isExtendedComponent) throws PageException {
    PageSource currPS = pc.getCurrentPageSource(null);
    ImportDefintion[] importDefintions = null;
    if (currPS != null) {
        Page currP;
        Component cfc = pc.getActiveComponent();
        if (cfc instanceof ComponentImpl && currPS.equals(cfc.getPageSource())) {
            importDefintions = ((ComponentImpl) cfc)._getImportDefintions();
        } else if ((currP = currPS.loadPage(pc, false, null)) != null) {
            importDefintions = currP.getImportDefintions();
        }
    }
    int dialect = currPS == null ? pc.getCurrentTemplateDialect() : currPS.getDialect();
    // first try for the current dialect
    Object obj = _search(pc, loadingLocation, rawPath, searchLocal, searchRoot, executeConstr, returnType, currPS, importDefintions, dialect, isExtendedComponent);
    // then we try the opposite dialect
    if (obj == null && ((ConfigImpl) pc.getConfig()).allowLuceeDialect()) {
        // only when the lucee dialect is enabled we have to check the opposite
        obj = _search(pc, loadingLocation, rawPath, searchLocal, searchRoot, executeConstr, returnType, currPS, importDefintions, dialect == CFMLEngine.DIALECT_CFML ? CFMLEngine.DIALECT_LUCEE : CFMLEngine.DIALECT_CFML, isExtendedComponent);
    }
    if (obj == null)
        throw new ExpressionException("invalid " + toStringType(returnType, dialect) + " definition, can't find " + toStringType(returnType, dialect) + " [" + rawPath + "]");
    return obj;
}
Also used : Page(lucee.runtime.Page) CIPage(lucee.runtime.CIPage) CIObject(lucee.runtime.CIObject) Component(lucee.runtime.Component) ComponentImpl(lucee.runtime.ComponentImpl) ExpressionException(lucee.runtime.exp.ExpressionException) PageSource(lucee.runtime.PageSource)

Aggregations

ExpressionException (lucee.runtime.exp.ExpressionException)136 Element (org.w3c.dom.Element)24 Key (lucee.runtime.type.Collection.Key)15 SecurityException (lucee.runtime.exp.SecurityException)13 ArrayList (java.util.ArrayList)12 Struct (lucee.runtime.type.Struct)12 List (java.util.List)11 Collection (lucee.runtime.type.Collection)11 Entry (java.util.Map.Entry)10 Node (org.w3c.dom.Node)10 Resource (lucee.commons.io.res.Resource)9 Iterator (java.util.Iterator)8 PageException (lucee.runtime.exp.PageException)8 Map (java.util.Map)7 CasterException (lucee.runtime.exp.CasterException)7 NodeList (org.w3c.dom.NodeList)7 PageContextImpl (lucee.runtime.PageContextImpl)6 PageSource (lucee.runtime.PageSource)5 Casting (lucee.runtime.interpreter.ref.cast.Casting)5 ArrayImpl (lucee.runtime.type.ArrayImpl)5