Search in sources :

Example 1 with PageRuntimeException

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

the class HTTPClient method getMetaData.

private Struct getMetaData(PageContext pc) {
    if (meta == null) {
        pc = ThreadLocalPageContext.get(pc);
        InputStream is = null;
        HTTPResponse rsp = null;
        try {
            rsp = HTTPEngine.get(metaURL, username, password, -1, false, "UTF-8", createUserAgent(pc), proxyData, null);
            MimeType mt = getMimeType(rsp, null);
            int format = MimeType.toFormat(mt, -1);
            if (format == -1)
                throw new ApplicationException("cannot convert response with mime type [" + mt + "] to a CFML Object");
            is = rsp.getContentAsStream();
            Struct data = Caster.toStruct(ReqRspUtil.toObject(pc, IOUtil.toBytes(is, false), format, mt.getCharset(), null));
            Object oUDF = data.get(KeyConstants._functions, null);
            Object oAACF = data.get(ComponentPageImpl.ACCEPT_ARG_COLL_FORMATS, null);
            if (oUDF != null && oAACF != null) {
                meta = Caster.toStruct(oUDF);
                String[] strFormats = ListUtil.listToStringArray(Caster.toString(oAACF), ',');
                argumentsCollectionFormat = UDFUtil.toReturnFormat(strFormats, UDF.RETURN_FORMAT_JSON);
            } else {
                meta = data;
            }
        } catch (Throwable t) {
            ExceptionUtil.rethrowIfNecessary(t);
            throw new PageRuntimeException(Caster.toPageException(t));
        } finally {
            IOUtil.closeEL(is);
            HTTPEngine.closeEL(rsp);
        }
    }
    return meta;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) InputStream(java.io.InputStream) HTTPResponse(lucee.commons.net.http.HTTPResponse) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) MimeType(lucee.commons.lang.mimetype.MimeType) Struct(lucee.runtime.type.Struct)

Example 2 with PageRuntimeException

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

the class XMLDocumentStruct method setXmlStandalone.

// used only with java 7, do not set @Override
public void setXmlStandalone(boolean arg0) throws DOMException {
    // dynamic load to support jre 1.4 and 1.5
    try {
        Method m = doc.getClass().getMethod("setXmlStandalone", new Class[] { boolean.class });
        m.invoke(doc, new Object[] { Caster.toBoolean(arg0) });
    } catch (Exception e) {
        throw new PageRuntimeException(Caster.toPageException(e));
    }
}
Also used : Method(java.lang.reflect.Method) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) DOMException(org.w3c.dom.DOMException) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 3 with PageRuntimeException

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

the class XMLDocumentStruct method setXmlVersion.

// used only with java 7, do not set @Override
public void setXmlVersion(String arg0) throws DOMException {
    // dynamic load to support jre 1.4 and 1.5
    try {
        Method m = doc.getClass().getMethod("setXmlVersion", new Class[] { arg0.getClass() });
        m.invoke(doc, new Object[] { arg0 });
    } catch (Exception e) {
        throw new PageRuntimeException(Caster.toPageException(e));
    }
}
Also used : Method(java.lang.reflect.Method) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) DOMException(org.w3c.dom.DOMException) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 4 with PageRuntimeException

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

the class XMLDocumentStruct method normalizeDocument.

// used only with java 7, do not set @Override
public void normalizeDocument() {
    // dynamic load to support jre 1.4 and 1.5
    try {
        Method m = doc.getClass().getMethod("normalizeDocument", new Class[] {});
        m.invoke(doc, ArrayUtil.OBJECT_EMPTY);
    } catch (Exception e) {
        throw new PageRuntimeException(Caster.toPageException(e));
    }
}
Also used : Method(java.lang.reflect.Method) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) DOMException(org.w3c.dom.DOMException) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 5 with PageRuntimeException

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

the class XMLDocumentStruct method setDocumentURI.

// used only with java 7, do not set @Override
public void setDocumentURI(String arg0) {
    // dynamic load to support jre 1.4 and 1.5
    try {
        Method m = doc.getClass().getMethod("setDocumentURI", new Class[] { arg0.getClass() });
        m.invoke(doc, new Object[] { arg0 });
    } catch (Exception e) {
        throw new PageRuntimeException(Caster.toPageException(e));
    }
}
Also used : Method(java.lang.reflect.Method) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) DOMException(org.w3c.dom.DOMException) 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