diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
index b6dba7f6b52..e59b9702af4 100644
--- a/.github/workflows/ci-build.yml
+++ b/.github/workflows/ci-build.yml
@@ -19,23 +19,23 @@ jobs:
fail-fast: false
matrix:
java: [ '17' ]
- maven: [ '3.9.4' ]
+ maven: [ '3.9.6' ]
os: [ 'ubuntu-22.04' ]
name: Build (Java ${{ matrix.java }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
if: github.head_ref == ''
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Checkout merge
if: github.head_ref != ''
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: Set up Cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: |
~/.m2/repository
@@ -45,13 +45,13 @@ jobs:
${{ runner.os }}-maven-
- name: Set up Java ${{ matrix.java }}
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Set up Maven ${{ matrix.maven }}
- uses: stCarolas/setup-maven@v4.5
+ uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ matrix.maven }}
@@ -73,14 +73,14 @@ jobs:
- name: Upload Build Log
if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: build-log-java-${{ matrix.java }}-${{ matrix.os }}
path: build.log
- name: Upload SAT Summary Report
if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: sat-summary-report
path: target/summary_report.html
diff --git a/README.md b/README.md
index 06b306d29ac..1ce5ff03b59 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
[![GitHub Actions Build Status](https://github.com/openhab/openhab-core/actions/workflows/ci-build.yml/badge.svg?branch=main)](https://github.com/openhab/openhab-core/actions/workflows/ci-build.yml)
[![Jenkins Build Status](https://ci.openhab.org/job/openHAB-Core/badge/icon)](https://ci.openhab.org/job/openHAB-Core/)
+[![JavaDoc Build Status](https://ci.openhab.org/view/Documentation/job/openHAB-JavaDoc/badge/icon?subject=javadoc)](https://ci.openhab.org/view/Documentation/job/openHAB-JavaDoc/)
[![EPL-2.0](https://img.shields.io/badge/license-EPL%202-green.svg)](https://opensource.org/licenses/EPL-2.0)
[![Crowdin](https://badges.crowdin.net/openhab-core/localized.svg)](https://crowdin.com/project/openhab-core)
diff --git a/bom/compile-model/pom.xml b/bom/compile-model/pom.xml
index 1e978a5f069..278ac411205 100644
--- a/bom/compile-model/pom.xml
+++ b/bom/compile-model/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.compile-model
diff --git a/bom/compile/pom.xml b/bom/compile/pom.xml
index 856dd33e40d..0636f906400 100644
--- a/bom/compile/pom.xml
+++ b/bom/compile/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.compile
@@ -195,7 +195,7 @@
org.jmdnsjmdns
- 3.5.7
+ 3.5.9compile
@@ -203,8 +203,7 @@
org.jupnporg.jupnp
-
- 2.7.1.OH1
+ 3.0.0compile
@@ -364,20 +363,10 @@
- de.jollyday
- jollyday
- 0.5.10
+ de.focus-shift
+ jollyday-jackson
+ 0.23.2compile
-
-
- javax.xml.bind
- jaxb-api
-
-
- org.glassfish.jaxb
- jaxb-runtime
-
-
diff --git a/bom/openhab-core-index/pom.xml b/bom/openhab-core-index/pom.xml
index 965df57110d..95effdb3115 100644
--- a/bom/openhab-core-index/pom.xml
+++ b/bom/openhab-core-index/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.openhab-core-index
diff --git a/bom/openhab-core/pom.xml b/bom/openhab-core/pom.xml
index e8f72da9320..905bfb7e0fd 100644
--- a/bom/openhab-core/pom.xml
+++ b/bom/openhab-core/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.openhab-core
@@ -304,6 +304,42 @@
${project.version}compile
+
+ org.openhab.core.bundles
+ org.openhab.core.config.discovery.addon
+ ${project.version}
+ compile
+
+
+ org.openhab.core.bundles
+ org.openhab.core.config.discovery.addon.ip
+ ${project.version}
+ compile
+
+
+ org.openhab.core.bundles
+ org.openhab.core.config.discovery.addon.mdns
+ ${project.version}
+ compile
+
+
+ org.openhab.core.bundles
+ org.openhab.core.config.discovery.addon.process
+ ${project.version}
+ compile
+
+
+ org.openhab.core.bundles
+ org.openhab.core.config.discovery.addon.upnp
+ ${project.version}
+ compile
+
+
+ org.openhab.core.bundles
+ org.openhab.core.config.discovery.addon.usb
+ ${project.version}
+ compile
+ org.openhab.core.bundlesorg.openhab.core.config.discovery.mdns
@@ -340,6 +376,12 @@
${project.version}compile
+
+ org.openhab.core.bundles
+ org.openhab.core.config.jupnp
+ ${project.version}
+ compile
+ org.openhab.core.bundlesorg.openhab.core.config.serial
@@ -496,6 +538,12 @@
${project.version}compile
+
+ org.openhab.core.bundles
+ org.openhab.core.model.yaml
+ ${project.version}
+ compile
+ org.openhab.core.bundlesorg.openhab.core.ui
diff --git a/bom/pom.xml b/bom/pom.xml
index 45c66587d4a..c8c08e84cf1 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -7,7 +7,7 @@
org.openhab.coreorg.openhab.core.reactor
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom
diff --git a/bom/runtime-index/pom.xml b/bom/runtime-index/pom.xml
index f1c2ec9a301..b2d08cf386c 100644
--- a/bom/runtime-index/pom.xml
+++ b/bom/runtime-index/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.runtime-index
diff --git a/bom/runtime/pom.xml b/bom/runtime/pom.xml
index 9d6d8a7041e..30d434af8f6 100644
--- a/bom/runtime/pom.xml
+++ b/bom/runtime/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.runtime
@@ -18,7 +18,7 @@
2.7.43.6.2
- 2.15.2
+ 2.16.09.4.52.v202308232.2.38.0.22
@@ -61,6 +61,12 @@
1.5.0compile
+
+ org.osgi
+ org.osgi.service.component.annotations
+ 1.5.0
+ compile
+ org.apache.felixorg.apache.felix.scr
@@ -461,7 +467,7 @@
org.jmdnsjmdns
- 3.5.8
+ 3.5.9compile
@@ -469,8 +475,7 @@
org.jupnporg.jupnp
-
- 2.7.1.OH1
+ 3.0.0compile
@@ -942,20 +947,10 @@
- de.jollyday
- jollyday
- 0.5.10
+ de.focus-shift
+ jollyday-jackson
+ 0.23.2compile
-
-
- javax.xml.bind
- jaxb-api
-
-
- org.glassfish.jaxb
- jaxb-runtime
-
-
diff --git a/bom/test-index/pom.xml b/bom/test-index/pom.xml
index 03525fcad77..fe176069958 100644
--- a/bom/test-index/pom.xml
+++ b/bom/test-index/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.test-index
diff --git a/bom/test/pom.xml b/bom/test/pom.xml
index 90ac8d337ad..854438f2870 100644
--- a/bom/test/pom.xml
+++ b/bom/test/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bomorg.openhab.core.reactor.bom
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.bom.test
@@ -65,7 +65,7 @@
com.jayway.jsonpathjson-path
- 2.8.0
+ 2.9.0org.apache.aries.jax.rs
diff --git a/bundles/org.openhab.core.addon.eclipse/pom.xml b/bundles/org.openhab.core.addon.eclipse/pom.xml
index 1d5c0f10f8f..1b519d2e27a 100644
--- a/bundles/org.openhab.core.addon.eclipse/pom.xml
+++ b/bundles/org.openhab.core.addon.eclipse/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.addon.eclipse
diff --git a/bundles/org.openhab.core.addon.eclipse/src/main/java/org/openhab/core/addon/eclipse/internal/EclipseAddonService.java b/bundles/org.openhab.core.addon.eclipse/src/main/java/org/openhab/core/addon/eclipse/internal/EclipseAddonService.java
index 6e5f063850a..08d79eda2d9 100644
--- a/bundles/org.openhab.core.addon.eclipse/src/main/java/org/openhab/core/addon/eclipse/internal/EclipseAddonService.java
+++ b/bundles/org.openhab.core.addon.eclipse/src/main/java/org/openhab/core/addon/eclipse/internal/EclipseAddonService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -142,9 +142,12 @@ private Addon getAddon(Bundle bundle, @Nullable Locale locale) {
AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale);
if (addonInfo != null) {
- // only enrich if this add-on is installed, otherwise wrong data might be added
- addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription())
- .withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
+ if (addonInfo.isMasterAddonInfo()) {
+ addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription());
+ } else {
+ addon = addon.withLabel(name);
+ }
+ addon = addon.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
.withLink(getDefaultDocumentationLink(type, name))
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI());
} else {
diff --git a/bundles/org.openhab.core.addon.marketplace.karaf/pom.xml b/bundles/org.openhab.core.addon.marketplace.karaf/pom.xml
index f8a43259cad..ee04295b653 100644
--- a/bundles/org.openhab.core.addon.marketplace.karaf/pom.xml
+++ b/bundles/org.openhab.core.addon.marketplace.karaf/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.addon.marketplace.karaf
diff --git a/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java b/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java
index 04f0f490b66..cb4875d5a2f 100644
--- a/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java
+++ b/bundles/org.openhab.core.addon.marketplace.karaf/src/main/java/org/openhab/core/addon/marketplace/karaf/internal/community/CommunityKarafAddonHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/pom.xml b/bundles/org.openhab.core.addon.marketplace/pom.xml
index 8da6c041a37..317d25824c2 100644
--- a/bundles/org.openhab.core.addon.marketplace/pom.xml
+++ b/bundles/org.openhab.core.addon.marketplace/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.addon.marketplace
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java
index 3ce55c4f6cd..5fe13694263 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -12,17 +12,22 @@
*/
package org.openhab.core.addon.marketplace;
+import static org.openhab.core.common.ThreadPoolManager.THREAD_POOL_NAME_COMMON;
+
import java.io.IOException;
import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.Dictionary;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -34,6 +39,7 @@
import org.openhab.core.addon.AddonService;
import org.openhab.core.addon.AddonType;
import org.openhab.core.cache.ExpiringCache;
+import org.openhab.core.common.ThreadPoolManager;
import org.openhab.core.config.core.ConfigParser;
import org.openhab.core.events.Event;
import org.openhab.core.events.EventPublisher;
@@ -58,6 +64,25 @@
public abstract class AbstractRemoteAddonService implements AddonService {
static final String CONFIG_REMOTE_ENABLED = "remote";
static final String CONFIG_INCLUDE_INCOMPATIBLE = "includeIncompatible";
+ static final Comparator BY_COMPATIBLE_AND_VERSION = (addon1, addon2) -> {
+ // prefer compatible to incompatible
+ int compatible = Boolean.compare(addon2.getCompatible(), addon1.getCompatible());
+ if (compatible != 0) {
+ return compatible;
+ }
+ try {
+ // Add-on versions often contain a dash instead of a dot as separator for the qualifier (e.g. -SNAPSHOT)
+ // This is not a valid format and everything after the dash needs to be removed.
+ BundleVersion version1 = new BundleVersion(addon1.getVersion().replaceAll("-.*", ".0"));
+ BundleVersion version2 = new BundleVersion(addon2.getVersion().replaceAll("-.*", ".0"));
+
+ // prefer newer version over older
+ return version2.compareTo(version1);
+ } catch (IllegalArgumentException e) {
+ // assume they are equal (for ordering) if we can't compare the versions
+ return 0;
+ }
+ };
protected final BundleVersion coreVersion;
@@ -73,8 +98,9 @@ public abstract class AbstractRemoteAddonService implements AddonService {
protected List installedAddons = List.of();
private final Logger logger = LoggerFactory.getLogger(AbstractRemoteAddonService.class);
+ private final ScheduledExecutorService scheduler = ThreadPoolManager.getScheduledPool(THREAD_POOL_NAME_COMMON);
- public AbstractRemoteAddonService(EventPublisher eventPublisher, ConfigurationAdmin configurationAdmin,
+ protected AbstractRemoteAddonService(EventPublisher eventPublisher, ConfigurationAdmin configurationAdmin,
StorageService storageService, AddonInfoRegistry addonInfoRegistry, String servicePid) {
this.addonInfoRegistry = addonInfoRegistry;
this.eventPublisher = eventPublisher;
@@ -104,9 +130,14 @@ public void refreshSource() {
getClass());
return;
}
+
List addons = new ArrayList<>();
+
+ // retrieve add-ons that should be available from storage and check if they are really installed
+ // this is safe, because the {@link AddonHandler}s only report ready when they installed everything from the
+ // cache
try {
- installedAddonStorage.stream().map(this::convertFromStorage).forEach(addons::add);
+ installedAddonStorage.stream().map(this::convertFromStorage).peek(this::setInstalled).forEach(addons::add);
} catch (JsonSyntaxException e) {
List.copyOf(installedAddonStorage.getKeys()).forEach(installedAddonStorage::remove);
logger.error(
@@ -115,24 +146,45 @@ public void refreshSource() {
refreshSource();
}
+ // remove not installed add-ons from the add-ons list, but remember their UIDs to re-install them
+ List missingAddons = addons.stream().filter(addon -> !addon.isInstalled()).map(Addon::getUid).toList();
+ missingAddons.forEach(installedAddonStorage::remove);
+ addons.removeIf(addon -> missingAddons.contains(addon.getUid()));
+
// create lookup list to make sure installed addons take precedence
List installedAddons = addons.stream().map(Addon::getUid).toList();
+ // get the remote addons
if (remoteEnabled()) {
List remoteAddons = Objects.requireNonNullElse(cachedRemoteAddons.getValue(), List.of());
- remoteAddons.stream().filter(a -> !installedAddons.contains(a.getUid())).forEach(addons::add);
+ remoteAddons.stream().filter(a -> !installedAddons.contains(a.getUid())).peek(this::setInstalled)
+ .forEach(addons::add);
}
- // check real installation status based on handlers
- addons.forEach(
- addon -> addon.setInstalled(addonHandlers.stream().anyMatch(h -> h.isInstalled(addon.getUid()))));
-
// remove incompatible add-ons if not enabled
boolean showIncompatible = includeIncompatible();
addons.removeIf(addon -> !addon.isInstalled() && !addon.getCompatible() && !showIncompatible);
+ // check and remove duplicate uids
+ Map> addonMap = new HashMap<>();
+ addons.forEach(a -> addonMap.computeIfAbsent(a.getUid(), k -> new ArrayList<>()).add(a));
+ for (List partialAddonList : addonMap.values()) {
+ if (partialAddonList.size() > 1) {
+ partialAddonList.stream().sorted(BY_COMPATIBLE_AND_VERSION).skip(1).forEach(addons::remove);
+ }
+ }
+
cachedAddons = addons;
this.installedAddons = installedAddons;
+
+ if (!missingAddons.isEmpty()) {
+ logger.info("Re-installing missing add-ons from remote repository: {}", missingAddons);
+ scheduler.execute(() -> missingAddons.forEach(this::install));
+ }
+ }
+
+ private void setInstalled(Addon addon) {
+ addon.setInstalled(addonHandlers.stream().anyMatch(h -> h.isInstalled(addon.getUid())));
}
/**
@@ -181,52 +233,57 @@ public List getTypes(@Nullable Locale locale) {
@Override
public void install(String id) {
Addon addon = getAddon(id, null);
- if (addon != null) {
- for (MarketplaceAddonHandler handler : addonHandlers) {
- if (handler.supports(addon.getType(), addon.getContentType())) {
- if (!handler.isInstalled(addon.getUid())) {
- try {
- handler.install(addon);
- installedAddonStorage.put(id, gson.toJson(addon));
- refreshSource();
- postInstalledEvent(addon.getUid());
- } catch (MarketplaceHandlerException e) {
- postFailureEvent(addon.getUid(), e.getMessage());
- }
- } else {
- postFailureEvent(addon.getUid(), "Add-on is already installed.");
+ if (addon == null) {
+ postFailureEvent(id, "Add-on can't be installed because it is not known.");
+ return;
+ }
+ for (MarketplaceAddonHandler handler : addonHandlers) {
+ if (handler.supports(addon.getType(), addon.getContentType())) {
+ if (!handler.isInstalled(addon.getUid())) {
+ try {
+ handler.install(addon);
+ addon.setInstalled(true);
+ installedAddonStorage.put(id, gson.toJson(addon));
+ refreshSource();
+ postInstalledEvent(addon.getUid());
+ } catch (MarketplaceHandlerException e) {
+ postFailureEvent(addon.getUid(), e.getMessage());
}
- return;
+ } else {
+ postFailureEvent(addon.getUid(), "Add-on is already installed.");
}
+ return;
}
}
- postFailureEvent(id, "Add-on not known.");
+ postFailureEvent(id, "Add-on can't be installed because there is no handler for it.");
}
@Override
public void uninstall(String id) {
Addon addon = getAddon(id, null);
- if (addon != null) {
- for (MarketplaceAddonHandler handler : addonHandlers) {
- if (handler.supports(addon.getType(), addon.getContentType())) {
- if (handler.isInstalled(addon.getUid())) {
- try {
- handler.uninstall(addon);
- installedAddonStorage.remove(id);
- refreshSource();
- postUninstalledEvent(addon.getUid());
- } catch (MarketplaceHandlerException e) {
- postFailureEvent(addon.getUid(), e.getMessage());
- }
- } else {
+ if (addon == null) {
+ postFailureEvent(id, "Add-on can't be uninstalled because it is not known.");
+ return;
+ }
+ for (MarketplaceAddonHandler handler : addonHandlers) {
+ if (handler.supports(addon.getType(), addon.getContentType())) {
+ if (handler.isInstalled(addon.getUid())) {
+ try {
+ handler.uninstall(addon);
installedAddonStorage.remove(id);
- postFailureEvent(addon.getUid(), "Add-on is not installed.");
+ refreshSource();
+ postUninstalledEvent(addon.getUid());
+ } catch (MarketplaceHandlerException e) {
+ postFailureEvent(addon.getUid(), e.getMessage());
}
- return;
+ } else {
+ installedAddonStorage.remove(id);
+ postFailureEvent(addon.getUid(), "Add-on is not installed.");
}
+ return;
}
}
- postFailureEvent(id, "Add-on not known.");
+ postFailureEvent(id, "Add-on can't be uninstalled because there is no handler for it.");
}
@Override
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java
index 42b5dfa7442..bf8adc1845d 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/BundleVersion.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceAddonHandler.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceAddonHandler.java
index ad77a2a68d8..c0b60ed140b 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceAddonHandler.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceAddonHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceBundleInstaller.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceBundleInstaller.java
index 0b5a15fffc0..da86b2aaf70 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceBundleInstaller.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceBundleInstaller.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceHandlerException.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceHandlerException.java
index ba9c5f56b1c..803fffc78c2 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceHandlerException.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/MarketplaceHandlerException.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/automation/MarketplaceRuleTemplateProvider.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/automation/MarketplaceRuleTemplateProvider.java
index f4d8e6889d3..091c60f6ede 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/automation/MarketplaceRuleTemplateProvider.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/automation/MarketplaceRuleTemplateProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -129,7 +129,7 @@ public void addTemplateAsJSON(String uid, String json) throws ParsingException {
* This adds a new rule template to the persistent storage from its YAML representation.
*
* @param uid the UID to be used for the template
- * @param json the template content as a YAML string
+ * @param yaml the template content as a YAML string
*
* @throws ParsingException if the content cannot be parsed correctly
*/
@@ -137,7 +137,7 @@ public void addTemplateAsYAML(String uid, String yaml) throws ParsingException {
try {
RuleTemplateDTO dto = yamlMapper.readValue(yaml, RuleTemplateDTO.class);
// add a tag with the add-on ID to be able to identify the widget in the registry
- dto.tags = new HashSet<@Nullable String>((dto.tags != null) ? dto.tags : new HashSet());
+ dto.tags = new HashSet<@Nullable String>((dto.tags != null) ? dto.tags : new HashSet<>());
dto.tags.add(uid);
RuleTemplate entry = RuleTemplateDTOMapper.map(dto);
RuleTemplate template = new RuleTemplate(entry.getUID(), entry.getLabel(), entry.getDescription(),
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBlockLibaryAddonHandler.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBlockLibaryAddonHandler.java
index 75424c35ab4..7d2e3fb8116 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBlockLibaryAddonHandler.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBlockLibaryAddonHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBundleAddonHandler.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBundleAddonHandler.java
index 710708af7e8..71035401539 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBundleAddonHandler.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityBundleAddonHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java
index 8b278c53408..7bc9a8d3078 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityRuleTemplateAddonHandler.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityRuleTemplateAddonHandler.java
index f68ae2eb1bb..009d362eb7b 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityRuleTemplateAddonHandler.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityRuleTemplateAddonHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityUIWidgetAddonHandler.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityUIWidgetAddonHandler.java
index d69f39f2cf9..f16f38a71d2 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityUIWidgetAddonHandler.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityUIWidgetAddonHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -86,7 +86,8 @@ public void install(Addon addon) throws MarketplaceHandlerException {
} else if (yamlContent != null) {
addWidgetAsYAML(addon.getUid(), yamlContent);
} else {
- throw new IllegalArgumentException("Couldn't find the widget in the add-on entry");
+ throw new IllegalArgumentException(
+ "Couldn't find the widget in the add-on entry. The starting code fence may not be marked as ```yaml");
}
} catch (IOException e) {
logger.error("Widget from marketplace cannot be downloaded: {}", e.getMessage());
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java
index fb55deabd6b..b1f1f4e2641 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/SerializedNameAnnotationIntrospector.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseCategoryResponseDTO.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseCategoryResponseDTO.java
index a6ff9f77dee..98dc7bbbe7c 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseCategoryResponseDTO.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseCategoryResponseDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseTopicResponseDTO.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseTopicResponseDTO.java
index 13b4daf2c45..12caf21dc4c 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseTopicResponseDTO.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/model/DiscourseTopicResponseDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java
index 362f5311ea1..b8d4d03d551 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/JsonAddonService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -34,6 +34,7 @@
import org.openhab.core.addon.marketplace.AbstractRemoteAddonService;
import org.openhab.core.addon.marketplace.MarketplaceAddonHandler;
import org.openhab.core.addon.marketplace.internal.json.model.AddonEntryDTO;
+import org.openhab.core.config.core.ConfigParser;
import org.openhab.core.config.core.ConfigurableService;
import org.openhab.core.events.EventPublisher;
import org.openhab.core.storage.StorageService;
@@ -87,9 +88,9 @@ public JsonAddonService(@Reference EventPublisher eventPublisher, @Reference Sto
@Modified
public void modified(@Nullable Map config) {
if (config != null) {
- String urls = Objects.requireNonNullElse((String) config.get(CONFIG_URLS), "");
+ String urls = ConfigParser.valueAsOrElse(config.get(CONFIG_URLS), String.class, "");
addonServiceUrls = Arrays.asList(urls.split("\\|"));
- showUnstable = (Boolean) config.getOrDefault(CONFIG_SHOW_UNSTABLE, false);
+ showUnstable = ConfigParser.valueAsOrElse(config.get(CONFIG_SHOW_UNSTABLE), Boolean.class, false);
cachedRemoteAddons.invalidateValue();
refreshSource();
}
@@ -131,8 +132,26 @@ protected List getRemoteAddons() {
} catch (IOException e) {
return List.of();
}
- }).flatMap(List::stream).filter(Objects::nonNull).map(e -> (AddonEntryDTO) e)
- .filter(e -> showUnstable || "stable".equals(e.maturity)).map(this::fromAddonEntry).toList();
+ }).flatMap(List::stream).filter(Objects::nonNull).map(e -> (AddonEntryDTO) e).filter(this::showAddon)
+ .map(this::fromAddonEntry).toList();
+ }
+
+ /**
+ * Check if the addon UID is present and the entry is eitehr stable or unstable add-ons are requested
+ *
+ * @param addonEntry the add-on entry to check
+ * @return {@code true} if the add-on entry should be processed, {@code false otherwise}
+ */
+ private boolean showAddon(AddonEntryDTO addonEntry) {
+ if (addonEntry.uid.isBlank()) {
+ logger.debug("Skipping {} because the UID is not set", addonEntry);
+ return false;
+ }
+ if (!showUnstable && !"stable".equals(addonEntry.maturity)) {
+ logger.debug("Skipping {} because the the add-on is not stable and showUnstable is disabled.", addonEntry);
+ return false;
+ }
+ return true;
}
@Override
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/model/AddonEntryDTO.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/model/AddonEntryDTO.java
index 227c4c42524..3875b5f700e 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/model/AddonEntryDTO.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/json/model/AddonEntryDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/resources/OH-INF/i18n/marketplace_da.properties b/bundles/org.openhab.core.addon.marketplace/src/main/resources/OH-INF/i18n/marketplace_da.properties
new file mode 100644
index 00000000000..88cf83ceb55
--- /dev/null
+++ b/bundles/org.openhab.core.addon.marketplace/src/main/resources/OH-INF/i18n/marketplace_da.properties
@@ -0,0 +1,13 @@
+system.config.jsonaddonservice.showUnstable.label = Vis ustabile tilføjelser
+system.config.jsonaddonservice.showUnstable.description = Inkludér poster, der ikke er blevet mærket som "stabile". Disse tilføjelser bør kun anvendes til testformål og anses ikke for at være klar til produktionssystemer.
+system.config.jsonaddonservice.urls.label = Tjeneste-URL'er for tilføjelser
+system.config.jsonaddonservice.urls.description = Pipe (|)-separeret liste af URL'er der leverer tredjeparts tilføjelsestjenester via JSON-filer. Advarsel\: Bundles distribueret over tredjeparts tilføjelsestjenester kan mangle ordentlig gennemgang og kan potentielt indeholde ondsindet kode og dermed forvolde skade på dit system.
+system.config.marketplace.apiKey.label = API-nøgle for community.openhab.org
+system.config.marketplace.apiKey.description = Angiv API-nøglen, der skal bruges på community-forummet (for stab og kuratorer - dette giver mulighed for fx at se indhold, der endnu ikke er gennemgået eller som på anden måde er skjult for den brede offentlighed). Efterlad tomt, hvis du ikke har en.
+system.config.marketplace.enable.label = Aktiver Community Marketplace
+system.config.marketplace.enable.description = Hvis deaktiveret vil tilføjelser fra Community Marketplace ikke blive vist. Allerede installerede tilføjelser vil stadig være tilgængelige.
+system.config.marketplace.showUnpublished.label = Vis upublicerede poster
+system.config.marketplace.showUnpublished.description = Inkludér poster, der ikke er blevet mærket som publicerede. Advarsel\: Dette kan omfatte poster, der ikke er klar og måske ikke virker eller forårsager skade på din installation. Aktiver på egen risiko, kun til testformål.
+
+service.system.marketplace.label = Community Marketplace
+service.system.jsonaddonservice.label = JSON tredjeparts-tilføjelsestjeneste
diff --git a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonServiceTest.java b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonServiceTest.java
index dac9fa3fc09..577aeafbf92 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonServiceTest.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/AbstractRemoteAddonServiceTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -13,11 +13,8 @@
package org.openhab.core.addon.marketplace;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.*;
+import static org.mockito.Mockito.*;
import static org.openhab.core.addon.marketplace.AbstractRemoteAddonService.CONFIG_REMOTE_ENABLED;
import static org.openhab.core.addon.marketplace.test.TestAddonService.ALL_ADDON_COUNT;
import static org.openhab.core.addon.marketplace.test.TestAddonService.COMPATIBLE_ADDON_COUNT;
@@ -31,6 +28,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
+import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.BeforeEach;
@@ -247,13 +245,44 @@ public void testAddonUninstallFailsOnUnknownAddon() {
}
@Test
- public void testAddonUninstallRemovesStorageEntryOnUninstalledAddon() {
+ public void testUninstalledAddonIsReinstalled() {
addonService.addToStorage(TEST_ADDON);
addonService.getAddons(null);
- addonService.uninstall(TEST_ADDON);
+ checkResult(TEST_ADDON, getFullAddonId(TEST_ADDON) + "/installed", true, true);
+ }
- checkResult(TEST_ADDON, getFullAddonId(TEST_ADDON) + "/failed", false, true);
+ // add-comparisons
+ @Test
+ public void testAddonOrdering() {
+ Addon addon1 = getMockedAddon("4.1.0", false);
+ Addon addon2 = getMockedAddon("4.2.0", true);
+ Addon addon3 = getMockedAddon("4.1.4", false);
+ Addon addon4 = getMockedAddon("4.2.1", true);
+ List actual = Stream.of(addon1, addon2, addon3, addon4)
+ .sorted(AbstractRemoteAddonService.BY_COMPATIBLE_AND_VERSION).toList();
+ List expected = List.of(addon4, addon2, addon3, addon1);
+
+ assertThat(actual, is(equalTo(expected)));
+ }
+
+ @Test
+ public void testSnapshotVersionsAreParsedProperly() {
+ Addon addon1 = getMockedAddon("4.1.0", true);
+ Addon addon2 = getMockedAddon("4.2.0-SNAPSHOT", true);
+
+ List actual = Stream.of(addon1, addon2).sorted(AbstractRemoteAddonService.BY_COMPATIBLE_AND_VERSION)
+ .toList();
+ List expected = List.of(addon2, addon1);
+
+ assertThat(actual, is(equalTo(expected)));
+ }
+
+ private Addon getMockedAddon(String version, boolean compatible) {
+ Addon addon = mock(Addon.class);
+ when(addon.getVersion()).thenReturn(version);
+ when(addon.getCompatible()).thenReturn(compatible);
+ return addon;
}
/**
@@ -267,11 +296,11 @@ public void testAddonUninstallRemovesStorageEntryOnUninstalledAddon() {
private void checkResult(String id, String expectedEventTopic, boolean installStatus, boolean present) {
// assert expected event is posted
ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(Event.class);
- Mockito.verify(eventPublisher).post(eventCaptor.capture());
+ Mockito.verify(eventPublisher, timeout(5000)).post(eventCaptor.capture());
Event event = eventCaptor.getValue();
String topic = "openhab/addons/" + expectedEventTopic;
- assertThat(event.getTopic(), is(topic));
+ assertThat(event.toString(), event.getTopic(), is(topic));
// assert addon handler was called (by checking it's installed status)
assertThat(addonHandler.isInstalled(getFullAddonId(id)), is(installStatus));
diff --git a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/BundleVersionTest.java b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/BundleVersionTest.java
index 29938f74cf2..6e977dc1a75 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/BundleVersionTest.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/BundleVersionTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonHandler.java b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonHandler.java
index 447c95e1cff..39ca570e57d 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonHandler.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java
index 1471c6d11ba..793180f49c1 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java
+++ b/bundles/org.openhab.core.addon.marketplace/src/test/java/org/openhab/core/addon/marketplace/test/TestAddonService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -73,9 +73,12 @@ public void removeAddonHandler(MarketplaceAddonHandler handler) {
@Override
protected List getRemoteAddons() {
remoteCalls++;
- return REMOTE_ADDONS.stream().map(id -> Addon.create(SERVICE_PID + ":" + id).withType("binding")
- .withId(id.substring("binding-".length())).withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE)
- .withCompatible(!id.equals(INCOMPATIBLE_VERSION)).build()).toList();
+ return REMOTE_ADDONS.stream()
+ .map(id -> Addon.create(SERVICE_PID + ":" + id).withType("binding").withVersion("4.1.0")
+ .withId(id.substring("binding-".length()))
+ .withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE)
+ .withCompatible(!id.equals(INCOMPATIBLE_VERSION)).build())
+ .toList();
}
@Override
@@ -90,7 +93,7 @@ public String getName() {
@Override
public @Nullable Addon getAddon(String id, @Nullable Locale locale) {
- String remoteId = SERVICE_PID + ":" + id;
+ String remoteId = id.startsWith(SERVICE_PID) ? id : SERVICE_PID + ":" + id;
return cachedAddons.stream().filter(a -> remoteId.equals(a.getUid())).findAny().orElse(null);
}
@@ -115,7 +118,7 @@ public int getRemoteCalls() {
*/
public void setInstalled(String id) {
Addon addon = Addon.create(SERVICE_PID + ":" + id).withType("binding").withId(id.substring("binding-".length()))
- .withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE).build();
+ .withVersion("4.1.0").withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE).build();
addonHandlers.forEach(addonHandler -> {
try {
@@ -133,7 +136,7 @@ public void setInstalled(String id) {
*/
public void addToStorage(String id) {
Addon addon = Addon.create(SERVICE_PID + ":" + id).withType("binding").withId(id.substring("binding-".length()))
- .withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE).build();
+ .withVersion("4.1.0").withContentType(TestAddonHandler.TEST_ADDON_CONTENT_TYPE).build();
addon.setInstalled(true);
installedAddonStorage.put(id, gson.toJson(addon));
diff --git a/bundles/org.openhab.core.addon/pom.xml b/bundles/org.openhab.core.addon/pom.xml
index 383589723ac..24d774631cc 100644
--- a/bundles/org.openhab.core.addon/pom.xml
+++ b/bundles/org.openhab.core.addon/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.addon
diff --git a/bundles/org.openhab.core.addon/schema/addon-1.0.0.xsd b/bundles/org.openhab.core.addon/schema/addon-1.0.0.xsd
index 21142133d17..64e6b042618 100644
--- a/bundles/org.openhab.core.addon/schema/addon-1.0.0.xsd
+++ b/bundles/org.openhab.core.addon/schema/addon-1.0.0.xsd
@@ -7,35 +7,36 @@
-
-
-
-
-
-
-
-
-
- Comma-separated list of two-letter ISO country codes.
-
-
-
-
- The ID (service.pid or component.name) of the main add-on service, which can be configured through OSGi configuration admin service. Should only be used in combination with a config description definition. The default value is <type>.<name>
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ Comma-separated list of two-letter ISO country codes.
+
+
+
- The id is used to construct the UID of this add-on to <type>-<name>
+ The ID (service.pid or component.name) of the main add-on service, which can be configured through OSGi configuration admin service. Should only be used in combination with a config description definition. The default value is <type>.<name>
-
-
-
+
+
+
+
+
+
+
+
+
+ The id is used to construct the UID of this add-on to <type>-<name>
+
+
+
@@ -80,4 +81,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.addon/schema/addon-info-list-1.0.0.xsd b/bundles/org.openhab.core.addon/schema/addon-info-list-1.0.0.xsd
new file mode 100644
index 00000000000..4f720dc9815
--- /dev/null
+++ b/bundles/org.openhab.core.addon/schema/addon-info-list-1.0.0.xsd
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/Addon.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/Addon.java
index e1d06175ae9..17f1337f31b 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/Addon.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/Addon.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonDiscoveryMethod.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonDiscoveryMethod.java
new file mode 100644
index 00000000000..b8d85236319
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonDiscoveryMethod.java
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * DTO for serialization of a suggested addon discovery method.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+public class AddonDiscoveryMethod {
+ private @NonNullByDefault({}) String serviceType;
+ private @Nullable List parameters;
+ private @Nullable List matchProperties;
+
+ public String getServiceType() {
+ return serviceType.toLowerCase();
+ }
+
+ public List getParameters() {
+ List parameters = this.parameters;
+ return parameters != null ? parameters : List.of();
+ }
+
+ public List getMatchProperties() {
+ List matchProperties = this.matchProperties;
+ return matchProperties != null ? matchProperties : List.of();
+ }
+
+ public AddonDiscoveryMethod setServiceType(String serviceType) {
+ this.serviceType = serviceType.toLowerCase();
+ return this;
+ }
+
+ public AddonDiscoveryMethod setParameters(@Nullable List parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+
+ public AddonDiscoveryMethod setMatchProperties(@Nullable List matchProperties) {
+ this.matchProperties = matchProperties;
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(serviceType, parameters, matchProperties);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AddonDiscoveryMethod other = (AddonDiscoveryMethod) obj;
+ return Objects.equals(serviceType, other.serviceType) && Objects.equals(parameters, other.parameters)
+ && Objects.equals(matchProperties, other.matchProperties);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEvent.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEvent.java
index 40d084f8438..9dbd50377a7 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEvent.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEventFactory.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEventFactory.java
index ff5ee032abf..8792ebf355f 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEventFactory.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonEventFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonI18nLocalizationService.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonI18nLocalizationService.java
index e18d2353795..d565dcc4197 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonI18nLocalizationService.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonI18nLocalizationService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfo.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfo.java
index 8de5d828f70..04aa834b729 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfo.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfo.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -32,11 +32,13 @@
*/
@NonNullByDefault
public class AddonInfo implements Identifiable {
+
private static final Set SUPPORTED_ADDON_TYPES = Set.of("automation", "binding", "misc", "persistence",
"transformation", "ui", "voice");
private final String id;
private final String type;
+ private final String uid;
private final String name;
private final String description;
private final @Nullable String connection;
@@ -44,10 +46,15 @@ public class AddonInfo implements Identifiable {
private final @Nullable String configDescriptionURI;
private final String serviceId;
private @Nullable String sourceBundle;
+ private @Nullable List discoveryMethods;
+
+ private boolean masterAddonInfo = true;
- private AddonInfo(String id, String type, String name, String description, @Nullable String connection,
- List countries, @Nullable String configDescriptionURI, @Nullable String serviceId,
- @Nullable String sourceBundle) throws IllegalArgumentException {
+ private AddonInfo(String id, String type, @Nullable String uid, String name, String description,
+ @Nullable String connection, List countries, @Nullable String configDescriptionURI,
+ @Nullable String serviceId, @Nullable String sourceBundle,
+ @Nullable List discoveryMethods, boolean isMasterAddonInfo)
+ throws IllegalArgumentException {
// mandatory fields
if (id.isBlank()) {
throw new IllegalArgumentException("The ID must neither be null nor empty!");
@@ -64,6 +71,7 @@ private AddonInfo(String id, String type, String name, String description, @Null
}
this.id = id;
this.type = type;
+ this.uid = uid != null ? uid : type + Addon.ADDON_SEPARATOR + id;
this.name = name;
this.description = description;
@@ -73,6 +81,9 @@ private AddonInfo(String id, String type, String name, String description, @Null
this.configDescriptionURI = configDescriptionURI;
this.serviceId = Objects.requireNonNullElse(serviceId, type + "." + id);
this.sourceBundle = sourceBundle;
+ this.discoveryMethods = discoveryMethods;
+
+ this.masterAddonInfo = isMasterAddonInfo;
}
/**
@@ -82,7 +93,7 @@ private AddonInfo(String id, String type, String name, String description, @Null
*/
@Override
public String getUID() {
- return type + Addon.ADDON_SEPARATOR + id;
+ return uid;
}
/**
@@ -142,6 +153,15 @@ public List getCountries() {
return countries;
}
+ public List getDiscoveryMethods() {
+ List discoveryMethods = this.discoveryMethods;
+ return discoveryMethods != null ? discoveryMethods : List.of();
+ }
+
+ public boolean isMasterAddonInfo() {
+ return masterAddonInfo;
+ }
+
public static Builder builder(String id, String type) {
return new Builder(id, type);
}
@@ -154,6 +174,7 @@ public static class Builder {
private final String id;
private final String type;
+ private @Nullable String uid;
private String name = "";
private String description = "";
private @Nullable String connection;
@@ -161,6 +182,9 @@ public static class Builder {
private @Nullable String configDescriptionURI = "";
private @Nullable String serviceId;
private @Nullable String sourceBundle;
+ private @Nullable List discoveryMethods;
+
+ private boolean masterAddonInfo = true;
private Builder(String id, String type) {
this.id = id;
@@ -170,6 +194,7 @@ private Builder(String id, String type) {
private Builder(AddonInfo addonInfo) {
this.id = addonInfo.id;
this.type = addonInfo.type;
+ this.uid = addonInfo.uid;
this.name = addonInfo.name;
this.description = addonInfo.description;
this.connection = addonInfo.connection;
@@ -177,6 +202,13 @@ private Builder(AddonInfo addonInfo) {
this.configDescriptionURI = addonInfo.configDescriptionURI;
this.serviceId = addonInfo.serviceId;
this.sourceBundle = addonInfo.sourceBundle;
+ this.discoveryMethods = addonInfo.discoveryMethods;
+ this.masterAddonInfo = addonInfo.masterAddonInfo;
+ }
+
+ public Builder withUID(@Nullable String uid) {
+ this.uid = uid;
+ return this;
}
public Builder withName(String name) {
@@ -219,6 +251,16 @@ public Builder withSourceBundle(@Nullable String sourceBundle) {
return this;
}
+ public Builder withDiscoveryMethods(@Nullable List discoveryMethods) {
+ this.discoveryMethods = discoveryMethods;
+ return this;
+ }
+
+ public Builder isMasterAddonInfo(boolean masterAddonInfo) {
+ this.masterAddonInfo = masterAddonInfo;
+ return this;
+ }
+
/**
* Build an {@link AddonInfo} from this builder
*
@@ -226,8 +268,8 @@ public Builder withSourceBundle(@Nullable String sourceBundle) {
* @throws IllegalArgumentException if any of the information in this builder is invalid
*/
public AddonInfo build() throws IllegalArgumentException {
- return new AddonInfo(id, type, name, description, connection, countries, configDescriptionURI, serviceId,
- sourceBundle);
+ return new AddonInfo(id, type, uid, name, description, connection, countries, configDescriptionURI,
+ serviceId, sourceBundle, discoveryMethods, masterAddonInfo);
}
}
}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoList.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoList.java
new file mode 100644
index 00000000000..4e0aea6e771
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoList.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * DTO containing a list of {@code AddonInfo}
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+public class AddonInfoList {
+ protected @Nullable List addons;
+
+ public List getAddons() {
+ List addons = this.addons;
+ return addons != null ? addons : List.of();
+ }
+
+ public AddonInfoList setAddons(@Nullable List addons) {
+ this.addons = addons;
+ return this;
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoProvider.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoProvider.java
index edd8b095883..b262bedbf75 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoProvider.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -31,15 +31,15 @@
public interface AddonInfoProvider {
/**
- * Returns the binding information for the specified binding ID and locale (language),
+ * Returns the binding information for the specified binding UID and locale (language),
* or {@code null} if no binding information could be found.
*
- * @param id the ID to be looked for (could be null or empty)
+ * @param uid the UID to be looked for (could be null or empty)
* @param locale the locale to be used for the binding information (could be null)
* @return a localized binding information object (could be null)
*/
@Nullable
- AddonInfo getAddonInfo(@Nullable String id, @Nullable Locale locale);
+ AddonInfo getAddonInfo(@Nullable String uid, @Nullable Locale locale);
/**
* Returns all binding information in the specified locale (language) this provider contains.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoRegistry.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoRegistry.java
index 678c329ca2d..2815fe8a0d1 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoRegistry.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonInfoRegistry.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -13,10 +13,13 @@
package org.openhab.core.addon;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -25,6 +28,8 @@
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The {@link AddonInfoRegistry} provides access to {@link AddonInfo} objects.
@@ -37,6 +42,8 @@
@NonNullByDefault
public class AddonInfoRegistry {
+ private final Logger logger = LoggerFactory.getLogger(AddonInfoRegistry.class);
+
private final Collection addonInfoProviders = new CopyOnWriteArrayList<>();
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
@@ -44,34 +51,95 @@ protected void addAddonInfoProvider(AddonInfoProvider addonInfoProvider) {
addonInfoProviders.add(addonInfoProvider);
}
- protected void removeAddonInfoProvider(AddonInfoProvider addonInfoProvider) {
+ public void removeAddonInfoProvider(AddonInfoProvider addonInfoProvider) {
addonInfoProviders.remove(addonInfoProvider);
}
/**
- * Returns the add-on information for the specified add-on ID, or {@code null} if no add-on information could be
+ * Returns the add-on information for the specified add-on UID, or {@code null} if no add-on information could be
* found.
*
- * @param id the ID to be looked
+ * @param uid the UID to be looked
* @return a add-on information object (could be null)
*/
- public @Nullable AddonInfo getAddonInfo(String id) {
- return getAddonInfo(id, null);
+ public @Nullable AddonInfo getAddonInfo(String uid) {
+ return getAddonInfo(uid, null);
}
/**
- * Returns the add-on information for the specified add-on ID and locale (language),
+ * Returns the add-on information for the specified add-on UID and locale (language),
* or {@code null} if no add-on information could be found.
+ *
+ * If more than one provider provides information for the specified add-on UID and locale,
+ * it returns a new {@link AddonInfo} containing merged information from all such providers.
*
- * @param id the ID to be looked for
+ * @param uid the UID to be looked for
* @param locale the locale to be used for the add-on information (could be null)
* @return a localized add-on information object (could be null)
*/
- public @Nullable AddonInfo getAddonInfo(String id, @Nullable Locale locale) {
- return addonInfoProviders.stream().map(p -> p.getAddonInfo(id, locale)).filter(Objects::nonNull).findAny()
- .orElse(null);
+ public @Nullable AddonInfo getAddonInfo(String uid, @Nullable Locale locale) {
+ return addonInfoProviders.stream().map(p -> p.getAddonInfo(uid, locale)).filter(Objects::nonNull)
+ .collect(Collectors.toMap(a -> a.getUID(), Function.identity(), mergeAddonInfos)).get(uid);
}
+ /**
+ * A {@link BinaryOperator} to merge the field values from two {@link AddonInfo} objects into a third such object.
+ *
+ * If the first object has a non-null field value the result object takes the first value, or if the second object
+ * has a non-null field value the result object takes the second value. Otherwise the field remains null.
+ *
+ * @param a the first {@link AddonInfo} (could be null)
+ * @param b the second {@link AddonInfo} (could be null)
+ * @return a new {@link AddonInfo} containing the combined field values (could be null)
+ */
+ private static BinaryOperator<@Nullable AddonInfo> mergeAddonInfos = (a, b) -> {
+ if (a == null) {
+ return b;
+ } else if (b == null) {
+ return a;
+ }
+ AddonInfo.Builder builder = AddonInfo.builder(a);
+ if (a.isMasterAddonInfo()) {
+ builder.withName(a.getName());
+ builder.withDescription(a.getDescription());
+ } else {
+ builder.withName(b.getName());
+ builder.withDescription(b.getDescription());
+ }
+ if (!(a.isMasterAddonInfo() || b.isMasterAddonInfo())) {
+ builder.isMasterAddonInfo(false);
+ }
+ if (a.getConnection() == null && b.getConnection() != null) {
+ builder.withConnection(b.getConnection());
+ }
+ Set countries = new HashSet<>(a.getCountries());
+ countries.addAll(b.getCountries());
+ if (!countries.isEmpty()) {
+ builder.withCountries(countries.stream().toList());
+ }
+ String aConfigDescriptionURI = a.getConfigDescriptionURI();
+ if (aConfigDescriptionURI == null || aConfigDescriptionURI.isEmpty() && b.getConfigDescriptionURI() != null) {
+ builder.withConfigDescriptionURI(b.getConfigDescriptionURI());
+ }
+ if (a.getSourceBundle() == null && b.getSourceBundle() != null) {
+ builder.withSourceBundle(b.getSourceBundle());
+ }
+ String defaultServiceId = a.getType() + "." + a.getId();
+ if (defaultServiceId.equals(a.getServiceId()) && !defaultServiceId.equals(b.getServiceId())) {
+ builder.withServiceId(b.getServiceId());
+ }
+ String defaultUID = a.getType() + Addon.ADDON_SEPARATOR + a.getId();
+ if (defaultUID.equals(a.getUID()) && !defaultUID.equals(b.getUID())) {
+ builder.withUID(b.getUID());
+ }
+ Set discoveryMethods = new HashSet<>(a.getDiscoveryMethods());
+ discoveryMethods.addAll(b.getDiscoveryMethods());
+ if (!discoveryMethods.isEmpty()) {
+ builder.withDiscoveryMethods(discoveryMethods.stream().toList());
+ }
+ return builder.build();
+ };
+
/**
* Returns all add-on information this registry contains.
*
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonMatchProperty.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonMatchProperty.java
new file mode 100644
index 00000000000..7c614942d2b
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonMatchProperty.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon;
+
+import java.util.Objects;
+import java.util.regex.Pattern;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * DTO for serialization of a property match regular expression.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+public class AddonMatchProperty {
+ private @NonNullByDefault({}) String name;
+ private @NonNullByDefault({}) String regex;
+ private transient @NonNullByDefault({}) Pattern pattern;
+
+ public AddonMatchProperty(String name, String regex) {
+ this.name = name;
+ this.regex = regex;
+ this.pattern = null;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Pattern getPattern() {
+ Pattern pattern = this.pattern;
+ if (pattern == null) {
+ this.pattern = Pattern.compile(regex);
+ }
+ return this.pattern;
+ }
+
+ public String getRegex() {
+ return regex;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, regex);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AddonMatchProperty other = (AddonMatchProperty) obj;
+ return Objects.equals(name, other.name) && Objects.equals(regex, other.regex);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonParameter.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonParameter.java
new file mode 100644
index 00000000000..8430f87461d
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonParameter.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon;
+
+import java.util.Objects;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * DTO for serialization of a add-on discovery parameter.
+ *
+ * @author Mark Herwege - Initial contribution
+ */
+@NonNullByDefault
+public class AddonParameter {
+ private @NonNullByDefault({}) String name;
+ private @NonNullByDefault({}) String value;
+
+ public AddonParameter(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, value);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AddonParameter other = (AddonParameter) obj;
+ return Objects.equals(name, other.name) && Objects.equals(value, other.value);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonService.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonService.java
index 0a4aa31a177..1c2036f3b36 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonService.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonType.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonType.java
index 84d3cb719a9..b27d752bdc9 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonType.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/AddonType.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/AddonI18nUtil.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/AddonI18nUtil.java
index 3de65735b7e..7b621d94366 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/AddonI18nUtil.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/AddonI18nUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/JarFileAddonService.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/JarFileAddonService.java
index 106930d00a7..64aa378998c 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/JarFileAddonService.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/JarFileAddonService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -157,7 +157,7 @@ private Addon toAddon(Bundle bundle, AddonInfo addonInfo) {
.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI())
.withDescription(Objects.requireNonNullElse(addonInfo.getDescription(), bundle.getSymbolicName()))
- .withContentType(ADDONS_CONTENT_TYPE).build();
+ .withContentType(ADDONS_CONTENT_TYPE).withLoggerPackages(List.of(bundle.getSymbolicName())).build();
}
@Override
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonDiscoveryMethodConverter.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonDiscoveryMethodConverter.java
new file mode 100644
index 00000000000..cd1d84c70a5
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonDiscoveryMethodConverter.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon.internal.xml;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.addon.AddonDiscoveryMethod;
+import org.openhab.core.addon.AddonMatchProperty;
+import org.openhab.core.addon.AddonParameter;
+import org.openhab.core.config.core.xml.util.GenericUnmarshaller;
+import org.openhab.core.config.core.xml.util.NodeIterator;
+
+import com.thoughtworks.xstream.converters.Converter;
+import com.thoughtworks.xstream.converters.UnmarshallingContext;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+
+/**
+ * The {@link AddonDiscoveryMethodConverter} is a concrete implementation of the {@code XStream} {@link Converter}
+ * interface used to convert add-on discovery method information within an XML document into a
+ * {@link AddonDiscoveryMethod} object.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+public class AddonDiscoveryMethodConverter extends GenericUnmarshaller {
+
+ public AddonDiscoveryMethodConverter() {
+ super(AddonDiscoveryMethod.class);
+ }
+
+ @Override
+ public @Nullable Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
+ List> nodes = (List>) context.convertAnother(context, List.class);
+ NodeIterator nodeIterator = new NodeIterator(nodes);
+
+ String serviceType = requireNonEmpty((String) nodeIterator.nextValue("service-type", true),
+ "Service type is null or empty");
+
+ Object paramObject = nodeIterator.nextList("discovery-parameters", false);
+ List parameters = !(paramObject instanceof List> list) ? null
+ : list.stream().filter(AddonParameter.class::isInstance).map(e -> ((AddonParameter) e)).toList();
+
+ Object matchPropObject = nodeIterator.nextList("match-properties", false);
+ List matchProperties = !(matchPropObject instanceof List> list) ? null
+ : list.stream().filter(AddonMatchProperty.class::isInstance).map(e -> ((AddonMatchProperty) e))
+ .toList();
+
+ nodeIterator.assertEndOfType();
+
+ return new AddonDiscoveryMethod().setServiceType(serviceType).setParameters(parameters)
+ .setMatchProperties(matchProperties);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoAddonsXmlProvider.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoAddonsXmlProvider.java
new file mode 100644
index 00000000000..bbcbcf9f783
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoAddonsXmlProvider.java
@@ -0,0 +1,140 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon.internal.xml;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+import java.util.regex.PatternSyntaxException;
+import java.util.stream.Collectors;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.OpenHAB;
+import org.openhab.core.addon.AddonDiscoveryMethod;
+import org.openhab.core.addon.AddonInfo;
+import org.openhab.core.addon.AddonInfoProvider;
+import org.openhab.core.addon.AddonMatchProperty;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.thoughtworks.xstream.XStreamException;
+import com.thoughtworks.xstream.converters.ConversionException;
+
+/**
+ * The {@link AddonInfoAddonsXmlProvider} reads the {@code runtime/etc/addons.xml} file, which
+ * should contain a list of {@code addon} elements, and convert its combined contents into a list
+ * of {@link AddonInfo} objects that can be accessed via the {@link AddonInfoProvider} interface.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ * @author Kai Kreuzer - Reduce it to support a single addons.xml file
+ */
+@NonNullByDefault
+@Component(service = AddonInfoProvider.class, name = AddonInfoAddonsXmlProvider.SERVICE_NAME)
+public class AddonInfoAddonsXmlProvider implements AddonInfoProvider {
+
+ private static final String ADDONS_XML_FILE = "etc" + File.separator + "addons.xml";
+ public static final String SERVICE_NAME = "addons-info-provider";
+
+ private final Logger logger = LoggerFactory.getLogger(AddonInfoAddonsXmlProvider.class);
+ private final String fileName = OpenHAB.getRuntimeFolder() + File.separator + ADDONS_XML_FILE;
+ private final Set addonInfos = new HashSet<>();
+
+ @Activate
+ public AddonInfoAddonsXmlProvider() {
+ initialize();
+ testAddonDeveloperRegexSyntax();
+ }
+
+ @Deactivate
+ public void deactivate() {
+ addonInfos.clear();
+ }
+
+ @Override
+ public @Nullable AddonInfo getAddonInfo(@Nullable String uid, @Nullable Locale locale) {
+ return addonInfos.stream().filter(a -> a.getUID().equals(uid)).findFirst().orElse(null);
+ }
+
+ @Override
+ public Set getAddonInfos(@Nullable Locale locale) {
+ return addonInfos;
+ }
+
+ private void initialize() {
+ File file = new File(fileName);
+ try {
+ if (!file.isFile()) {
+ logger.debug("File '{}' does not exist.", fileName);
+ return;
+ }
+ } catch (SecurityException e) {
+ logger.warn("File '{}' threw a security exception: {}", fileName, e.getMessage());
+ return;
+ }
+ AddonInfoListReader reader = new AddonInfoListReader();
+ try {
+ String xml = Files.readString(file.toPath());
+ if (xml != null && !xml.isBlank()) {
+ addonInfos.addAll(reader.readFromXML(xml).getAddons().stream()
+ .map(a -> AddonInfo.builder(a).isMasterAddonInfo(false).build()).collect(Collectors.toSet()));
+ } else {
+ logger.warn("File '{}' contents are null or empty", file.getName());
+ }
+ } catch (IOException e) {
+ logger.warn("File '{}' could not be read", file.getName());
+ } catch (ConversionException e) {
+ logger.warn("File '{}' has invalid content: {}", file.getName(), e.getMessage());
+ } catch (XStreamException e) {
+ logger.warn("File '{}' could not be deserialized", file.getName());
+ } catch (SecurityException e) {
+ logger.warn("File '{}' threw a security exception: {}", file, e.getMessage());
+ }
+ }
+
+ /*
+ * The openhab-addons Maven build process checks individual developer addon.xml contributions
+ * against the 'addon-1.0.0.xsd' schema, but it can't check the discovery-method match-property
+ * regex syntax. Invalid regexes do throw exceptions at run-time, but the log can't identify the
+ * culprit addon. Ideally we need to add syntax checks to the Maven build; and this test is an
+ * interim solution.
+ */
+ private void testAddonDeveloperRegexSyntax() {
+ List patternErrors = new ArrayList<>();
+ for (AddonInfo addonInfo : addonInfos) {
+ for (AddonDiscoveryMethod discoveryMethod : addonInfo.getDiscoveryMethods()) {
+ for (AddonMatchProperty matchProperty : discoveryMethod.getMatchProperties()) {
+ try {
+ matchProperty.getPattern();
+ } catch (PatternSyntaxException e) {
+ patternErrors.add(String.format(
+ "Regex syntax error in org.openhab.%s.%s addon.xml => %s in \"%s\" position %d",
+ addonInfo.getType(), addonInfo.getId(), e.getDescription(), e.getPattern(),
+ e.getIndex()));
+ }
+ }
+ }
+ }
+ if (!patternErrors.isEmpty()) {
+ logger.warn("The following errors were found:\n\t{}", String.join("\n\t", patternErrors));
+ }
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoConverter.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoConverter.java
index 257dfff682f..6b3550c5310 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoConverter.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoConverter.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -18,6 +18,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.addon.AddonDiscoveryMethod;
import org.openhab.core.addon.AddonInfo;
import org.openhab.core.config.core.ConfigDescription;
import org.openhab.core.config.core.ConfigDescriptionBuilder;
@@ -37,6 +38,7 @@
* @author Michael Grammling - Initial contribution
* @author Andre Fuechsel - Made author tag optional
* @author Jan N. Klug - Refactored to cover all add-ons
+ * @author Andrew Fiddian-Green - Added discovery methods
*/
@NonNullByDefault
public class AddonInfoConverter extends GenericUnmarshaller {
@@ -107,6 +109,11 @@ public AddonInfoConverter() {
addonInfo.withConfigDescriptionURI(configDescriptionURI);
+ Object object = nodeIterator.nextList("discovery-methods", false);
+ addonInfo.withDiscoveryMethods(!(object instanceof List> list) ? null
+ : list.stream().filter(AddonDiscoveryMethod.class::isInstance).map(e -> ((AddonDiscoveryMethod) e))
+ .toList());
+
nodeIterator.assertEndOfType();
// create object
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoListConverter.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoListConverter.java
new file mode 100644
index 00000000000..14a68aeded6
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoListConverter.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon.internal.xml;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.addon.AddonInfo;
+import org.openhab.core.addon.AddonInfoList;
+import org.openhab.core.config.core.xml.util.GenericUnmarshaller;
+import org.openhab.core.config.core.xml.util.NodeIterator;
+
+import com.thoughtworks.xstream.converters.Converter;
+import com.thoughtworks.xstream.converters.UnmarshallingContext;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+
+/**
+ * The {@link AddonInfoListConverter} is a concrete implementation of the {@code XStream} {@link Converter}
+ * interface used to convert a list of add-on information within an XML document into a list of {@link AddonInfo}
+ * objects.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+public class AddonInfoListConverter extends GenericUnmarshaller {
+
+ public AddonInfoListConverter() {
+ super(AddonInfoList.class);
+ }
+
+ @Override
+ public @Nullable Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
+ List> nodes = (List>) context.convertAnother(context, List.class);
+ NodeIterator nodeIterator = new NodeIterator(nodes);
+
+ Object object = nodeIterator.nextList("addons", false);
+ List addons = (object instanceof List> list)
+ ? list.stream().filter(Objects::nonNull).filter(AddonInfoXmlResult.class::isInstance)
+ .map(e -> (AddonInfoXmlResult) e).map(AddonInfoXmlResult::addonInfo).toList()
+ : null;
+
+ nodeIterator.assertEndOfType();
+
+ return new AddonInfoList().setAddons(addons);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoListReader.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoListReader.java
new file mode 100644
index 00000000000..7cc1d162c26
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoListReader.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon.internal.xml;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.core.addon.AddonDiscoveryMethod;
+import org.openhab.core.addon.AddonInfoList;
+import org.openhab.core.addon.AddonMatchProperty;
+import org.openhab.core.addon.AddonParameter;
+import org.openhab.core.config.core.ConfigDescription;
+import org.openhab.core.config.core.ConfigDescriptionParameter;
+import org.openhab.core.config.core.ConfigDescriptionParameterGroup;
+import org.openhab.core.config.core.FilterCriteria;
+import org.openhab.core.config.core.xml.ConfigDescriptionConverter;
+import org.openhab.core.config.core.xml.ConfigDescriptionParameterConverter;
+import org.openhab.core.config.core.xml.ConfigDescriptionParameterGroupConverter;
+import org.openhab.core.config.core.xml.FilterCriteriaConverter;
+import org.openhab.core.config.core.xml.util.NodeAttributes;
+import org.openhab.core.config.core.xml.util.NodeAttributesConverter;
+import org.openhab.core.config.core.xml.util.NodeList;
+import org.openhab.core.config.core.xml.util.NodeListConverter;
+import org.openhab.core.config.core.xml.util.NodeValue;
+import org.openhab.core.config.core.xml.util.NodeValueConverter;
+import org.openhab.core.config.core.xml.util.XmlDocumentReader;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * The {@link AddonInfoListReader} reads XML documents, which contain the {@code addon} XML tag, and converts them to
+ * a List of {@link AddonInfoXmlResult} objects.
+ *
+ * This reader uses {@code XStream} and {@code StAX} to parse and convert the XML document.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+public class AddonInfoListReader extends XmlDocumentReader {
+
+ /**
+ * The default constructor of this class.
+ */
+ public AddonInfoListReader() {
+ ClassLoader classLoader = AddonInfoListReader.class.getClassLoader();
+ if (classLoader != null) {
+ super.setClassLoader(classLoader);
+ }
+ }
+
+ @Override
+ protected void registerConverters(XStream xstream) {
+ xstream.registerConverter(new NodeAttributesConverter());
+ xstream.registerConverter(new NodeListConverter());
+ xstream.registerConverter(new NodeValueConverter());
+ xstream.registerConverter(new AddonInfoListConverter());
+ xstream.registerConverter(new AddonInfoConverter());
+ xstream.registerConverter(new ConfigDescriptionConverter());
+ xstream.registerConverter(new ConfigDescriptionParameterConverter());
+ xstream.registerConverter(new ConfigDescriptionParameterGroupConverter());
+ xstream.registerConverter(new FilterCriteriaConverter());
+ xstream.registerConverter(new AddonDiscoveryMethodConverter());
+ xstream.registerConverter(new AddonParameterConverter());
+ xstream.registerConverter(new AddonMatchPropertyConverter());
+ }
+
+ @Override
+ protected void registerAliases(XStream xstream) {
+ xstream.alias("addon-info-list", AddonInfoList.class);
+ xstream.alias("addons", NodeList.class);
+ xstream.alias("addon", AddonInfoXmlResult.class);
+ xstream.alias("name", NodeValue.class);
+ xstream.alias("description", NodeValue.class);
+ xstream.alias("type", NodeValue.class);
+ xstream.alias("connection", NodeValue.class);
+ xstream.alias("countries", NodeValue.class);
+ xstream.alias("config-description", ConfigDescription.class);
+ xstream.alias("config-description-ref", NodeAttributes.class);
+ xstream.alias("parameter", ConfigDescriptionParameter.class);
+ xstream.alias("parameter-group", ConfigDescriptionParameterGroup.class);
+ xstream.alias("options", NodeList.class);
+ xstream.alias("option", NodeValue.class);
+ xstream.alias("filter", List.class);
+ xstream.alias("criteria", FilterCriteria.class);
+ xstream.alias("service-id", NodeValue.class);
+ xstream.alias("discovery-methods", NodeList.class);
+ xstream.alias("discovery-method", AddonDiscoveryMethod.class);
+ xstream.alias("service-type", NodeValue.class);
+ xstream.alias("discovery-parameters", NodeList.class);
+ xstream.alias("discovery-parameter", AddonParameter.class);
+ xstream.alias("match-properties", NodeList.class);
+ xstream.alias("match-property", AddonMatchProperty.class);
+ xstream.alias("value", NodeValue.class);
+ xstream.alias("regex", NodeValue.class);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoReader.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoReader.java
index a33cdd09cd8..ab697c9c054 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoReader.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoReader.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -15,6 +15,9 @@
import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.core.addon.AddonDiscoveryMethod;
+import org.openhab.core.addon.AddonMatchProperty;
+import org.openhab.core.addon.AddonParameter;
import org.openhab.core.config.core.ConfigDescription;
import org.openhab.core.config.core.ConfigDescriptionParameter;
import org.openhab.core.config.core.ConfigDescriptionParameterGroup;
@@ -26,6 +29,7 @@
import org.openhab.core.config.core.xml.util.NodeAttributes;
import org.openhab.core.config.core.xml.util.NodeAttributesConverter;
import org.openhab.core.config.core.xml.util.NodeList;
+import org.openhab.core.config.core.xml.util.NodeListConverter;
import org.openhab.core.config.core.xml.util.NodeValue;
import org.openhab.core.config.core.xml.util.NodeValueConverter;
import org.openhab.core.config.core.xml.util.XmlDocumentReader;
@@ -33,7 +37,7 @@
import com.thoughtworks.xstream.XStream;
/**
- * The {@link AddonInfoReader} reads XML documents, which contain the {@code binding} XML tag,
+ * The {@link AddonInfoReader} reads XML documents, which contain the {@code addon} XML tag,
* and converts them to {@link AddonInfoXmlResult} objects.
*
* This reader uses {@code XStream} and {@code StAX} to parse and convert the XML document.
@@ -59,12 +63,16 @@ public AddonInfoReader() {
@Override
protected void registerConverters(XStream xstream) {
xstream.registerConverter(new NodeAttributesConverter());
+ xstream.registerConverter(new NodeListConverter());
xstream.registerConverter(new NodeValueConverter());
xstream.registerConverter(new AddonInfoConverter());
xstream.registerConverter(new ConfigDescriptionConverter());
xstream.registerConverter(new ConfigDescriptionParameterConverter());
xstream.registerConverter(new ConfigDescriptionParameterGroupConverter());
xstream.registerConverter(new FilterCriteriaConverter());
+ xstream.registerConverter(new AddonDiscoveryMethodConverter());
+ xstream.registerConverter(new AddonParameterConverter());
+ xstream.registerConverter(new AddonMatchPropertyConverter());
}
@Override
@@ -84,5 +92,14 @@ protected void registerAliases(XStream xstream) {
xstream.alias("filter", List.class);
xstream.alias("criteria", FilterCriteria.class);
xstream.alias("service-id", NodeValue.class);
+ xstream.alias("discovery-methods", NodeList.class);
+ xstream.alias("discovery-method", AddonDiscoveryMethod.class);
+ xstream.alias("service-type", NodeValue.class);
+ xstream.alias("discovery-parameters", NodeList.class);
+ xstream.alias("discovery-parameter", AddonParameter.class);
+ xstream.alias("match-properties", NodeList.class);
+ xstream.alias("match-property", AddonMatchProperty.class);
+ xstream.alias("value", NodeValue.class);
+ xstream.alias("regex", NodeValue.class);
}
}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlProvider.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlProvider.java
index 60d28ec2837..1604cfd7d90 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlProvider.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -26,7 +26,8 @@
* objects by a {@link AddonInfoReader} for a certain bundle.
*
* This implementation registers each {@link AddonInfo} object at the {@link XmlAddonInfoProvider} which is itself
- * registered as {@link AddonInfoProvider} service at the OSGi service registry.
+ * registered as {@link org.openhab.core.addon.AddonInfoProvider AddonInfoProvider} service at the OSGi service
+ * registry.
*
* If there is a {@link ConfigDescription} object within the {@link AddonInfoXmlResult} object, it is added to the
* {@link AbstractXmlConfigDescriptionProvider} which is itself registered as OSGi service at the service
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlResult.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlResult.java
index b005d16512a..af21b306273 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlResult.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonInfoXmlResult.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonMatchPropertyConverter.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonMatchPropertyConverter.java
new file mode 100644
index 00000000000..6bcd5bd324d
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonMatchPropertyConverter.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon.internal.xml;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.addon.AddonMatchProperty;
+import org.openhab.core.config.core.xml.util.GenericUnmarshaller;
+import org.openhab.core.config.core.xml.util.NodeIterator;
+
+import com.thoughtworks.xstream.converters.Converter;
+import com.thoughtworks.xstream.converters.UnmarshallingContext;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+
+/**
+ * The {@link AddonMatchPropertyConverter} is a concrete implementation of the {@code XStream} {@link Converter}
+ * interface used to convert add-on discovery method match property information within an XML document into a
+ * {@link AddonMatchProperty} object.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+public class AddonMatchPropertyConverter extends GenericUnmarshaller {
+
+ public AddonMatchPropertyConverter() {
+ super(AddonMatchProperty.class);
+ }
+
+ @Override
+ public @Nullable Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
+ List> nodes = (List>) context.convertAnother(context, List.class);
+ NodeIterator nodeIterator = new NodeIterator(nodes);
+
+ String name = requireNonEmpty((String) nodeIterator.nextValue("name", true), "Name is null or empty");
+ String regex = requireNonEmpty((String) nodeIterator.nextValue("regex", true), "Regex is null or empty");
+
+ nodeIterator.assertEndOfType();
+
+ return new AddonMatchProperty(name, regex);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonParameterConverter.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonParameterConverter.java
new file mode 100644
index 00000000000..5b0474078de
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonParameterConverter.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon.internal.xml;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.addon.AddonMatchProperty;
+import org.openhab.core.addon.AddonParameter;
+import org.openhab.core.config.core.xml.util.GenericUnmarshaller;
+import org.openhab.core.config.core.xml.util.NodeIterator;
+
+import com.thoughtworks.xstream.converters.Converter;
+import com.thoughtworks.xstream.converters.UnmarshallingContext;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+
+/**
+ * The {@link AddonParameterConverter} is a concrete implementation of the {@code XStream} {@link Converter}
+ * interface used to convert add-on discovery method parameter information within an XML document into a
+ * {@link AddonMatchProperty} object.
+ *
+ * @author Mark Herwege - Initial contribution
+ */
+@NonNullByDefault
+public class AddonParameterConverter extends GenericUnmarshaller {
+
+ public AddonParameterConverter() {
+ super(AddonParameter.class);
+ }
+
+ @Override
+ public @Nullable Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
+ List> nodes = (List>) context.convertAnother(context, List.class);
+ NodeIterator nodeIterator = new NodeIterator(nodes);
+
+ String name = requireNonEmpty((String) nodeIterator.nextValue("name", true), "Name is null or empty");
+ String value = requireNonEmpty((String) nodeIterator.nextValue("value", true), "Value is null or empty");
+
+ nodeIterator.assertEndOfType();
+
+ return new AddonParameter(name, value);
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonXmlConfigDescriptionProvider.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonXmlConfigDescriptionProvider.java
index 4bd3c670d14..504d933f663 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonXmlConfigDescriptionProvider.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/AddonXmlConfigDescriptionProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/XmlAddonInfoProvider.java b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/XmlAddonInfoProvider.java
index 7edb8e4f718..52379b75c00 100644
--- a/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/XmlAddonInfoProvider.java
+++ b/bundles/org.openhab.core.addon/src/main/java/org/openhab/core/addon/internal/xml/XmlAddonInfoProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.addon/src/test/java/org/openhab/core/addon/AddonInfoListReaderTest.java b/bundles/org.openhab.core.addon/src/test/java/org/openhab/core/addon/AddonInfoListReaderTest.java
new file mode 100644
index 00000000000..91bf7b860f3
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/test/java/org/openhab/core/addon/AddonInfoListReaderTest.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.junit.jupiter.api.Test;
+import org.openhab.core.addon.internal.xml.AddonInfoListReader;
+
+/**
+ * JUnit tests for {@link AddonInfoListReader}.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+class AddonInfoListReaderTest {
+
+ // @formatter:off
+ private final String testXml =
+ ""
+ + " "
+ + " automation"
+ + " Groovy Scripting"
+ + " This adds a Groovy script engine."
+ + " none"
+ + " "
+ + " "
+ + " mdns"
+ + " "
+ + " "
+ + " mdnsServiceType"
+ + " _printer._tcp.local."
+ + " "
+ + " "
+ + " "
+ + " "
+ + " rp"
+ + " .*"
+ + " "
+ + " "
+ + " ty"
+ + " hp (.*)"
+ + " "
+ + " "
+ + " "
+ + " "
+ + " upnp"
+ + " "
+ + " "
+ + " modelName"
+ + " Philips hue bridge"
+ + " "
+ + " "
+ + " "
+ + " "
+ + " "
+ + "";
+ // @formatter:on
+
+ @Test
+ void testAddonInfoListReader() {
+ AddonInfoList addons = null;
+ try {
+ AddonInfoListReader reader = new AddonInfoListReader();
+ addons = reader.readFromXML(testXml);
+ } catch (Exception e) {
+ fail(e);
+ }
+ assertNotNull(addons);
+ List addonsInfos = addons.getAddons();
+ assertEquals(1, addonsInfos.size());
+ AddonInfo addon = addonsInfos.get(0);
+ assertNotNull(addon);
+ List discoveryMethods = addon.getDiscoveryMethods();
+ assertNotNull(discoveryMethods);
+ assertEquals(2, discoveryMethods.size());
+
+ AddonDiscoveryMethod method = discoveryMethods.get(0);
+ assertNotNull(method);
+ assertEquals("mdns", method.getServiceType());
+ List parameters = method.getParameters();
+ assertNotNull(parameters);
+ assertEquals(1, parameters.size());
+ AddonParameter parameter = parameters.get(0);
+ assertNotNull(parameter);
+ assertEquals("mdnsServiceType", parameter.getName());
+ assertEquals("_printer._tcp.local.", parameter.getValue());
+ List matchProperties = method.getMatchProperties();
+ assertNotNull(matchProperties);
+ assertEquals(2, matchProperties.size());
+ AddonMatchProperty property = matchProperties.get(0);
+ assertNotNull(property);
+ assertEquals("rp", property.getName());
+ assertEquals(".*", property.getRegex());
+ assertTrue(property.getPattern().matcher("the cat sat on the mat").matches());
+
+ method = discoveryMethods.get(1);
+ assertNotNull(method);
+ assertEquals("upnp", method.getServiceType());
+ parameters = method.getParameters();
+ assertNotNull(parameters);
+ assertEquals(0, parameters.size());
+ matchProperties = method.getMatchProperties();
+ assertNotNull(matchProperties);
+ assertEquals(1, matchProperties.size());
+ property = matchProperties.get(0);
+ assertNotNull(property);
+ assertEquals("modelName", property.getName());
+ assertEquals("Philips hue bridge", property.getRegex());
+ assertTrue(property.getPattern().matcher("Philips hue bridge").matches());
+ }
+}
diff --git a/bundles/org.openhab.core.addon/src/test/java/org/openhab/core/addon/AddonInfoRegistryMergeTest.java b/bundles/org.openhab.core.addon/src/test/java/org/openhab/core/addon/AddonInfoRegistryMergeTest.java
new file mode 100644
index 00000000000..8e755a02c43
--- /dev/null
+++ b/bundles/org.openhab.core.addon/src/test/java/org/openhab/core/addon/AddonInfoRegistryMergeTest.java
@@ -0,0 +1,191 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.addon;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+
+/**
+ * JUnit test for the {@link AddonInfoRegistry} merge function.
+ *
+ * @author Andrew Fiddian-Green - Initial contribution
+ */
+@NonNullByDefault
+@TestInstance(Lifecycle.PER_CLASS)
+class AddonInfoRegistryMergeTest {
+
+ private @Nullable AddonInfoProvider addonInfoProvider0;
+ private @Nullable AddonInfoProvider addonInfoProvider1;
+ private @Nullable AddonInfoProvider addonInfoProvider2;
+
+ @BeforeAll
+ void beforeAll() {
+ addonInfoProvider0 = createAddonInfoProvider0();
+ addonInfoProvider1 = createAddonInfoProvider1();
+ addonInfoProvider2 = createAddonInfoProvider2();
+ }
+
+ private AddonInfoProvider createAddonInfoProvider0() {
+ AddonInfo addonInfo = AddonInfo.builder("hue", "binding").withName("name-zero")
+ .withDescription("description-zero").build();
+ AddonInfoProvider provider = mock(AddonInfoProvider.class);
+ when(provider.getAddonInfo(anyString(), any(Locale.class))).thenReturn(null);
+ when(provider.getAddonInfo(anyString(), eq(null))).thenReturn(null);
+ when(provider.getAddonInfo(eq("binding-hue"), any(Locale.class))).thenReturn(addonInfo);
+ when(provider.getAddonInfo(eq("binding-hue"), eq(null))).thenReturn(null);
+ return provider;
+ }
+
+ private AddonInfoProvider createAddonInfoProvider1() {
+ AddonDiscoveryMethod discoveryMethod = new AddonDiscoveryMethod().setServiceType("mdns")
+ .setParameters(List.of(new AddonParameter("mdnsServiceType", "_hue._tcp.local.")));
+ AddonInfo addonInfo = AddonInfo.builder("hue", "binding").withName("name-one")
+ .withDescription("description-one").withCountries("GB,NL").withConnection("local")
+ .withDiscoveryMethods(List.of(discoveryMethod)).build();
+ AddonInfoProvider provider = mock(AddonInfoProvider.class);
+ when(provider.getAddonInfo(anyString(), any(Locale.class))).thenReturn(null);
+ when(provider.getAddonInfo(anyString(), eq(null))).thenReturn(null);
+ when(provider.getAddonInfo(eq("binding-hue"), any(Locale.class))).thenReturn(addonInfo);
+ when(provider.getAddonInfo(eq("binding-hue"), eq(null))).thenReturn(null);
+ return provider;
+ }
+
+ private AddonInfoProvider createAddonInfoProvider2() {
+ AddonDiscoveryMethod discoveryMethod = new AddonDiscoveryMethod().setServiceType("upnp")
+ .setMatchProperties(List.of(new AddonMatchProperty("modelName", "Philips hue bridge")));
+ AddonInfo addonInfo = AddonInfo.builder("hue", "binding").withName("name-two")
+ .withDescription("description-two").withCountries("DE,FR").withSourceBundle("source-bundle")
+ .withServiceId("service-id").withConfigDescriptionURI("http://www.openhab.org")
+ .withDiscoveryMethods(List.of(discoveryMethod)).build();
+ AddonInfoProvider provider = mock(AddonInfoProvider.class);
+ when(provider.getAddonInfo(anyString(), any(Locale.class))).thenReturn(null);
+ when(provider.getAddonInfo(anyString(), eq(null))).thenReturn(null);
+ when(provider.getAddonInfo(eq("binding-hue"), any(Locale.class))).thenReturn(addonInfo);
+ when(provider.getAddonInfo(eq("binding-hue"), eq(null))).thenReturn(null);
+ return provider;
+ }
+
+ /**
+ * Test fetching a single addon-info from the registry with no merging.
+ */
+ @Test
+ void testGetOneAddonInfo() {
+ AddonInfoRegistry registry = new AddonInfoRegistry();
+ assertNotNull(addonInfoProvider0);
+ registry.addAddonInfoProvider(Objects.requireNonNull(addonInfoProvider0));
+
+ AddonInfo addonInfo;
+ addonInfo = registry.getAddonInfo("aardvark", Locale.US);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("aardvark", null);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("binding-hue", null);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("binding-hue", Locale.US);
+ assertNotNull(addonInfo);
+
+ assertEquals("hue", addonInfo.getId());
+ assertEquals("binding", addonInfo.getType());
+ assertEquals("binding-hue", addonInfo.getUID());
+ assertTrue(addonInfo.getName().startsWith("name-"));
+ assertTrue(addonInfo.getDescription().startsWith("description-"));
+ assertNull(addonInfo.getSourceBundle());
+ assertNotEquals("local", addonInfo.getConnection());
+ assertEquals(0, addonInfo.getCountries().size());
+ assertNotEquals("http://www.openhab.org", addonInfo.getConfigDescriptionURI());
+ assertEquals("binding.hue", addonInfo.getServiceId());
+ assertEquals(0, addonInfo.getDiscoveryMethods().size());
+ }
+
+ /**
+ * Test fetching two addon-info's from the registry with merging.
+ */
+ @Test
+ void testMergeAddonInfos2() {
+ AddonInfoRegistry registry = new AddonInfoRegistry();
+ assertNotNull(addonInfoProvider0);
+ registry.addAddonInfoProvider(Objects.requireNonNull(addonInfoProvider0));
+ assertNotNull(addonInfoProvider1);
+ registry.addAddonInfoProvider(Objects.requireNonNull(addonInfoProvider1));
+
+ AddonInfo addonInfo;
+ addonInfo = registry.getAddonInfo("aardvark", Locale.US);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("aardvark", null);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("binding-hue", null);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("binding-hue", Locale.US);
+ assertNotNull(addonInfo);
+
+ assertEquals("hue", addonInfo.getId());
+ assertEquals("binding", addonInfo.getType());
+ assertEquals("binding-hue", addonInfo.getUID());
+ assertTrue(addonInfo.getName().startsWith("name-"));
+ assertTrue(addonInfo.getDescription().startsWith("description-"));
+ assertNull(addonInfo.getSourceBundle());
+ assertEquals("local", addonInfo.getConnection());
+ assertEquals(2, addonInfo.getCountries().size());
+ assertNotEquals("http://www.openhab.org", addonInfo.getConfigDescriptionURI());
+ assertEquals("binding.hue", addonInfo.getServiceId());
+ assertEquals(1, addonInfo.getDiscoveryMethods().size());
+ }
+
+ /**
+ * Test fetching three addon-info's from the registry with full merging.
+ */
+ @Test
+ void testMergeAddonInfos3() {
+ AddonInfoRegistry registry = new AddonInfoRegistry();
+ assertNotNull(addonInfoProvider0);
+ registry.addAddonInfoProvider(Objects.requireNonNull(addonInfoProvider0));
+ assertNotNull(addonInfoProvider1);
+ registry.addAddonInfoProvider(Objects.requireNonNull(addonInfoProvider1));
+ assertNotNull(addonInfoProvider2);
+ registry.addAddonInfoProvider(Objects.requireNonNull(addonInfoProvider2));
+
+ AddonInfo addonInfo;
+ addonInfo = registry.getAddonInfo("aardvark", Locale.US);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("aardvark", null);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("binding-hue", null);
+ assertNull(addonInfo);
+ addonInfo = registry.getAddonInfo("binding-hue", Locale.US);
+ assertNotNull(addonInfo);
+
+ assertEquals("hue", addonInfo.getId());
+ assertEquals("binding", addonInfo.getType());
+ assertEquals("binding-hue", addonInfo.getUID());
+ assertTrue(addonInfo.getName().startsWith("name-"));
+ assertTrue(addonInfo.getDescription().startsWith("description-"));
+ assertEquals("source-bundle", addonInfo.getSourceBundle());
+ assertEquals("local", addonInfo.getConnection());
+ assertEquals(4, addonInfo.getCountries().size());
+ assertEquals("http://www.openhab.org", addonInfo.getConfigDescriptionURI());
+ assertEquals("service-id", addonInfo.getServiceId());
+ assertEquals(2, addonInfo.getDiscoveryMethods().size());
+ }
+}
diff --git a/bundles/org.openhab.core.audio/pom.xml b/bundles/org.openhab.core.audio/pom.xml
index 844a3b7e2a7..2603aa967e1 100644
--- a/bundles/org.openhab.core.audio/pom.xml
+++ b/bundles/org.openhab.core.audio/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.audio
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioException.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioException.java
index 4a30d500630..9c02664672c 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioException.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioException.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioFormat.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioFormat.java
index 21f94ef9f14..64987e08659 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioFormat.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioFormat.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -12,6 +12,7 @@
*/
package org.openhab.core.audio;
+import java.util.Objects;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -23,9 +24,13 @@
* @author Harald Kuhn - Initial contribution
* @author Kelly Davis - Modified to match discussion in #584
* @author Kai Kreuzer - Moved class, included constants, added toString
+ * @author Miguel Álvarez Díez - Add pcm signed format
*/
@NonNullByDefault
public class AudioFormat {
+ // generic pcm signed format (no container) without any further constraints
+ public static final AudioFormat PCM_SIGNED = new AudioFormat(AudioFormat.CONTAINER_NONE,
+ AudioFormat.CODEC_PCM_SIGNED, null, null, null, null);
// generic mp3 format without any further constraints
public static final AudioFormat MP3 = new AudioFormat(AudioFormat.CONTAINER_NONE, AudioFormat.CODEC_MP3, null, null,
@@ -436,29 +441,13 @@ public boolean isCompatible(@Nullable AudioFormat audioFormat) {
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof AudioFormat format) {
- if (!(null == getCodec() ? null == format.getCodec() : getCodec().equals(format.getCodec()))) {
- return false;
- }
- if (!(null == getContainer() ? null == format.getContainer()
- : getContainer().equals(format.getContainer()))) {
- return false;
- }
- if (!(null == isBigEndian() ? null == format.isBigEndian() : isBigEndian().equals(format.isBigEndian()))) {
- return false;
- }
- if (!(null == getBitDepth() ? null == format.getBitDepth() : getBitDepth().equals(format.getBitDepth()))) {
- return false;
- }
- if (!(null == getBitRate() ? null == format.getBitRate() : getBitRate().equals(format.getBitRate()))) {
- return false;
- }
- if (!(null == getFrequency() ? null == format.getFrequency()
- : getFrequency().equals(format.getFrequency()))) {
- return false;
- }
- if (!(null == getChannels() ? null == format.getChannels() : getChannels().equals(format.getChannels()))) {
- return false;
- }
+ return Objects.equals(getCodec(), format.getCodec()) && //
+ Objects.equals(getContainer(), format.getContainer()) && //
+ Objects.equals(isBigEndian(), format.isBigEndian()) && //
+ Objects.equals(getBitDepth(), format.getBitDepth()) && //
+ Objects.equals(getBitRate(), format.getBitRate()) && //
+ Objects.equals(getFrequency(), format.getFrequency()) && //
+ Objects.equals(getChannels(), format.getChannels());
}
return super.equals(obj);
}
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioHTTPServer.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioHTTPServer.java
index 57e1f55c105..75900be83c3 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioHTTPServer.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioHTTPServer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioManager.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioManager.java
index d640c0f3996..3a447960e3d 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioManager.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -33,7 +33,7 @@ public interface AudioManager {
/**
* Name of the sub-directory of the config folder, holding sound files.
*/
- static final String SOUND_DIR = "sounds";
+ String SOUND_DIR = "sounds";
/**
* Plays the passed audio stream using the default audio sink.
@@ -206,7 +206,7 @@ public interface AudioManager {
/**
* Get a list of source ids that match a given pattern
*
- * @param pattern pattern to search, can include `*` and `?` placeholders
+ * @param pattern pattern to search, can include {@code *} and {@code ?} placeholders
* @return ids of matching sources
*/
Set getSourceIds(String pattern);
@@ -248,7 +248,7 @@ public interface AudioManager {
/**
* Get a list of sink ids that match a given pattern
*
- * @param pattern pattern to search, can include `*` and `?` placeholders
+ * @param pattern pattern to search, can include {@code *} and {@code ?} placeholders
* @return ids of matching sinks
*/
Set getSinkIds(String pattern);
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSink.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSink.java
index adc542a5ce4..640984c3deb 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSink.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSink.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkAsync.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkAsync.java
index c88d20c93c9..33ca794aa30 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkAsync.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkAsync.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkSync.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkSync.java
index 97c888f7468..b355b95ef42 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkSync.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSinkSync.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSource.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSource.java
index a023e47b31b..e03500df8f3 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSource.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioSource.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioStream.java
index 560fcc21278..382255d20f9 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/AudioStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ByteArrayAudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ByteArrayAudioStream.java
index 6386e39db53..ed0b79b109e 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ByteArrayAudioStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ByteArrayAudioStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ClonableAudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ClonableAudioStream.java
index 57dfcdc3c80..a86954ea35f 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ClonableAudioStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/ClonableAudioStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -31,5 +31,5 @@ public interface ClonableAudioStream {
* @return a new input stream that can be consumed by the caller
* @throws AudioException if stream cannot be created
*/
- public InputStream getClonedStream() throws AudioException;
+ InputStream getClonedStream() throws AudioException;
}
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FileAudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FileAudioStream.java
index ab35257b6f5..a42f487604a 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FileAudioStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FileAudioStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FixedLengthAudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FixedLengthAudioStream.java
index daaf6657a33..2efb1029d6e 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FixedLengthAudioStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/FixedLengthAudioStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/PipedAudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/PipedAudioStream.java
new file mode 100644
index 00000000000..03b81881b48
--- /dev/null
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/PipedAudioStream.java
@@ -0,0 +1,283 @@
+/**
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.core.audio;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.LinkedList;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is an implementation of an {@link AudioStream} used to transmit raw audio data to a sink.
+ *
+ * It just pipes the audio through it, the default pipe size is equal to 0.5 seconds of audio,
+ * the implementation locks if you set a pipe size lower to the byte length used to write.
+ *
+ * In order to support audio multiplex out of the box you should create a {@link PipedAudioStream.Group} instance
+ * which can be used to create the {@link PipedAudioStream} connected to it and then write to all of them though the
+ * group.
+ *
+ * @author Miguel Álvarez Díez - Initial contribution
+ */
+@NonNullByDefault
+public class PipedAudioStream extends AudioStream {
+ private final AudioFormat format;
+ private final PipedInputStream pipedInput;
+ private final PipedOutputStream pipedOutput;
+ private final AtomicBoolean closed = new AtomicBoolean(false);
+ private final LinkedList onCloseChain = new LinkedList<>();
+
+ protected PipedAudioStream(AudioFormat format, int pipeSize, PipedOutputStream outputStream) throws IOException {
+ this.pipedOutput = outputStream;
+ this.pipedInput = new PipedInputStream(outputStream, pipeSize);
+ this.format = format;
+ }
+
+ @Override
+ public AudioFormat getFormat() {
+ return this.format;
+ }
+
+ @Override
+ public int read() throws IOException {
+ if (closed.get()) {
+ return -1;
+ }
+ return pipedInput.read();
+ }
+
+ @Override
+ public int read(byte @Nullable [] b) throws IOException {
+ if (closed.get()) {
+ return -1;
+ }
+ return pipedInput.read(b);
+ }
+
+ @Override
+ public int read(byte @Nullable [] b, int off, int len) throws IOException {
+ if (closed.get()) {
+ return -1;
+ }
+ return pipedInput.read(b, off, len);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (closed.getAndSet(true)) {
+ return;
+ }
+ if (this.onCloseChain.size() > 0) {
+ this.onCloseChain.forEach(Runnable::run);
+ this.onCloseChain.clear();
+ }
+ pipedOutput.close();
+ pipedInput.close();
+ }
+
+ /**
+ * Add a new handler that will be executed on stream close.
+ * It will be chained to the previous handler if any, and executed in order.
+ *
+ * @param onClose block to run on stream close
+ */
+ public void onClose(Runnable onClose) {
+ this.onCloseChain.add(onClose);
+ }
+
+ protected PipedOutputStream getOutputStream() {
+ return pipedOutput;
+ }
+
+ /**
+ * Creates a new piped stream group used to open new streams and write data to them.
+ *
+ * Internal pipe size is 0.5s.
+ *
+ * @param format the audio format of the group audio streams
+ * @return a group instance
+ */
+ public static Group newGroup(AudioFormat format) {
+ int pipeSize = Math.round(( //
+ (float) Objects.requireNonNull(format.getFrequency()) * //
+ (float) Objects.requireNonNull(format.getBitDepth()) * //
+ (float) Objects.requireNonNull(format.getChannels()) //
+ ) / 2f);
+ return new Group(format, pipeSize);
+ }
+
+ /**
+ * Creates a new piped stream group used to open new streams and write data to them.
+ *
+ * @param format the audio format of the group audio streams
+ * @param pipeSize the pipe size of the created streams
+ * @return a piped stream group instance
+ */
+ public static Group newGroup(AudioFormat format, int pipeSize) {
+ return new Group(format, pipeSize);
+ }
+
+ /**
+ * The {@link PipedAudioStream.Group} is an {@link OutputStream} implementation that can be use to
+ * create one or more {@link PipedAudioStream} instances and write to them at once.
+ *
+ * The created {@link PipedAudioStream} instances are removed from the group when closed.
+ */
+ public static class Group extends OutputStream {
+ private final int pipeSize;
+ private final AudioFormat format;
+ private final ConcurrentLinkedQueue openPipes = new ConcurrentLinkedQueue<>();
+ private final Logger logger = LoggerFactory.getLogger(Group.class);
+
+ protected Group(AudioFormat format, int pipeSize) {
+ this.pipeSize = pipeSize;
+ this.format = format;
+ }
+
+ /**
+ * Creates a new {@link PipedAudioStream} connected to the group.
+ * The stream unregisters itself from the group on close.
+ *
+ * @return a new {@link PipedAudioStream} to pipe data written to the group
+ * @throws IOException when unable to create the stream
+ */
+ public PipedAudioStream getAudioStreamInGroup() throws IOException {
+ var pipedOutput = new PipedOutputStream();
+ var audioStream = new PipedAudioStream(format, pipeSize, pipedOutput);
+ if (!openPipes.add(audioStream)) {
+ audioStream.close();
+ throw new IOException("Unable to add new piped stream to group");
+ }
+ audioStream.onClose(() -> {
+ if (!openPipes.remove(audioStream)) {
+ logger.warn("Trying to remove an unregistered stream, this is not expected");
+ }
+ });
+ return audioStream;
+ }
+
+ /**
+ * Returns true if this group has no streams connected.
+ *
+ * @return true if this group has no streams connected
+ */
+ public boolean isEmpty() {
+ return openPipes.isEmpty();
+ }
+
+ /**
+ * Returns the number of streams connected.
+ *
+ * @return the number of streams connected
+ */
+ public int size() {
+ return openPipes.size();
+ }
+
+ @Override
+ public void write(byte @Nullable [] b, int off, int len) {
+ synchronized (openPipes) {
+ for (var pipe : openPipes) {
+ try {
+ pipe.getOutputStream().write(b, off, len);
+ } catch (InterruptedIOException e) {
+ logger.warn("InterruptedIOException while writing to pipe: {}", e.getMessage());
+ } catch (IOException e) {
+ logger.warn("IOException while writing to pipe: {}", e.getMessage());
+ } catch (RuntimeException e) {
+ logger.warn("RuntimeException while writing to pipe: {}", e.getMessage());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ synchronized (openPipes) {
+ for (var pipe : openPipes) {
+ try {
+ pipe.getOutputStream().write(b);
+ } catch (InterruptedIOException e) {
+ logger.warn("InterruptedIOException while writing to pipe: {}", e.getMessage());
+ } catch (IOException e) {
+ logger.warn("IOException while writing to pipe: {}", e.getMessage());
+ } catch (RuntimeException e) {
+ logger.warn("RuntimeException while writing to pipe: {}", e.getMessage());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void write(byte @Nullable [] bytes) {
+ synchronized (openPipes) {
+ for (var pipe : openPipes) {
+ try {
+ pipe.getOutputStream().write(bytes);
+ } catch (InterruptedIOException e) {
+ logger.warn("InterruptedIOException on pipe flush: {}", e.getMessage());
+ } catch (IOException e) {
+ logger.warn("IOException on pipe flush: {}", e.getMessage());
+ } catch (RuntimeException e) {
+ logger.warn("RuntimeException on pipe flush: {}", e.getMessage());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void flush() {
+ synchronized (openPipes) {
+ for (var pipe : openPipes) {
+ try {
+ pipe.getOutputStream().flush();
+ } catch (InterruptedIOException e) {
+ logger.warn("InterruptedIOException while writing to pipe: {}", e.getMessage());
+ } catch (IOException e) {
+ logger.warn("IOException while writing to pipe: {}", e.getMessage());
+ } catch (RuntimeException e) {
+ logger.warn("RuntimeException while writing to pipe: {}", e.getMessage());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void close() {
+ synchronized (openPipes) {
+ for (var pipe : openPipes) {
+ try {
+ pipe.close();
+ } catch (InterruptedIOException e) {
+ logger.warn("InterruptedIOException closing pipe: {}", e.getMessage());
+ } catch (IOException e) {
+ logger.warn("IOException closing pipe: {}", e.getMessage());
+ } catch (RuntimeException e) {
+ logger.warn("RuntimeException closing pipe: {}", e.getMessage());
+ }
+ }
+ openPipes.clear();
+ }
+ }
+ }
+}
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/SizeableAudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/SizeableAudioStream.java
index 6074f2424c2..ed0c7368467 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/SizeableAudioStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/SizeableAudioStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -27,5 +27,5 @@ public interface SizeableAudioStream {
*
* @return absolute length in bytes
*/
- public long length();
+ long length();
}
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/StreamServed.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/StreamServed.java
index 35bf5946957..317618ce64f 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/StreamServed.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/StreamServed.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/URLAudioStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/URLAudioStream.java
index d365829097a..2f5effda070 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/URLAudioStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/URLAudioStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioFormatException.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioFormatException.java
index 7d13e9ae831..9ff8c824210 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioFormatException.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioFormatException.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioStreamException.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioStreamException.java
index b9f08a38b97..7557a0d47d4 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioStreamException.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/UnsupportedAudioStreamException.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioConsoleCommandExtension.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioConsoleCommandExtension.java
index 4d8ebf5c067..51e9142ca6e 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioConsoleCommandExtension.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioConsoleCommandExtension.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -161,7 +161,7 @@ private void play(String[] args, Console console) {
playOnSinks(args[0], args[1], null, console);
break;
case 3:
- PercentType volume = null;
+ PercentType volume;
try {
volume = PercentType.valueOf(args[2]);
} catch (Exception e) {
@@ -184,7 +184,7 @@ private void synthesizeMelody(String[] args, Console console) {
playMelodyOnSinks(args[0], args[1], null, console);
break;
case 3:
- PercentType volume = null;
+ PercentType volume;
try {
volume = PercentType.valueOf(args[2]);
} catch (Exception e) {
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java
index 41a77393797..cf1f5bac570 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioManagerImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -120,7 +120,7 @@ public void play(@Nullable AudioStream audioStream, @Nullable String sinkId, @Nu
AudioSink sink = getSink(sinkId);
if (sink != null) {
Runnable restoreVolume = handleVolumeCommand(volume, sink);
- sink.processAndComplete(audioStream).exceptionally((exception) -> {
+ sink.processAndComplete(audioStream).exceptionally(exception -> {
logger.warn("Error playing '{}': {}", audioStream, exception.getMessage(), exception);
return null;
}).thenRun(restoreVolume);
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java
index 7238df8fbbb..ae76aabebb9 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/AudioServlet.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -102,7 +102,7 @@ public AudioServlet(@Reference AudioSinkUtils audioSinkUtils) {
@Deactivate
protected synchronized void deactivate() {
- servedStreams.values().stream().map(streamServed -> streamServed.audioStream()).forEach(this::tryClose);
+ servedStreams.values().stream().map(StreamServed::audioStream).forEach(this::tryClose);
servedStreams.clear();
}
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/AudioPlayer.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/AudioPlayer.java
index e127b1f5589..f6214a4df00 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/AudioPlayer.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/AudioPlayer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -17,7 +17,6 @@
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
-import javax.sound.sampled.Line;
import javax.sound.sampled.Line.Info;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
@@ -49,7 +48,7 @@ public class AudioPlayer extends Thread {
/**
* Constructs an AudioPlayer to play the passed AudioSource
*
- * @param audioSource The AudioSource to play
+ * @param audioStream The AudioStream to play
*/
public AudioPlayer(AudioStream audioStream) {
this.audioStream = audioStream;
@@ -77,10 +76,10 @@ public void run() {
logger.warn("No line found: {}", e.getMessage());
logger.info("Available lines are:");
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); // get available mixers
- Mixer mixer = null;
- for (int cnt = 0; cnt < mixerInfo.length; cnt++) {
- mixer = AudioSystem.getMixer(mixerInfo[cnt]);
- Line.Info[] lineInfos = mixer.getSourceLineInfo();
+ Mixer mixer;
+ for (Mixer.Info value : mixerInfo) {
+ mixer = AudioSystem.getMixer(value);
+ Info[] lineInfos = mixer.getSourceLineInfo();
for (Info lineInfo : lineInfos) {
logger.info("{}", lineInfo);
}
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSink.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSink.java
index 41208b514f6..ae173752ef5 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSink.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSink.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -33,6 +33,7 @@
import org.openhab.core.audio.AudioSink;
import org.openhab.core.audio.AudioSinkAsync;
import org.openhab.core.audio.AudioStream;
+import org.openhab.core.audio.PipedAudioStream;
import org.openhab.core.audio.URLAudioStream;
import org.openhab.core.audio.UnsupportedAudioFormatException;
import org.openhab.core.audio.UnsupportedAudioStreamException;
@@ -51,13 +52,14 @@
*
* @author Kai Kreuzer - Initial contribution and API
* @author Christoph Weitkamp - Added getSupportedStreams() and UnsupportedAudioStreamException
+ * @author Miguel Álvarez Díez - Added piped audio stream support
*
*/
@NonNullByDefault
@Component(service = AudioSink.class, immediate = true)
public class JavaSoundAudioSink extends AudioSinkAsync {
- private static final Logger LOGGER = LoggerFactory.getLogger(JavaSoundAudioSink.class);
+ private final Logger logger = LoggerFactory.getLogger(JavaSoundAudioSink.class);
private boolean isMac = false;
private @Nullable PercentType macVolumeValue = null;
@@ -65,7 +67,8 @@ public class JavaSoundAudioSink extends AudioSinkAsync {
private NamedThreadFactory threadFactory = new NamedThreadFactory("audio");
- private static final Set SUPPORTED_AUDIO_FORMATS = Set.of(AudioFormat.MP3, AudioFormat.WAV);
+ private static final Set SUPPORTED_AUDIO_FORMATS = Set.of(AudioFormat.MP3, AudioFormat.WAV,
+ AudioFormat.PCM_SIGNED);
// we accept any stream
private static final Set> SUPPORTED_AUDIO_STREAMS = Set.of(AudioStream.class);
@@ -81,14 +84,24 @@ protected void activate(BundleContext context) {
@Override
public synchronized void processAsynchronously(final @Nullable AudioStream audioStream)
throws UnsupportedAudioFormatException, UnsupportedAudioStreamException {
- if (audioStream != null && !AudioFormat.CODEC_MP3.equals(audioStream.getFormat().getCodec())) {
+ if (audioStream instanceof PipedAudioStream pipedAudioStream
+ && AudioFormat.PCM_SIGNED.isCompatible(pipedAudioStream.getFormat())) {
+ pipedAudioStream.onClose(() -> playbackFinished(pipedAudioStream));
+ AudioPlayer audioPlayer = new AudioPlayer(pipedAudioStream);
+ audioPlayer.start();
+ try {
+ audioPlayer.join();
+ } catch (InterruptedException e) {
+ logger.debug("Audio stream has been interrupted.");
+ }
+ } else if (audioStream != null && !AudioFormat.CODEC_MP3.equals(audioStream.getFormat().getCodec())) {
AudioPlayer audioPlayer = new AudioPlayer(audioStream);
audioPlayer.start();
try {
audioPlayer.join();
playbackFinished(audioStream);
} catch (InterruptedException e) {
- LOGGER.error("Playing audio has been interrupted.");
+ logger.error("Playing audio has been interrupted.");
}
} else {
if (audioStream == null || audioStream instanceof URLAudioStream) {
@@ -106,7 +119,7 @@ public synchronized void processAsynchronously(final @Nullable AudioStream audio
// we start a new continuous stream and store its handle
playInThread(audioStream, true);
} catch (JavaLayerException e) {
- LOGGER.error("An exception occurred while playing url audio stream : '{}'", e.getMessage());
+ logger.error("An exception occurred while playing url audio stream : '{}'", e.getMessage());
}
return;
}
@@ -115,7 +128,7 @@ public synchronized void processAsynchronously(final @Nullable AudioStream audio
try {
playInThread(audioStream, false);
} catch (JavaLayerException e) {
- LOGGER.error("An exception occurred while playing audio : '{}'", e.getMessage());
+ logger.error("An exception occurred while playing audio : '{}'", e.getMessage());
}
}
}
@@ -131,7 +144,7 @@ private void playInThread(final AudioStream audioStream, boolean store) throws J
try {
streamPlayerFinal.play();
} catch (Exception e) {
- LOGGER.error("An exception occurred while playing audio : '{}'", e.getMessage());
+ logger.error("An exception occurred while playing audio : '{}'", e.getMessage());
} finally {
streamPlayerFinal.close();
playbackFinished(audioStream);
@@ -179,7 +192,7 @@ public PercentType getVolume() throws IOException {
if (volumes[0] != null) {
return new PercentType(Math.round(volumes[0] * 100f));
} else {
- LOGGER.warn("Cannot determine master volume level - assuming 100%");
+ logger.warn("Cannot determine master volume level - assuming 100%");
return PercentType.HUNDRED;
}
} else {
@@ -188,7 +201,7 @@ public PercentType getVolume() throws IOException {
if (cachedVolume == null) {
Process p = Runtime.getRuntime()
.exec(new String[] { "osascript", "-e", "output volume of (get volume settings)" });
- String value = null;
+ String value;
try (Scanner scanner = new Scanner(p.getInputStream(), StandardCharsets.UTF_8.name())) {
value = scanner.useDelimiter("\\A").next().strip();
}
@@ -196,7 +209,7 @@ public PercentType getVolume() throws IOException {
cachedVolume = new PercentType(value);
macVolumeValue = cachedVolume;
} catch (NumberFormatException e) {
- LOGGER.warn("Cannot determine master volume level, received response '{}' - assuming 100%", value);
+ logger.warn("Cannot determine master volume level, received response '{}' - assuming 100%", value);
return PercentType.HUNDRED;
}
}
@@ -236,7 +249,7 @@ private void runVolumeCommand(Function closure) {
}
port.close();
} catch (LineUnavailableException e) {
- LOGGER.error("Cannot access master volume control", e);
+ logger.error("Cannot access master volume control", e);
}
}
}
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSource.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSource.java
index ae3b6a244ff..571f4665b85 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSource.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundAudioSource.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -13,13 +13,8 @@
package org.openhab.core.audio.internal.javasound;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
import java.util.Locale;
import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
@@ -32,6 +27,7 @@
import org.openhab.core.audio.AudioFormat;
import org.openhab.core.audio.AudioSource;
import org.openhab.core.audio.AudioStream;
+import org.openhab.core.audio.PipedAudioStream;
import org.openhab.core.common.ThreadPoolManager;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
@@ -43,6 +39,7 @@
* @author Kelly Davis - Initial contribution and API
* @author Kai Kreuzer - Refactored and stabilized
* @author Miguel Álvarez - Share microphone line only under Windows OS
+ * @author Miguel Álvarez - Share microphone line on all OS using piped audio streams
*
*/
@NonNullByDefault
@@ -63,22 +60,17 @@ public class JavaSoundAudioSource implements AudioSource {
private final AudioFormat audioFormat = convertAudioFormat(format);
/**
- * Running on Windows OS
- */
- private final boolean windowsOS = System.getProperty("os.name", "Unknown").startsWith("Win");
-
- /**
- * TargetDataLine for sharing the mic on Windows OS due to limitations
+ * TargetDataLine for sharing the mic
*/
private @Nullable TargetDataLine microphone;
/**
- * Set for control microphone sharing on Windows OS
+ * Group for microphone sharing
*/
- private final ConcurrentLinkedQueue openStreamRefs = new ConcurrentLinkedQueue<>();
+ private final PipedAudioStream.Group streamGroup = PipedAudioStream.newGroup(audioFormat);
/**
- * Task for writing microphone data to each of the open sources on Windows OS
+ * Task for writing microphone data to each of the open sources
*/
private @Nullable Future> pipeWriteTask;
@@ -106,50 +98,35 @@ public AudioStream getInputStream(AudioFormat expectedFormat) throws AudioExcept
if (!expectedFormat.isCompatible(audioFormat)) {
throw new AudioException("Cannot produce streams in format " + expectedFormat);
}
- // on OSs other than windows we can open multiple lines for the microphone
- if (!windowsOS) {
- TargetDataLine microphone = initMicrophone(format);
- var inputStream = new JavaSoundInputStream(new InputStream() {
- @Override
- public int read() throws IOException {
- return microphone.available();
- }
-
- @Override
- public int read(byte @Nullable [] b, int off, int len) throws IOException {
- return microphone.read(b, off, len);
- }
-
- @Override
- public void close() throws IOException {
- microphone.close();
- }
- }, audioFormat);
- microphone.start();
- return inputStream;
- }
- // on Windows OS we share the microphone line
- synchronized (openStreamRefs) {
+ synchronized (streamGroup) {
TargetDataLine microphone = this.microphone;
if (microphone == null) {
microphone = initMicrophone(format);
this.microphone = microphone;
}
- var pipedOutputStream = new PipedOutputStream();
- PipedInputStream pipedInputStream;
+ PipedAudioStream audioStream;
try {
- pipedInputStream = new PipedInputStream(pipedOutputStream, 1024 * 10) {
- @Override
- public void close() throws IOException {
- unregisterPipe(pipedOutputStream);
- super.close();
+ audioStream = streamGroup.getAudioStreamInGroup();
+ audioStream.onClose(() -> {
+ synchronized (streamGroup) {
+ if (streamGroup.isEmpty()) {
+ Future> pipeWriteTask = this.pipeWriteTask;
+ if (pipeWriteTask != null) {
+ pipeWriteTask.cancel(true);
+ this.pipeWriteTask = null;
+ }
+ TargetDataLine microphoneDataLine = this.microphone;
+ if (microphoneDataLine != null) {
+ microphoneDataLine.close();
+ this.microphone = null;
+ }
+ }
}
- };
+ });
} catch (IOException ie) {
throw new AudioException("Cannot open stream pipe: " + ie.getMessage());
}
- openStreamRefs.add(pipedOutputStream);
- var inputStream = new JavaSoundInputStream(pipedInputStream, audioFormat);
+ var inputStream = new JavaSoundInputStream(audioStream, audioFormat);
microphone.start();
startPipeWrite();
return inputStream;
@@ -161,30 +138,13 @@ private void startPipeWrite() {
this.pipeWriteTask = executor.submit(() -> {
int lengthRead;
byte[] buffer = new byte[1024];
- while (!openStreamRefs.isEmpty()) {
+ while (!streamGroup.isEmpty()) {
TargetDataLine stream = this.microphone;
if (stream != null) {
try {
lengthRead = stream.read(buffer, 0, buffer.length);
- for (PipedOutputStream output : openStreamRefs) {
- try {
- output.write(buffer, 0, lengthRead);
- if (openStreamRefs.contains(output)) {
- output.flush();
- }
- } catch (InterruptedIOException e) {
- if (openStreamRefs.isEmpty()) {
- // task has been ended while writing
- return;
- }
- logger.warn("InterruptedIOException while writing to source pipe: {}",
- e.getMessage());
- } catch (IOException e) {
- logger.warn("IOException while writing to source pipe: {}", e.getMessage());
- } catch (RuntimeException e) {
- logger.warn("RuntimeException while writing to source pipe: {}", e.getMessage());
- }
- }
+ streamGroup.write(buffer, 0, lengthRead);
+ streamGroup.flush();
} catch (RuntimeException e) {
logger.warn("RuntimeException while reading from JavaSound source: {}", e.getMessage());
}
@@ -197,32 +157,6 @@ private void startPipeWrite() {
}
}
- private void unregisterPipe(PipedOutputStream pipedOutputStream) {
- synchronized (openStreamRefs) {
- openStreamRefs.remove(pipedOutputStream);
- try {
- Thread.sleep(0);
- } catch (InterruptedException ignored) {
- }
- if (openStreamRefs.isEmpty()) {
- Future> pipeWriteTask = this.pipeWriteTask;
- if (pipeWriteTask != null) {
- pipeWriteTask.cancel(true);
- this.pipeWriteTask = null;
- }
- TargetDataLine microphone = this.microphone;
- if (microphone != null) {
- microphone.close();
- this.microphone = null;
- }
- }
- try {
- pipedOutputStream.close();
- } catch (IOException ignored) {
- }
- }
- }
-
@Override
public String toString() {
return "javasound";
@@ -235,7 +169,7 @@ public String toString() {
* @return The converted AudioFormat
*/
private static AudioFormat convertAudioFormat(javax.sound.sampled.AudioFormat audioFormat) {
- String container = AudioFormat.CONTAINER_WAVE;
+ String container = AudioFormat.CONTAINER_NONE;
String codec = audioFormat.getEncoding().toString();
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundInputStream.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundInputStream.java
index 4773235c9da..04a8fdd8a14 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundInputStream.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/javasound/JavaSoundInputStream.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/PlayURLEvent.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/PlayURLEvent.java
index 3e6e0a36157..b34bf0399d4 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/PlayURLEvent.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/PlayURLEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -16,7 +16,8 @@
import org.openhab.core.events.AbstractEvent;
/**
- * This is an {@link Event} that is sent when a web client should play an audio stream from a url.
+ * This is an {@link org.openhab.core.events.Event Event} that is sent when a web client should play an audio stream
+ * from a url.
*
* @author Kai Kreuzer - Initial contribution and API
*/
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioAudioSink.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioAudioSink.java
index 389a935a204..dffbee7afac 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioAudioSink.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioAudioSink.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioEventFactory.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioEventFactory.java
index 6b5fb9ad4e5..e30dbaba620 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioEventFactory.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/internal/webaudio/WebAudioEventFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtils.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtils.java
index b5a96e10811..f63fd5d9bd9 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtils.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtils.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtilsImpl.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtilsImpl.java
index 069096baee8..32d5af24a48 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtilsImpl.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioSinkUtilsImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioStreamUtils.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioStreamUtils.java
index 04f6a80fe36..98e3c4335cb 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioStreamUtils.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioStreamUtils.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioWaveUtils.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioWaveUtils.java
index f6d0df3db59..df8b0c7606d 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioWaveUtils.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/AudioWaveUtils.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -89,7 +89,7 @@ public static AudioFormat parseWavFormat(InputStream inputStream) throws IOExcep
*/
public static void removeFMT(InputStream data) throws IOException {
DataInputStream dataInputStream = new DataInputStream(data);
- Integer nextInt = dataInputStream.readInt();
+ int nextInt = dataInputStream.readInt();
int i = 0;
while (nextInt != DATA_MAGIC && i < 200) {
nextInt = dataInputStream.readInt();
diff --git a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/ToneSynthesizer.java b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/ToneSynthesizer.java
index c6c7f613289..39725db5238 100644
--- a/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/ToneSynthesizer.java
+++ b/bundles/org.openhab.core.audio/src/main/java/org/openhab/core/audio/utils/ToneSynthesizer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -68,8 +69,7 @@ public static List parseMelody(String melody) throws ParseException {
var melodySounds = new ArrayList();
var noteTextList = melody.split("\\s");
var melodyTextIndex = 0;
- for (var i = 0; i < noteTextList.length; i++) {
- var noteText = noteTextList[i];
+ for (String noteText : noteTextList) {
var noteTextParts = noteText.split(":");
var soundMillis = 200;
switch (noteTextParts.length) {
@@ -112,17 +112,11 @@ public static Tone silenceTone(long millis) {
}
public ToneSynthesizer(AudioFormat audioFormat) {
- assert audioFormat.getFrequency() != null;
- this.sampleRate = audioFormat.getFrequency();
- assert audioFormat.getBitDepth() != null;
- this.bitDepth = audioFormat.getBitDepth();
- assert audioFormat.getBitRate() != null;
- this.bitRate = audioFormat.getBitRate();
- assert audioFormat.getChannels() != null;
- this.channels = audioFormat.getChannels();
- var bigEndian = audioFormat.isBigEndian();
- assert bigEndian != null;
- this.bigEndian = bigEndian;
+ this.sampleRate = Objects.requireNonNull(audioFormat.getFrequency());
+ this.bitDepth = Objects.requireNonNull(audioFormat.getBitDepth());
+ this.bitRate = Objects.requireNonNull(audioFormat.getBitRate());
+ this.channels = Objects.requireNonNull(audioFormat.getChannels());
+ this.bigEndian = Objects.requireNonNull(audioFormat.isBigEndian());
}
/**
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AbstractAudioServletTest.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AbstractAudioServletTest.java
index c70545adc4e..250f256a30d 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AbstractAudioServletTest.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AbstractAudioServletTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioConsoleTest.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioConsoleTest.java
index b01978803e5..523f9e18c89 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioConsoleTest.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioConsoleTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioFormatTest.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioFormatTest.java
index 090a48c8225..e30d18f1f6b 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioFormatTest.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioFormatTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerServletTest.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerServletTest.java
index 4b67d74b471..62327f8479b 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerServletTest.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerServletTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerTest.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerTest.java
index 860d817e270..5d431837eab 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerTest.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioManagerTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioServletTest.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioServletTest.java
index da5eafc1d0e..227df2b14bf 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioServletTest.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/AudioServletTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/fake/AudioSinkFake.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/fake/AudioSinkFake.java
index 6bf2a61d40b..9dc9938b5b4 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/fake/AudioSinkFake.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/fake/AudioSinkFake.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/utils/BundledSoundFileHandler.java b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/utils/BundledSoundFileHandler.java
index 05de1268042..9dbdf0a69a0 100644
--- a/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/utils/BundledSoundFileHandler.java
+++ b/bundles/org.openhab.core.audio/src/test/java/org/openhab/core/audio/internal/utils/BundledSoundFileHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.jaas/pom.xml b/bundles/org.openhab.core.auth.jaas/pom.xml
index 89bfc6c6379..78a75892340 100644
--- a/bundles/org.openhab.core.auth.jaas/pom.xml
+++ b/bundles/org.openhab.core.auth.jaas/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.auth.jaas
diff --git a/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/JaasAuthenticationProvider.java b/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/JaasAuthenticationProvider.java
index 345e1f8a7ce..d6eb8900892 100644
--- a/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/JaasAuthenticationProvider.java
+++ b/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/JaasAuthenticationProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginConfiguration.java b/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginConfiguration.java
index 520143ff55e..1e8f11fe5e3 100644
--- a/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginConfiguration.java
+++ b/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginConfiguration.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -28,6 +28,6 @@ public class ManagedUserLoginConfiguration extends Configuration {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[] { new AppConfigurationEntry(ManagedUserLoginModule.class.getCanonicalName(),
- LoginModuleControlFlag.SUFFICIENT, new HashMap()) };
+ LoginModuleControlFlag.SUFFICIENT, new HashMap<>()) };
}
}
diff --git a/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginModule.java b/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginModule.java
index c285b5a0038..959103df09c 100644
--- a/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginModule.java
+++ b/bundles/org.openhab.core.auth.jaas/src/main/java/org/openhab/core/auth/jaas/internal/ManagedUserLoginModule.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.oauth2client/pom.xml b/bundles/org.openhab.core.auth.oauth2client/pom.xml
index ebf3eb6e263..0eb0a93e4ef 100644
--- a/bundles/org.openhab.core.auth.oauth2client/pom.xml
+++ b/bundles/org.openhab.core.auth.oauth2client/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.auth.oauth2client
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/Keyword.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/Keyword.java
index ddd067c60bd..117db668519 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/Keyword.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/Keyword.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthClientServiceImpl.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthClientServiceImpl.java
index 1d8ce4cb125..523f2b55de8 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthClientServiceImpl.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthClientServiceImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -25,6 +25,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.util.UrlEncoded;
import org.openhab.core.auth.client.oauth2.AccessTokenRefreshListener;
import org.openhab.core.auth.client.oauth2.AccessTokenResponse;
@@ -73,6 +74,8 @@ public class OAuthClientServiceImpl implements OAuthClientService {
private PersistedParams persistedParams = new PersistedParams();
+ private @Nullable Fields extraAuthFields = null;
+
private volatile boolean closed = false;
private OAuthClientServiceImpl(String handle, int tokenExpiresInSeconds, HttpClientFactory httpClientFactory,
@@ -86,7 +89,6 @@ private OAuthClientServiceImpl(String handle, int tokenExpiresInSeconds, HttpCli
/**
* It should only be used internally, thus the access is package level
*
- * @param bundleContext Bundle Context
* @param handle The handle produced previously from
* {@link org.openhab.core.auth.client.oauth2.OAuthFactory#createOAuthClientService}
* @param storeHandler Storage handler
@@ -116,12 +118,11 @@ private OAuthClientServiceImpl(String handle, int tokenExpiresInSeconds, HttpCli
/**
* It should only be used internally, thus the access is package level
*
- * @param bundleContext Bundle Context*
* @param handle The handle produced previously from
* {@link org.openhab.core.auth.client.oauth2.OAuthFactory#createOAuthClientService}*
* @param storeHandler Storage handler
* @param httpClientFactory Http client factory
- * @param persistedParams These parameters are static with respect to the OAuth provider and thus can be persisted.
+ * @param params These parameters are static with respect to the OAuth provider and thus can be persisted.
* @return OAuthClientServiceImpl an instance
*/
static OAuthClientServiceImpl createInstance(String handle, OAuthStoreHandler storeHandler,
@@ -157,8 +158,8 @@ public String getAuthorizationUrl(@Nullable String redirectURI, @Nullable String
}
GsonBuilder gsonBuilder = this.gsonBuilder;
- OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory)
- : new OAuthConnector(httpClientFactory, gsonBuilder);
+ OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory, extraAuthFields)
+ : new OAuthConnector(httpClientFactory, extraAuthFields, gsonBuilder);
return connector.getAuthorizationUrl(authorizationUrl, clientId, redirectURI, persistedParams.state,
scopeToUse);
}
@@ -213,8 +214,8 @@ public AccessTokenResponse getAccessTokenResponseByAuthorizationCode(String auth
}
GsonBuilder gsonBuilder = this.gsonBuilder;
- OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory)
- : new OAuthConnector(httpClientFactory, gsonBuilder);
+ OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory, extraAuthFields)
+ : new OAuthConnector(httpClientFactory, extraAuthFields, gsonBuilder);
AccessTokenResponse accessTokenResponse = connector.grantTypeAuthorizationCode(tokenUrl, authorizationCode,
clientId, persistedParams.clientSecret, redirectURI,
Boolean.TRUE.equals(persistedParams.supportsBasicAuth));
@@ -247,8 +248,8 @@ public AccessTokenResponse getAccessTokenByResourceOwnerPasswordCredentials(Stri
}
GsonBuilder gsonBuilder = this.gsonBuilder;
- OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory)
- : new OAuthConnector(httpClientFactory, gsonBuilder);
+ OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory, extraAuthFields)
+ : new OAuthConnector(httpClientFactory, extraAuthFields, gsonBuilder);
AccessTokenResponse accessTokenResponse = connector.grantTypePassword(tokenUrl, username, password,
persistedParams.clientId, persistedParams.clientSecret, scope,
Boolean.TRUE.equals(persistedParams.supportsBasicAuth));
@@ -274,8 +275,8 @@ public AccessTokenResponse getAccessTokenByClientCredentials(@Nullable String sc
}
GsonBuilder gsonBuilder = this.gsonBuilder;
- OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory)
- : new OAuthConnector(httpClientFactory, gsonBuilder);
+ OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory, extraAuthFields)
+ : new OAuthConnector(httpClientFactory, extraAuthFields, gsonBuilder);
// depending on usage, cannot guarantee every parameter is not null at the beginning
AccessTokenResponse accessTokenResponse = connector.grantTypeClientCredentials(tokenUrl, clientId,
persistedParams.clientSecret, scope, Boolean.TRUE.equals(persistedParams.supportsBasicAuth));
@@ -310,8 +311,8 @@ public AccessTokenResponse refreshToken() throws OAuthException, IOException, OA
}
GsonBuilder gsonBuilder = this.gsonBuilder;
- OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory)
- : new OAuthConnector(httpClientFactory, gsonBuilder);
+ OAuthConnector connector = gsonBuilder == null ? new OAuthConnector(httpClientFactory, extraAuthFields)
+ : new OAuthConnector(httpClientFactory, extraAuthFields, gsonBuilder);
AccessTokenResponse accessTokenResponse = connector.grantTypeRefreshToken(tokenUrl,
lastAccessToken.getRefreshToken(), persistedParams.clientId, persistedParams.clientSecret,
persistedParams.scope, Boolean.TRUE.equals(persistedParams.supportsBasicAuth));
@@ -412,6 +413,20 @@ private String createNewState() {
return UUID.randomUUID().toString();
}
+ /**
+ * Adds extra fields to include in the form data when doing the token request
+ *
+ * @param key The name of the key to add to the auth form
+ * @param value The value of the new auth form param
+ */
+ @Override
+ public void addExtraAuthField(String key, String value) {
+ if (extraAuthFields == null) {
+ extraAuthFields = new Fields();
+ }
+ extraAuthFields.add(key, value);
+ }
+
@Override
public OAuthClientService withGsonBuilder(GsonBuilder gsonBuilder) {
OAuthClientServiceImpl clientService = new OAuthClientServiceImpl(handle, persistedParams.tokenExpiresInSeconds,
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthConnector.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthConnector.java
index 00d5a28d879..46d4216eeb5 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthConnector.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthConnector.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -63,15 +63,26 @@ public class OAuthConnector {
private final HttpClientFactory httpClientFactory;
+ private final @Nullable Fields extraFields;
+
private final Logger logger = LoggerFactory.getLogger(OAuthConnector.class);
private final Gson gson;
public OAuthConnector(HttpClientFactory httpClientFactory) {
- this(httpClientFactory, new GsonBuilder());
+ this(httpClientFactory, null, new GsonBuilder());
+ }
+
+ public OAuthConnector(HttpClientFactory httpClientFactory, @Nullable Fields extraFields) {
+ this(httpClientFactory, extraFields, new GsonBuilder());
}
public OAuthConnector(HttpClientFactory httpClientFactory, GsonBuilder gsonBuilder) {
+ this(httpClientFactory, null, gsonBuilder);
+ }
+
+ public OAuthConnector(HttpClientFactory httpClientFactory, @Nullable Fields extraFields, GsonBuilder gsonBuilder) {
this.httpClientFactory = httpClientFactory;
+ this.extraFields = extraFields;
gson = gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.registerTypeAdapter(Instant.class, (JsonDeserializer) (json, typeOfT, context) -> {
try {
@@ -291,6 +302,14 @@ private Fields initFields(String... parameters) {
fields.add(parameters[i], parameters[i + 1]);
}
}
+
+ if (extraFields != null) {
+ for (Fields.Field extra : extraFields) {
+ logger.debug("Oauth request (extra) parameter {}, value {}", extra.getName(), extra.getValue());
+ fields.put(extra);
+ }
+ }
+
return fields;
}
@@ -326,24 +345,27 @@ private AccessTokenResponse doRequest(final String grantType, HttpClient httpCli
throw new IOException("Exception in oauth communication, grant type " + grantType, e);
} catch (JsonSyntaxException e) {
throw new OAuthException(String.format(
- "Unable to deserialize json into AccessTokenResponse/ OAuthResponseException. httpCode: %d json: %s",
- statusCode, content), e);
+ "Unable to deserialize json into AccessTokenResponse/ OAuthResponseException. httpCode: %d json: %s: %s",
+ statusCode, content, e.getMessage()), e);
} catch (Exception e) {
// Dont know what exception it is, wrap it up and throw it out
- throw new OAuthException("Exception in oauth communication, grant type " + grantType, e);
+ throw new OAuthException(
+ "Exception in oauth communication, grant type " + grantType + ": " + e.getMessage(), e);
}
}
/**
* This is a special case where the httpClient (jetty) is created due to the need for certificate pinning.
- * If certificate pinning is needed, please refer to {@code TrustManagerProvider}. The http client is
- * created, used and then shutdown immediately after use. There is little reason to cache the client/ connections
+ * If certificate pinning is needed, please refer to
+ * {@code org.openhab.core.io.net.http.ExtensibleTrustManager ExtensibleTrustManager}.
+ * The http client is created, used and then shutdown immediately after use. There is little reason to cache the
+ * client/ connections
* because oauth requests are short; and it may take hours/ days before the next request is needed.
*
* @param tokenUrl access token url
* @return http client. This http client
* @throws OAuthException If any exception is thrown while starting the http client.
- * @see TrustManagerProvider
+ * @see org.openhab.core.io.net.http.ExtensibleTrustManager
*/
private HttpClient createHttpClient(String tokenUrl) throws OAuthException {
HttpClient httpClient = httpClientFactory.createHttpClient(HTTP_CLIENT_CONSUMER_NAME);
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthFactoryImpl.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthFactoryImpl.java
index f08af82a82e..b5d3d8d081c 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthFactoryImpl.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthFactoryImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandler.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandler.java
index d2e4a7f149a..abc7cb18666 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandler.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerImpl.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerImpl.java
index 9fb9a9eae25..d54df5f53f4 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerImpl.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/PersistedParams.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/PersistedParams.java
index 861c3aed9cf..f606bf10b70 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/PersistedParams.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/PersistedParams.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/StorageRecordType.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/StorageRecordType.java
index f489fd8bdac..67ca1431670 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/StorageRecordType.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/StorageRecordType.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -29,7 +29,7 @@ public enum StorageRecordType {
private String suffix;
- private StorageRecordType(String suffix) {
+ StorageRecordType(String suffix) {
this.suffix = suffix;
}
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/cipher/SymmetricKeyCipher.java b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/cipher/SymmetricKeyCipher.java
index 060bb8b7b2a..244e8cd55b9 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/cipher/SymmetricKeyCipher.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/main/java/org/openhab/core/auth/oauth2client/internal/cipher/SymmetricKeyCipher.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -132,7 +132,7 @@ private static SecretKey generateEncryptionKey() throws NoSuchAlgorithmException
private SecretKey getOrGenerateEncryptionKey() throws NoSuchAlgorithmException, IOException {
Configuration configuration = configurationAdmin.getConfiguration(PID);
- String encryptionKeyInBase64 = null;
+ String encryptionKeyInBase64;
Dictionary properties = configuration.getProperties();
if (properties == null) {
properties = new Hashtable<>();
diff --git a/bundles/org.openhab.core.auth.oauth2client/src/test/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerTest.java b/bundles/org.openhab.core.auth.oauth2client/src/test/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerTest.java
index 0e7561c18b1..c8275ec85f2 100644
--- a/bundles/org.openhab.core.auth.oauth2client/src/test/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerTest.java
+++ b/bundles/org.openhab.core.auth.oauth2client/src/test/java/org/openhab/core/auth/oauth2client/internal/OAuthStoreHandlerTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -38,7 +38,7 @@
/**
* The {@link OAuthStoreHandlerTest} contains tests for
- * {@link org.openhab.core.auth.oauth2client.OAuthStoreHandlerImpl}
+ * {@link org.openhab.core.auth.oauth2client.internal.OAuthStoreHandlerImpl}
*
* @author Jacob Laursen - Initial contribution
*/
diff --git a/bundles/org.openhab.core.automation.module.media/pom.xml b/bundles/org.openhab.core.automation.module.media/pom.xml
index ff55187501f..4bbad43616f 100644
--- a/bundles/org.openhab.core.automation.module.media/pom.xml
+++ b/bundles/org.openhab.core.automation.module.media/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.automation.module.media
diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java
index 0cd84f477bd..9234b0676e3 100644
--- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java
+++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -148,7 +148,7 @@ private List getSoundOptions() {
options.add(new ParameterOption(fileName, capitalizedSoundName));
}
}
- options.sort(comparing(o -> o.getLabel()));
+ options.sort(comparing(ParameterOption::getLabel));
}
return options;
}
diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java
index 954abcfb6ec..935dd32e21f 100644
--- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaScriptScopeProvider.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaScriptScopeProvider.java
index 02486091099..6f1cd42ca9f 100644
--- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaScriptScopeProvider.java
+++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaScriptScopeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java
index 027404b6d32..3554ea81fa9 100644
--- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java
+++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java
index 66757d48fb0..6b9ec6fabdf 100644
--- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java
+++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SynthesizeActionHandler.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SynthesizeActionHandler.java
index 2dc89d27496..874b019fc09 100644
--- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SynthesizeActionHandler.java
+++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SynthesizeActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/pom.xml b/bundles/org.openhab.core.automation.module.script.rulesupport/pom.xml
index 6984e85d432..241ad616912 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/pom.xml
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.automation.module.script.rulesupport
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/AbstractScriptedModuleHandlerFactory.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/AbstractScriptedModuleHandlerFactory.java
index 714ff83b7fa..077226bc085 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/AbstractScriptedModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/AbstractScriptedModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java
index def3ae78056..f9358c42a34 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtension.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java
index ab5aa8c945d..e4888099ada 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -18,6 +18,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -154,11 +155,8 @@ public Collection getTypes() {
return obj;
}
- Map objects = objectCache.get(scriptIdentifier);
- if (objects == null) {
- objects = new HashMap<>();
- objectCache.put(scriptIdentifier, objects);
- }
+ Map objects = Objects
+ .requireNonNull(objectCache.computeIfAbsent(scriptIdentifier, k -> new HashMap<>()));
obj = objects.get(type);
if (obj != null) {
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleHandlerFactory.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleHandlerFactory.java
index 5bd36075246..26fa88d575d 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java
index 23eadc0f242..c0181f4ce93 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedCustomModuleTypeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedPrivateModuleHandlerFactory.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedPrivateModuleHandlerFactory.java
index 8f6f050156c..40993a7910e 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedPrivateModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/ScriptedPrivateModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java
index bfd0ce10457..0b25d41c469 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleConditionHandlerDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleConditionHandlerDelegate.java
index 25cae5ad84c..0051329508f 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleConditionHandlerDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleConditionHandlerDelegate.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerCallbackDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerCallbackDelegate.java
index b4722e7c113..c827a175391 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerCallbackDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerCallbackDelegate.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerDelegate.java
index ab43d8375d9..1f0bb89c8dc 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleTriggerHandlerDelegate.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/BidiSetBag.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/BidiSetBag.java
index 8e4578a9f74..9d7faeab4ea 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/BidiSetBag.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/BidiSetBag.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DefaultScriptFileWatcher.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DefaultScriptFileWatcher.java
index a962b2ff866..8e0906676cc 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DefaultScriptFileWatcher.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DefaultScriptFileWatcher.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileReference.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileReference.java
index acb886e2b93..3b635fbebdc 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileReference.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileReference.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTracker.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTracker.java
index 52293dd137e..d7b928d9445 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTracker.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTracker.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -52,7 +52,7 @@ public abstract class AbstractScriptDependencyTracker
private final BidiSetBag scriptToLibs = new BidiSetBag<>();
private final WatchService watchService;
- public AbstractScriptDependencyTracker(WatchService watchService, final String fileDirectory) {
+ protected AbstractScriptDependencyTracker(WatchService watchService, final String fileDirectory) {
this.watchService = watchService;
this.libraryPath = watchService.getWatchPath().resolve(fileDirectory);
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java
index 1177fd5c280..1014014d08d 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcher.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -96,7 +96,7 @@ public abstract class AbstractScriptFileWatcher implements WatchService.WatchEve
private volatile int currentStartLevel;
- public AbstractScriptFileWatcher(final WatchService watchService, final ScriptEngineManager manager,
+ protected AbstractScriptFileWatcher(final WatchService watchService, final ScriptEngineManager manager,
final ReadyService readyService, final StartLevelService startLevelService, final String fileDirectory,
boolean watchSubDirectories) {
this.watchService = watchService;
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/ScriptFileWatcher.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/ScriptFileWatcher.java
index e0fa918acd1..a3cb6adb4c4 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/ScriptFileWatcher.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/loader/ScriptFileWatcher.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java
index 88cc4b796bb..a3a1a5aaf33 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java
index b0e7f5e14ab..7c7f047e329 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -164,8 +164,7 @@ public Rule addUnmanagedRule(Rule element) {
// triggers are optional
}
- List actions = new ArrayList<>();
- actions.addAll(element.getActions());
+ List actions = new ArrayList<>(element.getActions());
if (element instanceof SimpleRuleActionHandler handler) {
String privId = addPrivateActionHandler(new SimpleRuleActionHandlerDelegate(handler));
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedHandler.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedHandler.java
index 82a9d6d2c28..035e054e915 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedHandler.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java
index 08e427250dd..54a4cd824cd 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java
index 017030b18ac..d736eb56353 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ValueCache.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedActionHandlerFactory.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedActionHandlerFactory.java
index dc98181e234..367f6ea2ad1 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedActionHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedActionHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedConditionHandlerFactory.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedConditionHandlerFactory.java
index e98fcd76c38..f64df739204 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedConditionHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedConditionHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedTriggerHandlerFactory.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedTriggerHandlerFactory.java
index bfaa6484177..3e8828a29e4 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedTriggerHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/factories/ScriptedTriggerHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleActionHandler.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleActionHandler.java
index 4d36fae80df..298453a60a5 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleActionHandler.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleConditionHandler.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleConditionHandler.java
index 60029a6f9c0..659b675190e 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleConditionHandler.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java
index 9a03498f2c9..d4f2f0f5a8e 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandler.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandler.java
index 8c307af81d6..1166064a266 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandler.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandlerDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandlerDelegate.java
index 0f21f84fc59..6af04a0243f 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandlerDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRuleActionHandlerDelegate.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandler.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandler.java
index 086ebb6dcd6..71cff7a7ac3 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandler.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandlerCallback.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandlerCallback.java
index 196a9271bf1..0d94c3b696e 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandlerCallback.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleTriggerHandlerCallback.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtensionTest.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtensionTest.java
index 467992a08f3..1067573e78c 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtensionTest.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/CacheScriptExtensionTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DelegatingScheduledExecutorService.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DelegatingScheduledExecutorService.java
index 9bfe5ec4937..3dcd90e9df0 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DelegatingScheduledExecutorService.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/DelegatingScheduledExecutorService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTrackerTest.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTrackerTest.java
index 3b27f589964..933e3982c23 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTrackerTest.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptDependencyTrackerTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcherTest.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcherTest.java
index 878c20762c9..21c79d3ccd3 100644
--- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcherTest.java
+++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/test/java/org/openhab/core/automation/module/script/rulesupport/loader/AbstractScriptFileWatcherTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/pom.xml b/bundles/org.openhab.core.automation.module.script/pom.xml
index 2a27ac644bc..011647661b2 100644
--- a/bundles/org.openhab.core.automation.module.script/pom.xml
+++ b/bundles/org.openhab.core.automation.module.script/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.automation.module.script
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/AbstractScriptEngineFactory.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/AbstractScriptEngineFactory.java
index fff6652ae60..cdeab8ca4b2 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/AbstractScriptEngineFactory.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/AbstractScriptEngineFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/LifecycleScriptExtensionProvider.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/LifecycleScriptExtensionProvider.java
index 6a710aeee93..1c6407b550f 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/LifecycleScriptExtensionProvider.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/LifecycleScriptExtensionProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyListener.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyListener.java
index dedebcbc6ad..eee754cfe64 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyListener.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyListener.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyTracker.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyTracker.java
index 94d44747748..0cb5609d023 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyTracker.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptDependencyTracker.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineContainer.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineContainer.java
index 20c8f6a2511..d8715d94608 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineContainer.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineContainer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineFactory.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineFactory.java
index 6ee107c2918..857ab343c66 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineFactory.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -33,7 +33,7 @@
@NonNullByDefault
public interface ScriptEngineFactory {
- static final ScriptEngineManager ENGINE_MANAGER = new ScriptEngineManager();
+ ScriptEngineManager ENGINE_MANAGER = new ScriptEngineManager();
/**
* Key to access engine identifier in script context.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineManager.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineManager.java
index e6fb4e9bf3d..b0ebcf8d72d 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineManager.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptEngineManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionAccessor.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionAccessor.java
index 8f80330b202..7bd0ee26ab0 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionAccessor.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionAccessor.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionManagerWrapper.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionManagerWrapper.java
index 36932ab0049..ac7b063843c 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionManagerWrapper.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionManagerWrapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionProvider.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionProvider.java
index 13e095779ef..fcab1e53976 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionProvider.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptExtensionProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java
index b1cb90f7583..c83807ac98c 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationServiceFactory.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationServiceFactory.java
index fdcd21adc52..f7d9d3397a4 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationServiceFactory.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/ScriptTransformationServiceFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/ScriptExecution.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/ScriptExecution.java
index 808659ef5d8..2c9f8613bd0 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/ScriptExecution.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/ScriptExecution.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/Timer.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/Timer.java
index 51767f66bfa..3704b0a0577 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/Timer.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/action/Timer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptBusEvent.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptBusEvent.java
index 01d5ba319ea..66335a09781 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptBusEvent.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptBusEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptThingActions.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptThingActions.java
index 69555e1e7d2..c1e7d422d5a 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptThingActions.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/defaultscope/ScriptThingActions.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryBundleTracker.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryBundleTracker.java
index 69c23fecc66..e60e1a831f8 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryBundleTracker.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryBundleTracker.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryHelper.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryHelper.java
index aa9935baba1..143bd6d5a6e 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryHelper.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineFactoryHelper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java
index bdab13e386f..313249e6f8b 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java
index b82d1f8570b..c63b808c86b 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManagerWrapperImpl.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManagerWrapperImpl.java
index 4b362f8d1a8..f198f36072b 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManagerWrapperImpl.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManagerWrapperImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptActionScriptScopeProvider.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptActionScriptScopeProvider.java
index 16008680bd1..6d19d2989b8 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptActionScriptScopeProvider.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptActionScriptScopeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptExecutionImpl.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptExecutionImpl.java
index 954f6d66002..f40e539d578 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptExecutionImpl.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/ScriptExecutionImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/TimerImpl.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/TimerImpl.java
index 2d94f8f44cd..159e73887e3 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/TimerImpl.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/action/TimerImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/DefaultScriptScopeProvider.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/DefaultScriptScopeProvider.java
index bebbbfb5756..df611b5a0b5 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/DefaultScriptScopeProvider.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/DefaultScriptScopeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java
index f49d0d3c0bb..84f1db0874a 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptBusEventImpl.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptBusEventImpl.java
index 11e51c39e03..c3eb79941bc 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptBusEventImpl.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptBusEventImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptThingActionsImpl.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptThingActionsImpl.java
index d0529a41cb4..2c48db540f8 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptThingActionsImpl.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ScriptThingActionsImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/factory/ScriptModuleHandlerFactory.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/factory/ScriptModuleHandlerFactory.java
index b1524466349..3efdb54ed00 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/factory/ScriptModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/factory/ScriptModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java
index 71f6ae2b76e..af1cc293c7a 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -59,7 +59,7 @@ public abstract class AbstractScriptModuleHandler extends Base
protected final String ruleUID;
- public AbstractScriptModuleHandler(T module, String ruleUID, ScriptEngineManager scriptEngineManager) {
+ protected AbstractScriptModuleHandler(T module, String ruleUID, ScriptEngineManager scriptEngineManager) {
super(module);
this.scriptEngineManager = scriptEngineManager;
this.ruleUID = ruleUID;
@@ -71,7 +71,7 @@ public AbstractScriptModuleHandler(T module, String ruleUID, ScriptEngineManager
private static String getValidConfigParameter(String parameter, Configuration config, String moduleId) {
Object value = config.get(parameter);
- if (value != null && value instanceof String string && !string.trim().isEmpty()) {
+ if (value instanceof String string && !string.trim().isEmpty()) {
return string;
} else {
throw new IllegalStateException(String.format(
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java
index 3727fbe7bd3..8c44c63429b 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptConditionHandler.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptConditionHandler.java
index 4721be85910..00c953ac070 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptConditionHandler.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java
index dce05230548..ecdf69879eb 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -99,7 +99,7 @@ private List getModuleTypesUnconditionally(@Nullable Locale locale)
}
/**
- * This method creates the {@link ConfigurationDescriptionParameter}s used by the generated ScriptActionType and
+ * This method creates the {@link ConfigDescriptionParameter}s used by the generated ScriptActionType and
* ScriptConditionType. {@link AbstractScriptModuleHandler} requires that the names of these be 'type' and 'script'.
*
* @return a list of {#link ConfigurationDescriptionParameter}s
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfile.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfile.java
index e9e720bcb5f..ccd0c370864 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfile.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfile.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -43,6 +43,8 @@ public class ScriptProfile implements StateProfile {
public static final String CONFIG_TO_ITEM_SCRIPT = "toItemScript";
public static final String CONFIG_TO_HANDLER_SCRIPT = "toHandlerScript";
+ public static final String CONFIG_COMMAND_FROM_ITEM_SCRIPT = "commandFromItemScript";
+ public static final String CONFIG_STATE_FROM_ITEM_SCRIPT = "stateFromItemScript";
private final Logger logger = LoggerFactory.getLogger(ScriptProfile.class);
@@ -54,7 +56,8 @@ public class ScriptProfile implements StateProfile {
private final List> handlerAcceptedCommandTypes;
private final String toItemScript;
- private final String toHandlerScript;
+ private final String commandFromItemScript;
+ private final String stateFromItemScript;
private final ProfileTypeUID profileTypeUID;
private final boolean isConfigured;
@@ -71,12 +74,22 @@ public ScriptProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback, Pr
this.toItemScript = ConfigParser.valueAsOrElse(profileContext.getConfiguration().get(CONFIG_TO_ITEM_SCRIPT),
String.class, "");
- this.toHandlerScript = ConfigParser
+ String toHandlerScript = ConfigParser
.valueAsOrElse(profileContext.getConfiguration().get(CONFIG_TO_HANDLER_SCRIPT), String.class, "");
+ String localCommandFromItemScript = ConfigParser.valueAsOrElse(
+ profileContext.getConfiguration().get(CONFIG_COMMAND_FROM_ITEM_SCRIPT), String.class, "");
+ this.commandFromItemScript = localCommandFromItemScript.isBlank() ? toHandlerScript
+ : localCommandFromItemScript;
+ this.stateFromItemScript = ConfigParser
+ .valueAsOrElse(profileContext.getConfiguration().get(CONFIG_STATE_FROM_ITEM_SCRIPT), String.class, "");
+
+ if (!toHandlerScript.isBlank() && commandFromItemScript.isBlank()) {
+ logger.warn("'toHandlerScript' has been deprecated! Please use 'commandFromItemScript' instead.");
+ }
- if (toItemScript.isBlank() && toHandlerScript.isBlank()) {
+ if (toItemScript.isBlank() && commandFromItemScript.isBlank() && stateFromItemScript.isBlank()) {
logger.error(
- "Neither 'toItemScript' nor 'toHandlerScript' defined in link '{}'. Profile will discard all states and commands.",
+ "Neither 'toItemScript', 'commandFromItemScript' nor 'stateFromItemScript' defined in link '{}'. Profile will discard all states and commands.",
callback.getItemChannelLink());
isConfigured = false;
return;
@@ -92,18 +105,27 @@ public ProfileTypeUID getProfileTypeUID() {
@Override
public void onStateUpdateFromItem(State state) {
+ if (isConfigured) {
+ fromItem(stateFromItemScript, state);
+ }
}
@Override
public void onCommandFromItem(Command command) {
if (isConfigured) {
- String returnValue = executeScript(toHandlerScript, command);
- if (returnValue != null) {
- // try to parse the value
- Command newCommand = TypeParser.parseCommand(handlerAcceptedCommandTypes, returnValue);
- if (newCommand != null) {
- callback.handleCommand(newCommand);
- }
+ fromItem(commandFromItemScript, command);
+ }
+ }
+
+ private void fromItem(String script, Type type) {
+ String returnValue = executeScript(script, type);
+ if (returnValue != null) {
+ // try to parse the value
+ Command newCommand = TypeParser.parseCommand(handlerAcceptedCommandTypes, returnValue);
+ if (newCommand != null) {
+ callback.handleCommand(newCommand);
+ } else {
+ logger.debug("The given type {} could not be transformed to a command", type);
}
}
}
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfileFactory.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfileFactory.java
index 48961c93cc8..3699356f573 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfileFactory.java
+++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfileFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/config/script-profile.xml b/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/config/script-profile.xml
index c6edd1a2290..d77445d30ae 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/config/script-profile.xml
+++ b/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/config/script-profile.xml
@@ -11,12 +11,26 @@
may return null to discard the updates/commands and not pass them through.
false
-
-
+
+
The Script for transforming commands from the item to the Thing handler. The script may return null to
discard the commands and not pass them through.false
+
+
+ The Script for transforming states from the item to the Thing handler. The script may return null to
+ discard the states and not pass them through.
+ false
+
+
+
+ The Script for transforming commands from the item to the Thing handler. The script may return null to
+ discard the commands and not pass them through. This is deprecated and has been replaced by
+ 'commandFromItemScript'.
+ false
+ true
+
diff --git a/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/i18n/scriptprofile.properties b/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/i18n/scriptprofile.properties
index 8c0323b52b6..c844fe5ab50 100644
--- a/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/i18n/scriptprofile.properties
+++ b/bundles/org.openhab.core.automation.module.script/src/main/resources/OH-INF/i18n/scriptprofile.properties
@@ -1,4 +1,8 @@
-profile.system.script.toItemScript.label = Thing To Item Transformation
-profile.system.script.toItemScript.description = The Script for transforming state updates and commands from the Thing handler to the item. The script may return null to discard the updates/commands and not pass them through.
-profile.system.script.toHandlerScript.label = Item To Thing Transformation
-profile.system.script.toHandlerScript.description = The Script for transforming commands from the item to the Thing handler. The script may return null to discard the commands and not pass them through.
+profile.config.transform.SCRIPT.commandFromItemScript.label = Item Command To Thing Transformation
+profile.config.transform.SCRIPT.commandFromItemScript.description = The Script for transforming commands from the item to the Thing handler. The script may return null to discard the commands and not pass them through.
+profile.config.transform.SCRIPT.stateFromItemScript.label = Item State To Thing Transformation
+profile.config.transform.SCRIPT.stateFromItemScript.description = The Script for transforming states from the item to the Thing handler. The script may return null to discard the states and not pass them through.
+profile.config.transform.SCRIPT.toHandlerScript.label = Item To Thing Transformation (DEPRECATED)
+profile.config.transform.SCRIPT.toHandlerScript.description = The Script for transforming commands from the item to the Thing handler. The script may return null to discard the commands and not pass them through. This is deprecated and has been replaced by 'commandFromItemScript'.
+profile.config.transform.SCRIPT.toItemScript.label = Thing To Item Transformation
+profile.config.transform.SCRIPT.toItemScript.description = The Script for transforming state updates and commands from the Thing handler to the item. The script may return null to discard the updates/commands and not pass them through.
diff --git a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/ScriptTransformationServiceTest.java b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/ScriptTransformationServiceTest.java
index 7620c313525..53e0c38a37c 100644
--- a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/ScriptTransformationServiceTest.java
+++ b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/ScriptTransformationServiceTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/TimerImplTest.java b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/TimerImplTest.java
index 05b7077882e..827b3b35373 100644
--- a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/TimerImplTest.java
+++ b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/TimerImplTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImplTest.java b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImplTest.java
index 6967b7df820..3dae8467d0b 100644
--- a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImplTest.java
+++ b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImplTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/profile/ScriptProfileTest.java b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/profile/ScriptProfileTest.java
index d4268e65fe8..867ee651dc6 100644
--- a/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/profile/ScriptProfileTest.java
+++ b/bundles/org.openhab.core.automation.module.script/src/test/java/org/openhab/core/automation/module/script/profile/ScriptProfileTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -18,6 +18,8 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.openhab.core.automation.module.script.profile.ScriptProfile.CONFIG_COMMAND_FROM_ITEM_SCRIPT;
+import static org.openhab.core.automation.module.script.profile.ScriptProfile.CONFIG_STATE_FROM_ITEM_SCRIPT;
import static org.openhab.core.automation.module.script.profile.ScriptProfile.CONFIG_TO_HANDLER_SCRIPT;
import static org.openhab.core.automation.module.script.profile.ScriptProfile.CONFIG_TO_ITEM_SCRIPT;
@@ -90,14 +92,14 @@ public void testScriptNotExecutedAndNoValueForwardedToCallbackIfNoScriptDefined(
verify(profileCallback, never()).sendCommand(any());
assertLogMessage(ScriptProfile.class, LogLevel.ERROR,
- "Neither 'toItemScript' nor 'toHandlerScript' defined in link '" + link.toString()
- + "'. Profile will discard all states and commands.");
+ "Neither 'toItemScript', 'commandFromItemScript' nor 'stateFromItemScript' defined in link '"
+ + link.toString() + "'. Profile will discard all states and commands.");
}
@Test
public void scriptExecutionErrorForwardsNoValueToCallback() throws TransformationException {
ProfileContext profileContext = ProfileContextBuilder.create().withToItemScript("inScript")
- .withToHandlerScript("outScript").build();
+ .withCommandFromItemScript("outScript").withStateFromItemScript("outScript").build();
when(transformationServiceMock.transform(any(), any()))
.thenThrow(new TransformationException("intentional failure"));
@@ -108,8 +110,9 @@ public void scriptExecutionErrorForwardsNoValueToCallback() throws Transformatio
scriptProfile.onCommandFromHandler(OnOffType.ON);
scriptProfile.onStateUpdateFromHandler(OnOffType.ON);
scriptProfile.onCommandFromItem(OnOffType.ON);
+ scriptProfile.onStateUpdateFromItem(OnOffType.ON);
- verify(transformationServiceMock, times(3)).transform(any(), any());
+ verify(transformationServiceMock, times(4)).transform(any(), any());
verify(profileCallback, never()).handleCommand(any());
verify(profileCallback, never()).sendUpdate(any());
verify(profileCallback, never()).sendCommand(any());
@@ -118,7 +121,7 @@ public void scriptExecutionErrorForwardsNoValueToCallback() throws Transformatio
@Test
public void scriptExecutionResultNullForwardsNoValueToCallback() throws TransformationException {
ProfileContext profileContext = ProfileContextBuilder.create().withToItemScript("inScript")
- .withToHandlerScript("outScript").build();
+ .withCommandFromItemScript("outScript").withStateFromItemScript("outScript").build();
when(transformationServiceMock.transform(any(), any())).thenReturn(null);
@@ -128,8 +131,9 @@ public void scriptExecutionResultNullForwardsNoValueToCallback() throws Transfor
scriptProfile.onCommandFromHandler(OnOffType.ON);
scriptProfile.onStateUpdateFromHandler(OnOffType.ON);
scriptProfile.onCommandFromItem(OnOffType.ON);
+ scriptProfile.onStateUpdateFromItem(OnOffType.ON);
- verify(transformationServiceMock, times(3)).transform(any(), any());
+ verify(transformationServiceMock, times(4)).transform(any(), any());
verify(profileCallback, never()).handleCommand(any());
verify(profileCallback, never()).sendUpdate(any());
verify(profileCallback, never()).sendCommand(any());
@@ -138,8 +142,8 @@ public void scriptExecutionResultNullForwardsNoValueToCallback() throws Transfor
@Test
public void scriptExecutionResultForwardsTransformedValueToCallback() throws TransformationException {
ProfileContext profileContext = ProfileContextBuilder.create().withToItemScript("inScript")
- .withToHandlerScript("outScript").withAcceptedCommandTypes(List.of(OnOffType.class))
- .withAcceptedDataTypes(List.of(OnOffType.class))
+ .withCommandFromItemScript("outScript").withStateFromItemScript("outScript")
+ .withAcceptedCommandTypes(List.of(OnOffType.class)).withAcceptedDataTypes(List.of(OnOffType.class))
.withHandlerAcceptedCommandTypes(List.of(OnOffType.class)).build();
when(transformationServiceMock.transform(any(), any())).thenReturn(OnOffType.OFF.toString());
@@ -150,9 +154,10 @@ public void scriptExecutionResultForwardsTransformedValueToCallback() throws Tra
scriptProfile.onCommandFromHandler(DecimalType.ZERO);
scriptProfile.onStateUpdateFromHandler(DecimalType.ZERO);
scriptProfile.onCommandFromItem(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromItem(DecimalType.ZERO);
- verify(transformationServiceMock, times(3)).transform(any(), any());
- verify(profileCallback).handleCommand(OnOffType.OFF);
+ verify(transformationServiceMock, times(4)).transform(any(), any());
+ verify(profileCallback, times(2)).handleCommand(OnOffType.OFF);
verify(profileCallback).sendUpdate(OnOffType.OFF);
verify(profileCallback).sendCommand(OnOffType.OFF);
}
@@ -171,6 +176,7 @@ public void onlyToItemScriptDoesNotForwardOutboundCommands() throws Transformati
scriptProfile.onCommandFromHandler(DecimalType.ZERO);
scriptProfile.onStateUpdateFromHandler(DecimalType.ZERO);
scriptProfile.onCommandFromItem(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromItem(DecimalType.ZERO);
verify(transformationServiceMock, times(2)).transform(any(), any());
verify(profileCallback, never()).handleCommand(any());
@@ -179,8 +185,30 @@ public void onlyToItemScriptDoesNotForwardOutboundCommands() throws Transformati
}
@Test
- public void onlyToHandlerScriptDoesNotForwardInboundCommands() throws TransformationException {
- ProfileContext profileContext = ProfileContextBuilder.create().withToHandlerScript("outScript")
+ public void onlyToHandlerCommandScriptDoesNotForwardInboundCommands() throws TransformationException {
+ ProfileContext profileContext = ProfileContextBuilder.create().withCommandFromItemScript("outScript")
+ .withAcceptedCommandTypes(List.of(DecimalType.class)).withAcceptedDataTypes(List.of(DecimalType.class))
+ .withHandlerAcceptedCommandTypes(List.of(OnOffType.class)).build();
+
+ when(transformationServiceMock.transform(any(), any())).thenReturn(OnOffType.OFF.toString());
+
+ ScriptProfile scriptProfile = new ScriptProfile(mock(ProfileTypeUID.class), profileCallback, profileContext,
+ transformationServiceMock);
+
+ scriptProfile.onCommandFromHandler(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromHandler(DecimalType.ZERO);
+ scriptProfile.onCommandFromItem(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromItem(DecimalType.ZERO);
+
+ verify(transformationServiceMock, times(1)).transform(any(), any());
+ verify(profileCallback, times(1)).handleCommand(OnOffType.OFF);
+ verify(profileCallback, never()).sendUpdate(any());
+ verify(profileCallback, never()).sendCommand(any());
+ }
+
+ @Test
+ public void onlyToHandlerStateScriptDoesNotForwardInboundCommands() throws TransformationException {
+ ProfileContext profileContext = ProfileContextBuilder.create().withStateFromItemScript("outScript")
.withAcceptedCommandTypes(List.of(DecimalType.class)).withAcceptedDataTypes(List.of(DecimalType.class))
.withHandlerAcceptedCommandTypes(List.of(OnOffType.class)).build();
@@ -192,9 +220,10 @@ public void onlyToHandlerScriptDoesNotForwardInboundCommands() throws Transforma
scriptProfile.onCommandFromHandler(DecimalType.ZERO);
scriptProfile.onStateUpdateFromHandler(DecimalType.ZERO);
scriptProfile.onCommandFromItem(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromItem(DecimalType.ZERO);
- verify(transformationServiceMock).transform(any(), any());
- verify(profileCallback).handleCommand(OnOffType.OFF);
+ verify(transformationServiceMock, times(1)).transform(any(), any());
+ verify(profileCallback, times(1)).handleCommand(OnOffType.OFF);
verify(profileCallback, never()).sendUpdate(any());
verify(profileCallback, never()).sendCommand(any());
}
@@ -202,8 +231,8 @@ public void onlyToHandlerScriptDoesNotForwardInboundCommands() throws Transforma
@Test
public void incompatibleStateOrCommandNotForwardedToCallback() throws TransformationException {
ProfileContext profileContext = ProfileContextBuilder.create().withToItemScript("inScript")
- .withToHandlerScript("outScript").withAcceptedCommandTypes(List.of(DecimalType.class))
- .withAcceptedDataTypes(List.of(PercentType.class))
+ .withCommandFromItemScript("outScript").withStateFromItemScript("outScript")
+ .withAcceptedCommandTypes(List.of(DecimalType.class)).withAcceptedDataTypes(List.of(PercentType.class))
.withHandlerAcceptedCommandTypes(List.of(HSBType.class)).build();
when(transformationServiceMock.transform(any(), any())).thenReturn(OnOffType.OFF.toString());
@@ -214,13 +243,36 @@ public void incompatibleStateOrCommandNotForwardedToCallback() throws Transforma
scriptProfile.onCommandFromHandler(DecimalType.ZERO);
scriptProfile.onStateUpdateFromHandler(DecimalType.ZERO);
scriptProfile.onCommandFromItem(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromItem(DecimalType.ZERO);
- verify(transformationServiceMock, times(3)).transform(any(), any());
+ verify(transformationServiceMock, times(4)).transform(any(), any());
verify(profileCallback, never()).handleCommand(any());
verify(profileCallback, never()).sendUpdate(any());
verify(profileCallback, never()).sendCommand(any());
}
+ @Test
+ public void fallbackToToHandlerScriptIfNotToHandlerCommandScript() throws TransformationException {
+ ProfileContext profileContext = ProfileContextBuilder.create().withToHandlerScript("outScript")
+ .withAcceptedCommandTypes(List.of(DecimalType.class)).withAcceptedDataTypes(List.of(DecimalType.class))
+ .withHandlerAcceptedCommandTypes(List.of(OnOffType.class)).build();
+
+ when(transformationServiceMock.transform(any(), any())).thenReturn(OnOffType.OFF.toString());
+
+ ScriptProfile scriptProfile = new ScriptProfile(mock(ProfileTypeUID.class), profileCallback, profileContext,
+ transformationServiceMock);
+
+ scriptProfile.onCommandFromHandler(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromHandler(DecimalType.ZERO);
+ scriptProfile.onCommandFromItem(DecimalType.ZERO);
+ scriptProfile.onStateUpdateFromItem(DecimalType.ZERO);
+
+ verify(transformationServiceMock, times(1)).transform(any(), any());
+ verify(profileCallback, times(1)).handleCommand(OnOffType.OFF);
+ verify(profileCallback, never()).sendUpdate(any());
+ verify(profileCallback, never()).sendCommand(any());
+ }
+
private static class ProfileContextBuilder {
private final Map configuration = new HashMap<>();
private List> acceptedDataTypes = List.of();
@@ -241,6 +293,16 @@ public ProfileContextBuilder withToHandlerScript(String toHandlerScript) {
return this;
}
+ public ProfileContextBuilder withCommandFromItemScript(String commandFromItemScript) {
+ configuration.put(CONFIG_COMMAND_FROM_ITEM_SCRIPT, commandFromItemScript);
+ return this;
+ }
+
+ public ProfileContextBuilder withStateFromItemScript(String stateFromItemScript) {
+ configuration.put(CONFIG_STATE_FROM_ITEM_SCRIPT, stateFromItemScript);
+ return this;
+ }
+
public ProfileContextBuilder withAcceptedDataTypes(List> acceptedDataTypes) {
this.acceptedDataTypes = acceptedDataTypes;
return this;
diff --git a/bundles/org.openhab.core.automation.rest/pom.xml b/bundles/org.openhab.core.automation.rest/pom.xml
index d9ec662bef1..f74d4ec9a3a 100644
--- a/bundles/org.openhab.core.automation.rest/pom.xml
+++ b/bundles/org.openhab.core.automation.rest/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.automation.rest
diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java
index 7c1a5c7c043..61e4fb54391 100644
--- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java
+++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java
index 09b163c3f76..b40a82d5724 100644
--- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java
+++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/RuleResource.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -188,6 +188,7 @@ public Response get(@Context SecurityContext securityContext, @Context Request r
.map(rule -> EnrichedRuleDTOMapper.map(rule, ruleManager, managedRuleProvider));
CacheControl cc = new CacheControl();
+ cc.setNoCache(true);
cc.setMustRevalidate(true);
cc.setPrivate(true);
rules = dtoMapper.limitToFields(rules, "uid,templateUID,name,visibility,description,tags,editable");
diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java
index 20e1d78e1c5..93b8fba0afa 100644
--- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java
+++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/TemplateResource.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java
index 3a46a40c1e3..eca85f72948 100644
--- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java
+++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTO.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTO.java
index 7ef2d61be78..924ea6d5a67 100644
--- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTO.java
+++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTOMapper.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTOMapper.java
index 9c983bf5e24..d593624276e 100644
--- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTOMapper.java
+++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/dto/EnrichedRuleDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/pom.xml b/bundles/org.openhab.core.automation/pom.xml
index 2b66f59eb68..18c4bcd6242 100644
--- a/bundles/org.openhab.core.automation/pom.xml
+++ b/bundles/org.openhab.core.automation/pom.xml
@@ -7,7 +7,7 @@
org.openhab.core.bundlesorg.openhab.core.reactor.bundles
- 4.1.0-SNAPSHOT
+ 4.2.0-SNAPSHOTorg.openhab.core.automation
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Action.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Action.java
index 530724002a1..15ef5c5cf8b 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Action.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Action.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/AnnotatedActions.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/AnnotatedActions.java
index e2ae1a68181..a12608ea23e 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/AnnotatedActions.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/AnnotatedActions.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Condition.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Condition.java
index 16a3760dc73..eb90eec3d52 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Condition.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Condition.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ManagedRuleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ManagedRuleProvider.java
index 3bd92592f4d..0f66046d452 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ManagedRuleProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ManagedRuleProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Module.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Module.java
index f0c7daebe04..0a3fc0b9274 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Module.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Module.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ModuleHandlerCallback.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ModuleHandlerCallback.java
index 7acd1f0ef1b..31294e6e1e1 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ModuleHandlerCallback.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/ModuleHandlerCallback.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Rule.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Rule.java
index 31bb633c398..a32539a3dfe 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Rule.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Rule.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleExecution.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleExecution.java
index 0cc0a064f5c..a68a4086a0a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleExecution.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleExecution.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleManager.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleManager.java
index 65ab05175d6..4d9890fb9aa 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleManager.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RulePredicates.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RulePredicates.java
index d7fbee8891f..238021be71a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RulePredicates.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RulePredicates.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -44,9 +44,9 @@ public class RulePredicates {
*
* The name space is part of the UID and the prefix thereof.
*
- * If the UID does not contain a {@link PREFIX_SEPARATOR} {@code null} will be returned.
+ * If the UID does not contain a {@link #PREFIX_SEPARATOR} {@code null} will be returned.
*
- * If the UID does contain a {@link PREFIX_SEPARATOR} the prefix until the first occurrence will be returned.
+ * If the UID does contain a {@link #PREFIX_SEPARATOR} the prefix until the first occurrence will be returned.
*
* If the prefix would have a zero length {@code null} will be returned.
*
@@ -87,9 +87,7 @@ public static Predicate hasPrefix(final @Nullable String prefix) {
*/
public static Predicate hasAnyOfPrefixes(String... prefixes) {
final HashSet namespaceSet = new HashSet<>(prefixes.length);
- for (final String namespace : prefixes) {
- namespaceSet.add(namespace);
- }
+ namespaceSet.addAll(Arrays.asList(prefixes));
// this will even work for null namespace
return r -> namespaceSet.contains(getPrefix(r));
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleProvider.java
index 65bbc06fb75..605b6462d65 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleRegistry.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleRegistry.java
index d21d07ee961..71c23597ee2 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleRegistry.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleRegistry.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatus.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatus.java
index 9a2feb7fc0b..7af0fa9465d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatus.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatus.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -84,7 +84,7 @@ public enum RuleStatus {
private final int value;
- private RuleStatus(final int newValue) {
+ RuleStatus(final int newValue) {
value = newValue;
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusDetail.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusDetail.java
index bb6c65d7e2b..2c14951422f 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusDetail.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusDetail.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -95,7 +95,7 @@ public enum RuleStatusDetail {
private final int value;
- private RuleStatusDetail(final int newValue) {
+ RuleStatusDetail(final int newValue) {
value = newValue;
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusInfo.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusInfo.java
index d2d1521a057..91226422b94 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusInfo.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/RuleStatusInfo.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Trigger.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Trigger.java
index 07d71d79174..c7666de8ae2 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Trigger.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Trigger.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Visibility.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Visibility.java
index 7f65ca152db..94f3de9b00f 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Visibility.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/Visibility.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInput.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInput.java
index 58386f17719..2694b163a30 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInput.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInput.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInputs.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInputs.java
index c444017f293..6e17e45dcc1 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInputs.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionInputs.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutput.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutput.java
index 7dedc7e4608..0859602a2fd 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutput.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutput.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutputs.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutputs.java
index 6274bced228..30c240df2a7 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutputs.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionOutputs.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionScope.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionScope.java
index ce49acd5bdf..1e4fe9d0b11 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionScope.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/ActionScope.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/RuleAction.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/RuleAction.java
index 7f1061a97c6..edccc089b06 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/RuleAction.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/annotation/RuleAction.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTO.java
index 11160ce3393..cff08a6109f 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java
index f41cdebea74..7adaf6c4909 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTO.java
index 5eae69b0036..2e509c5c866 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java
index c9f8c714e06..cf26e865a12 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeActionTypeDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeActionTypeDTO.java
index bdf4f2c1c9a..146d14039fb 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeActionTypeDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeActionTypeDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeConditionTypeDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeConditionTypeDTO.java
index a0320b4deb5..c1f2e32af95 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeConditionTypeDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeConditionTypeDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeTriggerTypeDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeTriggerTypeDTO.java
index 1d77d93aa63..8f3baa7800c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeTriggerTypeDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/CompositeTriggerTypeDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTO.java
index 0d52da90d3e..1f52d817b55 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java
index eef4da1adc2..4ef17cc3738 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTO.java
index 06009d6f4a5..58d1c29ac8e 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java
index df4a84e8a36..375755272d8 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTO.java
index ddf4c48990d..df80521a437 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTOMapper.java
index 6e75a994c0f..78b89ed4c3c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTO.java
index 6f4759be123..6ab04ea7fa6 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTOMapper.java
index cab9eb8e05c..bfade4cc22e 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ModuleTypeDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTO.java
index 6f026096cc9..f7421755e5a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTOMapper.java
index 35ed9290521..651b6d30f05 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTO.java
index ce103095a87..85dbbf5b347 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTOMapper.java
index dff7fea61b0..660d87f5485 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/RuleTemplateDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTO.java
index feab5e9cda0..18e4f83730a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java
index 720af4277aa..20b30dd1cfb 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTO.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTO.java
index 62847953d9a..9fe561a0350 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTO.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTO.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java
index ea520d745ba..4e31230ffa2 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AbstractRuleRegistryEvent.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AbstractRuleRegistryEvent.java
index 6de56f50553..b87934b5b4d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AbstractRuleRegistryEvent.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AbstractRuleRegistryEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -36,7 +36,7 @@ public abstract class AbstractRuleRegistryEvent extends AbstractEvent {
* @param source the source of the event
* @param rule the rule for which this event is created
*/
- public AbstractRuleRegistryEvent(String topic, String payload, @Nullable String source, RuleDTO rule) {
+ protected AbstractRuleRegistryEvent(String topic, String payload, @Nullable String source, RuleDTO rule) {
super(topic, payload, source);
this.rule = rule;
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AutomationEventFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AutomationEventFactory.java
index fe85cf3794f..d2790a631c1 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AutomationEventFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/AutomationEventFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/ExecutionEvent.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/ExecutionEvent.java
index 20177bdec23..53af96ce496 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/ExecutionEvent.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/ExecutionEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleAddedEvent.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleAddedEvent.java
index e4df2b46bfa..8ce5bb2bc1e 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleAddedEvent.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleAddedEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleRemovedEvent.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleRemovedEvent.java
index ec24688f96d..704d7820ec5 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleRemovedEvent.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleRemovedEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleStatusInfoEvent.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleStatusInfoEvent.java
index 68335338f7f..e818d95d0ee 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleStatusInfoEvent.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleStatusInfoEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleUpdatedEvent.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleUpdatedEvent.java
index 7cce51723fa..db1008eea5e 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleUpdatedEvent.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/RuleUpdatedEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/TimerEvent.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/TimerEvent.java
index 98db2e0bf7d..359c2b69399 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/TimerEvent.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/events/TimerEvent.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ActionHandler.java
index 8b5d99e1b4d..355dba470c6 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ActionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseActionModuleHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseActionModuleHandler.java
index a05a824fdfe..743b8346f3d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseActionModuleHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseActionModuleHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseConditionModuleHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseConditionModuleHandler.java
index 03e7a85bc30..bf5f6e30970 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseConditionModuleHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseConditionModuleHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandler.java
index 187cdda65ba..08be9e81255 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandlerFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandlerFactory.java
index cde2d8a830b..5dd0201a347 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseTriggerModuleHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseTriggerModuleHandler.java
index ac9fbab5af8..7156a646454 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseTriggerModuleHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/BaseTriggerModuleHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ConditionHandler.java
index 1bf0363151c..7adc0b6ce2d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandler.java
index 81a1ccc0a03..c991f73adee 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandlerFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandlerFactory.java
index fc6b9199bf3..64b35d83254 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/ModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedConditionHandler.java
index 6e571faae3f..44c02ac864d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedTriggerHandler.java
index 095a50c636d..8862e336c4f 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TimeBasedTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandler.java
index 2b279a042d5..5163cf42448 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandlerCallback.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandlerCallback.java
index 80e302bf98c..4af23ea8c7c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandlerCallback.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/handler/TriggerHandlerCallback.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ActionImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ActionImpl.java
index 679452ab0f2..a82ba7ce4d3 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ActionImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ActionImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConditionImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConditionImpl.java
index 2ecb14056f1..908f314bd2c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConditionImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConditionImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/Connection.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/Connection.java
index 041e6f73faf..ba571e49a18 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/Connection.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/Connection.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConnectionValidator.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConnectionValidator.java
index 5424fbb0bd3..cecd45e1954 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConnectionValidator.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ConnectionValidator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -14,7 +14,6 @@
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -109,17 +108,15 @@ private static void validateActionConnections(ModuleTypeRegistry mtRegistry, Act
List inputs = type.getInputs(); // get inputs of the condition according to module type definition
// gets connected inputs from the condition module and put them into map
- Set cons = getConnections(action.getInputs());
+ Set connections = getConnections(action.getInputs());
Map connectionsMap = new HashMap<>();
- Iterator connectionsI = cons.iterator();
- while (connectionsI.hasNext()) {
- Connection connection = connectionsI.next();
+ for (Connection connection : connections) {
String inputName = connection.getInputName();
connectionsMap.put(inputName, connection);
}
// checks is there unconnected required inputs
- if (inputs != null && !inputs.isEmpty()) {
+ if (!inputs.isEmpty()) {
for (Input input : inputs) {
String name = input.getName();
Connection connection = connectionsMap.get(name);
@@ -185,17 +182,15 @@ private static void validateConditionConnections(ModuleTypeRegistry mtRegistry,
List inputs = type.getInputs(); // get inputs of the condition according to module type definition
// gets connected inputs from the condition module and put them into map
- Set cons = getConnections(condition.getInputs());
+ Set connections = getConnections(condition.getInputs());
Map connectionsMap = new HashMap<>();
- Iterator connectionsI = cons.iterator();
- while (connectionsI.hasNext()) {
- Connection connection = connectionsI.next();
+ for (Connection connection : connections) {
String inputName = connection.getInputName();
connectionsMap.put(inputName, connection);
}
// checks is there unconnected required inputs
- if (inputs != null && !inputs.isEmpty()) {
+ if (!inputs.isEmpty()) {
for (Input input : inputs) {
String name = input.getName();
Connection connection = connectionsMap.get(name);
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ModuleImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ModuleImpl.java
index 1dc452e6bda..e2f4c295757 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ModuleImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ModuleImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java
index 5b3a204e6a5..07b803cca73 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -76,6 +76,7 @@
import org.openhab.core.common.registry.RegistryChangeListener;
import org.openhab.core.events.Event;
import org.openhab.core.events.EventPublisher;
+import org.openhab.core.events.system.SystemEventFactory;
import org.openhab.core.service.ReadyMarker;
import org.openhab.core.service.ReadyMarkerFilter;
import org.openhab.core.service.ReadyService;
@@ -256,8 +257,7 @@ public void runNow(String uid, boolean considerConditions, @Nullable Map getStorage(DISABLED_RULE_STORAGE,
- this.getClass().getClassLoader());
+ this.disabledRulesStorage = storageService.getStorage(DISABLED_RULE_STORAGE, this.getClass().getClassLoader());
mtRegistry = moduleTypeRegistry;
mtRegistry.addRegistryChangeListener(this);
@@ -709,7 +709,7 @@ ModuleHandler getModuleHandler(Module m, String ruleUID) {
* @return the {@link ModuleHandlerFactory} responsible for the {@link ModuleType}.
*/
public @Nullable ModuleHandlerFactory getModuleHandlerFactory(String moduleTypeId) {
- ModuleHandlerFactory mhf = null;
+ ModuleHandlerFactory mhf;
synchronized (this) {
mhf = moduleHandlerFactories.get(moduleTypeId);
}
@@ -855,8 +855,8 @@ private boolean activateRule(final WrappedRule rule) {
if (slTriggers.stream()
.anyMatch(t -> ((BigDecimal) t.getConfiguration().get(SystemTriggerHandler.CFG_STARTLEVEL))
.intValue() <= startLevelService.getStartLevel())) {
- runNow(rule.getUID(), true,
- Map.of(SystemTriggerHandler.OUT_STARTLEVEL, StartLevelService.STARTLEVEL_RULES));
+ runNow(rule.getUID(), true, Map.of(SystemTriggerHandler.OUT_STARTLEVEL, StartLevelService.STARTLEVEL_RULES,
+ "event", SystemEventFactory.createStartlevelEvent(StartLevelService.STARTLEVEL_RULES)));
}
return true;
@@ -919,7 +919,7 @@ protected void scheduleRuleInitialization(final String rUID) {
private void removeMissingModuleTypes(Collection moduleTypes) {
Map> mapMissingHandlers = null;
for (String moduleTypeName : moduleTypes) {
- Set rules = null;
+ Set rules;
synchronized (this) {
rules = mapModuleTypeToRules.get(moduleTypeName);
}
@@ -1146,7 +1146,7 @@ private boolean calculateConditions(WrappedRule rule) {
return true;
}
final String ruleUID = rule.getUID();
- RuleStatus ruleStatus = null;
+ RuleStatus ruleStatus;
for (WrappedCondition wrappedCondition : conditions) {
ruleStatus = getRuleStatus(ruleUID);
if (ruleStatus != RuleStatus.RUNNING) {
@@ -1174,7 +1174,7 @@ private void executeActions(WrappedRule rule, boolean stopOnFirstFail) {
if (actions.isEmpty()) {
return;
}
- RuleStatus ruleStatus = null;
+ RuleStatus ruleStatus;
for (WrappedAction wrappedAction : actions) {
ruleStatus = getRuleStatus(ruleUID);
if (ruleStatus != RuleStatus.RUNNING) {
@@ -1349,10 +1349,10 @@ private boolean addAutoMapConnections(Input input, Map, OutputRef> o
OutputRef outputRef = null;
boolean conflict = false;
if (!inputTags.isEmpty()) {
- for (Set outTags : outputTagMap.keySet()) {
- if (outTags.containsAll(inputTags)) { // input tags must be subset of the output ones
+ for (Entry, OutputRef> entry : outputTagMap.entrySet()) {
+ if (entry.getKey().containsAll(inputTags)) { // input tags must be subset of the output ones
if (outputRef == null) {
- outputRef = outputTagMap.get(outTags);
+ outputRef = entry.getValue();
} else {
conflict = true; // already exist candidate for autoMap
break;
@@ -1414,7 +1414,7 @@ private Set copyConnections(Set connections) {
return result;
}
- class OutputRef {
+ static class OutputRef {
private final String moduleId;
private final String outputName;
@@ -1448,7 +1448,8 @@ private void executeRulesWithStartLevel() {
ruleRegistry.getAll().stream() //
.filter(this::mustTrigger) //
.forEach(r -> runNow(r.getUID(), true,
- Map.of(SystemTriggerHandler.OUT_STARTLEVEL, StartLevelService.STARTLEVEL_RULES)));
+ Map.of(SystemTriggerHandler.OUT_STARTLEVEL, StartLevelService.STARTLEVEL_RULES, "event",
+ SystemEventFactory.createStartlevelEvent(StartLevelService.STARTLEVEL_RULES))));
started = true;
readyService.markReady(MARKER);
logger.info("Rule engine started.");
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEventFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEventFactory.java
index 7523db57350..29cd7a5bf8e 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEventFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEventFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleExecutionSimulator.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleExecutionSimulator.java
index b3847fd470f..11123e8bedf 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleExecutionSimulator.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleExecutionSimulator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -95,9 +95,7 @@ private List simulateExecutionsForRule(Rule rule, ZonedDateTime f
// Only triggers that are time-based will be considered within the simulation
if (triggerHandler instanceof TimeBasedTriggerHandler handler) {
SchedulerTemporalAdjuster temporalAdjuster = handler.getTemporalAdjuster();
- if (temporalAdjuster != null) {
- executions.addAll(simulateExecutionsForCronBasedRule(rule, from, until, temporalAdjuster));
- }
+ executions.addAll(simulateExecutionsForCronBasedRule(rule, from, until, temporalAdjuster));
}
}
logger.debug("Created {} rule simulations for rule {}.", executions.size(), rule.getName());
@@ -110,7 +108,7 @@ private List simulateExecutionsForRule(Rule rule, ZonedDateTime f
* @param rule {@link Rule} to be simulated.
* @param from {@link ZonedDateTime} earliest time to be contained in the rule simulation.
* @param until {@link ZonedDateTime} latest time to be contained in the rule simulation.
- * @param cron cron-expression to be evaluated for determining the execution times.
+ * @param temporalAdjuster {@link SchedulerTemporalAdjuster} to be evaluated for determining the execution times.
* @return a list of expected executions.
*/
private List simulateExecutionsForCronBasedRule(Rule rule, ZonedDateTime from, ZonedDateTime until,
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java
index 6a241d61838..52d9f1e1f13 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java
index 27fa4b9802a..bd849baf129 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -17,10 +17,10 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -63,7 +63,7 @@
* The {@link RuleRegistryImpl} provides basic functionality for managing {@link Rule}s.
* It can be used to
*
- *
Add Rules with the {@link #add(Rule)}, {@link #added(Provider, Rule)}, {@link #addProvider(RuleProvider)}
+ *
Add Rules with the {@link #add(Rule)}, {@link #added(Provider, Rule)}, {@link #addProvider(Provider)}
* methods.
*
Get the existing rules with the {@link #get(String)}, {@link #getAll()}, {@link #getByTag(String)},
* {@link #getByTags(String[])} methods.
@@ -130,7 +130,7 @@ public RuleRegistryImpl() {
/**
* Activates this component. Called from DS.
*
- * @param componentContext this component context.
+ * @param bundleContext this component context.
*/
@Override
@Activate
@@ -377,11 +377,8 @@ private Rule resolveRuleByTemplate(Rule rule) {
*/
private void updateRuleTemplateMapping(String templateUID, String ruleUID, boolean resolved) {
synchronized (this) {
- Set ruleUIDs = mapTemplateToRules.get(templateUID);
- if (ruleUIDs == null) {
- ruleUIDs = new HashSet<>();
- mapTemplateToRules.put(templateUID, ruleUIDs);
- }
+ Set ruleUIDs = Objects
+ .requireNonNull(mapTemplateToRules.computeIfAbsent(templateUID, k -> new HashSet<>()));
if (resolved) {
ruleUIDs.remove(ruleUID);
} else {
@@ -537,9 +534,7 @@ private void validateConfiguration(List configDescri
private boolean isOptionalConfig(List configDescriptions) {
if (configDescriptions != null && !configDescriptions.isEmpty()) {
boolean required = false;
- Iterator i = configDescriptions.iterator();
- while (i.hasNext()) {
- ConfigDescriptionParameter param = i.next();
+ for (ConfigDescriptionParameter param : configDescriptions) {
required = required || param.isRequired();
}
return !required;
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerHandlerCallbackImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerHandlerCallbackImpl.java
index cbd4eb18531..c14bd20e8be 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerHandlerCallbackImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerHandlerCallbackImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerImpl.java
index 808fa1eb066..d49ded31fc4 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/TriggerImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -18,7 +18,7 @@
import org.openhab.core.config.core.Configuration;
/**
- * This class is implementation of {@link Trigger} modules used in the {@link RuleEngine}s.
+ * This class is implementation of {@link Trigger} modules used in the rule engines.
*
* @author Yordan Mihaylov - Initial contribution
*/
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java
index e569d7fc9ad..77fcdba7752 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -82,7 +82,7 @@ public abstract class AbstractCommandProvider<@NonNull E> implements ServiceTrac
* high performance at runtime of the system, when the Rule Engine asks for any particular object, instead of
* waiting it for parsing every time.
*
- * The Map has for keys UIDs of the objects and for values {@link Localizer}s of the objects.
+ * The Map has for keys UIDs of the objects and for values the objects.
*/
protected final Map providedObjectsHolder = new HashMap<>();
@@ -94,14 +94,13 @@ public abstract class AbstractCommandProvider<@NonNull E> implements ServiceTrac
* @param context is the {@link BundleContext}, used for creating a tracker for {@link Parser} services.
*/
@SuppressWarnings("unchecked")
- public AbstractCommandProvider(BundleContext context) {
+ protected AbstractCommandProvider(BundleContext context) {
this.bundleContext = context;
parserTracker = new ServiceTracker(context, Parser.class.getName(), this);
parserTracker.open();
}
/**
- * This method is inherited from {@link AbstractPersistentProvider}.
* Extends parent's functionality with closing the {@link Parser} service tracker.
* Clears the {@link #parsers}, {@link #providedObjectsHolder}, {@link #providerPortfolio}
*/
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommand.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommand.java
index d43e027e3f8..da2bab4c633 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommand.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommand.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandEnableRule.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandEnableRule.java
index 54507f0cb71..933f19558e5 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandEnableRule.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandEnableRule.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandExport.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandExport.java
index 80d0d9bd894..1c5e0214765 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandExport.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandExport.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandImport.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandImport.java
index bffd97e1e5d..06a78f937ce 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandImport.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandImport.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java
index 12762f0de99..85b45439368 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
@@ -278,7 +277,7 @@ private String listModuleTypes() {
private Collection getRuleByFilter(Map list) {
Collection rules = new ArrayList<>();
if (!list.isEmpty()) {
- Rule r = null;
+ Rule r;
String uid = list.get(id);
if (uid != null) {
r = autoCommands.getRule(uid);
@@ -313,7 +312,7 @@ private Collection getRuleByFilter(Map list) {
*/
private Collection getTemplateByFilter(Map list) {
Collection templates = new ArrayList<>();
- RuleTemplate t = null;
+ RuleTemplate t;
String uid = list.get(id);
if (uid != null) {
t = autoCommands.getTemplate(uid, locale);
@@ -328,7 +327,7 @@ private Collection getTemplateByFilter(Map list) {
return templates;
} else {
for (String templateUID : list.keySet()) {
- if (templateUID.indexOf(id) != -1) {
+ if (templateUID.contains(id)) {
templates.add(autoCommands.getTemplate(templateUID, locale));
}
}
@@ -348,7 +347,7 @@ private Collection getTemplateByFilter(Map list) {
private Collection getModuleTypeByFilter(Map list) {
Collection moduleTypes = new ArrayList<>();
if (!list.isEmpty()) {
- ModuleType mt = null;
+ ModuleType mt;
String uid = list.get(id);
if (uid != null) {
mt = autoCommands.getModuleType(uid, locale);
@@ -363,7 +362,7 @@ private Collection getModuleTypeByFilter(Map list) {
return moduleTypes;
} else {
for (String typeUID : list.values()) {
- if (typeUID.indexOf(id) != -1) {
+ if (typeUID.contains(id)) {
moduleTypes.add(autoCommands.getModuleType(typeUID, locale));
}
}
@@ -385,9 +384,7 @@ private Collection getModuleTypeByFilter(Map list) {
@SuppressWarnings({ "rawtypes", "unchecked" })
private void addCollection(Collection collection, Map list) {
if (collection != null && !collection.isEmpty()) {
- Iterator i = collection.iterator();
- while (i.hasNext()) {
- Object element = i.next();
+ for (Object element : collection) {
if (element instanceof ModuleType type) {
list.put(type.getUID(), element);
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandRemove.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandRemove.java
index 054caea0ab9..16ffc07ab62 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandRemove.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandRemove.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommands.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommands.java
index a38feef896a..dc3b41e09ab 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommands.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommands.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandsPluggable.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandsPluggable.java
index 08e3886dce7..5d25ef87f1a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandsPluggable.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandsPluggable.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -12,11 +12,9 @@
*/
package org.openhab.core.automation.internal.commands;
-import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
-import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -122,7 +120,7 @@ protected void deactivate(ComponentContext componentContext) {
@Override
public void execute(String[] args, Console console) {
if (args.length == 0) {
- console.println(getUsages().stream().collect(Collectors.joining("\n")));
+ console.println(String.join("\n", getUsages()));
return;
}
@@ -134,16 +132,12 @@ public void execute(String[] args, Console console) {
}
String res = super.executeCommand(command, params);
- if (res == null) {
- console.println(String.format("Unsupported command %s", command));
- } else {
- console.println(res);
- }
+ console.println(res);
}
@Override
public List getUsages() {
- return Arrays.asList(new String[] {
+ return List.of(
buildCommandUsage(LIST_MODULE_TYPES + " [-st] ",
"lists all Module Types. If filter is present, lists only matching Module Types."
+ " If language is missing, the default language will be used."),
@@ -175,7 +169,7 @@ public List getUsages() {
"Enables the Rule, specified by given UID. If enable parameter is missing, "
+ "the result of the command will be visualization of enabled/disabled state of the rule, "
+ "if its value is \"true\" or \"false\", "
- + "the result of the command will be to set enable/disable on the Rule.") });
+ + "the result of the command will be to set enable/disable on the Rule."));
}
@Override
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java
index e76b3e51c3d..56330d4ffe1 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -71,7 +71,7 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider getModuleTypes(@Nullable Locale locale) {
/**
* This method is responsible for removing a set of objects loaded from a specified file or URL resource.
*
- * @param providerType specifies the provider responsible for removing the objects loaded from a specified file or
- * URL resource.
* @param url is a specified file or URL resource.
* @return the string SUCCESS.
*/
public String remove(URL url) {
- List portfolio = null;
+ List portfolio;
synchronized (providerPortfolio) {
portfolio = providerPortfolio.remove(url);
}
@@ -186,7 +184,7 @@ protected Set importData(URL url, Parser parser, InputSt
throws ParsingException {
Set providedObjects = parser.parse(inputStreamReader);
if (providedObjects != null && !providedObjects.isEmpty()) {
- String uid = null;
+ String uid;
List portfolio = new ArrayList<>();
synchronized (providerPortfolio) {
providerPortfolio.put(url, portfolio);
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineRuleImporter.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineRuleImporter.java
index a7923909562..2a32b01adf7 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineRuleImporter.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineRuleImporter.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -17,7 +17,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
-import java.util.Iterator;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -119,9 +118,7 @@ protected Set importData(URL url, Parser parser, InputStreamReader i
throws ParsingException {
Set providedRules = parser.parse(inputStreamReader);
if (providedRules != null && !providedRules.isEmpty()) {
- Iterator i = providedRules.iterator();
- while (i.hasNext()) {
- Rule rule = i.next();
+ for (Rule rule : providedRules) {
if (rule != null) {
if (ruleRegistry.get(rule.getUID()) != null) {
ruleRegistry.update(rule);
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java
index 092461436b7..230f50441eb 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -146,13 +146,11 @@ public Collection getTemplates(@Nullable Locale locale) {
/**
* This method is responsible for removing a set of objects loaded from a specified file or URL resource.
*
- * @param providerType specifies the provider responsible for removing the objects loaded from a specified file or
- * URL resource.
* @param url is a specified file or URL resource.
* @return the string SUCCESS.
*/
public String remove(URL url) {
- List portfolio = null;
+ List portfolio;
synchronized (providerPortfolio) {
portfolio = providerPortfolio.remove(url);
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java
index ceb9de0c07f..bf24edfa2a0 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -323,7 +323,6 @@ static String printRuleStatus(String ruleUID, RuleStatus status) {
* This method is responsible for printing the strings, representing the auxiliary automation objects.
*
* @param columnWidths represents the column widths of the table.
- * @param width represents the table width.
* @param prop is a property name of the property with value the collection of the auxiliary automation objects for
* printing.
* @param list with the auxiliary automation objects for printing.
@@ -396,8 +395,8 @@ private static List getModuleRecords(Module module) {
int[] columnWidths = new int[] { COLUMN_PROPERTY_VALUE };
List columnValues = new ArrayList<>();
columnValues.add(module.getId());
- List moduleContent = new ArrayList<>();
- moduleContent.addAll(Utils.getTableTitle(Utils.getRow(columnWidths, columnValues), COLUMN_PROPERTY_VALUE));
+ List moduleContent = new ArrayList<>(
+ Utils.getTableTitle(Utils.getRow(columnWidths, columnValues), COLUMN_PROPERTY_VALUE));
columnWidths = new int[] { COLUMN_CONFIG_PARAMETER, COLUMN_CONFIG_PARAMETER_VALUE };
columnValues.set(0, ID);
@@ -530,10 +529,10 @@ private static List getConfigurationDescriptionRecords(
}
/**
- * This method is responsible for printing the set of {@link Input}s or {@link Output}s or {@link Inputs}s.
+ * This method is responsible for printing the set of tags.
*
- * @param set is the set of {@link Input}s or {@link Output}s or {@link Inputs}s for printing.
- * @return a formated string, representing the set of {@link Input}s or {@link Output}s or {@link Input}s.
+ * @param tags is the set of tags for printing.
+ * @return a formatted string, representing the set of tags.
*/
private static String getTagsRecord(Set tags) {
if (tags == null || tags.isEmpty()) {
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java
index 0b5beb3068d..c1273263c05 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -179,11 +179,7 @@ static String printChars(char ch, int count) {
if (count < 1) {
return "";
}
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < count; i++) {
- sb.append(ch);
- }
- return sb.toString();
+ return String.valueOf(ch).repeat(count);
}
/**
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java
index 74715fa91c4..20fd4422f5b 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -67,7 +67,8 @@ public abstract class AbstractCompositeModuleHandler mapModuleToHandler) {
+ protected AbstractCompositeModuleHandler(M module, MT moduleType,
+ LinkedHashMap mapModuleToHandler) {
this.module = module;
this.moduleType = moduleType;
this.moduleHandlerMap = mapModuleToHandler;
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java
index 90dd70a67c9..b2cd4f4df8f 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeConditionHandler.java
index 82a9a6b3f62..6bfc7465a0b 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java
index 1f9e7a97220..c872d6928df 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -17,7 +17,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+import java.util.Map.Entry;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -65,8 +65,7 @@ public class CompositeModuleHandlerFactory extends BaseModuleHandlerFactory impl
/**
* The constructor of system handler factory for composite module types.
*
- * @param context is a bundle context
- * @param mtManager is a module type manager
+ * @param mtRegistry is a module type registry
* @param re is a rule engine
*/
public CompositeModuleHandlerFactory(ModuleTypeRegistry mtRegistry, RuleEngineImpl re) {
@@ -95,9 +94,9 @@ public void ungetHandler(Module module, String childModulePrefix, ModuleHandler
ModuleHandler handlerOfModule = getHandlers().get(getModuleIdentifier(childModulePrefix, module.getId()));
if (handlerOfModule instanceof AbstractCompositeModuleHandler) {
AbstractCompositeModuleHandler h = (AbstractCompositeModuleHandler) handlerOfModule;
- Set modules = h.moduleHandlerMap.keySet();
- for (ModuleImpl child : modules) {
- ModuleHandler childHandler = h.moduleHandlerMap.get(child);
+ for (Entry entry : h.moduleHandlerMap.entrySet()) {
+ ModuleImpl child = entry.getKey();
+ ModuleHandler childHandler = entry.getValue();
if (childHandler == null) {
continue;
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java
index 2f43e2c5c21..fc8eee56f62 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -88,7 +88,7 @@ public void triggered(Trigger trigger, Map context) {
ref = ref.substring(i + 1);
}
}
- Object value = null;
+ Object value;
int idx = ReferenceResolver.getNextRefToken(ref, 1);
if (idx < ref.length()) {
String outputId = ref.substring(0, idx);
@@ -114,10 +114,10 @@ public ScheduledExecutorService getScheduler() {
/**
* The {@link CompositeTriggerHandler} sets itself as callback to the child triggers and store the callback to the
- * rule engine. In this way the trigger of composite type will be notified always when some of the child triggers
+ * rule engine. In this way the trigger of composite type will always be notified when some of the child triggers
* are triggered and has an opportunity to set the outputs of parent trigger to the rule context.
*
- * @see org.openhab.core.automation.handler.TriggerHandler#setTriggerHandlerCallback(org.openhab.core.automation.handler.TriggerHandlerCallback)
+ * @see org.openhab.core.automation.handler.TriggerHandler#setCallback(ModuleHandlerCallback)
*/
@Override
public void setCallback(@Nullable ModuleHandlerCallback callback) {
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/config/EphemerisConditionConfig.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/config/EphemerisConditionConfig.java
index 4816c44bf0b..5635b7db30c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/config/EphemerisConditionConfig.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/config/EphemerisConditionConfig.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/exception/UncomparableException.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/exception/UncomparableException.java
index eead67eb773..8e38ccb2c80 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/exception/UncomparableException.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/exception/UncomparableException.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/CoreModuleHandlerFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/CoreModuleHandlerFactory.java
index a6db11d2c28..4f5b379ee2d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/CoreModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/CoreModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactory.java
index b2f0335fa1d..62749802fdf 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/AnnotationActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/AnnotationActionHandler.java
index 0d5fb51db2f..5bfad2d86e7 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/AnnotationActionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/AnnotationActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandler.java
index 1d727083b50..4cbed939afd 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java
index bfcc52c47ed..288823d2f7a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -51,12 +51,11 @@ public CompareConditionHandler(Condition module) {
@Override
public boolean isSatisfied(Map context) {
Object operatorObj = this.module.getConfiguration().get(OPERATOR);
- String operator = (operatorObj != null && operatorObj instanceof String s) ? s : null;
+ String operator = operatorObj instanceof String s ? s : null;
Object rightObj = this.module.getConfiguration().get(RIGHT_OP);
- String rightOperandString = (rightObj != null && rightObj instanceof String s) ? s : null;
+ String rightOperandString = rightObj instanceof String s ? s : null;
Object leftObjFieldNameObj = this.module.getConfiguration().get(INPUT_LEFT_FIELD);
- String leftObjectFieldName = (leftObjFieldNameObj != null && leftObjFieldNameObj instanceof String s) ? s
- : null;
+ String leftObjectFieldName = leftObjFieldNameObj instanceof String s ? s : null;
if (rightOperandString == null || operator == null) {
return false;
} else {
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandler.java
index de01e4dabff..68e38766eba 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DayOfWeekConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DayOfWeekConditionHandler.java
index e2e9ec03963..7d893db54f8 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DayOfWeekConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/DayOfWeekConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/EphemerisConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/EphemerisConditionHandler.java
index e960ac589a1..d9e4ce80da6 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/EphemerisConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/EphemerisConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericCronTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericCronTriggerHandler.java
index 9bcfab5acf4..b3d0b760bba 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericCronTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericCronTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventConditionHandler.java
index bb7c35c3ae2..9079e86e6bb 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java
index 4756b858102..218a19539b9 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupCommandTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupCommandTriggerHandler.java
index b9d4a781ce5..d1e1ec5d928 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupCommandTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupCommandTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -21,6 +21,7 @@
import org.openhab.core.automation.Trigger;
import org.openhab.core.automation.handler.BaseTriggerModuleHandler;
import org.openhab.core.automation.handler.TriggerHandlerCallback;
+import org.openhab.core.config.core.ConfigParser;
import org.openhab.core.events.Event;
import org.openhab.core.events.EventSubscriber;
import org.openhab.core.items.Item;
@@ -50,7 +51,6 @@ public class GroupCommandTriggerHandler extends BaseTriggerModuleHandler impleme
private final @Nullable String command;
private final Set types;
- private final BundleContext bundleContext;
private final ItemRegistry itemRegistry;
public static final String MODULE_TYPE_ID = "core.GroupCommandTrigger";
@@ -59,18 +59,21 @@ public class GroupCommandTriggerHandler extends BaseTriggerModuleHandler impleme
public static final String CFG_COMMAND = "command";
private final String ruleUID;
- private ServiceRegistration> eventSubscriberRegistration;
+ private final ServiceRegistration> eventSubscriberRegistration;
public GroupCommandTriggerHandler(Trigger module, String ruleUID, BundleContext bundleContext,
ItemRegistry itemRegistry) {
super(module);
- this.groupName = (String) module.getConfiguration().get(CFG_GROUPNAME);
+ this.groupName = ConfigParser.valueAsOrElse(module.getConfiguration().get(CFG_GROUPNAME), String.class, "");
+ if (this.groupName.isBlank()) {
+ logger.warn("GroupCommandTrigger {} of rule {} has no groupName configured and will not work.",
+ module.getId(), ruleUID);
+ }
this.command = (String) module.getConfiguration().get(CFG_COMMAND);
this.types = Set.of(ItemCommandEvent.TYPE, ItemAddedEvent.TYPE, ItemRemovedEvent.TYPE);
- this.bundleContext = bundleContext;
this.itemRegistry = itemRegistry;
this.ruleUID = ruleUID;
- eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, null);
+ eventSubscriberRegistration = bundleContext.registerService(EventSubscriber.class.getName(), this, null);
if (itemRegistry.get(groupName) == null) {
logger.warn("Group '{}' needed for rule '{}' is missing. Trigger '{}' will not work.", groupName, ruleUID,
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupStateTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupStateTriggerHandler.java
index 5a069b87550..fa132518707 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupStateTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GroupStateTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -21,6 +21,7 @@
import org.openhab.core.automation.Trigger;
import org.openhab.core.automation.handler.BaseTriggerModuleHandler;
import org.openhab.core.automation.handler.TriggerHandlerCallback;
+import org.openhab.core.config.core.ConfigParser;
import org.openhab.core.events.Event;
import org.openhab.core.events.EventSubscriber;
import org.openhab.core.items.Item;
@@ -59,16 +60,19 @@ public class GroupStateTriggerHandler extends BaseTriggerModuleHandler implement
private final @Nullable String state;
private final String previousState;
private final String ruleUID;
- private Set types;
- private final BundleContext bundleContext;
- private ItemRegistry itemRegistry;
+ private final Set types;
+ private final ItemRegistry itemRegistry;
- private ServiceRegistration> eventSubscriberRegistration;
+ private final ServiceRegistration> eventSubscriberRegistration;
public GroupStateTriggerHandler(Trigger module, String ruleUID, BundleContext bundleContext,
ItemRegistry itemRegistry) {
super(module);
- this.groupName = (String) module.getConfiguration().get(CFG_GROUPNAME);
+ this.groupName = ConfigParser.valueAsOrElse(module.getConfiguration().get(CFG_GROUPNAME), String.class, "");
+ if (this.groupName.isBlank()) {
+ logger.warn("GroupStateTrigger {} of rule {} has no groupName configured and will not work.",
+ module.getId(), ruleUID);
+ }
this.state = (String) module.getConfiguration().get(CFG_STATE);
this.previousState = (String) module.getConfiguration().get(CFG_PREVIOUS_STATE);
if (UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) {
@@ -77,10 +81,9 @@ public GroupStateTriggerHandler(Trigger module, String ruleUID, BundleContext bu
this.types = Set.of(ItemStateChangedEvent.TYPE, GroupItemStateChangedEvent.TYPE, ItemAddedEvent.TYPE,
ItemRemovedEvent.TYPE);
}
- this.bundleContext = bundleContext;
this.ruleUID = ruleUID;
this.itemRegistry = itemRegistry;
- eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, null);
+ eventSubscriberRegistration = bundleContext.registerService(EventSubscriber.class.getName(), this, null);
if (itemRegistry.get(groupName) == null) {
logger.warn("Group '{}' needed for rule '{}' is missing. Trigger '{}' will not work.", groupName, ruleUID,
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandActionHandler.java
index e3224ea921e..7f179db88f2 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandActionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -50,9 +50,6 @@ public class ItemCommandActionHandler extends BaseActionModuleHandler {
/**
* constructs a new ItemCommandActionHandler
- *
- * @param module
- * @param moduleTypes
*/
public ItemCommandActionHandler(Action module, EventPublisher eventPublisher, ItemRegistry itemRegistry) {
super(module);
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java
index ac9cb07ca63..257adf84260 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandler.java
index c48fe7b98ef..dbb929a2c1c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java
index 820c641c262..7207db7f082 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateUpdateActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateUpdateActionHandler.java
index 4a515b0d57c..e96c992ed60 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateUpdateActionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateUpdateActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RuleEnablementActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RuleEnablementActionHandler.java
index 40cf13a34b8..be2747fa04c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RuleEnablementActionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RuleEnablementActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RunRuleActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RunRuleActionHandler.java
index 9a4c329d1ff..84a1b86ff65 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RunRuleActionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/RunRuleActionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandler.java
index d6ca1c80c93..a474c574b5a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -13,7 +13,6 @@
package org.openhab.core.automation.internal.module.handler;
import java.math.BigDecimal;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -87,7 +86,7 @@ public void receive(Event event) {
if (startlevel <= sl && startlevel > StartLevelService.STARTLEVEL_RULEENGINE) {
// only execute rules if their start level is higher than the rule engine activation level, since
// otherwise the rule engine takes care of the execution already
- trigger();
+ trigger(event);
}
}
}
@@ -101,15 +100,14 @@ public void dispose() {
super.dispose();
}
- public void trigger() {
+ private void trigger(Event event) {
final ModuleHandlerCallback callback = this.callback;
if (!(callback instanceof TriggerHandlerCallback)) {
return;
}
TriggerHandlerCallback thCallback = (TriggerHandlerCallback) callback;
- Map values = new HashMap<>();
- values.put(OUT_STARTLEVEL, startlevel);
+ Map values = Map.of(OUT_STARTLEVEL, startlevel, "event", event);
thCallback.triggered(module, values);
triggered = true;
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ThingStatusTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ThingStatusTriggerHandler.java
index c185cb4b82b..e271e81bc58 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ThingStatusTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ThingStatusTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayConditionHandler.java
index 0dcb2e43206..2b47bb3172d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayConditionHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayConditionHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayTriggerHandler.java
index a1a2b2d1db2..7743acc94b6 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayTriggerHandler.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimeOfDayTriggerHandler.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimerModuleHandlerFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimerModuleHandlerFactory.java
index 2c87ce5ea21..63b9568b143 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimerModuleHandlerFactory.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/TimerModuleHandlerFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/provider/AnnotatedActionModuleTypeProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/provider/AnnotatedActionModuleTypeProvider.java
index 26d1c042878..8e0d8a11b05 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/provider/AnnotatedActionModuleTypeProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/provider/AnnotatedActionModuleTypeProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/AbstractGSONParser.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/AbstractGSONParser.java
index dfeea7e58c7..8a2e96e380d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/AbstractGSONParser.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/AbstractGSONParser.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ActionInstanceCreator.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ActionInstanceCreator.java
index 6f980a5ed44..c54ddd31186 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ActionInstanceCreator.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ActionInstanceCreator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ConditionInstanceCreator.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ConditionInstanceCreator.java
index 01540effb15..d3f2d2d8c3d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ConditionInstanceCreator.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ConditionInstanceCreator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java
index 1a995ec9ede..45d90924c6f 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeParsingContainer.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeParsingContainer.java
index f27e5f90bba..8ab35ed0a12 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeParsingContainer.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeParsingContainer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/RuleGSONParser.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/RuleGSONParser.java
index 064134357fd..7013d1f8876 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/RuleGSONParser.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/RuleGSONParser.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TemplateGSONParser.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TemplateGSONParser.java
index 8c42db606d2..187dbd8026a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TemplateGSONParser.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TemplateGSONParser.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TriggerInstanceCreator.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TriggerInstanceCreator.java
index 12a6c095030..08c86a88bf4 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TriggerInstanceCreator.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/TriggerInstanceCreator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java
index 04e07495220..e26e54dd6f7 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -70,7 +70,7 @@
@NonNullByDefault
public abstract class AbstractResourceBundleProvider<@NonNull E> {
- public AbstractResourceBundleProvider(String path) {
+ protected AbstractResourceBundleProvider(String path) {
this.path = path;
}
@@ -162,12 +162,6 @@ protected void deactivate() {
}
}
- /**
- * This method is used to initialize field {@link #queue}, when the instance of
- * {@link AutomationResourceBundlesEventQueue} is created.
- *
- * @param queue provides an access to the queue for processing bundles.
- */
protected AutomationResourceBundlesEventQueue getQueue() {
return queue;
}
@@ -272,7 +266,7 @@ protected void removeUninstalledObjects(List previousPortfolio, List> snapshot = null;
+ List> snapshot;
synchronized (listeners) {
snapshot = new LinkedList<>(listeners);
}
@@ -339,7 +333,7 @@ protected void processAutomationProviderUninstalled(Bundle bundle) {
for (String uid : portfolio) {
final @Nullable E removedObject = providedObjectsHolder.remove(uid);
if (removedObject != null) {
- List> snapshot = null;
+ List> snapshot;
synchronized (listeners) {
snapshot = new LinkedList<>(listeners);
}
@@ -399,7 +393,6 @@ protected List getLocalizedConfigurationDescription(
* This method is called from {@link #processAutomationProvider(Bundle)} to process the loading of the provided
* objects.
*
- * @param vendor is a holder of information about the bundle providing data for import.
* @param parser the {@link Parser} which is responsible for parsing of a particular format in which the provided
* objects are presented
* @param url the resource which is used for loading the objects.
@@ -438,7 +431,7 @@ protected Set parseData(Parser parser, URL url, Bundle bundle) {
@SuppressWarnings("unchecked")
protected void addNewProvidedObjects(List newPortfolio, List previousPortfolio,
Set parsedObjects) {
- List> snapshot = null;
+ List> snapshot;
synchronized (listeners) {
snapshot = new LinkedList<>(listeners);
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java
index ecb2bf9d45e..690e389385d 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -13,7 +13,6 @@
package org.openhab.core.automation.internal.provider;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -94,7 +93,7 @@ public AutomationResourceBundlesEventQueue(AbstractResourceBundleProvider pro
public void run() {
boolean waitForEvents = true;
while (true) {
- List lQueue = null;
+ List lQueue;
synchronized (this) {
if (closed) {
notifyAll();
@@ -117,9 +116,7 @@ public void run() {
lQueue = queue;
shared = true;
}
- Iterator events = lQueue.iterator();
- while (events.hasNext()) {
- BundleEvent event = events.next();
+ for (BundleEvent event : lQueue) {
try {
processBundleChanged(event);
synchronized (this) {
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java
index b60262c6bb3..77c989b2fe1 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java
index 23d645a9b1e..e4ddda1004a 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -43,9 +43,7 @@ static Set>> getMapping() {
/**
* This method is used to get the host bundles of the parameter which is a fragment bundle.
*
- * @param pkgAdmin
- *
- * @param bundle an OSGi fragment bundle.
+ * @param fragment an OSGi fragment bundle.
* @return a list with the hosts of the fragment parameter.
*/
static List returnHostBundles(Bundle fragment) {
@@ -54,9 +52,9 @@ static List returnHostBundles(Bundle fragment) {
if (bundles != null) {
hosts = Arrays.asList(bundles);
} else {
- for (Bundle host : hostFragmentMapping.keySet()) {
- if (hostFragmentMapping.get(host).contains(fragment)) {
- hosts.add(host);
+ for (Entry> entry : hostFragmentMapping.entrySet()) {
+ if (entry.getValue().contains(fragment)) {
+ hosts.add(entry.getKey());
}
}
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java
index b8e232cc0c5..080bd0b5c2b 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -61,8 +61,6 @@ public class ModuleTypeResourceBundleProvider extends AbstractResourceBundleProv
/**
* This constructor is responsible for initializing the path to resources and tracking the
* {@link ModuleTypeRegistry}.
- *
- * @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services.
*/
@Activate
public ModuleTypeResourceBundleProvider(final @Reference ModuleTypeI18nService moduleTypeI18nService) {
@@ -138,7 +136,7 @@ protected String getUID(ModuleType parsedObject) {
/**
* This method is used to localize the {@link ModuleType}s.
*
- * @param element is the {@link ModuleType} that must be localized.
+ * @param defModuleType is the {@link ModuleType} that must be localized.
* @param locale represents a specific geographical, political, or cultural region.
* @return the localized {@link ModuleType}.
*/
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java
index 13ae95a82f8..9168944f7ac 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/RuleResourceBundleImporter.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -17,6 +17,7 @@
import java.net.URL;
import java.util.Enumeration;
import java.util.List;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -52,8 +53,6 @@ public class RuleResourceBundleImporter extends AbstractResourceBundleProvider newPortfolio, List pre
protected List getPreviousPortfolio(Vendor vendor) {
List portfolio = providerPortfolio.get(vendor);
if (portfolio == null) {
- for (Vendor v : providerPortfolio.keySet()) {
- if (v.getVendorSymbolicName().equals(vendor.getVendorSymbolicName())) {
- List vendorPortfolio = providerPortfolio.get(v);
- return vendorPortfolio == null ? List.of() : vendorPortfolio;
+ for (Entry> entry : providerPortfolio.entrySet()) {
+ if (entry.getKey().getVendorSymbolicName().equals(vendor.getVendorSymbolicName())) {
+ return entry.getValue();
}
}
}
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java
index 8a1b5e0bf43..34f775245cd 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -28,7 +28,6 @@
import org.openhab.core.automation.parser.Parser;
import org.openhab.core.automation.template.RuleTemplate;
import org.openhab.core.automation.template.RuleTemplateProvider;
-import org.openhab.core.automation.template.Template;
import org.openhab.core.automation.template.TemplateProvider;
import org.openhab.core.automation.type.ModuleType;
import org.openhab.core.common.registry.Provider;
@@ -46,15 +45,15 @@
import org.osgi.service.component.annotations.ReferencePolicy;
/**
- * This class is implementation of {@link TemplateProvider}. It serves for providing {@link RuleTemplates}s by loading
+ * This class is implementation of {@link TemplateProvider}. It serves for providing {@link RuleTemplate}s by loading
* bundle resources. It extends functionality of {@link AbstractResourceBundleProvider} by specifying:
*
- *
the path to resources, corresponding to the {@link RuleTemplates}s - root directory
+ *
the path to resources, corresponding to the {@link RuleTemplate}s - root directory
* {@link AbstractResourceBundleProvider#ROOT_DIRECTORY} with sub-directory "templates".
- *
type of the {@link Parser}s, corresponding to the {@link RuleTemplates}s - {@link Parser#PARSER_TEMPLATE}
- *
specific functionality for loading the {@link RuleTemplates}s
+ *
type of the {@link Parser}s, corresponding to the {@link RuleTemplate}s - {@link Parser#PARSER_TEMPLATE}
+ *
specific functionality for loading the {@link RuleTemplate}s
*
tracking the managing service of the {@link ModuleType}s.
- *
tracking the managing of the {@link RuleTemplates}s.
+ *
tracking the managing of the {@link RuleTemplate}s.
*
*
* @author Ana Dimova - Initial contribution
@@ -72,9 +71,7 @@ public class TemplateResourceBundleProvider extends AbstractResourceBundleProvid
/**
* This constructor is responsible for initializing the path to resources and tracking the managing service of the
- * {@link ModuleType}s and the managing service of the {@link RuleTemplates}s.
- *
- * @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services.
+ * {@link ModuleType}s and the managing service of the {@link RuleTemplate}s.
*/
@Activate
public TemplateResourceBundleProvider(final @Reference ConfigI18nLocalizationService configI18nService,
@@ -151,11 +148,11 @@ public Collection getTemplates(@Nullable Locale locale) {
}
/**
- * This method is used to localize the {@link Template}s.
+ * This method is used to localize the {@link RuleTemplate}s.
*
- * @param element is the {@link Template} that must be localized.
+ * @param defTemplate is the {@link RuleTemplate} that must be localized.
* @param locale represents a specific geographical, political, or cultural region.
- * @return the localized {@link Template}.
+ * @return the localized {@link RuleTemplate}.
*/
private @Nullable RuleTemplate getPerLocale(@Nullable RuleTemplate defTemplate, @Nullable Locale locale) {
if (locale == null || defTemplate == null) {
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/Vendor.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/Vendor.java
index e3136d74594..386a35c3299 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/Vendor.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/Vendor.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -58,7 +58,7 @@ public Vendor(String nameversion) {
}
/**
- * This constructor initialize the {@link vendorId} and the {@link vendorVersion} of the vendor with corresponding
+ * This constructor initialize the {@link #vendorID} and the {@link #vendorVersion} of the vendor with corresponding
* bundle ID and bundle version of a bundle that provides resources for the automation objects.
*
* @param name a bundle symbolic name of a bundle that providing resources for automation objects.
@@ -71,7 +71,7 @@ public Vendor(String name, String version) {
}
/**
- * Getter of {@link vendorSymbolicName}.
+ * Getter of {@link #vendorSymbolicName}.
*
* @return a bundle symbolic name of a bundle that provides resources for the automation objects.
*/
@@ -80,7 +80,7 @@ public String getVendorSymbolicName() {
}
/**
- * Getter of {@link vendorId}.
+ * Getter of {@link #vendorID}.
*
* @return a bundle symbolic name of a bundle that provides resources for the automation objects.
*/
@@ -89,7 +89,7 @@ public String getVendorID() {
}
/**
- * Getter of {@link vendorVersion}.
+ * Getter of {@link #vendorVersion}.
*
* @return a bundle version of a bundle that provides resources for the automation objects.
*/
@@ -98,7 +98,7 @@ public String getVendorVersion() {
}
/**
- * Setter of {@link vendorVersion}.
+ * Setter of {@link #vendorVersion}.
*
* @param version a bundle version of a bundle that provides resources for the automation objects.
*/
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java
index 140ecc16df4..ab6fc06cc29 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -86,7 +87,7 @@ public abstract class AbstractFileProvider<@NonNull E> implements Provider {
private final Map> urls = new ConcurrentHashMap<>();
private final List> listeners = new ArrayList<>();
- public AbstractFileProvider(String root) {
+ protected AbstractFileProvider(String root) {
this.rootSubdirectory = root;
configurationRoots = new String[] { OpenHAB.getConfigFolder() + File.separator + "automation" };
}
@@ -252,11 +253,7 @@ protected void importFile(String parserType, URL url) {
}
} else {
synchronized (urls) {
- List value = urls.get(parserType);
- if (value == null) {
- value = new ArrayList<>();
- urls.put(parserType, value);
- }
+ List value = Objects.requireNonNull(urls.computeIfAbsent(parserType, k -> new ArrayList<>()));
value.add(url);
}
logger.debug("Parser {} not available", parserType, new Exception());
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AutomationWatchService.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AutomationWatchService.java
index cfa59acf274..23fb60b7b90 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AutomationWatchService.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AutomationWatchService.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -19,8 +19,8 @@
import org.openhab.core.service.WatchService;
/**
- * This class is an implementation of {@link AbstractWatchService} which is responsible for tracking changes in file
- * system by Java WatchService.
+ * This class is an implementation of {@link WatchService.WatchEventListener} which is responsible for tracking file
+ * system changes.
*
* It provides functionality for tracking {@link #watchingDir} changes to import or remove the automation objects.
*
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java
index b6c2e54a8f8..abb46682159 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProviderWatcher.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProviderWatcher.java
index 4a78cd492ba..83c2606dcb7 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProviderWatcher.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProviderWatcher.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java
index 6282d471bb3..56e0b6e9234 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProviderWatcher.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProviderWatcher.java
index aa01bb79d53..8bfed782415 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProviderWatcher.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProviderWatcher.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java
index 69095d27c6b..4bdee813908 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -16,6 +16,7 @@
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.service.WatchService;
@@ -35,11 +36,8 @@ public static void initializeWatchService(String watchingDir, AbstractFileProvid
WatchService watchService) {
AutomationWatchService aws = null;
synchronized (WATCH_SERVICES) {
- Map watchers = WATCH_SERVICES.get(provider);
- if (watchers == null) {
- watchers = new HashMap<>();
- WATCH_SERVICES.put(provider, watchers);
- }
+ Map watchers = Objects
+ .requireNonNull(WATCH_SERVICES.computeIfAbsent(provider, k -> new HashMap<>()));
if (watchers.get(watchingDir) == null) {
aws = new AutomationWatchService(provider, watchService, watchingDir);
watchers.put(watchingDir, aws);
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java
index 1ba63685015..63c4275e59c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nServiceImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nServiceImpl.java
index 346685f7f86..d9bc368dd0c 100644
--- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nServiceImpl.java
+++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nServiceImpl.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
+ * Copyright (c) 2010-2024 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
@@ -69,7 +69,7 @@ public ModuleTypeI18nServiceImpl(final @Reference ConfigI18nLocalizationService
/**
* This method is used to localize the {@link ModuleType}s.
*
- * @param element is the {@link ModuleType} that must be localized.
+ * @param defModuleType is the {@link ModuleType} that must be localized.
* @param locale represents a specific geographical, political, or cultural region.
* @return the localized {@link ModuleType}.
*/
@@ -135,7 +135,7 @@ public ModuleTypeI18nServiceImpl(final @Reference ConfigI18nLocalizationService
@Nullable String llabel, @Nullable String ldescription) {
List inputs = moduleTypeI18nUtil.getLocalizedInputs(at.getInputs(), bundle, moduleTypeUID, locale);
List