Search in sources :

Example 1 with Extension

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

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

the class Admin method doGetExtensions.

private void doGetExtensions() throws PageException {
    Extension[] extensions = config.getExtensions();
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "type", "provider", "id", "config", "version", "category", "description", "image", "label", "name", "author", "codename", "video", "support", "documentation", "forum", "mailinglist", "network", "created" }, 0, "query");
    String provider = getString("provider", null);
    String id = getString("id", null);
    Extension extension;
    String extProvider, extId;
    int row = 0;
    for (int i = 0; i < extensions.length; i++) {
        extension = extensions[i];
        if (!extension.getType().equalsIgnoreCase("all") && toType(extension.getType(), false) != type)
            continue;
        extProvider = extension.getProvider();
        extId = extension.getId();
        if (provider != null && !provider.equalsIgnoreCase(extProvider))
            continue;
        if (id != null && !id.equalsIgnoreCase(extId))
            continue;
        qry.addRow();
        row++;
        qry.setAt("provider", row, extProvider);
        qry.setAt(KeyConstants._id, row, extId);
        qry.setAt(KeyConstants._config, row, extension.getConfig(pageContext));
        qry.setAt(KeyConstants._version, row, extension.getVersion());
        qry.setAt("category", row, extension.getCategory());
        qry.setAt(KeyConstants._description, row, extension.getDescription());
        qry.setAt("image", row, extension.getImage());
        qry.setAt(KeyConstants._label, row, extension.getLabel());
        qry.setAt(KeyConstants._name, row, extension.getName());
        qry.setAt(KeyConstants._author, row, extension.getAuthor());
        qry.setAt("codename", row, extension.getCodename());
        qry.setAt("video", row, extension.getVideo());
        qry.setAt("support", row, extension.getSupport());
        qry.setAt("documentation", row, extension.getDocumentation());
        qry.setAt("forum", row, extension.getForum());
        qry.setAt("mailinglist", row, extension.getMailinglist());
        qry.setAt("network", row, extension.getNetwork());
        qry.setAt(KeyConstants._created, row, extension.getCreated());
        qry.setAt(KeyConstants._type, row, extension.getType());
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : Extension(lucee.runtime.extension.Extension) RHExtension(lucee.runtime.extension.RHExtension) QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query)

Aggregations

Extension (lucee.runtime.extension.Extension)2 RHExtension (lucee.runtime.extension.RHExtension)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 ExtensionImpl (lucee.runtime.extension.ExtensionImpl)1 ExtensionProvider (lucee.runtime.extension.ExtensionProvider)1 ExtensionProviderImpl (lucee.runtime.extension.ExtensionProviderImpl)1 RHExtensionProvider (lucee.runtime.extension.RHExtensionProvider)1 Query (lucee.runtime.type.Query)1 QueryImpl (lucee.runtime.type.QueryImpl)1 Element (org.w3c.dom.Element)1