Search in sources :

Example 31 with PageRuntimeException

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

the class HTTPClient method toDumpData.

@Override
public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
    try {
        Array args;
        Struct sct = getMetaData(pageContext), val, a;
        DumpTable cfc = new DumpTable("udf", "#66ccff", "#ccffff", "#000000"), udf, arg;
        cfc.setTitle("Web Service (HTTP)");
        if (dp.getMetainfo())
            cfc.setComment(url.toExternalForm());
        Iterator<Entry<Key, Object>> it = sct.entryIterator();
        Entry<Key, Object> e;
        // Loop UDFs
        while (it.hasNext()) {
            e = it.next();
            val = Caster.toStruct(e.getValue());
            // udf name
            udf = new DumpTable("udf", "#66ccff", "#ccffff", "#000000");
            arg = new DumpTable("udf", "#66ccff", "#ccffff", "#000000");
            cfc.appendRow(1, new SimpleDumpData(e.getKey().getString()), udf);
            // args
            args = Caster.toArray(val.get(KeyConstants._arguments));
            udf.appendRow(1, new SimpleDumpData("arguments"), arg);
            arg.appendRow(7, new SimpleDumpData("name"), new SimpleDumpData("required"), new SimpleDumpData("type"));
            Iterator<Object> ait = args.valueIterator();
            while (ait.hasNext()) {
                a = Caster.toStruct(ait.next());
                arg.appendRow(0, new SimpleDumpData(Caster.toString(a.get(KeyConstants._name))), new SimpleDumpData(Caster.toString(a.get(KeyConstants._required))), new SimpleDumpData(Caster.toString(a.get(KeyConstants._type))));
            }
            // return type
            udf.appendRow(1, new SimpleDumpData("return type"), new SimpleDumpData(Caster.toString(val.get(KeyConstants._returntype))));
        /*
				cfc.appendRow(new DumpRow(0,new DumpData[]{
						new SimpleDumpData(arg.getDisplayName()),
						new SimpleDumpData(e.getKey().getString()),
						new SimpleDumpData(arg.isRequired()),
						new SimpleDumpData(arg.getTypeAsString()),
						def,
						new SimpleDumpData(arg.getHint())}));*/
        }
        return cfc;
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        throw new PageRuntimeException(Caster.toPageException(t));
    }
}
Also used : Array(lucee.runtime.type.Array) DumpTable(lucee.runtime.dump.DumpTable) Entry(java.util.Map.Entry) SimpleDumpData(lucee.runtime.dump.SimpleDumpData) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) Key(lucee.runtime.type.Collection.Key) Struct(lucee.runtime.type.Struct)

Example 32 with PageRuntimeException

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

the class JavaProxy method call.

