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();
}
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;
}
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;
}
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
}
}
}
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;
}
Aggregations