use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class JSONConverter method _serializeUDF.
private void _serializeUDF(PageContext pc, Set test, UDF udf, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
Struct sct = new StructImpl();
try {
// Meta
Struct meta = udf.getMetaData(pc);
sct.setEL("Metadata", meta);
// Parameters
sct.setEL("MethodAttributes", meta.get("PARAMETERS"));
} catch (PageException e) {
throw toConverterException(e);
}
sct.setEL("Access", ComponentUtil.toStringAccess(udf.getAccess(), "public"));
sct.setEL("Output", Caster.toBoolean(udf.getOutput()));
sct.setEL("ReturnType", udf.getReturnTypeAsString());
try {
sct.setEL("PagePath", udf.getSource());
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
_serializeStruct(pc, test, sct, sb, serializeQueryByColumns, true, done);
// TODO key SuperScope and next?
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class WDDXConverter method _deserializeStruct.
/**
* Desirialize a Struct Object
*
* @param elStruct
* Struct Object as XML Element
* @return Struct Object
* @throws ConverterException
*/
private Object _deserializeStruct(Element elStruct) throws ConverterException {
String type = elStruct.getAttribute("type");
Struct struct = new StructImpl();
NodeList list = elStruct.getChildNodes();
int len = list.getLength();
for (int i = 0; i < len; i++) {
// print.ln(i);
Node node = list.item(i);
if (node instanceof Element) {
Element var = (Element) node;
Element value = getChildElement((Element) node);
if (value != null) {
struct.setEL(var.getAttribute("name"), _deserialize(value));
}
}
}
/**
* java objects are serialized as empty struct with a type that denotes the class, so
* if it's not a known struct-type it is not a struct
*/
if (struct.isEmpty() && !StringUtil.isEmpty(type) && !KNOWN_STRUCT_TYPES.contains(type))
return "";
return struct;
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class CFMLEngineImpl method cli.
@Override
public void cli(Map<String, String> config, ServletConfig servletConfig) throws IOException, JspException, ServletException {
ServletContext servletContext = servletConfig.getServletContext();
HTTPServletImpl servlet = new HTTPServletImpl(servletConfig, servletContext, servletConfig.getServletName());
// webroot
String strWebroot = config.get("webroot");
if (StringUtil.isEmpty(strWebroot, true))
throw new IOException("missing webroot configuration");
Resource root = ResourcesImpl.getFileResourceProvider().getResource(strWebroot);
root.mkdirs();
// serverName
String serverName = config.get("server-name");
if (StringUtil.isEmpty(serverName, true))
serverName = "localhost";
// uri
String strUri = config.get("uri");
if (StringUtil.isEmpty(strUri, true))
throw new IOException("missing uri configuration");
URI uri;
try {
uri = lucee.commons.net.HTTPUtil.toURI(strUri);
} catch (URISyntaxException e) {
throw Caster.toPageException(e);
}
// cookie
Cookie[] cookies;
String strCookie = config.get("cookie");
if (StringUtil.isEmpty(strCookie, true))
cookies = new Cookie[0];
else {
Map<String, String> mapCookies = HTTPUtil.parseParameterList(strCookie, false, null);
int index = 0;
cookies = new Cookie[mapCookies.size()];
Entry<String, String> entry;
Iterator<Entry<String, String>> it = mapCookies.entrySet().iterator();
Cookie c;
while (it.hasNext()) {
entry = it.next();
c = ReqRspUtil.toCookie(entry.getKey(), entry.getValue(), null);
if (c != null)
cookies[index++] = c;
else
throw new IOException("cookie name [" + entry.getKey() + "] is invalid");
}
}
// header
Pair[] headers = new Pair[0];
// parameters
Pair[] parameters = new Pair[0];
// attributes
StructImpl attributes = new StructImpl();
ByteArrayOutputStream os = new ByteArrayOutputStream();
HttpServletRequestDummy req = new HttpServletRequestDummy(root, serverName, uri.getPath(), uri.getQuery(), cookies, headers, parameters, attributes, null, null);
req.setProtocol("CLI/1.0");
HttpServletResponse rsp = new HttpServletResponseDummy(os);
serviceCFML(servlet, req, rsp);
String res = os.toString(ReqRspUtil.getCharacterEncoding(null, rsp).name());
System.out.println(res);
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class CatchBlockImpl method duplicate.
@Override
public Collection duplicate(boolean deepCopy) {
Struct sct = new StructImpl();
StructUtil.copy(this, sct, true);
return sct;
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class PageExceptionImpl method addContext.
@Override
public void addContext(PageSource ps, int line, int column, StackTraceElement element) {
if (line == -187) {
sources.add(ps);
return;
}
Struct struct = new StructImpl();
// print.out(pr.getDisplayPath());
try {
String[] content = ps.getSource();
struct.set(KeyConstants._template, ps.getDisplayPath());
struct.set(KeyConstants._line, new Double(line));
struct.set(KeyConstants._id, "??");
struct.set(KeyConstants._Raw_Trace, (element != null) ? element.toString() : "");
struct.set(KeyConstants._Type, "cfml");
struct.set(KeyConstants._column, new Double(column));
if (content != null) {
struct.set(KeyConstants._codePrintHTML, getCodePrint(content, line, true));
struct.set(KeyConstants._codePrintPlain, getCodePrint(content, line, false));
}
tagContext.append(struct);
} catch (Exception e) {
}
}
Aggregations