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