public static Object call(ConfigWeb config, Component cfc, String methodName, Object... arguments) {
    boolean unregister = false;
    PageContext pc = null;
    try {
        pc = ThreadLocalPageContext.get();
        // create PageContext if necessary
        if (pc == null) {
            pc = ThreadUtil.createPageContext(config, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, Constants.NAME, "/", "", null, null, null, null, null, true, -1);
            unregister = true;
            pc.addPageSource(cfc.getPageSource(), true);
        }
        return cfc.call(pc, methodName, arguments);
    } catch (PageException pe) {
        throw new PageRuntimeException(pe);
    } finally {
        if (unregister)
            config.getFactory().releaseLuceePageContext(pc, true);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 33 with PageRuntimeException

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

the class GatewayEngineImpl method invokeListener.

public boolean invokeListener(String gatewayId, String method, Map data) {
    // do not add this method to loade, it can be removed with Lucee 5
    data = GatewayUtil.toCFML(data);
    GatewayEntry entry;
    try {
        entry = getGatewayEntry(gatewayId);
    } catch (PageException pe) {
        throw new PageRuntimeException(pe);
    }
    String cfcPath = entry.getListenerCfcPath();
    if (!StringUtil.isEmpty(cfcPath, true)) {
        try {
            if (!callOneWay(cfcPath, gatewayId, method, Caster.toStruct(data, null, false), false))
                log(gatewayId, LOGLEVEL_ERROR, "function [" + method + "] does not exist in cfc [" + cfcPath + "]");
            else
                return true;
        } catch (PageException e) {
            log(gatewayId, LOGLEVEL_ERROR, e.getMessage(), e);
        }
    } else
        log(gatewayId, LOGLEVEL_ERROR, "there is no listener cfc defined");
    return false;
}
Also used : PageException(lucee.runtime.exp.PageException) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 34 with PageRuntimeException

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

the class InstrumentationFactory method getInstrumentation.

public static synchronized Instrumentation getInstrumentation(final Config config) {
    final Log log = config.getLog("application");
    final CFMLEngine engine = ConfigWebUtil.getEngine(config);
    Instrumentation instr = _getInstrumentation(log, config);
    // agent already exist
    if (instr != null)
        return instr;
    AccessController.doPrivileged(new PrivilegedAction<Object>() {

        @Override
        public Object run() {
            ClassLoader ccl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
            try {
                JavaVendor vendor = JavaVendor.getCurrentVendor();
                Resource toolsJar = null;
                // When running on IBM, the attach api classes are packaged in vm.jar which is a part
                // of the default vm classpath.
                RefBoolean useOurOwn = new RefBooleanImpl(true);
                // if (!vendor.isIBM()) {
                // If we can't find the tools.jar and we're not on IBM we can't load the agent.
                toolsJar = findToolsJar(config, log, useOurOwn);
                if (toolsJar == null) {
                    return null;
                }
                // }
                log.info("Instrumentation", "tools.jar used:" + toolsJar);
                // add the attach native library
                if (useOurOwn.toBooleanValue())
                    addAttachIfNecessary(config, log);
                Class<?> vmClass = loadVMClass(toolsJar, log, vendor);
                log.info("Instrumentation", "loaded VirtualMachine class:" + (vmClass == null ? "null" : vmClass.getName()));
                if (vmClass == null) {
                    return null;
                }
                String agentPath = createAgentJar(log, config).getAbsolutePath();
                if (agentPath == null) {
                    return null;
                }
                log.info("Instrumentation", "try to load agent (path:" + agentPath + ")");
                loadAgent(config, log, agentPath, vmClass);
            // log.info("Instrumentation","agent loaded (path:"+agentPath+")");
            } catch (IOException ioe) {
                log.log(Log.LEVEL_INFO, "Instrumentation", ioe);
            } finally {
                Thread.currentThread().setContextClassLoader(ccl);
            }
            return null;
        }
    });
    // If the load(...) agent call was successful, this variable will no
    // longer be null.
    instr = _getInstrumentation(log, config);
    if (instr == null) {
        try {
            Resource agentJar = createAgentJar(log, config);
            throw new PageRuntimeException(new ApplicationException(Constants.NAME + " was not able to load a Agent dynamically! " + "You need to load one manually by adding the following to your JVM arguments [-javaagent:\"" + (agentJar) + "\"]"));
        } catch (IOException ioe) {
            SystemOut.printDate(ioe);
        }
    }
    return instr;
}
Also used : RefBoolean(lucee.commons.lang.types.RefBoolean) Log(lucee.commons.io.log.Log) Resource(lucee.commons.io.res.Resource) FileResource(lucee.commons.io.res.type.file.FileResource) Instrumentation(java.lang.instrument.Instrumentation) IOException(java.io.IOException) ApplicationException(lucee.runtime.exp.ApplicationException) URLClassLoader(java.net.URLClassLoader) CFMLEngine(lucee.loader.engine.CFMLEngine) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl)

Example 35 with PageRuntimeException

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

the class DatasourceResourceProvider method getOutputStream.

public synchronized OutputStream getOutputStream(ConnectionData data, int fullPathHash, int pathHash, String path, String name, boolean append) throws IOException {
    Attr attr = getAttr(data, fullPathHash, path, name);
    if (attr.getId() == 0) {
        create(data, fullPathHash, pathHash, path, name, Attr.TYPE_FILE);
        attr = getAttr(data, fullPathHash, path, name);
    }
    PipedInputStream pis = new PipedInputStream();
    PipedOutputStream pos = new PipedOutputStream();
    pis.connect(pos);
    DatasourceConnection dc = null;
    // Connection c=null;
    try {
        dc = getDatasourceConnection(data);
        // Connection c = dc.getConnection();
        DataWriter writer = new DataWriter(getCore(data), dc, data.getPrefix(), attr, pis, this, append);
        writer.start();
        return new DatasourceResourceOutputStream(writer, pos);
    // core.getOutputStream(dc, name, attr, pis);
    } catch (PageException e) {
        throw new PageRuntimeException(e);
    } finally {
        removeFromCache(data, path, name);
    // manager.releaseConnection(CONNECTION_ID,dc);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) DatasourceConnection(lucee.runtime.db.DatasourceConnection) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Aggregations

PageRuntimeException (lucee.runtime.exp.PageRuntimeException)37 PageException (lucee.runtime.exp.PageException)17 Method (java.lang.reflect.Method)7 SQLException (java.sql.SQLException)7 DOMException (org.w3c.dom.DOMException)7 IOException (java.io.IOException)4 Entry (java.util.Map.Entry)4 Pair (lucee.commons.lang.Pair)4 DatasourceConnection (lucee.runtime.db.DatasourceConnection)4 DatabaseException (lucee.runtime.exp.DatabaseException)4 DeprecatedException (lucee.runtime.exp.DeprecatedException)4 ORMDatasourceConnection (lucee.runtime.orm.ORMDatasourceConnection)4 HashMap (java.util.HashMap)3 ApplicationException (lucee.runtime.exp.ApplicationException)3 TemplateException (lucee.runtime.exp.TemplateException)3 Array (lucee.runtime.type.Array)3 Struct (lucee.runtime.type.Struct)3 BIF (lucee.transformer.bytecode.expression.var.BIF)3 Iterator (java.util.Iterator)2 Resource (lucee.commons.io.res.Resource)2