Search in sources :

Example 1 with ExtensionImpl

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

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

the class Admin method doUpdateExtension.

private void doUpdateExtension() throws PageException {
    admin.updateExtension(pageContext, new ExtensionImpl(getStruct("config", null), getString("admin", "UpdateExtensions", "id"), getString("admin", "UpdateExtensions", "provider"), getString("admin", "UpdateExtensions", "version"), getString("admin", "UpdateExtensions", "name"), getString("label", ""), getString("description", ""), getString("category", ""), getString("image", ""), getString("author", ""), getString("codename", ""), getString("video", ""), getString("support", ""), getString("documentation", ""), getString("forum", ""), getString("mailinglist", ""), getString("network", ""), getDateTime("created", null), getString("admin", "UpdateExtensions", "_type")));
    store();
// adminSync.broadcast(attributes, config);
}
Also used : ExtensionImpl(lucee.runtime.extension.ExtensionImpl)

Aggregations

ExtensionImpl (lucee.runtime.extension.ExtensionImpl)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 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