mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21: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.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
|
||||
|
Loading…
Reference in New Issue
Block a user