From 603988a96350a5640ea42725349e3652b8af0f58 Mon Sep 17 00:00:00 2001 From: J-N-K Date: Sun, 17 Jul 2022 21:04:25 +0200 Subject: [PATCH] Enrich distribution add-on with configDescriptionURI (#3045) When changing to addon.xml later, this can be extended to all add-ons. It is necessary to improve the UI code for changing add-on log levels. Signed-off-by: Jan N. Klug --- .../core/karaf/internal/KarafAddonService.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java index 3f7805af8..65d38b037 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java @@ -25,6 +25,8 @@ import org.apache.karaf.features.FeaturesService; import org.openhab.core.addon.Addon; import org.openhab.core.addon.AddonService; import org.openhab.core.addon.AddonType; +import org.openhab.core.binding.BindingInfo; +import org.openhab.core.binding.BindingInfoRegistry; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -48,12 +50,15 @@ public class KarafAddonService implements AddonService { private final FeaturesService featuresService; private final FeatureInstaller featureInstaller; + private final BindingInfoRegistry bindingInfoRegistry; @Activate public KarafAddonService(final @Reference FeatureInstaller featureInstaller, - final @Reference FeaturesService featuresService) { + final @Reference FeaturesService featuresService, + final @Reference BindingInfoRegistry bindingInfoRegistry) { this.featureInstaller = featureInstaller; this.featuresService = featuresService; + this.bindingInfoRegistry = bindingInfoRegistry; typeList.add(new AddonType(FeatureInstaller.EXTENSION_TYPE_AUTOMATION, "Automation")); typeList.add(new AddonType(FeatureInstaller.EXTENSION_TYPE_BINDING, "Bindings")); typeList.add(new AddonType(FeatureInstaller.EXTENSION_TYPE_MISC, "Misc")); @@ -111,12 +116,20 @@ public class KarafAddonService implements AddonService { String name = getName(feature.getName()); String type = getType(feature.getName()); String link = null; + String configDescriptionURI = ""; switch (type) { case FeatureInstaller.EXTENSION_TYPE_AUTOMATION: link = "https://www.openhab.org/addons/automation/" + name + "/"; break; case FeatureInstaller.EXTENSION_TYPE_BINDING: link = "https://www.openhab.org/addons/bindings/" + name + "/"; + BindingInfo bindingInfo = bindingInfoRegistry.getBindingInfo(name); + if (bindingInfo != null) { + URI uri = bindingInfo.getConfigDescriptionURI(); + if (uri != null) { + configDescriptionURI = uri.toString(); + } + } break; case FeatureInstaller.EXTENSION_TYPE_MISC: // Not possible to define URL @@ -148,7 +161,8 @@ public class KarafAddonService implements AddonService { return Addon.create(type + "-" + name).withType(type).withLabel(feature.getDescription()) .withVersion(feature.getVersion()).withContentType(ADDONS_CONTENTTYPE).withLink(link) .withLoggerPackages(packages).withAuthor(ADDONS_AUTHOR, true) - .withInstalled(featuresService.isInstalled(feature)).build(); + .withConfigDescriptionURI(configDescriptionURI).withInstalled(featuresService.isInstalled(feature)) + .build(); } @Override