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);
}
Aggregations