Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove package support from FeatureInstaller #3634

Merged
merged 1 commit into from May 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -83,8 +83,6 @@ public class FeatureInstaller implements ConfigurationListener {
protected static final String CONFIG_URI = "system:addons";

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 PAX_URL_PID = "org.ops4j.pax.url.mvn";
Expand Down Expand Up @@ -191,13 +189,6 @@ private synchronized void processConfigQueue() {
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)) {
changed = true;
}
Expand Down Expand Up @@ -278,7 +269,7 @@ private void waitForConfigUpdateEvent() {
private void changeAddonConfig(String type, String id, BiFunction<Collection<String>, String, Boolean> method)
throws IOException {
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);
String[] addonIds = typeProp != null ? typeProp.toString().split(",") : new String[0];
Set<String> normalizedIds = new HashSet<>(); // sets don't allow duplicates
Expand Down Expand Up @@ -512,27 +503,6 @@ private void uninstallFeature(String name) {
}
}

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) {
String extensionId = featureName.substring(PREFIX.length());
Event event = AddonEventFactory.createAddonInstalledEvent(extensionId);
Expand Down