Search in sources :

Example 26 with CFMLEngine

use of lucee.loader.engine.CFMLEngine in project Lucee by lucee.

the class DevNullOutputStream method flush.

public void flush() throws IOException {
    final CFMLEngine engine = CFMLEngineFactory.getInstance();
    final PageContext pc = engine.getThreadPageContext();
    pc.getRootWriter().flush();
}
Also used : PageContext(lucee.runtime.PageContext) CFMLEngine(lucee.loader.engine.CFMLEngine)

Example 27 with CFMLEngine

use of lucee.loader.engine.CFMLEngine in project Lucee by lucee.

the class DevNullOutputStream method _invoke.

private Object _invoke(final String methodName, final Object[] args) throws PageException {
    final CFMLEngine engine = CFMLEngineFactory.getInstance();
    final PageContext pc = engine.getThreadPageContext();
    initCFC(pc);
    return cfc.call(pc, methodName, args);
}
Also used : PageContext(lucee.runtime.PageContext) CFMLEngine(lucee.loader.engine.CFMLEngine)

Example 28 with CFMLEngine

use of lucee.loader.engine.CFMLEngine in project Lucee by lucee.

the class LuceeFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    try {
        CFMLEngine engine = CFMLEngineFactory.getInstance();
        // FUTURE add exeFilter
        engine.addServletConfig(new LuceeFilterImpl(request, response, chain, "filter"));
    } catch (Exception se) {
        se.printStackTrace();
    }
}
Also used : CFMLEngine(lucee.loader.engine.CFMLEngine) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 29 with CFMLEngine

use of lucee.loader.engine.CFMLEngine in project Lucee by lucee.

the class XMLUtilImpl method toInputSource.

public InputSource toInputSource(PageContext pc, Object value) throws IOException, PageException {
    if (value instanceof InputSource) {
        return (InputSource) value;
    }
    if (value instanceof String) {
        return toInputSource(pc, (String) value);
    }
    if (value instanceof StringBuffer) {
        return toInputSource(pc, value.toString());
    }
    CFMLEngine engine = CFMLEngineFactory.getInstance();
    IO io = engine.getIOUtil();
    if (value instanceof Resource) {
        String str = io.toString(((Resource) value), (Charset) null);
        return new InputSource(new StringReader(str));
    }
    if (value instanceof File) {
        String str = io.toString(engine.getCastUtil().toResource(((File) value)), (Charset) null);
        return new InputSource(new StringReader(str));
    }
    if (value instanceof InputStream) {
        InputStream is = (InputStream) value;
        try {
            String str = io.toString(is, (Charset) null);
            return new InputSource(new StringReader(str));
        } finally {
            io.closeSilent(is);
        }
    }
    if (value instanceof Reader) {
        Reader reader = (Reader) value;
        try {
            String str = io.toString(reader);
            return new InputSource(new StringReader(str));
        } finally {
            io.closeSilent(reader);
        }
    }
    if (value instanceof byte[]) {
        return new InputSource(new ByteArrayInputStream((byte[]) value));
    }
    throw engine.getExceptionUtil().createXMLException("can't cast object of type [" + value + "] to an Input for xml parser");
}
Also used : InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Resource(lucee.commons.io.res.Resource) StringReader(java.io.StringReader) Reader(java.io.Reader) XMLReader(org.xml.sax.XMLReader) StringReader(java.io.StringReader) CFMLEngine(lucee.loader.engine.CFMLEngine) File(java.io.File)

Example 30 with CFMLEngine

use of lucee.loader.engine.CFMLEngine in project Lucee by lucee.

the class XMLValidator method validate.

public Struct validate(InputSource xml) throws PageException {
    CFMLEngine engine = CFMLEngineFactory.getInstance();
    warnings = engine.getCreationUtil().createArray();
    errors = engine.getCreationUtil().createArray();
    fatals = engine.getCreationUtil().createArray();
    try {
        XMLReader parser = new XMLUtilImpl().createXMLReader("org.apache.xerces.parsers.SAXParser");
        parser.setContentHandler(this);
        parser.setErrorHandler(this);
        parser.setEntityResolver(this);
        parser.setFeature("http://xml.org/sax/features/validation", true);
        parser.setFeature("http://apache.org/xml/features/validation/schema", true);
        parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
        // if(!validateNamespace)
        if (!Util.isEmpty(strSchema))
            parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", strSchema);
        parser.parse(xml);
    } catch (SAXException e) {
    } catch (IOException e) {
        throw engine.getExceptionUtil().createXMLException(e.getMessage());
    }
    // result
    Struct result = engine.getCreationUtil().createStruct();
    result.setEL("warnings", warnings);
    result.setEL("errors", errors);
    result.setEL("fatalerrors", fatals);
    result.setEL("status", engine.getCastUtil().toBoolean(!hasErrors));
    release();
    return result;
}
Also used : CFMLEngine(lucee.loader.engine.CFMLEngine) IOException(java.io.IOException) XMLReader(org.xml.sax.XMLReader) SAXException(org.xml.sax.SAXException) Struct(lucee.runtime.type.Struct)

Aggregations

CFMLEngine (lucee.loader.engine.CFMLEngine)31 File (java.io.File)10 IOException (java.io.IOException)9 CFMLEngineFactory (lucee.loader.engine.CFMLEngineFactory)9 Bundle (org.osgi.framework.Bundle)9 Resource (lucee.commons.io.res.Resource)6 BundleFile (lucee.runtime.osgi.BundleFile)5 BundleException (org.osgi.framework.BundleException)5 ServletException (javax.servlet.ServletException)4 BundleContext (org.osgi.framework.BundleContext)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 Reader (java.io.Reader)3 BundleCollection (lucee.loader.osgi.BundleCollection)3 PageContext (lucee.runtime.PageContext)3 Struct (lucee.runtime.type.Struct)3 OutputStream (java.io.OutputStream)2 StringReader (java.io.StringReader)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2