Search in sources :

Example 1 with ExtensionProvider

use of lucee.runtime.extension.ExtensionProvider in project Lucee by lucee.

the class XMLConfigWebFactory method loadExtensions.

private static void loadExtensions(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
    Element xmlExtParent = getChildByName(doc.getDocumentElement(), "extensions");
    String strEnabled = getAttr(xmlExtParent, "enabled");
    if (!StringUtil.isEmpty(strEnabled)) {
        config.setExtensionEnabled(Caster.toBooleanValue(strEnabled, false));
    }
    // RH Providers
    {
        // providers
        Element[] xmlProviders = getChildren(xmlExtParent, "rhprovider");
        String strProvider;
        Map<RHExtensionProvider, String> providers = new HashMap<RHExtensionProvider, String>();
        for (int i = 0; i < Constants.RH_EXTENSION_PROVIDERS.length; i++) {
            providers.put(Constants.RH_EXTENSION_PROVIDERS[i], "");
        }
        for (int i = 0; i < xmlProviders.length; i++) {
            strProvider = getAttr(xmlProviders[i], "url");
            if (!StringUtil.isEmpty(strProvider, true)) {
                try {
                    providers.put(new RHExtensionProvider(strProvider.trim(), false), "");
                } catch (MalformedURLException e) {
                    SystemOut.printDate(e);
                }
            }
        }
        config.setRHExtensionProviders(providers.keySet().toArray(new RHExtensionProvider[providers.size()]));
    }
    // classic providers
    {
        Element[] xmlProviders = getChildren(xmlExtParent, "provider");
        String provider;
        Map list = new HashMap();
        for (int i = 0; i < Constants.CLASSIC_EXTENSION_PROVIDERS.length; i++) {
            list.put(Constants.CLASSIC_EXTENSION_PROVIDERS[i], "");
        }
        for (int i = 0; i < xmlProviders.length; i++) {
            provider = getAttr(xmlProviders[i], "url");
            if (!StringUtil.isEmpty(provider, true)) {
                list.put(new ExtensionProviderImpl(provider.trim(), false), "");
            }
        }
        config.setExtensionProviders((ExtensionProvider[]) list.keySet().toArray(new ExtensionProvider[list.size()]));
    }
    // extensions
    Element[] xmlExtensions = getChildren(xmlExtParent, "extension");
    Extension[] extensions = new Extension[xmlExtensions.length];
    Element xmlExtension;
    for (int i = 0; i < xmlExtensions.length; i++) {
        xmlExtension = xmlExtensions[i];
        extensions[i] = new ExtensionImpl(getAttr(xmlExtension, "config"), getAttr(xmlExtension, "id"), getAttr(xmlExtension, "provider"), getAttr(xmlExtension, "version"), getAttr(xmlExtension, "name"), getAttr(xmlExtension, "label"), getAttr(xmlExtension, "description"), getAttr(xmlExtension, "category"), getAttr(xmlExtension, "image"), getAttr(xmlExtension, "author"), getAttr(xmlExtension, "codename"), getAttr(xmlExtension, "video"), getAttr(xmlExtension, "support"), getAttr(xmlExtension, "documentation"), getAttr(xmlExtension, "forum"), getAttr(xmlExtension, "mailinglist"), getAttr(xmlExtension, "network"), DateCaster.toDateAdvanced(getAttr(xmlExtension, "created"), null, null), getAttr(xmlExtension, "type"));
    }
    config.setExtensions(extensions);
}
Also used : MalformedURLException(java.net.MalformedURLException) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Element(org.w3c.dom.Element) RHExtensionProvider(lucee.runtime.extension.RHExtensionProvider) ExtensionProvider(lucee.runtime.extension.ExtensionProvider) ExtensionProviderImpl(lucee.runtime.extension.ExtensionProviderImpl) lucee.aprint(lucee.aprint) RHExtensionProvider(lucee.runtime.extension.RHExtensionProvider) Extension(lucee.runtime.extension.Extension) RHExtension(lucee.runtime.extension.RHExtension) ExtensionImpl(lucee.runtime.extension.ExtensionImpl) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap)

Example 2 with ExtensionProvider

use of lucee.runtime.extension.ExtensionProvider in project Lucee by lucee.

the class Admin method doGetExtensionProviders.

private void doGetExtensionProviders() throws PageException {
    ExtensionProvider[] providers = config.getExtensionProviders();
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "url", "isReadOnly" }, providers.length, "query");
    ExtensionProvider provider;
    for (int i = 0; i < providers.length; i++) {
        provider = providers[i];
        int row = i + 1;
        // qry.setAt("name",row,provider.getName());
        qry.setAt(KeyConstants._url, row, provider.getUrlAsString());
        qry.setAt("isReadOnly", row, Caster.toBoolean(provider.isReadOnly()));
    // qry.setAt("cacheTimeout",row,Caster.toDouble(provider.getCacheTimeout()/1000));
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) RHExtensionProvider(lucee.runtime.extension.RHExtensionProvider) ExtensionProvider(lucee.runtime.extension.ExtensionProvider) Query(lucee.runtime.type.Query)

Aggregations

ExtensionProvider (lucee.runtime.extension.ExtensionProvider)2 RHExtensionProvider (lucee.runtime.extension.RHExtensionProvider)2 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 lucee.aprint (lucee.aprint)1 Extension (lucee.runtime.extension.Extension)1 ExtensionImpl (lucee.runtime.extension.ExtensionImpl)1 ExtensionProviderImpl (lucee.runtime.extension.ExtensionProviderImpl)1 RHExtension (lucee.runtime.extension.RHExtension)1 Query (lucee.runtime.type.Query)1 QueryImpl (lucee.runtime.type.QueryImpl)1 Element (org.w3c.dom.Element)1