Search in sources :

Example 46 with ApplicationException

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

the class ZipParam method doStartTag.

@Override
public int doStartTag() throws PageException {
    if (this.filter == null && !StringUtil.isEmpty(this.pattern)) {
        this.filter = new WildcardPatternFilter(pattern, patternDelimiters);
    }
    if (source != null) {
        notAllowed("source", "charset", charset);
        notAllowed("source", "content", content);
        getZip().setParam(new ZipParamSource(source, entryPath, filter, prefix, recurse()));
    } else if (content != null) {
        required("content", "entrypath", entryPath);
        notAllowed("content,entrypath", "filter", filter);
        notAllowed("content,entrypath", "prefix", prefix);
        notAllowed("content,entrypath", "source", source);
        notAllowed("content,entrypath", "recurse", recurse);
        getZip().setParam(new ZipParamContent(content, entryPath, charset));
    } else if (filter != null) {
        notAllowed("filter", "charset", charset);
        notAllowed("filter", "content", content);
        notAllowed("filter", "prefix", prefix);
        notAllowed("filter", "source", source);
        getZip()._setFilter(filter);
    // getZip().setParam(new ZipParamFilter(filter,entryPath,recurse()));
    } else if (entryPath != null) {
        notAllowed("entryPath", "charset", charset);
        notAllowed("entryPath", "content", content);
        notAllowed("entryPath", "prefix", prefix);
        notAllowed("entryPath", "source", source);
        getZip().setEntrypath(entryPath);
    } else
        throw new ApplicationException("invalid attribute combination");
    return SKIP_BODY;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) WildcardPatternFilter(lucee.commons.io.res.util.WildcardPatternFilter)

Example 47 with ApplicationException

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

the class SOAPUtil method getTypes.

public static Vector getTypes(Element body, SymbolTable st) throws ApplicationException {
    // get the data
    List<TempType> hrefs = new ArrayList<SOAPUtil.TempType>();
    Map<String, TempType> ids = new HashMap<String, SOAPUtil.TempType>();
    ArrayList<TempType> res = new ArrayList<SOAPUtil.TempType>();
    toTempTypes(XMLUtil.getChildNodes(body, Node.ELEMENT_NODE).iterator(), res, hrefs, ids, res);
    // replace href with real data
    Iterator<TempType> it = hrefs.iterator();
    TempType href, id;
    while (it.hasNext()) {
        href = it.next();
        id = ids.get(href.href);
        if (StringUtil.isEmpty(id))
            throw new ApplicationException("cannot handle href " + href.href);
        href.href = null;
        href.id = id.id;
        href.prefix = id.prefix;
        href.namespace = id.namespace;
        href.type = id.type;
        href.children = id.children;
        id.replicated = true;
    }
    // removes replicated types in root
    it = res.iterator();
    TempType t;
    while (it.hasNext()) {
        t = it.next();
        if (t.replicated)
            it.remove();
    }
    // now convert to types
    return toTypes(res, false);
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 48 with ApplicationException

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

the class ComponentController method _invoke.

public static Object _invoke(String name, Object[] args) throws PageException {
    Key key = Caster.toKey(name);
    Component c = component.get();
    PageContext p = pagecontext.get();
    MessageContext mc = messageContext.get();
    if (c == null)
        throw new ApplicationException("missing component");
    if (p == null)
        throw new ApplicationException("missing pagecontext");
    UDF udf = Caster.toFunction(c.get(p, key, null), null);
    FunctionArgument[] fa = null;
    if (udf != null)
        fa = udf.getFunctionArguments();
    for (int i = 0; i < args.length; i++) {
        if (fa != null && i < fa.length && fa[i].getType() == CFTypes.TYPE_UNKNOW) {
            args[i] = AxisCaster.toLuceeType(p, fa[i].getTypeAsString(), args[i]);
        } else
            args[i] = AxisCaster.toLuceeType(p, args[i]);
    }
    // return type
    String rtnType = udf != null ? udf.getReturnTypeAsString() : "any";
    Object rtn = c.call(p, key, args);
    // cast return value to Axis type
    try {
        RPCServer server = RPCServer.getInstance(p.getId(), p, p.getServletContext());
        TypeMapping tm = mc != null ? mc.getTypeMapping() : TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry());
        rtn = Caster.castTo(p, rtnType, rtn, false);
        Class<?> clazz = Caster.cfTypeToClass(rtnType);
        return AxisCaster.toAxisType(tm, rtn, clazz.getComponentType() != null ? clazz : null);
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        throw Caster.toPageException(t);
    }
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) UDF(lucee.runtime.type.UDF) TypeMapping(javax.xml.rpc.encoding.TypeMapping) PageContext(lucee.runtime.PageContext) MessageContext(org.apache.axis.MessageContext) Component(lucee.runtime.Component) FunctionArgument(lucee.runtime.type.FunctionArgument) Key(lucee.runtime.type.Collection.Key)

Example 49 with ApplicationException

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

the class CredentialImpl method toRole.

/**
 * convert a Object to a String Array of Roles
 * @param oRoles
 * @return roles
 * @throws PageException
 */
public static String[] toRole(Object oRoles) throws PageException {
    if (oRoles instanceof String) {
        oRoles = ListUtil.listToArrayRemoveEmpty(oRoles.toString(), ",");
    }
    if (oRoles instanceof Array) {
        Array arrRoles = (Array) oRoles;
        String[] roles = new String[arrRoles.size()];
        for (int i = 0; i < roles.length; i++) {
            roles[i] = Caster.toString(arrRoles.get(i + 1, ""));
        }
        return roles;
    }
    throw new ApplicationException("invalid roles definition for tag loginuser");
}
Also used : Array(lucee.runtime.type.Array) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 50 with ApplicationException

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

the class Admin method doGetRemoteClient.

private void doGetRemoteClient() throws PageException {
    String url = getString("admin", action, "url");
    RemoteClient[] clients = config.getRemoteClients();
    RemoteClient client;
    for (int i = 0; i < clients.length; i++) {
        client = clients[i];
        if (client.getUrl().equalsIgnoreCase(url)) {
            Struct sct = new StructImpl();
            ProxyData pd = client.getProxyData();
            sct.setEL("label", client.getLabel());
            sct.setEL("usage", client.getUsage());
            sct.setEL("securityKey", client.getSecurityKey());
            sct.setEL("adminPassword", client.getAdminPassword());
            sct.setEL("ServerUsername", client.getServerUsername());
            sct.setEL("ServerPassword", client.getServerPassword());
            sct.setEL("type", client.getType());
            sct.setEL("url", client.getUrl());
            sct.setEL("proxyServer", pd == null ? "" : StringUtil.emptyIfNull(pd.getServer()));
            sct.setEL("proxyUsername", pd == null ? "" : StringUtil.emptyIfNull(pd.getUsername()));
            sct.setEL("proxyPassword", pd == null ? "" : StringUtil.emptyIfNull(pd.getPassword()));
            sct.setEL("proxyPort", pd == null ? "" : (pd.getPort() == -1 ? "" : Caster.toString(pd.getPort())));
            pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
            return;
        }
    }
    throw new ApplicationException("there is no remote client with url [" + url + "]");
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ProxyData(lucee.runtime.net.proxy.ProxyData) ApplicationException(lucee.runtime.exp.ApplicationException) RemoteClient(lucee.runtime.config.RemoteClient) Struct(lucee.runtime.type.Struct)

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