mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Remove package support from FeatureInstaller (#3634)
Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
+1
-31
@@ -83,8 +83,6 @@ public class FeatureInstaller implements ConfigurationListener {
|
|||||||
protected static final String CONFIG_URI = "system:addons";
|
protected static final String CONFIG_URI = "system:addons";
|
||||||
|
|
||||||
public static final String PREFIX = "openhab-";
|
public static final String PREFIX = "openhab-";
|
||||||
public static final String PREFIX_PACKAGE = "package-";
|
|
||||||
public static final String MINIMAL_PACKAGE = "minimal";
|
|
||||||
|
|
||||||
private static final String CFG_REMOTE = "remote";
|
private static final String CFG_REMOTE = "remote";
|
||||||
private static final String PAX_URL_PID = "org.ops4j.pax.url.mvn";
|
private static final String PAX_URL_PID = "org.ops4j.pax.url.mvn";
|
||||||
@@ -191,13 +189,6 @@ public class FeatureInstaller implements ConfigurationListener {
|
|||||||
waitForConfigUpdateEvent();
|
waitForConfigUpdateEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installPackage(config)) {
|
|
||||||
changed = true;
|
|
||||||
// our package selection has changed, so let's wait for the values to be available in config admin
|
|
||||||
// which we will receive as another call to modified
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installAddons(config)) {
|
if (installAddons(config)) {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -278,7 +269,7 @@ public class FeatureInstaller implements ConfigurationListener {
|
|||||||
private void changeAddonConfig(String type, String id, BiFunction<Collection<String>, String, Boolean> method)
|
private void changeAddonConfig(String type, String id, BiFunction<Collection<String>, String, Boolean> method)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Configuration cfg = configurationAdmin.getConfiguration(OpenHAB.ADDONS_SERVICE_PID, null);
|
Configuration cfg = configurationAdmin.getConfiguration(OpenHAB.ADDONS_SERVICE_PID, null);
|
||||||
Dictionary<String, Object> props = cfg.getProperties();
|
Dictionary<String, Object> props = Objects.requireNonNullElse(cfg.getProperties(), new Hashtable<>());
|
||||||
Object typeProp = props.get(type);
|
Object typeProp = props.get(type);
|
||||||
String[] addonIds = typeProp != null ? typeProp.toString().split(",") : new String[0];
|
String[] addonIds = typeProp != null ? typeProp.toString().split(",") : new String[0];
|
||||||
Set<String> normalizedIds = new HashSet<>(); // sets don't allow duplicates
|
Set<String> normalizedIds = new HashSet<>(); // sets don't allow duplicates
|
||||||
@@ -512,27 +503,6 @@ public class FeatureInstaller implements ConfigurationListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean installPackage(final Map<String, Object> config) {
|
|
||||||
boolean configChanged = false;
|
|
||||||
Object packageName = config.get(OpenHAB.CFG_PACKAGE);
|
|
||||||
if (packageName instanceof String currentPackage) {
|
|
||||||
String fullName = PREFIX + PREFIX_PACKAGE + currentPackage.strip();
|
|
||||||
if (!MINIMAL_PACKAGE.equals(currentPackage)) {
|
|
||||||
configChanged = installFeature(fullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// uninstall all other packages
|
|
||||||
try {
|
|
||||||
Stream.of(featuresService.listFeatures()).map(Feature::getName)
|
|
||||||
.filter(feature -> feature.startsWith(PREFIX + PREFIX_PACKAGE) && !feature.equals(fullName))
|
|
||||||
.forEach(this::uninstallFeature);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Failed retrieving features: {}", e.getMessage(), debugException(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return configChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void postInstalledEvent(String featureName) {
|
private void postInstalledEvent(String featureName) {
|
||||||
String extensionId = featureName.substring(PREFIX.length());
|
String extensionId = featureName.substring(PREFIX.length());
|
||||||
Event event = AddonEventFactory.createAddonInstalledEvent(extensionId);
|
Event event = AddonEventFactory.createAddonInstalledEvent(extensionId);
|
||||||
|
|||||||
Reference in New Issue
Block a user