Search in sources :

Example 56 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class Admin method doGetMonitors.

private void doGetMonitors() throws PageException {
    if (!(config instanceof ConfigServerImpl))
        throw new ApplicationException("invalid context for this action");
    ConfigServerImpl cs = (ConfigServerImpl) config;
    IntervallMonitor[] intervalls = cs.getIntervallMonitors();
    RequestMonitor[] requests = cs.getRequestMonitors();
    lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._name, KeyConstants._type, LOG_ENABLED, CLASS }, 0, "monitors");
    doGetMonitors(qry, intervalls);
    doGetMonitors(qry, requests);
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : IntervallMonitor(lucee.runtime.monitor.IntervallMonitor) QueryImpl(lucee.runtime.type.QueryImpl) ApplicationException(lucee.runtime.exp.ApplicationException) BundleCollection(lucee.loader.osgi.BundleCollection) Collection(lucee.runtime.type.Collection) ConfigServerImpl(lucee.runtime.config.ConfigServerImpl) Query(lucee.runtime.type.Query) RequestMonitor(lucee.runtime.monitor.RequestMonitor)

Example 57 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class Admin method doGetBundles.

private void doGetBundles() throws PageException {
    CFMLEngine engine = ConfigWebUtil.getEngine(config);
    BundleCollection coreBundles = engine.getBundleCollection();
    java.util.Collection<BundleDefinition> extBundles = config.getAllExtensionBundleDefintions();
    List<BundleDefinition> bds = OSGiUtil.getBundleDefinitions(engine.getBundleContext());
    Iterator<BundleDefinition> it = bds.iterator();
    BundleDefinition bd;
    Bundle b;
    String str;
    Query qry = new QueryImpl(new Key[] { SYMBOLIC_NAME, KeyConstants._title, KeyConstants._description, KeyConstants._version, VENDOR, KeyConstants._state, PATH, USED_BY, KeyConstants._id, FRAGMENT, HEADERS }, bds.size(), "bundles");
    int row = 0;
    while (it.hasNext()) {
        row++;
        bd = it.next();
        b = bd.getLoadedBundle();
        qry.setAt(SYMBOLIC_NAME, row, bd.getName());
        qry.setAt(KeyConstants._title, row, bd.getName());
        qry.setAt(KeyConstants._version, row, bd.getVersionAsString());
        qry.setAt(USED_BY, row, _usedBy(bd.getName(), bd.getVersion(), coreBundles, extBundles));
        BundleFile bf = null;
        try {
            if (b != null) {
                qry.setAt(PATH, row, b.getLocation());
            } else {
                bf = bd.getBundleFile(false);
                qry.setAt(PATH, row, bf.getFile());
            }
        } catch (Throwable t) {
            ExceptionUtil.rethrowIfNecessary(t);
        }
        Map<String, Object> headers = null;
        if (b != null) {
            qry.setAt(KeyConstants._version, row, bd.getVersion().toString());
            qry.setAt(KeyConstants._id, row, b.getBundleId());
            qry.setAt(KeyConstants._state, row, OSGiUtil.toState(b.getState(), null));
            qry.setAt(FRAGMENT, row, OSGiUtil.isFragment(b));
            headers = OSGiUtil.getHeaders(b);
        } else {
            qry.setAt(KeyConstants._state, row, "notinstalled");
            try {
                if (b != null) {
                    qry.setAt(KeyConstants._version, row, b.getVersion().toString());
                    qry.setAt(FRAGMENT, row, OSGiUtil.isFragment(b));
                    Dictionary<String, String> dic = b.getHeaders();
                    Enumeration<String> keys = dic.keys();
                    headers = new HashMap<String, Object>();
                    String key;
                    while (keys.hasMoreElements()) {
                        key = keys.nextElement();
                        headers.put(key, dic.get(key));
                    }
                } else {
                    if (bf != null)
                        bf = bd.getBundleFile(false);
                    qry.setAt(KeyConstants._version, row, bf.getVersionAsString());
                    // qry.setAt(KeyConstants._id, row, bf.getBundleId());
                    qry.setAt(FRAGMENT, row, OSGiUtil.isFragment(bf));
                    headers = bf.getHeaders();
                }
            } catch (BundleException e) {
            }
        }
        if (headers != null) {
            Struct h = Caster.toStruct(headers, false);
            qry.setAt(HEADERS, row, h);
            // title
            str = Caster.toString(h.get("Bundle-Title", null), null);
            if (StringUtil.isEmpty(str))
                str = Caster.toString(h.get("Implementation-Title", null), null);
            if (StringUtil.isEmpty(str))
                str = Caster.toString(h.get("Specification-Title", null), null);
            if (StringUtil.isEmpty(str))
                str = Caster.toString(h.get("Bundle-Name", null), null);
            if (!StringUtil.isEmpty(str))
                qry.setAt(KeyConstants._title, row, str);
            // description
            str = Caster.toString(h.get("Bundle-Description", null), null);
            if (StringUtil.isEmpty(str))
                str = Caster.toString(h.get("Implementation-Description", null), null);
            if (StringUtil.isEmpty(str))
                str = Caster.toString(h.get("Specification-Description", null), null);
            if (!StringUtil.isEmpty(str))
                qry.setAt(KeyConstants._description, row, str);
            // Vendor
            str = Caster.toString(h.get("Bundle-Vendor", null), null);
            if (StringUtil.isEmpty(str))
                str = Caster.toString(h.get("Implementation-Vendor", null), null);
            if (StringUtil.isEmpty(str))
                str = Caster.toString(h.get("Specification-Vendor", null), null);
            if (!StringUtil.isEmpty(str))
                qry.setAt(VENDOR, row, str);
        // Specification-Vendor,Bundle-Vendor
        }
    }
    QuerySort.call(pageContext, qry, "title");
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : Query(lucee.runtime.type.Query) Bundle(org.osgi.framework.Bundle) Struct(lucee.runtime.type.Struct) BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) BundleCollection(lucee.loader.osgi.BundleCollection) QueryImpl(lucee.runtime.type.QueryImpl) CFMLEngine(lucee.loader.engine.CFMLEngine) BundleException(org.osgi.framework.BundleException) BundleFile(lucee.runtime.osgi.BundleFile)

