use of lucee.runtime.type.Query in project Lucee by lucee.
the class Feed method doActionCreate.
private void doActionCreate() throws PageException {
// name
Query qry;
Struct props;
boolean splitString = true;
if (name != null) {
Struct data;
if (name instanceof String) {
data = Caster.toStruct(pageContext.getVariable(Caster.toString(name)));
} else
data = Caster.toStruct(name, false);
qry = FeedQuery.toQuery(data, false);
props = FeedProperties.toProperties(data);
splitString = false;
} else if (query != null && properties != null) {
qry = FeedQuery.toQuery(Caster.toQuery(query));
props = FeedProperties.toProperties(Caster.toStruct(properties, false));
} else {
throw new ApplicationException("missing attribute [name] or attributes [query] and [properties]");
}
StringBuffer xml = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
if (type == TYPE_AUTO) {
String version = Caster.toString(props.get("version", "rss"), "rss");
type = StringUtil.startsWithIgnoreCase(version, "rss") ? TYPE_RSS : TYPE_ATOM;
}
if (type == TYPE_RSS) {
createRSS(xml, qry, props, splitString);
} else {
createAtom(xml, qry, props, splitString);
}
// variable
if (!StringUtil.isEmpty(xmlVar)) {
pageContext.setVariable(xmlVar, xml);
}
// file
if (outputFile != null) {
if (outputFile.exists() && !overwrite)
throw new ApplicationException("destiniation file [" + outputFile + "] already exist");
if (StringUtil.isEmpty(charset))
charset = ((PageContextImpl) pageContext).getResourceCharset().name();
try {
IOUtil.write(outputFile, xml.toString(), charset, false);
} catch (IOException e) {
throw Caster.toPageException(e);
}
}
/*
<cffeed
action = "create"
name = "#structure#"
One or both of the following:
outputFile = "path"
xmlVar = "variable name"
optional
overwrite = "no|yes">
<cffeed
action = "create"
properties = "#metadata structure#"
query = "#items/entries query name#"
One or both of the following:
outputFile = "path"
xmlVar = "variable name"
optional
columnMap = "mapping structure"
overwrite = "no|yes">
*/
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class Admin method doGetRHExtensionProviders.
private void doGetRHExtensionProviders() throws PageException {
RHExtensionProvider[] providers = config.getRHExtensionProviders();
lucee.runtime.type.Query qry = new QueryImpl(new Key[] { KeyConstants._url, KeyConstants._readonly }, providers.length, "query");
RHExtensionProvider provider;
for (int i = 0; i < providers.length; i++) {
provider = providers[i];
int row = i + 1;
qry.setAt(KeyConstants._url, row, provider.getURL().toExternalForm());
qry.setAt(KeyConstants._readonly, row, provider.isReadonly());
}
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class Admin method getSSLCertificate.
public static Query getSSLCertificate(Config config, String host, int port) throws PageException {
Resource cacerts = config.getSecurityDirectory();
CertificateInstaller installer;
try {
installer = new CertificateInstaller(cacerts, host, port);
} catch (Exception e) {
throw Caster.toPageException(e);
}
X509Certificate[] certs = installer.getCertificates();
X509Certificate cert;
Query qry = new QueryImpl(new String[] { "subject", "issuer" }, certs.length, "certificates");
for (int i = 0; i < certs.length; i++) {
cert = certs[i];
qry.setAtEL("subject", i + 1, cert.getSubjectDN().getName());
qry.setAtEL("issuer", i + 1, cert.getIssuerDN().getName());
}
return qry;
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class Admin method doGetJavaCFXTags.
/**
* @throws PageException
*/
private void doGetJavaCFXTags() throws PageException {
Map map = config.getCFXTagPool().getClasses();
lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._displayname, KeyConstants._sourcename, KeyConstants._readonly, KeyConstants._name, KeyConstants._class, KeyConstants._bundleName, KeyConstants._bundleVersion, KeyConstants._isvalid }, 0, "query");
Iterator it = map.keySet().iterator();
int row = 0;
while (it.hasNext()) {
CFXTagClass tag = (CFXTagClass) map.get(it.next());
if (tag instanceof JavaCFXTagClass) {
row++;
qry.addRow(1);
JavaCFXTagClass jtag = (JavaCFXTagClass) tag;
qry.setAt(KeyConstants._displayname, row, tag.getDisplayType());
qry.setAt(KeyConstants._sourcename, row, tag.getSourceName());
qry.setAt(KeyConstants._readonly, row, Caster.toBoolean(tag.isReadOnly()));
qry.setAt(KeyConstants._isvalid, row, Caster.toBoolean(tag.isValid()));
qry.setAt(KeyConstants._name, row, jtag.getName());
qry.setAt(KeyConstants._class, row, jtag.getClassDefinition().getClassName());
qry.setAt(KeyConstants._bundleName, row, jtag.getClassDefinition().getName());
qry.setAt(KeyConstants._bundleVersion, row, jtag.getClassDefinition().getVersionAsString());
}
}
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class Admin method doGetCPPCFXTags.
private void doGetCPPCFXTags() throws PageException {
Map map = config.getCFXTagPool().getClasses();
lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._displayname, KeyConstants._sourcename, KeyConstants._readonly, PROCEDURE, KeyConstants._name, KeyConstants._isvalid, SERVER_LIBRARY, KEEP_ALIVE }, 0, "query");
Iterator it = map.keySet().iterator();
int row = 0;
while (it.hasNext()) {
CFXTagClass tag = (CFXTagClass) map.get(it.next());
if (tag instanceof CPPCFXTagClass) {
row++;
qry.addRow(1);
CPPCFXTagClass ctag = (CPPCFXTagClass) tag;
qry.setAt(KeyConstants._displayname, row, tag.getDisplayType());
qry.setAt(KeyConstants._sourcename, row, tag.getSourceName());
qry.setAt(KeyConstants._readonly, row, Caster.toBoolean(tag.isReadOnly()));
qry.setAt(KeyConstants._isvalid, row, Caster.toBoolean(tag.isValid()));
qry.setAt(KeyConstants._name, row, ctag.getName());
qry.setAt(PROCEDURE, row, ctag.getProcedure());
qry.setAt(SERVER_LIBRARY, row, ctag.getServerLibrary());
qry.setAt(KEEP_ALIVE, row, Caster.toBoolean(ctag.getKeepAlive()));
}
}
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Aggregations