Search in sources :

Example 26 with ApplicationException

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

the class Admin method doRemoveRHExtension.

private void doRemoveRHExtension() throws PageException {
    String id = getString("admin", "removeRHExtensions", "id");
    if (!Decision.isUUId(id))
        throw new ApplicationException("invalid id [" + id + "], id must be a UUID");
    try {
        admin.removeRHExtension(id);
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
    store();
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) PageException(lucee.runtime.exp.PageException) SecurityException(lucee.runtime.exp.SecurityException) IOException(java.io.IOException) DeprecatedException(lucee.runtime.exp.DeprecatedException) BundleException(org.osgi.framework.BundleException) MalformedURLException(java.net.MalformedURLException) SMTPException(lucee.runtime.net.mail.SMTPException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 27 with ApplicationException

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

the class Application method setScopecascading.

public void setScopecascading(String scopeCascading) throws ApplicationException {
    if (StringUtil.isEmpty(scopeCascading))
        return;
    short NULL = -1;
    short tmp = ConfigWebUtil.toScopeCascading(scopeCascading, NULL);
    if (tmp == NULL)
        throw new ApplicationException("invalid value (" + scopeCascading + ") for attribute [ScopeCascading], valid values are [strict,small,standard]");
    this.scopeCascading = tmp;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException)

Example 28 with ApplicationException

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

the class Associate method doStartTag.

@Override
public int doStartTag() throws PageException {
    // current
    CFTag current = getCFTag();
    Struct value;
    if (current == null || (value = current.getAttributesScope()) == null)
        throw new ApplicationException("invalid context, tag is no inside a custom tag");
    // parent
    CFTag parent = GetBaseTagData.getParentCFTag(current.getParent(), basetag, -1);
    if (parent == null)
        throw new ApplicationException("there is no parent tag with name [" + basetag + "]");
    Struct thisTag = parent.getThis();
    Object obj = thisTag.get(datacollection, null);
    Array array;
    if (obj == null) {
        array = new ArrayImpl(new Object[] { value });
        thisTag.set(datacollection, array);
    } else if (Decision.isArray(obj) && (array = Caster.toArray(obj)).getDimension() == 1) {
        array.append(value);
    } else {
        array = new ArrayImpl(new Object[] { obj, value });
        thisTag.set(datacollection, array);
    }
    return SKIP_BODY;
}
Also used : Array(lucee.runtime.type.Array) ApplicationException(lucee.runtime.exp.ApplicationException) ArrayImpl(lucee.runtime.type.ArrayImpl) Struct(lucee.runtime.type.Struct)

Example 29 with ApplicationException

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

the class CFTag method validateAttributes.

private static void validateAttributes(Component cfc, StructImpl attributesScope, String tagName) throws ApplicationException, ExpressionException {
    TagLibTag tag = getAttributeRequirments(cfc, false);
    if (tag == null)
        return;
    if (tag.getAttributeType() == TagLibTag.ATTRIBUTE_TYPE_FIXED || tag.getAttributeType() == TagLibTag.ATTRIBUTE_TYPE_MIXED) {
        Iterator<Entry<String, TagLibTagAttr>> it = tag.getAttributes().entrySet().iterator();
        int count = 0;
        Collection.Key key;
        TagLibTagAttr attr;
        Object value;
        Entry<String, TagLibTagAttr> entry;
        // check existing attributes
        while (it.hasNext()) {
            entry = it.next();
            count++;
            key = KeyImpl.toKey(entry.getKey(), null);
            attr = entry.getValue();
            value = attributesScope.get(key, null);
            // check alias
            if (value == null) {
                String[] alias = attr.getAlias();
                if (!ArrayUtil.isEmpty(alias))
                    for (int i = 0; i < alias.length; i++) {
                        value = attributesScope.get(KeyImpl.toKey(alias[i], null), null);
                        if (value != null)
                            break;
                    }
            }
            if (value == null) {
                if (attr.getDefaultValue() != null) {
                    value = attr.getDefaultValue();
                    attributesScope.setEL(key, value);
                } else if (attr.isRequired())
                    throw new ApplicationException("attribute [" + key.getString() + "] is required for tag [" + tagName + "]");
            }
            if (value != null) {
                if (!Decision.isCastableTo(attr.getType(), value, true, true, -1))
                    throw new CasterException(createMessage(attr.getType(), value));
            }
        }
        // check if there are attributes not supported
        if (tag.getAttributeType() == TagLibTag.ATTRIBUTE_TYPE_FIXED && count < attributesScope.size()) {
            Collection.Key[] keys = attributesScope.keys();
            for (int i = 0; i < keys.length; i++) {
                if (tag.getAttribute(keys[i].getLowerString(), true) == null)
                    throw new ApplicationException("attribute [" + keys[i].getString() + "] is not supported for tag [" + tagName + "]");
            }
        // Attribute susi is not allowed for tag cfmail
        }
    }
}
Also used : TagLibTagAttr(lucee.transformer.library.tag.TagLibTagAttr) TagLibTag(lucee.transformer.library.tag.TagLibTag) CasterException(lucee.runtime.exp.CasterException) Key(lucee.runtime.type.Collection.Key) Entry(java.util.Map.Entry) ApplicationException(lucee.runtime.exp.ApplicationException) Collection(lucee.runtime.type.Collection) Key(lucee.runtime.type.Collection.Key)

Example 30 with ApplicationException

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

the class Col method doStartTag.

@Override
public int doStartTag() throws ExpressionException, ApplicationException {
    Tag parent = getParent();
    while (parent != null && !(parent instanceof Table)) {
        parent = parent.getParent();
    }
    if (parent instanceof Table) {
        Table table = (Table) parent;
        table.setCol(header, text, align, width);
    } else
        throw new ApplicationException("invalid context for tag col, tag must be inside a table tag");
    return SKIP_BODY;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) Tag(javax.servlet.jsp.tagext.Tag)

Aggregations

ApplicationException (lucee.runtime.exp.ApplicationException)173 IOException (java.io.IOException)41 Resource (lucee.commons.io.res.Resource)36 PageException (lucee.runtime.exp.PageException)30 Struct (lucee.runtime.type.Struct)25 SecurityException (lucee.runtime.exp.SecurityException)17 BundleException (org.osgi.framework.BundleException)16 StructImpl (lucee.runtime.type.StructImpl)15 MalformedURLException (java.net.MalformedURLException)13 Element (org.w3c.dom.Element)13 Array (lucee.runtime.type.Array)12 Key (lucee.runtime.type.Collection.Key)12 Iterator (java.util.Iterator)11 InputStream (java.io.InputStream)10 Query (lucee.runtime.type.Query)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 ExpressionException (lucee.runtime.exp.ExpressionException)9 Entry (java.util.Map.Entry)8 PageContextImpl (lucee.runtime.PageContextImpl)8 ClassDefinition (lucee.runtime.db.ClassDefinition)8