Example 58 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class Admin method doGetContexts.

/**
 * @throws PageException
 */
private void doGetContexts() throws PageException {
    CFMLFactory[] factories;
    if (config instanceof ConfigServerImpl) {
        ConfigServerImpl cs = (ConfigServerImpl) config;
        factories = cs.getJSPFactories();
    } else {
        ConfigWebImpl cw = (ConfigWebImpl) config;
        factories = new CFMLFactory[] { cw.getFactory() };
    }
    lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._path, KeyConstants._id, KeyConstants._hash, KeyConstants._label, HAS_OWN_SEC_CONTEXT, KeyConstants._url, CONFIG_FILE, CLIENT_SIZE, CLIENT_ELEMENTS, SESSION_SIZE, SESSION_ELEMENTS }, factories.length, getString("admin", action, "returnVariable"));
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    ConfigWebImpl cw;
    for (int i = 0; i < factories.length; i++) {
        int row = i + 1;
        CFMLFactoryImpl factory = (CFMLFactoryImpl) factories[i];
        cw = (ConfigWebImpl) factory.getConfig();
        qry.setAtEL(KeyConstants._path, row, ReqRspUtil.getRootPath(factory.getConfigWebImpl().getServletContext()));
        qry.setAtEL(CONFIG_FILE, row, factory.getConfigWebImpl().getConfigFile().getAbsolutePath());
        if (factory.getURL() != null)
            qry.setAtEL(KeyConstants._url, row, factory.getURL().toExternalForm());
        qry.setAtEL(KeyConstants._id, row, factory.getConfig().getIdentification().getId());
        qry.setAtEL(KeyConstants._hash, row, SystemUtil.hash(factory.getConfigWebImpl().getServletContext()));
        qry.setAtEL(KeyConstants._label, row, factory.getLabel());
        qry.setAtEL(HAS_OWN_SEC_CONTEXT, row, Caster.toBoolean(cw.hasIndividualSecurityManager()));
        setScopeDirInfo(qry, row, CLIENT_SIZE, CLIENT_ELEMENTS, cw.getClientScopeDir());
        setScopeDirInfo(qry, row, SESSION_SIZE, SESSION_ELEMENTS, cw.getSessionScopeDir());
    }
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) QueryImpl(lucee.runtime.type.QueryImpl) CFMLFactoryImpl(lucee.runtime.CFMLFactoryImpl) BundleCollection(lucee.loader.osgi.BundleCollection) Collection(lucee.runtime.type.Collection) CFMLFactory(lucee.runtime.CFMLFactory) ConfigServerImpl(lucee.runtime.config.ConfigServerImpl) Query(lucee.runtime.type.Query)

Example 59 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class Admin method doGetRemoteClients.

