Search in sources :

Example 1 with ExtensionProviderImpl

use of lucee.runtime.extension.ExtensionProviderImpl 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)

Aggregations

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 ExtensionProvider (lucee.runtime.extension.ExtensionProvider)1 ExtensionProviderImpl (lucee.runtime.extension.ExtensionProviderImpl)1 RHExtension (lucee.runtime.extension.RHExtension)1 RHExtensionProvider (lucee.runtime.extension.RHExtensionProvider)1 Element (org.w3c.dom.Element)1