Search in sources :

Example 11 with Query

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"> 
		 */
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) FeedQuery(lucee.runtime.text.feed.FeedQuery) Query(lucee.runtime.type.Query) GetHttpTimeString(lucee.runtime.functions.dateTime.GetHttpTimeString) IOException(java.io.IOException) Struct(lucee.runtime.type.Struct)

Example 12 with Query

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);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) RHExtensionProvider(lucee.runtime.extension.RHExtensionProvider)

Example 13 with Query

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;
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) Resource(lucee.commons.io.res.Resource) PageException(lucee.runtime.exp.PageException) SecurityException(lucee.runtime.exp.SecurityException) IOException(java.io.IOException) DeprecatedException(lucee.runtime.exp.DeprecatedException) BundleException(org.osgi.framework.BundleException) MalformedURLException(java.net.MalformedURLException) SMTPException(lucee.runtime.net.mail.SMTPException) ApplicationException(lucee.runtime.exp.ApplicationException) X509Certificate(java.security.cert.X509Certificate) CertificateInstaller(lucee.runtime.net.http.CertificateInstaller)

Example 14 with Query

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);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) Iterator(java.util.Iterator) BundleCollection(lucee.loader.osgi.BundleCollection) Collection(lucee.runtime.type.Collection) CFXTagClass(lucee.runtime.cfx.customtag.CFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) Map(java.util.Map) HashMap(java.util.HashMap) Query(lucee.runtime.type.Query)

Example 15 with Query

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);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Iterator(java.util.Iterator) BundleCollection(lucee.loader.osgi.BundleCollection) Collection(lucee.runtime.type.Collection) CFXTagClass(lucee.runtime.cfx.customtag.CFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) Map(java.util.Map) HashMap(java.util.HashMap) Query(lucee.runtime.type.Query)

Aggregations

Query (lucee.runtime.type.Query)82 QueryImpl (lucee.runtime.type.QueryImpl)52 Struct (lucee.runtime.type.Struct)19 Array (lucee.runtime.type.Array)16 Collection (lucee.runtime.type.Collection)14 Iterator (java.util.Iterator)13 PageException (lucee.runtime.exp.PageException)12 Map (java.util.Map)11 StructImpl (lucee.runtime.type.StructImpl)11 ApplicationException (lucee.runtime.exp.ApplicationException)10 Stopwatch (lucee.runtime.timer.Stopwatch)10 Key (lucee.runtime.type.Collection.Key)9 List (java.util.List)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 QueryColumn (lucee.runtime.type.QueryColumn)7 Enumeration (java.util.Enumeration)6 Entry (java.util.Map.Entry)6 FunctionException (lucee.runtime.exp.FunctionException)6