mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
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 <github@klug.nrw>
This commit is contained in:
parent
13beca58ce
commit
603988a963
@ -25,6 +25,8 @@ import org.apache.karaf.features.FeaturesService;
|
|||||||
import org.openhab.core.addon.Addon;
|
import org.openhab.core.addon.Addon;
|
||||||
import org.openhab.core.addon.AddonService;
|
import org.openhab.core.addon.AddonService;
|
||||||
import org.openhab.core.addon.AddonType;
|
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.Activate;
|
||||||
import org.osgi.service.component.annotations.Component;
|
import org.osgi.service.component.annotations.Component;
|
||||||
import org.osgi.service.component.annotations.Reference;
|
import org.osgi.service.component.annotations.Reference;
|
||||||
@ -48,12 +50,15 @@ public class KarafAddonService implements AddonService {
|
|||||||
|
|
||||||
private final FeaturesService featuresService;
|
private final FeaturesService featuresService;
|
||||||
private final FeatureInstaller featureInstaller;
|
private final FeatureInstaller featureInstaller;
|
||||||
|
private final BindingInfoRegistry bindingInfoRegistry;
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
public KarafAddonService(final @Reference FeatureInstaller featureInstaller,
|
public KarafAddonService(final @Reference FeatureInstaller featureInstaller,
|
||||||
final @Reference FeaturesService featuresService) {
|
final @Reference FeaturesService featuresService,
|
||||||
|
final @Reference BindingInfoRegistry bindingInfoRegistry) {
|
||||||
this.featureInstaller = featureInstaller;
|
this.featureInstaller = featureInstaller;
|
||||||
this.featuresService = featuresService;
|
this.featuresService = featuresService;
|
||||||
|
this.bindingInfoRegistry = bindingInfoRegistry;
|
||||||
typeList.add(new AddonType(FeatureInstaller.EXTENSION_TYPE_AUTOMATION, "Automation"));
|
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_BINDING, "Bindings"));
|
||||||
typeList.add(new AddonType(FeatureInstaller.EXTENSION_TYPE_MISC, "Misc"));
|
typeList.add(new AddonType(FeatureInstaller.EXTENSION_TYPE_MISC, "Misc"));
|
||||||
@ -111,12 +116,20 @@ public class KarafAddonService implements AddonService {
|
|||||||
String name = getName(feature.getName());
|
String name = getName(feature.getName());
|
||||||
String type = getType(feature.getName());
|
String type = getType(feature.getName());
|
||||||
String link = null;
|
String link = null;
|
||||||
|
String configDescriptionURI = "";
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FeatureInstaller.EXTENSION_TYPE_AUTOMATION:
|
case FeatureInstaller.EXTENSION_TYPE_AUTOMATION:
|
||||||
link = "https://www.openhab.org/addons/automation/" + name + "/";
|
link = "https://www.openhab.org/addons/automation/" + name + "/";
|
||||||
break;
|
break;
|
||||||
case FeatureInstaller.EXTENSION_TYPE_BINDING:
|
case FeatureInstaller.EXTENSION_TYPE_BINDING:
|
||||||
link = "https://www.openhab.org/addons/bindings/" + name + "/";
|
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;
|
break;
|
||||||
case FeatureInstaller.EXTENSION_TYPE_MISC:
|
case FeatureInstaller.EXTENSION_TYPE_MISC:
|
||||||
// Not possible to define URL
|
// Not possible to define URL
|
||||||
@ -148,7 +161,8 @@ public class KarafAddonService implements AddonService {
|
|||||||
return Addon.create(type + "-" + name).withType(type).withLabel(feature.getDescription())
|
return Addon.create(type + "-" + name).withType(type).withLabel(feature.getDescription())
|
||||||
.withVersion(feature.getVersion()).withContentType(ADDONS_CONTENTTYPE).withLink(link)
|
.withVersion(feature.getVersion()).withContentType(ADDONS_CONTENTTYPE).withLink(link)
|
||||||
.withLoggerPackages(packages).withAuthor(ADDONS_AUTHOR, true)
|
.withLoggerPackages(packages).withAuthor(ADDONS_AUTHOR, true)
|
||||||
.withInstalled(featuresService.isInstalled(feature)).build();
|
.withConfigDescriptionURI(configDescriptionURI).withInstalled(featuresService.isInstalled(feature))
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user