private void doGetRemoteClients() throws PageException {
    RemoteClient[] clients = config.getRemoteClients();
    RemoteClient client;
    ProxyData pd;
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "label", "usage", "securityKey", "adminPassword", "serverUsername", "serverPassword", "type", "url", "proxyServer", "proxyUsername", "proxyPassword", "proxyPort" }, clients.length, "query");
    int row = 0;
    for (int i = 0; i < clients.length; i++) {
        client = clients[i];
        pd = client.getProxyData();
        row = i + 1;
        qry.setAt("label", row, client.getLabel());
        qry.setAt("usage", row, client.getUsage());
        qry.setAt("securityKey", row, client.getSecurityKey());
        qry.setAt("adminPassword", row, client.getAdminPassword());
        qry.setAt("ServerUsername", row, client.getServerUsername());
        qry.setAt("ServerPassword", row, client.getServerPassword());
        qry.setAt("type", row, client.getType());
        qry.setAt("url", row, client.getUrl());
        qry.setAt("proxyServer", row, pd == null ? "" : pd.getServer());
        qry.setAt("proxyUsername", row, pd == null ? "" : pd.getUsername());
        qry.setAt("proxyPassword", row, pd == null ? "" : pd.getPassword());
        qry.setAt("proxyPort", row, pd == null ? "" : Caster.toString(pd.getPort()));
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) ProxyData(lucee.runtime.net.proxy.ProxyData) RemoteClient(lucee.runtime.config.RemoteClient) Query(lucee.runtime.type.Query)

Example 60 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class Admin method doGetGatewayEntries.

private void doGetGatewayEntries() throws PageException {
    Map entries = ((ConfigWebImpl) config).getGatewayEngine().getEntries();
    Iterator it = entries.entrySet().iterator();
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "class", "bundleName", "bundleVersion", "id", "custom", "cfcPath", "listenerCfcPath", "startupMode", "state", "readOnly" }, 0, "entries");
    Map.Entry entry;
    GatewayEntry ge;
    // Gateway g;
    int row = 0;
    while (it.hasNext()) {
        row++;
        entry = (Entry) it.next();
        ge = (GatewayEntry) entry.getValue();
        // g=ge.getGateway();
        qry.addRow();
        qry.setAtEL("class", row, ge.getClassDefinition().getClassName());
        qry.setAtEL("bundleName", row, ge.getClassDefinition().getName());
        qry.setAtEL("bundleVersion", row, ge.getClassDefinition().getVersionAsString());
        qry.setAtEL("id", row, ge.getId());
        qry.setAtEL("listenerCfcPath", row, ge.getListenerCfcPath());
        qry.setAtEL("cfcPath", row, ge.getCfcPath());
        qry.setAtEL("startupMode", row, GatewayEntryImpl.toStartup(ge.getStartupMode(), "automatic"));
        qry.setAtEL("custom", row, ge.getCustom());
        qry.setAtEL("readOnly", row, Caster.toBoolean(ge.isReadOnly()));
        qry.setAtEL("state", row, GatewayEngineImpl.toStringState(GatewayUtil.getState(ge), "failed"));
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : Entry(java.util.Map.Entry) QueryImpl(lucee.runtime.type.QueryImpl) Iterator(java.util.Iterator) GatewayEntry(lucee.runtime.gateway.GatewayEntry) Map(java.util.Map) HashMap(java.util.HashMap) Query(lucee.runtime.type.Query)

Aggregations

QueryImpl (lucee.runtime.type.QueryImpl)82 Query (lucee.runtime.type.Query)65 Collection (lucee.runtime.type.Collection)17 Struct (lucee.runtime.type.Struct)16 StructImpl (lucee.runtime.type.StructImpl)13 PageException (lucee.runtime.exp.PageException)12 Key (lucee.runtime.type.Collection.Key)12 Iterator (java.util.Iterator)11 Map (java.util.Map)10 ApplicationException (lucee.runtime.exp.ApplicationException)10 Array (lucee.runtime.type.Array)10 DatabaseException (lucee.runtime.exp.DatabaseException)9 Stopwatch (lucee.runtime.timer.Stopwatch)9 HashMap (java.util.HashMap)8 Resource (lucee.commons.io.res.Resource)7 BundleCollection (lucee.loader.osgi.BundleCollection)7 Entry (java.util.Map.Entry)6 IOException (java.io.IOException)5 ResultSet (java.sql.ResultSet)5 ArrayImpl (lucee.runtime.type.ArrayImpl)5